forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDashboardRouter.tsx
More file actions
50 lines (48 loc) · 1.99 KB
/
DashboardRouter.tsx
File metadata and controls
50 lines (48 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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';
export default () => {
const location = useLocation();
return (
<>
<NavigationBar />
{location.pathname.startsWith('/account') && (
<SubNavigation>
<div>
{routes.account
.filter((route) => !!route.name)
.map(({ path, name, exact = false }) => (
<NavLink key={path} to={`/account/${path}`.replace('//', '/')} exact={exact}>
{name}
</NavLink>
))}
</div>
</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>
))}
<Route path={'*'}>
<NotFound />
</Route>
</Switch>
</React.Suspense>
</TransitionRouter>
</>
);
};