fix: historial shows error detail and correct Colombia timestamp

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-07-17 15:37:00 -05:00
co-authored by Claude Sonnet 4.6
parent 83c8b2aa0b
commit 33e569c27a
+16 -4
View File
@@ -343,7 +343,12 @@ async function cargarHistorialScheduler() {
</thead>
<tbody class="divide-y divide-gray-50">
${sched.map((r, i) => {
const fecha = r.created_at.replace('T', ' ').slice(0, 16);
const dt = new Date(r.created_at.replace(' ', 'T') + 'Z');
const fecha = dt.toLocaleString('es-CO', {
timeZone: 'America/Bogota',
year: 'numeric', month: '2-digit', day: '2-digit',
hour: '2-digit', minute: '2-digit', hour12: false
});
const errDet = r.errores_det ? JSON.parse(r.errores_det) : [];
const pacientes = r.detalle_json ? JSON.parse(r.detalle_json) : [];
const rowId = 'hist-det-' + i;
@@ -403,8 +408,10 @@ async function cargarHistorialScheduler() {
<td class="py-2 pr-3 text-right font-medium">${r.total}</td>
<td class="py-2 pr-3 text-right text-blue-600 font-medium">${r.created}</td>
<td class="py-2 pr-3 text-right text-green-600">${r.updated}</td>
<td class="py-2 pr-3 text-right ${r.errores > 0 ? 'text-red-500 font-medium' : 'text-gray-300'}">
${r.errores || '—'}
<td class="py-2 pr-3 text-right">
${r.errores > 0
? `<button onclick="toggleDet('${rowId}')" class="text-red-500 font-medium hover:underline">${r.errores}</button>`
: '<span class="text-gray-300">—</span>'}
</td>
<td class="py-2 text-right">
${pacientes.length ? `
@@ -412,9 +419,14 @@ async function cargarHistorialScheduler() {
class="text-xs text-blue-500 hover:underline">Ver ${pacientes.length}</button>` : '—'}
</td>
</tr>
${pacientes.length ? `
${(pacientes.length || errDet.length) ? `
<tr id="${rowId}" class="hidden">
<td colspan="7" class="px-3 pb-4 pt-2">
${errDet.length ? `
<div class="mb-3 bg-red-50 border border-red-200 rounded-lg px-3 py-2 text-xs text-red-700">
<p class="font-medium mb-1"><i class="fas fa-exclamation-circle mr-1"></i>${errDet.length} error(es):</p>
<ul class="list-disc ml-4 space-y-0.5">${errDet.map(e => `<li>${e}</li>`).join('')}</ul>
</div>` : ''}
<div class="max-h-96 overflow-y-auto space-y-2 text-xs">
${detHtml}
</div>