9 lines
324 B
TypeScript
9 lines
324 B
TypeScript
|
|
import { Navigate } from 'react-router';
|
||
|
|
import { useAuthStore } from './auth-store';
|
||
|
|
|
||
|
|
export function ProtectedRoute({ children }: { children: React.ReactNode }) {
|
||
|
|
const isAuthenticated = useAuthStore((s) => s.isAuthenticated);
|
||
|
|
if (!isAuthenticated) return <Navigate to="/login" replace />;
|
||
|
|
return <>{children}</>;
|
||
|
|
}
|