show credential pw

This commit is contained in:
ff
2026-04-07 23:52:05 -04:00
parent cb97e249d0
commit b9edd6a5e6
16 changed files with 1846 additions and 318 deletions

View File

@@ -9,23 +9,25 @@ type ComponentLike = React.ComponentType; // works for both lazy() and regular c
export function ProtectedRoute({
path,
component: Component,
adminOnly = false,
}: {
path: string;
component: ComponentLike;
adminOnly?: boolean;
}) {
const { user, isLoading } = useAuth();
return (
<Route path={path}>
{/* While auth is resolving: keep layout visible and show a small spinner in the content area */}
{isLoading ? (
<AppLayout>
<LoadingScreen />
</AppLayout>
) : !user ? (
<Redirect to="/auth" />
) : adminOnly && user.username !== "admin" ? (
<Redirect to="/insurance-status" />
) : (
// Authenticated: render page inside layout. Lazy pages load with an in-layout spinner.
<AppLayout>
<Suspense fallback={<LoadingScreen />}>
<Component />