2021-06-22 22:15:43 +00:00
|
|
|
import { Redirect, Route } from "react-router-dom";
|
|
|
|
import { useAuth } from "./AuthProvider";
|
|
|
|
|
|
|
|
const PrivateRoute = ({ component: Component, ...rest }) => {
|
|
|
|
const [logged] = useAuth();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Route
|
|
|
|
{...rest}
|
|
|
|
render={(props) =>
|
|
|
|
logged ? <Component {...props} /> : <Redirect to="/login" />
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2021-06-23 01:40:37 +00:00
|
|
|
export default PrivateRoute;
|