ai-gateway/web/default/src/components/PrivateRoute.js

13 lines
285 B
JavaScript
Raw Normal View History

2023-04-22 12:39:27 +00:00
import { Navigate } from 'react-router-dom';
import { history } from '../helpers';
function PrivateRoute({ children }) {
if (!localStorage.getItem('user')) {
return <Navigate to='/login' state={{ from: history.location }} />;
}
return children;
}
export { PrivateRoute };