import { Navigate, useLocation } from "react-router-dom"; import { useAuth } from "../context/AuthContext.jsx"; export default function ProtectedRoute({ children }) { const { user, loading } = useAuth(); const location = useLocation(); if (loading) { return (
); } if (!user) { // Redirect unauthenticated users to login page return ; } return children; }