import React from 'react'; import { Navigate, useLocation, Outlet } from 'react-router'; import { useAppSelector } from '@/store/hooks'; interface ProtectedRouteProps { children?: React.ReactNode; } const ProtectedRoute: React.FC = ({ children }) => { const { isAuthenticated } = useAppSelector((state) => state.auth); const location = useLocation(); if (!isAuthenticated) { // Redirect to the login page, but save the current location they were trying to go to return ; } return children ? <>{children} : ; }; export default ProtectedRoute;