import { Navigate, useLocation } from "react-router-dom"; import { useAuth } from "../state/auth"; export const ProtectedRoute = ({ children }: { children: React.ReactNode }) => { const { state } = useAuth(); const location = useLocation(); if (state === "loading") { return
Checking session...
; } if (state === "unauthenticated") { const nextPath = encodeURIComponent(location.pathname); return ; } return <>{children}; };