Add account related routes to router file
This commit is contained in:
parent
7197d28815
commit
b50e722948
3 changed files with 58 additions and 27 deletions
|
@ -1,16 +1,13 @@
|
|||
import React from 'react';
|
||||
import { NavLink, Route, Switch } from 'react-router-dom';
|
||||
import AccountOverviewContainer from '@/components/dashboard/AccountOverviewContainer';
|
||||
import NavigationBar from '@/components/NavigationBar';
|
||||
import DashboardContainer from '@/components/dashboard/DashboardContainer';
|
||||
import AccountApiContainer from '@/components/dashboard/AccountApiContainer';
|
||||
import { NotFound } from '@/components/elements/ScreenBlock';
|
||||
import TransitionRouter from '@/TransitionRouter';
|
||||
import SubNavigation from '@/components/elements/SubNavigation';
|
||||
import AccountSSHContainer from '@/components/dashboard/ssh/AccountSSHContainer';
|
||||
import { useLocation } from 'react-router';
|
||||
import ActivityLogContainer from '@/components/dashboard/activity/ActivityLogContainer';
|
||||
import Spinner from '@/components/elements/Spinner';
|
||||
import routes from '@/routers/routes';
|
||||
|
||||
export default () => {
|
||||
const location = useLocation();
|
||||
|
@ -21,10 +18,15 @@ export default () => {
|
|||
{location.pathname.startsWith('/account') &&
|
||||
<SubNavigation>
|
||||
<div>
|
||||
<NavLink to={'/account'} exact>Settings</NavLink>
|
||||
<NavLink to={'/account/api'}>API Credentials</NavLink>
|
||||
<NavLink to={'/account/ssh'}>SSH Keys</NavLink>
|
||||
<NavLink to={'/account/activity'}>Activity</NavLink>
|
||||
{routes.account.filter((route) => !!route.name).map(({ path, name, exact = false }) => (
|
||||
<NavLink
|
||||
key={path}
|
||||
to={`/account/${path}`.replace('//', '/')}
|
||||
exact={exact}
|
||||
>
|
||||
{name}
|
||||
</NavLink>
|
||||
))}
|
||||
</div>
|
||||
</SubNavigation>
|
||||
}
|
||||
|
@ -34,18 +36,11 @@ export default () => {
|
|||
<Route path={'/'} exact>
|
||||
<DashboardContainer/>
|
||||
</Route>
|
||||
<Route path={'/account'} exact>
|
||||
<AccountOverviewContainer/>
|
||||
</Route>
|
||||
<Route path={'/account/api'} exact>
|
||||
<AccountApiContainer/>
|
||||
</Route>
|
||||
<Route path={'/account/ssh'} exact>
|
||||
<AccountSSHContainer/>
|
||||
</Route>
|
||||
<Route path={'/account/activity'} exact>
|
||||
<ActivityLogContainer/>
|
||||
</Route>
|
||||
{routes.account.map(({ path, component: Component }) => (
|
||||
<Route key={path} path={`/account/${path}`.replace('//', '/')} exact>
|
||||
<Component/>
|
||||
</Route>
|
||||
))}
|
||||
<Route path={'*'}>
|
||||
<NotFound/>
|
||||
</Route>
|
||||
|
|
Reference in a new issue