-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathNavigation.tsx
More file actions
81 lines (69 loc) · 2.72 KB
/
Navigation.tsx
File metadata and controls
81 lines (69 loc) · 2.72 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { Routes, Route, Outlet, Navigate, useNavigate, useParams } from 'react-router-dom';
import usePageTracking from '../hooks/usePageTracking';
import {
Layout as CompetitionLayout,
Home as CompetitionHomePage,
Staff as StaffPage,
Rooms as RoomsPage,
Round as RoundPage,
Person as PersonPage,
Assignments as AssignmentsPage,
Export as ExportPage,
Import as ImportPage,
ScramblerSchedule as ScramblerSchedulePage,
} from '../pages/Competition';
import FirstTimers from '../pages/Competition/Checks/FirstTimers';
import { GroupifierPrintingConfig } from '../pages/Competition/External/GroupifierPrinting';
import GanttChart from '../pages/Competition/GanttChart';
import QueryPage from '../pages/Competition/Query';
import HomePage from '../pages/Home';
import { useAuth } from '../providers/AuthProvider';
import Layout from './Layout';
const AuthenticatedRoute = () => {
const { signIn, signedIn } = useAuth();
if (!signedIn()) {
signIn();
return <div />;
}
return <Outlet />;
};
const Comp404 = () => {
// const navigate = useNavigate();
// const { competitionId } = useParams();
// useEffect(() => {
// navigate(`/competitions/${competitionId}`, { replace: true });
// }, [competitionId, navigate]);
return null;
};
const Navigation = () => {
usePageTracking(import.meta.env.VITE_GA_MEASUREMENT_ID);
return (
<Routes>
<Route path="/" element={<Layout />}>
<Route index element={<HomePage />} />
<Route path="/competitions/" element={<AuthenticatedRoute />}>
<Route path=":competitionId" element={<CompetitionLayout />}>
<Route index element={<CompetitionHomePage />} />
<Route path="staff" element={<StaffPage />} />
<Route path="rooms" element={<RoomsPage />} />
<Route path="events/:roundId" element={<RoundPage />} />
<Route path="persons/:registrantId" element={<PersonPage />} />
<Route path="assignments" element={<AssignmentsPage />} />
<Route path="export" element={<ExportPage />} />
<Route path="import" element={<ImportPage />} />
<Route path="scrambler-schedule" element={<ScramblerSchedulePage />} />
<Route path="query" element={<QueryPage />} />
<Route path="checks/first-timers" element={<FirstTimers />} />
<Route path="external/groupifier-printing" element={<GroupifierPrintingConfig />} />
<Route path="gantt-chart" element={<GanttChart />} />
<Route path="*" element={<Comp404 />} />
</Route>
</Route>
<Route path="*">
<Route path="*" element={<Navigate to="/" replace />} />
</Route>
</Route>
</Routes>
);
};
export default Navigation;