import React from "react";
import { useLocation, Navigate } from "react-router-dom";
import Cookies from "universal-cookie";
const cookies = new Cookies();
export default function ProtectedRoutes({children}) {
console.log("inside protectedroutes")
const token = cookies.get("TOKEN");
console.log("token is: ", token)
let location = useLocation();
if(!token){
return <Navigate to="/" state={{ from: location }} replace />;
}
return children;
};