import { useEffect } from "react"; import { BrowserRouter, Navigate, Outlet, Route, Routes } from "react-router-dom"; import { AppShell } from "@/components/layout/AppShell"; import { Login } from "@/pages/Login"; import { Dashboard } from "@/pages/Dashboard"; import { Stacks } from "@/pages/Stacks"; import { StackDetail } from "@/pages/StackDetail"; import { StackEditor } from "@/pages/StackEditor"; import { Images } from "@/pages/Images"; import { Files } from "@/pages/Files"; import { Volumes } from "@/pages/Volumes"; import { Templates } from "@/pages/Templates"; import { Settings } from "@/pages/Settings"; import { Audit } from "@/pages/Audit"; import { Networks } from "@/pages/Networks"; import { useAuthStore } from "@/store/auth"; import { useThemeStore } from "@/store/theme"; function RequireAuth() { const token = useAuthStore((s) => s.accessToken); const ready = useAuthStore((s) => s.ready); // The access token lives in memory, so on a reload we have nothing until the // cookie-based restore has run. Bouncing to /login before that would sign // people out on every refresh. if (!ready) return ; return token ? : ; } function BootSplash() { return (
Restoring your session… ); } export default function App() { const applyTheme = useThemeStore((s) => s.apply); const restore = useAuthStore((s) => s.restore); useEffect(() => { applyTheme(); }, [applyTheme]); // Trade the httpOnly refresh cookie for an access token once on boot. useEffect(() => { restore(); }, [restore]); return ( } /> }> }> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> ); }