Add Restaurant almost done

This commit is contained in:
2020-09-18 18:59:18 +02:00
parent 1c9d9e2021
commit 732ad74657
8 changed files with 243 additions and 21 deletions

View File

@@ -0,0 +1,25 @@
import React from "react";
import { useSelector } from "react-redux";
import { Redirect, Route } from "react-router-dom";
export default function PrivateRoute({ component, ...rest }) {
const loggedIn = useSelector((state) => state.data.loggedIn);
return (
<Route
{...rest}
render={({ location }) =>
loggedIn ? (
component
) : (
<Redirect
to={{
pathname: "/login",
state: { from: location },
}}
/>
)
}
/>
);
}