|
| 1 | +import { Route } from 'react-router-dom'; |
| 2 | + |
1 | 3 | import { AppRoute } from '~/libs/enums/enums.js';
|
| 4 | +import { UserGroupKey } from '~/packages/users/libs/enums/enums.js'; |
2 | 5 | import { Auth } from '~/pages/auth/auth.js';
|
3 | 6 | import { Dashboard } from '~/pages/dashboard/dashboard.js';
|
4 | 7 | import { NotFound } from '~/pages/not-found/not-found.js';
|
5 | 8 | import { WelcomePage } from '~/pages/welcome/welcome.js';
|
6 | 9 |
|
7 | 10 | import { App } from '../app/app.js';
|
| 11 | +import { ProtectedRoute } from '../components.js'; |
8 | 12 | import { PageLayout } from '../page-layout/page-layout.js';
|
9 | 13 | import { RouterProvider } from '../router-provider/router-provider.js';
|
10 | 14 |
|
11 | 15 | const Router = (): JSX.Element => (
|
12 |
| - <RouterProvider |
13 |
| - routes={[ |
14 |
| - { |
15 |
| - path: AppRoute.ROOT, |
16 |
| - element: <App />, |
17 |
| - children: [ |
18 |
| - { |
19 |
| - path: AppRoute.ROOT, |
20 |
| - element: 'Root', |
21 |
| - }, |
22 |
| - { |
23 |
| - path: AppRoute.WELCOME, |
24 |
| - element: <WelcomePage />, |
25 |
| - }, |
26 |
| - { |
27 |
| - path: AppRoute.SIGN_IN, |
28 |
| - element: <Auth />, |
29 |
| - }, |
30 |
| - { |
31 |
| - path: AppRoute.SIGN_UP, |
32 |
| - element: <Auth />, |
33 |
| - }, |
34 |
| - { |
35 |
| - path: AppRoute.ANY, |
36 |
| - element: <NotFound />, |
37 |
| - }, |
38 |
| - ], |
39 |
| - }, |
40 |
| - { |
41 |
| - path: AppRoute.DASHBOARD, |
42 |
| - element: ( |
| 16 | + <RouterProvider> |
| 17 | + <Route path={AppRoute.ROOT} element={<App />}> |
| 18 | + <Route path={AppRoute.WELCOME} element={<WelcomePage />} /> |
| 19 | + <Route path={AppRoute.SIGN_IN} element={<Auth />} /> |
| 20 | + <Route path={AppRoute.SIGN_UP} element={<Auth />} /> |
| 21 | + </Route> |
| 22 | + <Route |
| 23 | + path={AppRoute.ROOT} |
| 24 | + element={<ProtectedRoute allowedUserGroup={UserGroupKey.BUSINESS} />} |
| 25 | + > |
| 26 | + <Route |
| 27 | + path={AppRoute.DASHBOARD} |
| 28 | + element={ |
43 | 29 | <PageLayout>
|
44 | 30 | <Dashboard />
|
45 | 31 | </PageLayout>
|
46 |
| - ), |
47 |
| - }, |
48 |
| - ]} |
49 |
| - /> |
| 32 | + } |
| 33 | + /> |
| 34 | + </Route> |
| 35 | + <Route path={AppRoute.ANY} element={<NotFound />} /> |
| 36 | + </RouterProvider> |
50 | 37 | );
|
51 | 38 |
|
52 | 39 | export { Router };
|
| 40 | +export { Outlet as RouterOutlet } from 'react-router-dom'; |
0 commit comments