Skip to content

Commit 41d0568

Browse files
committed
Address review comments for handling 404 errors with React Router in manufacturers
1 parent ecc029b commit 41d0568

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

src/App.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,20 +119,15 @@ let router: Router;
119119
const isUsingMSW =
120120
import.meta.env.DEV || import.meta.env.VITE_APP_INCLUDE_MSW === 'true';
121121

122-
if (!isUsingMSW) {
123-
router = createBrowserRouter(routeObject);
124-
}
122+
if (!isUsingMSW) router = createBrowserRouter(routeObject);
125123

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

131129
export default function App() {
132-
if (isUsingMSW) {
133-
router = createBrowserRouter(routeObject);
134-
return <RouterProvider router={router} />;
135-
}
130+
if (isUsingMSW) router = createBrowserRouter(routeObject);
136131
return <RouterProvider router={router} />;
137132
}
138133

src/api/manufacturers.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ const getManufacturer = async (id: string): Promise<Manufacturer> => {
7676
.get(`/v1/manufacturers/${id}`)
7777
.then((response) => response.data);
7878
};
79-
export const getManufacturerQuery = (id?: string | null, loader?: boolean) =>
79+
export const getManufacturerQuery = (id?: string | null, retry?: boolean) =>
8080
queryOptions<Manufacturer, AxiosError>({
8181
queryKey: ['Manufacturer', id],
8282
queryFn: () => getManufacturer(id ?? ''),
8383
enabled: !!id,
84-
retry: loader ? false : undefined,
84+
retry: retry ? false : undefined,
8585
});
8686

8787
export const useGetManufacturer = (

src/app.types.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ export interface AllowedValuesList {
4141
values: { av_placement_id: string; value: any }[];
4242
};
4343
}
44+
45+
// ------------------------------------ CATALOGUE CATEGORIES ------------------------------------
46+
4447
export type AllowedValues = AllowedValuesList;
4548

4649
export interface AddCatalogueCategoryProperty {

0 commit comments

Comments
 (0)