/** * Guards `App`'s routes that need a session, the dump editor and * `/notifications`. * * @module */ import { Navigate } from "react-router"; import { useAuth } from "../hooks/auth/useAuth.ts"; /** Passed to {@link RestrictedLoggedIn} by `App`, around a route's page. */ export interface RestrictedLoggedInProps { children: React.ReactNode; } /** * Renders `children` when someone is signed in, and redirects to `/login` * otherwise. The page it came from is not remembered, so signing in lands on * `/`. */ export function RestrictedLoggedIn( { children }: RestrictedLoggedInProps, ): React.JSX.Element { const { user } = useAuth(); return user ? <>{children} : ; }