Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/resources/scripts/routers/DashboardRouter.tsx
7458 views
1
import React from 'react';
2
import { NavLink, Route, Switch } from 'react-router-dom';
3
import NavigationBar from '@/components/NavigationBar';
4
import DashboardContainer from '@/components/dashboard/DashboardContainer';
5
import { NotFound } from '@/components/elements/ScreenBlock';
6
import TransitionRouter from '@/TransitionRouter';
7
import SubNavigation from '@/components/elements/SubNavigation';
8
import { useLocation } from 'react-router';
9
import Spinner from '@/components/elements/Spinner';
10
import routes from '@/routers/routes';
11
12
export default () => {
13
const location = useLocation();
14
15
return (
16
<>
17
<NavigationBar />
18
{location.pathname.startsWith('/account') && (
19
<SubNavigation>
20
<div>
21
{routes.account
22
.filter((route) => !!route.name)
23
.map(({ path, name, exact = false }) => (
24
<NavLink key={path} to={`/account/${path}`.replace('//', '/')} exact={exact}>
25
{name}
26
</NavLink>
27
))}
28
</div>
29
</SubNavigation>
30
)}
31
<TransitionRouter>
32
<React.Suspense fallback={<Spinner centered />}>
33
<Switch location={location}>
34
<Route path={'/'} exact>
35
<DashboardContainer />
36
</Route>
37
{routes.account.map(({ path, component: Component }) => (
38
<Route key={path} path={`/account/${path}`.replace('//', '/')} exact>
39
<Component />
40
</Route>
41
))}
42
<Route path={'*'}>
43
<NotFound />
44
</Route>
45
</Switch>
46
</React.Suspense>
47
</TransitionRouter>
48
</>
49
);
50
};
51
52