-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathapp.tsx
136 lines (131 loc) · 4.07 KB
/
app.tsx
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import { Suspense, useEffect } from 'react';
import { createBrowserRouter, RouterProvider } from 'react-router-dom';
import 'i18n';
import HomeEditor from 'applications/editor/Home';
import HomeOperationalStudies from 'applications/operationalStudies/Home';
import Project from 'applications/operationalStudies/views/Project';
import Scenario from 'applications/operationalStudies/views/Scenario';
import Study from 'applications/operationalStudies/views/Study';
import HomeMap from 'applications/referenceMap/Home';
import HomeRollingStockEditor from 'applications/rollingStockEditor/Home';
import StdcmView from 'applications/stdcm/views/StdcmView';
import Error403 from 'common/authorization/components/Error403';
import InitialRedirect from 'common/authorization/components/InitialRedirect';
import ErrorBoundary from 'common/ErrorBoundary';
import { Loader } from 'common/Loaders';
import NotificationsState from 'common/Notifications';
import { OsrdContextLayout } from 'common/osrdContext';
import { MODES } from 'main/consts';
import { editorSlice } from 'reducers/editor';
import editorSelectors from 'reducers/editor/selectors';
import { updateLastInterfaceVersion } from 'reducers/main';
import { mapViewerSlice } from 'reducers/mapViewer';
import mapViewerSelectors from 'reducers/mapViewer/selectors';
import { operationalStudiesConfSlice } from 'reducers/osrdconf/operationalStudiesConf';
import simulationConfSelectors from 'reducers/osrdconf/operationalStudiesConf/selectors';
import { stdcmConfSlice } from 'reducers/osrdconf/stdcmConf';
import stdcmConfSelectors from 'reducers/osrdconf/stdcmConf/selectors';
import { useAppDispatch } from 'store';
import useAuth from 'utils/hooks/OsrdAuth';
import { DeploymentContextProvider } from 'utils/hooks/useDeploymentSettings';
import('@sncf/bootstrap-sncf.metier.reseau/dist/css/bootstrap-sncf.min.css');
const router = createBrowserRouter([
{
path: '/',
element: <InitialRedirect />,
},
{
path: 'map/*',
element: (
<OsrdContextLayout
slice={mapViewerSlice}
selectors={mapViewerSelectors}
mode={MODES.mapViewer}
/>
),
children: [{ path: '*', element: <HomeMap /> }],
},
{
path: 'editor/*',
element: (
<OsrdContextLayout slice={editorSlice} selectors={editorSelectors} mode={MODES.editor} />
),
children: [
{
path: '*',
element: <HomeEditor />,
},
],
},
{
path: 'stdcm/*',
element: (
<OsrdContextLayout slice={stdcmConfSlice} selectors={stdcmConfSelectors} mode={MODES.stdcm} />
),
children: [
{
path: '*',
element: <StdcmView />,
},
],
},
{
path: 'rolling-stock-editor/*',
element: <HomeRollingStockEditor />,
},
{
path: 'operational-studies/',
element: (
<OsrdContextLayout
slice={operationalStudiesConfSlice}
selectors={simulationConfSelectors}
mode={MODES.simulation}
/>
),
errorElement: <ErrorBoundary />,
children: [
{
path: 'projects',
element: <HomeOperationalStudies />,
},
{
path: 'projects/:projectId',
element: <Project />,
},
{
path: 'projects/:projectId/studies/:studyId',
element: <Study />,
},
{
path: 'projects/:projectId/studies/:studyId/scenarios/:scenarioId',
element: <Scenario />,
},
],
},
{
path: '403/*',
element: <Error403 />,
},
{
path: '*',
element: <ErrorBoundary />,
},
]);
export default function App() {
const dispatch = useAppDispatch();
useEffect(() => {
// eslint-disable-next-line react-hooks/exhaustive-deps
// Blindly dispatch current front version for storage
dispatch(updateLastInterfaceVersion(import.meta.env.VITE_OSRD_GIT_DESCRIBE));
}, []);
const { isLoading } = useAuth();
return (
<Suspense fallback={<Loader />}>
<DeploymentContextProvider>
<NotificationsState />
{!isLoading && <RouterProvider router={router} />}
{isLoading && <Loader />}
</DeploymentContextProvider>
</Suspense>
);
}