// src/routes/ProtectedRoute.tsx
import { Navigate, Outlet, useLocation } from 'react-router-dom';
import { useAppSelector } from '../../redux/hooks';

export default function ProtectedRoute() {
    const isAuthenticated = useAppSelector((state) => !!state.auth.jwt);
    const location = useLocation();

    if (!isAuthenticated) {
        return <Navigate to="/home/login" replace state={{ from: location }} />;
    }

    return <Outlet />;
}
