show credential pw
This commit is contained in:
@@ -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 />
|
||||
|
||||
Reference in New Issue
Block a user