2026-04-17 17:20:41 +08:00
|
|
|
import React from 'react';
|
2026-04-21 10:33:48 +08:00
|
|
|
import { useSelector } from 'react-redux';
|
2026-04-17 17:20:41 +08:00
|
|
|
import { Navigate, Outlet } from 'react-router-dom';
|
|
|
|
|
|
|
|
|
|
export default function ProtectedRoute() {
|
2026-04-21 10:33:48 +08:00
|
|
|
const isAuthenticated = localStorage.getItem('isAuthenticated') === 'true';
|
|
|
|
|
//const { isAuthenticated } = useSelector(state => state.user);
|
2026-04-17 17:20:41 +08:00
|
|
|
|
|
|
|
|
|
2026-04-21 10:33:48 +08:00
|
|
|
if (!isAuthenticated) {
|
|
|
|
|
return <Navigate to="/login" replace />;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return <Outlet />;
|
2026-04-17 17:20:41 +08:00
|
|
|
}
|