13 lines
302 B
TypeScript
13 lines
302 B
TypeScript
|
|
import React from 'react';
|
||
|
|
import { Navigate, Outlet } from 'react-router-dom';
|
||
|
|
|
||
|
|
export default function ProtectedRoute() {
|
||
|
|
const isAuthenticated = localStorage.getItem('isAuthenticated') === 'true';
|
||
|
|
|
||
|
|
if (!isAuthenticated) {
|
||
|
|
return <Navigate to="/login" replace />;
|
||
|
|
}
|
||
|
|
|
||
|
|
return <Outlet />;
|
||
|
|
}
|