mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-15 20:17:22 +00:00
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { Router, Switch, Route } from "wouter";
|
|
import Home from "./routes/home.tsx";
|
|
import { lazy, Suspense, useEffect, useState } from "react";
|
|
const Admin = lazy(() => import("./routes/admin.tsx"));
|
|
import { useAuth } from "bknd/client";
|
|
|
|
export default function App() {
|
|
const auth = useAuth();
|
|
const [verified, setVerified] = useState(false);
|
|
|
|
useEffect(() => {
|
|
auth.verify().then(() => setVerified(true));
|
|
}, []);
|
|
|
|
if (!verified) return null;
|
|
|
|
return (
|
|
<Router>
|
|
<Switch>
|
|
<Route path="/" component={Home} />
|
|
<Route path="/admin/*?">
|
|
<Suspense>
|
|
<Admin
|
|
config={{
|
|
basepath: "/admin",
|
|
logo_return_path: "/../",
|
|
}}
|
|
/>
|
|
</Suspense>
|
|
</Route>
|
|
<Route path="*">
|
|
<div className="w-full min-h-full flex justify-center items-center font-mono text-4xl">
|
|
404
|
|
</div>
|
|
</Route>
|
|
</Switch>
|
|
</Router>
|
|
);
|
|
}
|