import AppLayout from "@/components/layout/app-layout"; import LoadingScreen from "@/components/ui/LoadingScreen"; import { useAuth } from "@/hooks/use-auth"; import { Suspense } from "react"; import { Redirect, Route } from "wouter"; type ComponentLike = React.ComponentType; // works for both lazy() and regular components export function ProtectedRoute({ path, component: Component, adminOnly = false, }: { path: string; component: ComponentLike; adminOnly?: boolean; }) { const { user, isLoading } = useAuth(); return ( {isLoading ? ( ) : !user ? ( ) : adminOnly && user.username !== "admin" ? ( ) : ( }> )} ); }