import { lazy, Suspense } from "react"; import { SiteWrapper, SpinnerPage, Unhealthy } from "components"; import { useAuthState, useLocaleState } from "context"; import { useHealth } from "hooks"; import { BrowserRouter, Routes, Route } from "react-router-dom"; const AccessLists = lazy(() => import("pages/AccessLists")); const AuditLog = lazy(() => import("pages/AuditLog")); const Certificates = lazy(() => import("pages/Certificates")); const CertificateAuthorities = lazy( () => import("pages/CertificateAuthorities"), ); const Dashboard = lazy(() => import("pages/Dashboard")); const DNSProviders = lazy(() => import("pages/DNSProviders")); const Hosts = lazy(() => import("pages/Hosts")); const NginxTemplates = lazy(() => import("pages/NginxTemplates")); const Login = lazy(() => import("pages/Login")); const GeneralSettings = lazy(() => import("pages/Settings")); const Setup = lazy(() => import("pages/Setup")); const Users = lazy(() => import("pages/Users")); function Router() { const health = useHealth(); const { authenticated } = useAuthState(); const { locale } = useLocaleState(); const Spinner = ; if (health.isLoading) { return Spinner; } if (health.isError || !health.data?.healthy) { return ; } if (health.data?.healthy && !health.data?.setup) { return ( ); } if (!authenticated) { return ( ); } return ( } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> ); } export default Router;