import { Route, useNavigate } from "react-router-dom";
import { useGetUserDetails } from "../../controller/index";
export default function ProtectedRoute({ ...children }) {
const { isLoading, isError } = useGetUserDetails();
const navigate = useNavigate();
if (isLoading) return please wait while we authenticate you;
if (isError) {
// toast.error("Please sign in first!");
navigate("/login");
return you are not allowed here!;
}
// if we can successfully get user details, we are good to continue
return <>{children}>;
}