2020-11-08 21:18:15 +00:00
|
|
|
import React from 'react';
|
2022-05-28 17:32:35 +00:00
|
|
|
import { NavLink, Route, Switch } from 'react-router-dom';
|
2019-06-26 04:28:56 +00:00
|
|
|
import NavigationBar from '@/components/NavigationBar';
|
|
|
|
import DashboardContainer from '@/components/dashboard/DashboardContainer';
|
2021-01-31 02:01:32 +00:00
|
|
|
import { NotFound } from '@/components/elements/ScreenBlock';
|
2020-07-04 16:46:26 +00:00
|
|
|
import TransitionRouter from '@/TransitionRouter';
|
2020-07-04 22:40:41 +00:00
|
|
|
import SubNavigation from '@/components/elements/SubNavigation';
|
2022-05-28 17:32:35 +00:00
|
|
|
import { useLocation } from 'react-router';
|
2022-06-11 18:04:09 +00:00
|
|
|
import Spinner from '@/components/elements/Spinner';
|
2022-06-12 17:33:25 +00:00
|
|
|
import routes from '@/routers/routes';
|
2019-06-26 04:28:56 +00:00
|
|
|
|
2022-05-28 17:32:35 +00:00
|
|
|
export default () => {
|
|
|
|
const location = useLocation();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2022-06-26 19:13:52 +00:00
|
|
|
<NavigationBar />
|
|
|
|
{location.pathname.startsWith('/account') && (
|
2022-05-28 17:32:35 +00:00
|
|
|
<SubNavigation>
|
|
|
|
<div>
|
2022-06-26 19:13:52 +00:00
|
|
|
{routes.account
|
|
|
|
.filter((route) => !!route.name)
|
|
|
|
.map(({ path, name, exact = false }) => (
|
|
|
|
<NavLink key={path} to={`/account/${path}`.replace('//', '/')} exact={exact}>
|
|
|
|
{name}
|
|
|
|
</NavLink>
|
|
|
|
))}
|
2022-05-28 17:32:35 +00:00
|
|
|
</div>
|
|
|
|
</SubNavigation>
|
2022-06-26 19:13:52 +00:00
|
|
|
)}
|
2022-05-28 17:32:35 +00:00
|
|
|
<TransitionRouter>
|
2022-06-26 19:13:52 +00:00
|
|
|
<React.Suspense fallback={<Spinner centered />}>
|
2022-06-11 18:04:09 +00:00
|
|
|
<Switch location={location}>
|
|
|
|
<Route path={'/'} exact>
|
2022-06-26 19:13:52 +00:00
|
|
|
<DashboardContainer />
|
2022-06-11 18:04:09 +00:00
|
|
|
</Route>
|
2022-06-12 17:33:25 +00:00
|
|
|
{routes.account.map(({ path, component: Component }) => (
|
|
|
|
<Route key={path} path={`/account/${path}`.replace('//', '/')} exact>
|
2022-06-26 19:13:52 +00:00
|
|
|
<Component />
|
2022-06-12 17:33:25 +00:00
|
|
|
</Route>
|
|
|
|
))}
|
2022-06-11 18:04:09 +00:00
|
|
|
<Route path={'*'}>
|
2022-06-26 19:13:52 +00:00
|
|
|
<NotFound />
|
2022-06-11 18:04:09 +00:00
|
|
|
</Route>
|
|
|
|
</Switch>
|
|
|
|
</React.Suspense>
|
2022-05-28 17:32:35 +00:00
|
|
|
</TransitionRouter>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|