16 lines
383 B
TypeScript
16 lines
383 B
TypeScript
|
|
import { ReactNode } from 'react';
|
|
import { Navigate } from 'react-router-dom';
|
|
import { authService } from '@/services/authService';
|
|
|
|
interface ProtectedRouteProps {
|
|
children: ReactNode;
|
|
}
|
|
|
|
export const ProtectedRoute = ({ children }: ProtectedRouteProps) => {
|
|
if (!authService.isAuthenticated()) {
|
|
return <Navigate to="/login" replace />;
|
|
}
|
|
|
|
return <>{children}</>;
|
|
}; |