Files
Clarium/src/auth/RequireAuth.tsx
T
mroberts 9d7b0e805c style: drop redundant comments and apply formatting
Frontend now uses double quotes and semicolons. No behaviour change.
2026-10-02 15:06:56 -05:00

11 lines
385 B
TypeScript

import { Navigate, Outlet, useLocation } from "react-router";
import { useAuth } from "./AuthContext";
export function RequireAuth() {
const { user, loading } = useAuth();
const location = useLocation();
if (loading) return <p className="p-6 text-slate-500">Loading…</p>;
if (!user) return <Navigate to="/login" replace state={{ from: location }} />;
return <Outlet />;
}