Fix Uncaught ReferenceError: calcularEdad is not defined
This commit is contained in:
@@ -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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user