import { Navigate, Outlet, useLocation } from 'react-router-dom'; import { useAuth } from '../../contexts/AuthContext'; import PageLoader from '../common/PageLoader'; import DashboardLayout from '../layouts/DashboardLayout'; const ProtectedRoute = () => { const { isAuthenticated, loading } = useAuth(); const location = useLocation(); if (loading) { return ; } if (!isAuthenticated) { // Redirect to login page but save the page they tried to access return ; } // User is authenticated, render the protected route with dashboard layout return ( ); }; export default ProtectedRoute;