Fix Uncaught ReferenceError: calcularEdad is not defined

This commit is contained in:
2026-08-09 18:47:39 +00:00
parent e3a6690c30
commit 9b35fe7a9c
2 changed files with 14 additions and 1 deletions
+13
View File
@@ -24,3 +24,16 @@ export function getNombreProfesional(user?: Usuario | null): string {
if (nombre) return nombre; if (nombre) return nombre;
return 'Admin'; return 'Admin';
} }
export function calcularEdad(fechaNacimiento?: string): string | number {
if (!fechaNacimiento) return '-';
const hoy = new Date();
const cumple = new Date(fechaNacimiento);
if (isNaN(cumple.getTime())) return '-';
let edad = hoy.getFullYear() - cumple.getFullYear();
const m = hoy.getMonth() - cumple.getMonth();
if (m < 0 || (m === 0 && hoy.getDate() < cumple.getDate())) {
edad--;
}
return edad;
}
+1 -1
View File
@@ -8,7 +8,7 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@
import { Badge } from '@/components/ui/badge'; import { Badge } from '@/components/ui/badge';
import { toast } from 'sonner'; import { toast } from 'sonner';
import type { Paciente, Cama, Area, Internacion } from '@/types'; import type { Paciente, Cama, Area, Internacion } from '@/types';
import { getNombreProfesional } from '@/lib/utils'; import { getNombreProfesional, calcularEdad } from '@/lib/utils';
import { useHospitalStore } from '@/hooks/useHospitalStore'; import { useHospitalStore } from '@/hooks/useHospitalStore';
interface EditIngresoProps { interface EditIngresoProps {