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() as { token?: string | null };
  return token ? children : <Navigate to="/" />;
};

export default ProtectedRoute;
