mirror of
https://github.com/Dasemu/skipredictor.git
synced 2026-11-26 07:16:15 +00:00
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
import { HashRouter, Navigate, Route, Routes } from 'react-router-dom'
|
|
|
|
import { AppProvider } from './app/AppContext'
|
|
import { useAppContext } from './app/useAppContext'
|
|
import { AppShell } from './components/AppShell'
|
|
import { SplashScreen } from './components/StateViews'
|
|
import { AuthPage } from './pages/AuthPage'
|
|
import { PredictionsPage } from './pages/PredictionsPage'
|
|
import { SettingsPage } from './pages/SettingsPage'
|
|
import { StationPage } from './pages/StationPage'
|
|
import { StationsPage } from './pages/StationsPage'
|
|
|
|
function AppRoutes() {
|
|
const { isAuthenticated, isBooting } = useAppContext()
|
|
|
|
if (isBooting) {
|
|
return <SplashScreen />
|
|
}
|
|
|
|
if (!isAuthenticated) {
|
|
return <AuthPage />
|
|
}
|
|
|
|
return (
|
|
<HashRouter>
|
|
<Routes>
|
|
<Route element={<AppShell />}>
|
|
<Route index element={<Navigate to="/stations" replace />} />
|
|
<Route path="/stations" element={<StationsPage />} />
|
|
<Route path="/stations/:stationId" element={<StationPage />} />
|
|
<Route path="/predictions" element={<PredictionsPage />} />
|
|
<Route path="/predictions/:date" element={<PredictionsPage />} />
|
|
<Route path="/settings" element={<SettingsPage />} />
|
|
<Route path="*" element={<Navigate to="/stations" replace />} />
|
|
</Route>
|
|
</Routes>
|
|
</HashRouter>
|
|
)
|
|
}
|
|
|
|
function App() {
|
|
return (
|
|
<AppProvider>
|
|
<AppRoutes />
|
|
</AppProvider>
|
|
)
|
|
}
|
|
|
|
export default App
|