import { useAuth } from 'react-oidc-context';
import type { ReactNode } from 'react';
interface AuthWrapperProps {
children: ReactNode;
}
export function AuthWrapper({ children }: AuthWrapperProps) {
const auth = useAuth();
if (auth.isLoading) {
return (
);
}
if (auth.error) {
return (
⚠
Erro de Autenticação
{auth.error.message}
);
}
if (!auth.isAuthenticated) {
return (
🔐
Dashboard Descomplicar
Faça login para aceder ao dashboard
);
}
return <>{children}>;
}
export function UserInfo() {
const auth = useAuth();
if (!auth.isAuthenticated) return null;
return (
{auth.user?.profile?.name || auth.user?.profile?.email}
);
}