Files
gg-backend/frontend/src/components/ProtectedRoutes/ProtectedRoutes.tsx
T

13 lines
255 B
TypeScript
Raw Normal View History

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;
}