-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMainModuleRouter.tsx
More file actions
57 lines (45 loc) · 1.69 KB
/
MainModuleRouter.tsx
File metadata and controls
57 lines (45 loc) · 1.69 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
51
52
53
54
55
56
57
import React from 'react';
import { useRouteMatch, Route, Redirect, Switch } from 'react-router';
import { withLazy } from 'utils';
import { OnlyAdminRoute, OnlyAuthorizedRoute } from 'shared/guards';
import { TemplateCategory } from 'shared/models';
const AdminModule = withLazy(() => import('./admin'));
const Templates = withLazy(() => import('./templates'));
const TemplateDetails = withLazy(() => import('./template-details'));
const TemplateDocumentation = withLazy(() => import('./template-documentation'));
const TemplateManagement = withLazy(() => import('./template-management'));
const MainModuleRouter = (): JSX.Element => {
const match = useRouteMatch();
return (
<Switch>
<OnlyAdminRoute
redirect={`${match.path}/templates`}
path={`${match.path}/admin`}
component={AdminModule}
/>
<OnlyAuthorizedRoute
exact
redirect={`${match.path}/templates`}
path={`${match.path}/templates/management/:id?`}
component={TemplateManagement}
/>
<Route
exact
path={`${match.path}/templates`}
render={() => <Redirect to={`${match.path}/templates/${TemplateCategory.ALL}`} />}
/>
<Route exact path={`${match.path}/templates/:category`} component={Templates} />
<Route exact path={`${match.path}/templates/:category/:id`} component={TemplateDetails} />
<Route
exact
path={`${match.path}/templates/:category/:id/documentation`}
component={TemplateDocumentation}
/>
<Route
path="*"
render={() => <Redirect to={`${match.path}/templates/${TemplateCategory.ALL}`} />}
/>
</Switch>
);
};
export default MainModuleRouter;