import { Navigate } from "react-router"; import { useAuth } from "../contexts/AuthContext"; interface ProtectedRouteProps { children: React.ReactNode; } export function ProtectedRoute({ children }: ProtectedRouteProps) { const { isAuthenticated, isLoading, isAuthConfigured } = useAuth(); // Show loading state while checking auth if (isLoading) { return (
Loading...
); } // If auth is configured but user is not authenticated, redirect to login if (isAuthConfigured && !isAuthenticated) { return ; } return <>{children}; }