Fix: Corregir formato de fechas en auditoría

- Enviar datetime ISO completo en lugar de solo fecha (YYYY-MM-DD)
- Backend requiere formato datetime ISO 8601
- Agregar hora 00:00:00 para fecha inicio y 23:59:59 para fecha fin
- Manejar correctamente fechas custom vacías
- Soluciona error 422 (Unprocessable Entity)
This commit is contained in:
2026-02-16 08:24:14 -07:00
parent ff9a8998b2
commit 51a8515b40

View File

@@ -52,6 +52,8 @@
switch (periodFilter) {
case 'today':
from = new Date(today);
to = new Date();
to.setHours(23, 59, 59, 999);
break;
case 'yesterday':
from = new Date(today);
@@ -62,23 +64,35 @@
case 'last7days':
from = new Date(today);
from.setDate(from.getDate() - 7);
to = new Date();
to.setHours(23, 59, 59, 999);
break;
case 'last30days':
from = new Date(today);
from.setDate(from.getDate() - 30);
to = new Date();
to.setHours(23, 59, 59, 999);
break;
case 'custom':
// Para fechas custom, parsear las fechas string y agregar hora
if (!customDateFrom || !customDateTo) {
return { from: '', to: '' };
}
const fromDate = new Date(customDateFrom);
fromDate.setHours(0, 0, 0, 0);
const toDate = new Date(customDateTo);
toDate.setHours(23, 59, 59, 999);
return {
from: customDateFrom,
to: customDateTo
from: fromDate.toISOString(),
to: toDate.toISOString()
};
default:
from = new Date(today);
}
return {
from: from.toISOString().split('T')[0],
to: to.toISOString().split('T')[0]
from: from.toISOString(),
to: to.toISOString()
};
}