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:
@@ -52,6 +52,8 @@
|
|||||||
switch (periodFilter) {
|
switch (periodFilter) {
|
||||||
case 'today':
|
case 'today':
|
||||||
from = new Date(today);
|
from = new Date(today);
|
||||||
|
to = new Date();
|
||||||
|
to.setHours(23, 59, 59, 999);
|
||||||
break;
|
break;
|
||||||
case 'yesterday':
|
case 'yesterday':
|
||||||
from = new Date(today);
|
from = new Date(today);
|
||||||
@@ -62,23 +64,35 @@
|
|||||||
case 'last7days':
|
case 'last7days':
|
||||||
from = new Date(today);
|
from = new Date(today);
|
||||||
from.setDate(from.getDate() - 7);
|
from.setDate(from.getDate() - 7);
|
||||||
|
to = new Date();
|
||||||
|
to.setHours(23, 59, 59, 999);
|
||||||
break;
|
break;
|
||||||
case 'last30days':
|
case 'last30days':
|
||||||
from = new Date(today);
|
from = new Date(today);
|
||||||
from.setDate(from.getDate() - 30);
|
from.setDate(from.getDate() - 30);
|
||||||
|
to = new Date();
|
||||||
|
to.setHours(23, 59, 59, 999);
|
||||||
break;
|
break;
|
||||||
case 'custom':
|
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 {
|
return {
|
||||||
from: customDateFrom,
|
from: fromDate.toISOString(),
|
||||||
to: customDateTo
|
to: toDate.toISOString()
|
||||||
};
|
};
|
||||||
default:
|
default:
|
||||||
from = new Date(today);
|
from = new Date(today);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
from: from.toISOString().split('T')[0],
|
from: from.toISOString(),
|
||||||
to: to.toISOString().split('T')[0]
|
to: to.toISOString()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user