import { Redirect, Route } from "react-router-dom"; import { useAuth } from "../utils/context"; import ErrorPage from "../pages/ErrorPage"; const PrivateRoute = ({ component: Component, ...rest }) => { const { user } = useAuth(); return ( { if (user.id !== "") { if (rest.role) { if (rest.role === user.role) { return ; } else { return } } else { return } } else { return ; } }} /> ); }; export default PrivateRoute;