-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathmainContent.jsx
More file actions
71 lines (63 loc) · 2.14 KB
/
mainContent.jsx
File metadata and controls
71 lines (63 loc) · 2.14 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
/*
The main wrapper for the app
*/
import { Route, Routes, useLocation } from "react-router-dom"
import { useEffect } from "react"
import Toolbar from "./toolbar/toolbar"
import SettingsModal from "./settingsModal"
import { Commands } from "./spotlight/commandHandler"
// Wrappers
import SingleRunWrapper from "./SingleRunWrapper"
import { SettingsProvider } from "../helpers/settingsProvider"
// Routes
import FLA from "../fla"
import Graphs from "../graphs"
import Missions from "../missions"
import Params from "../params"
import Config from "../config"
import CameraWindow from "./dashboard/webcam/webcam"
import Dashboard from "../dashboard"
import Navbar from "./navbar"
// Redux
import { useDispatch } from "react-redux"
import { ErrorBoundary } from "react-error-boundary"
import AlertProvider from "./dashboard/alertProvider"
import ErrorBoundaryFallback from "./error/errorBoundary"
import { initSocket } from "../redux/slices/socketSlice"
export default function AppContent() {
// Conditionally render UI so the webcam route is literally just a webcam
const renderUI = useLocation().pathname !== "/webcam"
// Setup sockets for redux
const dispatch = useDispatch()
useEffect(() => {
dispatch(initSocket())
}, [])
return (
<SettingsProvider>
<SingleRunWrapper>
{renderUI && <Toolbar />}
<ErrorBoundary fallbackRender={ErrorBoundaryFallback}>
<SettingsModal />
{renderUI && <Navbar className="no-drag" />}
<Routes>
<Route
path="/"
element={
<AlertProvider>
<Dashboard />
</AlertProvider>
}
/>
<Route path="/missions" element={<Missions />} />
<Route path="/graphs" element={<Graphs />} />
<Route path="/params" element={<Params />} />
<Route path="/config" element={<Config />} />
<Route path="/webcam" element={<CameraWindow />} />
<Route path="/fla" element={<FLA />} />
</Routes>
{renderUI && <Commands />}
</ErrorBoundary>
</SingleRunWrapper>
</SettingsProvider>
)
}