Uecko_ERP/modules/auth/src/web/components/auth-guard.tsx
2025-05-28 16:21:09 +02:00

17 lines
397 B
TypeScript

import { JSX } from "react";
import { Navigate } from "react-router-dom";
import { useIsAuthenticated } from "../hooks";
/**
* Protege una ruta para usuarios autenticados.
*/
export const AuthGuard = ({ children }: { children: JSX.Element }) => {
const isAuthenticated = useIsAuthenticated();
if (!isAuthenticated) {
return <Navigate to='/login' replace />;
}
return children;
};