buckets/frontend/src/router.tsx
myrmidex bfaf5c49ed
Some checks failed
CI / backend (push) Failing after 8m48s
CI / frontend (push) Failing after 29s
CI / e2e (push) Has been skipped
53 - Frontend: wire scenario show route and distinct not-found state
2026-07-05 23:27:17 +02:00

36 lines
1.2 KiB
TypeScript

import { createBrowserRouter, Navigate, type RouteObject } from 'react-router'
import LoginPage from './auth/LoginPage'
import RegisterPage from './auth/RegisterPage'
import { RequireAuth, RequireGuest } from './auth/guards'
import ScenarioShowPage from './pages/ScenarioShowPage'
import ScenariosPage from './pages/ScenariosPage'
/**
* Application route tree. Guards are layout routes: their children render via
* <Outlet /> only when the guard allows it (RequireGuest = signed-out users,
* RequireAuth = signed-in users). Add new pages as children of the appropriate
* guard.
*
* Exported as a plain array so tests can drive the real route config through
* createMemoryRouter (see router.test.tsx).
*/
export const routes: RouteObject[] = [
{
element: <RequireGuest />,
children: [
{ path: '/login', element: <LoginPage /> },
{ path: '/register', element: <RegisterPage /> },
],
},
{
element: <RequireAuth />,
children: [
{ path: '/', element: <ScenariosPage /> },
{ path: '/scenarios/:id', element: <ScenarioShowPage /> },
],
},
// Unknown paths fall back to the app root (which re-guards).
{ path: '*', element: <Navigate to="/" replace /> },
]
export const router = createBrowserRouter(routes)