2023-04-27 17:04:33 -04:00
|
|
|
import loadable from '@loadable/component';
|
2023-09-27 02:07:40 -04:00
|
|
|
import { ThemeProvider } from '@mui/material/styles';
|
2022-10-28 01:09:59 -04:00
|
|
|
import { History } from '@remix-run/router';
|
2023-06-07 03:38:39 +03:00
|
|
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
|
|
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
|
2023-09-30 01:17:37 -04:00
|
|
|
import React from 'react';
|
2022-10-28 01:09:59 -04:00
|
|
|
|
2023-10-06 20:09:19 -07:00
|
|
|
import { DASHBOARD_APP_PATHS } from 'apps/dashboard/routes/routes';
|
2023-09-27 02:07:40 -04:00
|
|
|
import AppHeader from 'components/AppHeader';
|
|
|
|
import Backdrop from 'components/Backdrop';
|
|
|
|
import { ApiProvider } from 'hooks/useApi';
|
|
|
|
import { WebConfigProvider } from 'hooks/useWebConfig';
|
|
|
|
import theme from 'themes/theme';
|
2022-10-28 01:09:59 -04:00
|
|
|
|
2023-10-06 20:29:54 -07:00
|
|
|
const StableAppRouter = loadable(() => import('./apps/stable/AppRouter'));
|
2023-10-06 20:26:00 -07:00
|
|
|
const RootAppRouter = loadable(() => import('./RootAppRouter'));
|
2023-04-27 17:04:33 -04:00
|
|
|
|
2023-06-07 03:38:39 +03:00
|
|
|
const queryClient = new QueryClient();
|
|
|
|
|
2023-10-06 20:26:00 -07:00
|
|
|
const RootAppLayout = ({ history }: { history: History }) => {
|
2023-04-13 00:47:34 +03:00
|
|
|
const layoutMode = localStorage.getItem('layout');
|
2023-09-27 02:07:40 -04:00
|
|
|
const isExperimentalLayout = layoutMode === 'experimental';
|
2022-11-18 18:58:11 -05:00
|
|
|
|
2023-09-21 16:40:08 -04:00
|
|
|
const isNewLayoutPath = Object.values(DASHBOARD_APP_PATHS)
|
2023-10-06 20:26:00 -07:00
|
|
|
.some(path => window.location.pathname.startsWith(`/${path}`));
|
2023-09-21 16:40:08 -04:00
|
|
|
|
2022-10-28 01:09:59 -04:00
|
|
|
return (
|
2023-09-27 02:07:40 -04:00
|
|
|
<>
|
|
|
|
<Backdrop />
|
2023-09-21 16:40:08 -04:00
|
|
|
<AppHeader isHidden={isExperimentalLayout || isNewLayoutPath} />
|
2023-09-27 02:07:40 -04:00
|
|
|
|
2023-10-06 20:26:00 -07:00
|
|
|
{isExperimentalLayout ?
|
|
|
|
<RootAppRouter history={history} /> :
|
2023-10-06 20:29:54 -07:00
|
|
|
<StableAppRouter history={history} />
|
2023-09-27 02:07:40 -04:00
|
|
|
}
|
|
|
|
</>
|
2022-10-28 01:09:59 -04:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2023-09-27 02:07:40 -04:00
|
|
|
const RootApp = ({ history }: { history: History }) => (
|
|
|
|
<QueryClientProvider client={queryClient}>
|
|
|
|
<ApiProvider>
|
|
|
|
<WebConfigProvider>
|
|
|
|
<ThemeProvider theme={theme}>
|
2023-10-06 20:26:00 -07:00
|
|
|
<RootAppLayout history={history} />
|
2023-09-27 02:07:40 -04:00
|
|
|
</ThemeProvider>
|
|
|
|
</WebConfigProvider>
|
|
|
|
</ApiProvider>
|
|
|
|
<ReactQueryDevtools initialIsOpen={false} />
|
|
|
|
</QueryClientProvider>
|
|
|
|
);
|
|
|
|
|
2023-04-27 17:04:33 -04:00
|
|
|
export default RootApp;
|