import { Navigate, useLocation } from "react-router-dom"; import { ROUTES } from "../config/routes"; import { useAuth } from "../hooks/useAuth"; import SplashScreen from "./SplashScreen"; /** * Private route guard. * If not authenticated, capture the current url in route * state so the Login component can link them back after sign-in */ export function ProtectedRoute({ children }: { children: React.ReactNode }) { const { isAuthenticated, isInitializing } = useAuth(); const location = useLocation(); if (isInitializing) return ; if (!isAuthenticated) { return ; } return <>{children}; } /** * Public - auth route guard. * If authenticated, redirect all the auth related flows to the drawer */ export function PublicRoute({ children }: { children: React.ReactNode }) { const { isAuthenticated, isInitializing } = useAuth(); if (isInitializing) return ; if (isAuthenticated) { return ; } return <>{children}; }