Skip to content

Commit

Permalink
Address review comments #1211
Browse files Browse the repository at this point in the history
- manufacturer loader in the correct location
- Add scroll restoration react router
- add dev tool for react query
  • Loading branch information
joshuadkitenge committed Jan 8, 2025
1 parent e002b9d commit e24c5d5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
21 changes: 13 additions & 8 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { LocalizationProvider } from '@mui/x-date-pickers';
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFnsV3';
import type { Router } from '@remix-run/router';
import {
QueryCache,
QueryClient,
QueryClientProvider,
} from '@tanstack/react-query';
import React from 'react';
// import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import { LocalizationProvider } from '@mui/x-date-pickers';
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFnsV3';
import type { Router } from '@remix-run/router';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import { AxiosError } from 'axios';
import { enGB } from 'date-fns/locale/en-GB';
import React from 'react';
import {
RouterProvider,
ScrollRestoration,
createBrowserRouter,
type RouteObject,
} from 'react-router-dom';
Expand Down Expand Up @@ -119,11 +120,14 @@ const routeObject: RouteObject[] = [
{
path: paths.manufacturers,
Component: ManufacturerLayout,
loader: manufacturerLayoutLoader(queryClient),
ErrorBoundary: ManufacturerLayoutErrorComponent,
children: [
{ index: true, Component: ManufacturerTable },
{ path: paths.manufacturer, Component: ManufacturerLandingPage },
{
path: paths.manufacturer,
Component: ManufacturerLandingPage,
loader: manufacturerLayoutLoader(queryClient),
},
{
path: '*',
Component: ManufacturerErrorComponent,
Expand Down Expand Up @@ -188,7 +192,8 @@ export function Layout() {
}
>
<ViewTabs />
{/* <ReactQueryDevtools initialIsOpen={false} /> */}
<ReactQueryDevtools initialIsOpen={false} />
<ScrollRestoration />
</React.Suspense>
</QueryClientProvider>
</ConfigProvider>
Expand Down
4 changes: 2 additions & 2 deletions src/admin/adminCardView.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function AdminCardView() {
<Grid item key={0} xs={12} sm={6}>
<Button
component={Link}
to={'units'}
to="units"
fullWidth
sx={{
display: 'flex',
Expand All @@ -21,7 +21,7 @@ function AdminCardView() {
>
<Card
sx={{
padding: '8px',
padding: 1,
width: '100%',
display: 'flex',
height: '100px', // Set a fixed height for all cards
Expand Down
11 changes: 5 additions & 6 deletions src/admin/adminLayout.component.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { Outlet, useLocation } from 'react-router-dom';
import { BreadcrumbsInfo } from '../api/api.types';
import { paths } from '../App';
import BaseLayoutHeader from '../common/baseLayoutHeader.component';
import ErrorPage from '../common/errorPage.component';

Expand All @@ -18,14 +19,12 @@ export const useGetAdminPageName = (): string | null => {
const location = useLocation();

return React.useMemo(() => {
let adminPageName: string | null = location.pathname.replace(
'/admin-ims',
const adminPageName: string | null = location.pathname.replace(
paths.admin,
''
);
adminPageName =
adminPageName === '' ? null : adminPageName.replace('/', '');
return adminPageName;
}, [location.pathname]);
return adminPageName === '' ? null : adminPageName.replace('/', '');
}, []);

Check warning on line 27 in src/admin/adminLayout.component.tsx

View workflow job for this annotation

GitHub Actions / Lint & Unit Tests

React Hook React.useMemo has a missing dependency: 'location.pathname'. Either include it or remove the dependency array
};

const adminBreadCrumbsTrails: { [key: string]: [string, string] } = {
Expand Down

0 comments on commit e24c5d5

Please sign in to comment.