import { Navigate } from "react-router-dom";
import { useAuth } from "../components/AuthContext";
import type { JSX } from 'react';

const ProtectedRoute = ({ children }: { children: JSX.Element }) => {
  // const { token } = useAuth();
const token = localStorage.getItem('token');
  // console.log(token);
  if(token!=null)
    return children;
  else
    console.log(token)
    return <Navigate to="/" />;
  // return token ? children : <Navigate to="/" />;
};

export default ProtectedRoute;
