Skip to content

Commit

Permalink
chore(prettier): run linter
Browse files Browse the repository at this point in the history
  • Loading branch information
bas-kirill committed Aug 15, 2024
1 parent 3104869 commit daa7501
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 45 deletions.
16 changes: 5 additions & 11 deletions client/src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ import {
import {
CATALOGUE,
CREATE_INSTRUMENT,
EDIT_INSTRUMENT_BY_ID, FAVORITE,
EDIT_INSTRUMENT_BY_ID,
FAVORITE,
HOME,
INSTRUMENT_BY_ID,
LOGIN,
NOT_FOUND,
PROFILE,
REGISTRATION_URL
REGISTRATION_URL,
} from "shared/config/paths";
import {
CreateInstrument, // todo(refactor): add suffix `Page`
Expand All @@ -43,10 +44,7 @@ import {
RegistrationPage,
action as registrationAction,
} from "pages/registration";
import {
FavoritePage,
loader as favoriteLoader,
} from "pages/favorite";
import { FavoritePage, loader as favoriteLoader } from "pages/favorite";

const routes = createRoutesFromElements(
<Route>
Expand Down Expand Up @@ -76,11 +74,7 @@ const routes = createRoutesFromElements(
element={<RegistrationPage />}
action={registrationAction}
/>
<Route
path={FAVORITE}
element={<FavoritePage />}
loader={favoriteLoader}
/>
<Route path={FAVORITE} element={<FavoritePage />} loader={favoriteLoader} />
<Route path={NOT_FOUND} element={<NotFound />} />
</Route>,
);
Expand Down
2 changes: 1 addition & 1 deletion client/src/domain/model/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ export interface Page {
export interface PageRequest {
pageSize: number;
pageNumber: number;
}
}
4 changes: 3 additions & 1 deletion client/src/pages/catalogue/ui/Catalogue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ export function Catalogue() {
);

useEffect(() => {
fetchFavoriteInstrumentIdsList().then((ids) => setFavoriteInstrumentIds(ids));
fetchFavoriteInstrumentIdsList().then((ids) =>
setFavoriteInstrumentIds(ids),
);

if (instrumentName === "") {
filters.instrumentName = null;
Expand Down
8 changes: 4 additions & 4 deletions client/src/pages/favorite/api/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ export interface FavoriteLoader {
}

export const loader: LoaderFunction = async (): Promise<FavoriteLoader> => {
const favoriteInstrumentIds = await fetchFavoriteInstrumentIdsList()
const favoriteInstrumentIds = await fetchFavoriteInstrumentIdsList();
const filter = {
instrumentId: favoriteInstrumentIds,
} as unknown as Filters;
const instruments = await getInstrumentsByCriteria(filter)
const instruments = await getInstrumentsByCriteria(filter);

return {
instruments: instruments,
}
};
};
};
9 changes: 3 additions & 6 deletions client/src/pages/favorite/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import {FavoritePage} from "./ui/FavoritePage";
import {loader, FavoriteLoader} from "./api/loader";
import { FavoritePage } from "./ui/FavoritePage";
import { loader, FavoriteLoader } from "./api/loader";

export {
FavoritePage,
loader
};
export { FavoritePage, loader };
export type { FavoriteLoader };
16 changes: 9 additions & 7 deletions client/src/pages/favorite/ui/FavoritePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,30 @@ export const FavoritePage = () => {

useEffect(() => {
const fetchFavoriteInstruments = async () => {
const favoriteInstrumentIds = await fetchFavoriteInstrumentIdsList()
const favoriteInstrumentIds = await fetchFavoriteInstrumentIdsList();
const filter = {
instrumentIds: favoriteInstrumentIds,
} as unknown as Filters;
return await getInstrumentsByCriteria(filter);
}
};

fetchFavoriteInstruments().then(instruments => setInstruments(instruments));
fetchFavoriteInstruments().then((instruments) =>
setInstruments(instruments),
);
}, []);

return (
<>
<Header/>
<Header />

<h1>Favorite</h1>
{instruments.map(instrument => (
{instruments.map((instrument) => (
<InstrumentCard
key={instrument.id.toString()}
instrument={instrument}
favorite={true}
/>
))}
</>
)
}
);
};
6 changes: 2 additions & 4 deletions client/src/shared/api/instruments-by-criteria.list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { API_INSTRUMENTS, SERVER_URL } from "shared/config";
import { Filters } from "widgets/catalogue-filter";
import { Instruments } from "domain/model/instrument";

export const getInstrumentsByCriteria = async (
filters: Filters,
) => {
export const getInstrumentsByCriteria = async (filters: Filters) => {
const getInstrumentsByCriteriaRequestBody = JSON.stringify(filters, null, 2);

const { data, status } = await axios.post<Instruments>(
Expand All @@ -16,7 +14,7 @@ export const getInstrumentsByCriteria = async (
"Content-Type": "application/json",
},
},
)
);

if (status !== 200) {
throw new Error("Failed to fetch instruments");
Expand Down
3 changes: 1 addition & 2 deletions client/src/shared/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deleteInstrument } from "./api/delete-instrument";
import { getInstrumentsByCriteria } from "./api/instruments-by-criteria.list";
import { fetchFavoriteInstrumentIdsList} from "./api/fetch-favorite-instrument-ids.list"
import { fetchFavoriteInstrumentIdsList } from "./api/fetch-favorite-instrument-ids.list";
import { InstrumentCard } from "./ui/instrument-card/InstrumentCard";

import {
Expand All @@ -19,7 +19,6 @@ export {
getInstrumentsByCriteria,
fetchFavoriteInstrumentIdsList,
InstrumentCard,

SERVER_URL,
API_INSTRUMENTS,
API_AUTH_BASIC_LOGIN,
Expand Down
6 changes: 3 additions & 3 deletions client/src/shared/ui/instrument-card/InstrumentCard.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.instrument-card {
display: flex;
flex-direction: column;
background-color: darkslateblue;
display: flex;
flex-direction: column;
background-color: darkslateblue;
}
4 changes: 2 additions & 2 deletions client/src/shared/ui/instrument-card/InstrumentCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ export const InstrumentCard = (props: Props) => {
favorite={props.favorite}
/>
</div>
)
}
);
};
2 changes: 1 addition & 1 deletion client/src/widgets/catalogue-filter/model/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type Filters = {
countries: string[] | null;
materials: string[] | null;
instrumentIds: number[] | null;
}
};

export const DEFAULT_FILTER = {
instrumentName: null,
Expand Down
2 changes: 0 additions & 2 deletions client/src/widgets/catalogue-serp/ui/CatalogueSerpWidget.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#catalogue-serp {
background-color: darkkhaki;



.instrument-card:last-child {
margin-bottom: 30px;
}
Expand Down
3 changes: 2 additions & 1 deletion client/src/widgets/catalogue-serp/ui/CatalogueSerpWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export const CatalogueSerpWidget = ({
return (
<div id="catalogue-serp">
{instruments.map((instrument) => (
<InstrumentCard key={instrument.id.toString()}
<InstrumentCard
key={instrument.id.toString()}
instrument={instrument}
favorite={favoriteInstrumentIds.includes(instrument.id)}
/>
Expand Down

0 comments on commit daa7501

Please sign in to comment.