import { useEffect } from "react";
import { useAuth } from "../contexts/AuthContext";
import { useNavigate, Navigate } from "react-router-dom";

  

const ProtectedRoute = ({ children }) => {
    const { user } = useAuth();
    const navigate=useNavigate(); 
    const {isAuthenticated}=useAuth();
    
    if (!user) {
        return <Navigate to="/" />;
    }
    return children;
};

export default ProtectedRoute;