-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathNavigator.tsx
More file actions
66 lines (57 loc) · 2.24 KB
/
Navigator.tsx
File metadata and controls
66 lines (57 loc) · 2.24 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
58
59
60
61
62
63
64
65
66
import { Navigate, Route, Routes } from 'react-router-dom';
import { Suspense } from 'react';
import CenterLoadingSpinner from '../components/CenterLoadingSpinner';
// These Pages are loaded initially:
import Login from '../pages/Login';
import LoginToken from '../pages/LoginToken';
import { RequireAuth } from '../User';
import FullPageModal from '../modals/FullPageModal';
import { lazyWithRetry } from '../lazy';
import Logout from '../components/Logout';
import LoginWithIDP from '@/pages/LoginWithIDP';
// All other pages load lazy:
const RegistrationLazy = lazyWithRetry(() => import('./RegistrationLazy'), { prefetch: false });
const NavigatorLazy = lazyWithRetry(() => import('./NavigatorLazy'), { prefetch: !window.location.pathname.startsWith('/registration') });
// This component only exists to reliably test our support process:
function CrashMe() {
return ({} as any).very.stupid;
}
export default function Navigator() {
return (
<>
<Routes>
<Route path="/login" element={<Login />} />
<Route path="/login-token" element={<LoginToken />} />
<Route path="/login-with" element={<LoginWithIDP />} />
<Route path="/logout" element={<Logout />} />
<Route path="/welcome" element={<Navigate to="/login" />} />
<Route
path="/registration/*"
element={
<Suspense fallback={<CenterLoadingSpinner />}>
<RegistrationLazy />
</Suspense>
}
/>
<Route
path="/"
element={
<RequireAuth>
<Navigate to="/start" />
</RequireAuth>
}
/>
<Route
path="*"
element={
<Suspense fallback={<CenterLoadingSpinner />}>
<NavigatorLazy />
</Suspense>
}
/>
<Route path="/crash-me" element={<CrashMe />} />
</Routes>
<FullPageModal />
</>
);
}