ADD: added initial page with login
This commit is contained in:
8
frontend/src/pages/ProtectedRoute.tsx
Normal file
8
frontend/src/pages/ProtectedRoute.tsx
Normal file
@@ -0,0 +1,8 @@
|
||||
import { Navigate } from 'react-router-dom';
|
||||
import { useAuth } from './AuthContext';
|
||||
import { JSX } from 'react';
|
||||
|
||||
export default function ProtectedRoute({ children }: { children: JSX.Element }) {
|
||||
const { token } = useAuth();
|
||||
return token ? children : <Navigate to="/login" replace />;
|
||||
}
|
||||
Reference in New Issue
Block a user