import React, { useContext } from "react";
import { AuthContext } from "../Context/AuthProvider";
import { Navigate } from "react-router-dom";

const PrivateRoute = ({ children }) => {
  console.log("AuthContext", AuthContext);
  const { currentUserEmail } = useContext(AuthContext);
  console.log("currentUserEmail", currentUserEmail);
  return currentUserEmail === null ? <Navigate to="/" /> : children;
};

export default PrivateRoute;
