Skip to content

Commit

Permalink
Address review comments for handling 404 errors with React Router in …
Browse files Browse the repository at this point in the history
…manufacturers
  • Loading branch information
joshuadkitenge committed Jan 8, 2025
1 parent ecc029b commit 41d0568
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
9 changes: 2 additions & 7 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,15 @@ let router: Router;
const isUsingMSW =
import.meta.env.DEV || import.meta.env.VITE_APP_INCLUDE_MSW === 'true';

if (!isUsingMSW) {
router = createBrowserRouter(routeObject);
}
if (!isUsingMSW) router = createBrowserRouter(routeObject);

// If the application is using MSW (Mock Service Worker),
// it creates the router using `createBrowserRouter` within the App so it can wait for MSW to load. This is necessary
// because MSW needs to be running before the router is created to handle requests properly in the loader. In a production
// environment, this is not needed.

export default function App() {
if (isUsingMSW) {
router = createBrowserRouter(routeObject);
return <RouterProvider router={router} />;
}
if (isUsingMSW) router = createBrowserRouter(routeObject);
return <RouterProvider router={router} />;
}

Expand Down
4 changes: 2 additions & 2 deletions src/api/manufacturers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ const getManufacturer = async (id: string): Promise<Manufacturer> => {
.get(`/v1/manufacturers/${id}`)
.then((response) => response.data);
};
export const getManufacturerQuery = (id?: string | null, loader?: boolean) =>
export const getManufacturerQuery = (id?: string | null, retry?: boolean) =>
queryOptions<Manufacturer, AxiosError>({
queryKey: ['Manufacturer', id],
queryFn: () => getManufacturer(id ?? ''),
enabled: !!id,
retry: loader ? false : undefined,
retry: retry ? false : undefined,
});

export const useGetManufacturer = (
Expand Down
3 changes: 3 additions & 0 deletions src/app.types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export interface AllowedValuesList {
values: { av_placement_id: string; value: any }[];
};
}

// ------------------------------------ CATALOGUE CATEGORIES ------------------------------------

export type AllowedValues = AllowedValuesList;

export interface AddCatalogueCategoryProperty {
Expand Down

0 comments on commit 41d0568

Please sign in to comment.