2026-05-26 15:48:01 +05:30
|
|
|
import { Navigate } from 'react-router-dom';
|
|
|
|
|
import { useAuth } from '@/context/AuthContext';
|
2026-03-12 17:56:52 +05:30
|
|
|
|
2026-05-26 15:48:01 +05:30
|
|
|
export default function ProtectedRoute({ children }: any) {
|
|
|
|
|
const { token } = useAuth();
|
2026-03-12 17:56:52 +05:30
|
|
|
|
|
|
|
|
if (!token) {
|
|
|
|
|
return <Navigate to="/" />;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return children;
|
|
|
|
|
}
|