59 lines
2.6 KiB
TypeScript
59 lines
2.6 KiB
TypeScript
import React from 'react';
|
|
import { NavLink, Route, Switch } from 'react-router-dom';
|
|
import NavigationBar from '@/components/NavigationBar';
|
|
import DashboardContainer from '@/components/dashboard/DashboardContainer';
|
|
import { NotFound } from '@/components/elements/ScreenBlock';
|
|
import TransitionRouter from '@/TransitionRouter';
|
|
import SubNavigation from '@/components/elements/SubNavigation';
|
|
import { useLocation } from 'react-router';
|
|
import Spinner from '@/components/elements/Spinner';
|
|
import routes from '@/routers/routes';
|
|
|
|
import BeforeSubNavigation from '@/blueprint/components/Navigation/SubNavigation/BeforeSubNavigation';
|
|
import AdditionalAccountItems from '@/blueprint/components/Navigation/SubNavigation/AdditionalAccountItems';
|
|
import AfterSubNavigation from '@/blueprint/components/Navigation/SubNavigation/AfterSubNavigation';
|
|
import AdditionalDashboardRoutes from '@/blueprint/components/Navigation/Routes/AdditionalDashboardRoutes';
|
|
|
|
export default () => {
|
|
const location = useLocation();
|
|
|
|
return (
|
|
<>
|
|
<NavigationBar />
|
|
{location.pathname.startsWith('/account') && (
|
|
<SubNavigation>
|
|
<BeforeSubNavigation />
|
|
<div>
|
|
{routes.account
|
|
.filter((route) => !!route.name)
|
|
.map(({ path, name, exact = false }) => (
|
|
<NavLink key={path} to={`/account/${path}`.replace('//', '/')} exact={exact}>
|
|
{name}
|
|
</NavLink>
|
|
))}
|
|
<AdditionalAccountItems />
|
|
</div>
|
|
<AfterSubNavigation />
|
|
</SubNavigation>
|
|
)}
|
|
<TransitionRouter>
|
|
<React.Suspense fallback={<Spinner centered />}>
|
|
<Switch location={location}>
|
|
<Route path={'/'} exact>
|
|
<DashboardContainer />
|
|
</Route>
|
|
{routes.account.map(({ path, component: Component }) => (
|
|
<Route key={path} path={`/account/${path}`.replace('//', '/')} exact>
|
|
<Component />
|
|
</Route>
|
|
))}
|
|
<AdditionalDashboardRoutes />
|
|
<Route path={'*'}>
|
|
<NotFound />
|
|
</Route>
|
|
</Switch>
|
|
</React.Suspense>
|
|
</TransitionRouter>
|
|
</>
|
|
);
|
|
};
|