From 287d862f23afdf603af256f58e74243c4cd2fb7c Mon Sep 17 00:00:00 2001 From: marsalva Date: Mon, 16 Feb 2026 08:27:42 +0000 Subject: [PATCH] Actualizar aceptar.html --- aceptar.html | 61 +++++++++++++++++++++------------------------------- 1 file changed, 24 insertions(+), 37 deletions(-) diff --git a/aceptar.html b/aceptar.html index 1c5ce5b..5c2b1bf 100644 --- a/aceptar.html +++ b/aceptar.html @@ -15,7 +15,7 @@
-
+
@@ -71,10 +71,10 @@
@@ -109,14 +109,13 @@ document.getElementById('location').innerText = `${raw["Población"] || 'Zona'} (CP: ${raw["Código Postal"] || '---'})`; document.getElementById('desc').innerText = raw["Descripción"] || "Revisar en el lugar."; - // Mostrar debug si existe, si no, mensaje normal if (data.debug) { + const limitDate = new Date(data.debug.hora_limite_bd); + const timeStr = limitDate.toLocaleTimeString('es-ES', { hour: '2-digit', minute: '2-digit' }); + document.getElementById('timer').innerHTML = ` Responde antes de que caduque el turno
- - LÍMITE BD: ${new Date(data.debug.hora_limite_bd).toLocaleTimeString()}
- ACTUAL BD: ${new Date(data.debug.hora_actual_bd).toLocaleTimeString()} -
+ Límite hasta las: ${timeStr} `; } else { document.getElementById('timer').innerText = "Responde antes de que caduque el turno"; @@ -125,22 +124,24 @@ document.getElementById('loading').classList.add('hidden'); document.getElementById('content').classList.remove('hidden'); } else { - showError(data.error, data.debug); + showError(data.error); } } catch (e) { - showError("Error al conectar con el servidor", null); + showError("Error al conectar con el servidor"); } } async function respond(action) { - const btnText = action === 'accept' ? 'ACEPTANDO...' : 'RECHAZANDO...'; - const originalContent = document.getElementById('content').innerHTML; - if(!confirm(`¿Seguro que quieres ${action === 'accept' ? 'ACEPTAR' : 'RECHAZAR'} este servicio?`)) return; try { - document.getElementById('loading').classList.remove('hidden'); + // OCULTAMOS TODO PARA DEJAR LA PANTALLA LIMPIA + document.getElementById('top-header').classList.add('hidden'); document.getElementById('content').classList.add('hidden'); + + document.getElementById('loading').innerHTML = ``; + document.getElementById('loading').classList.remove('hidden'); + lucide.createIcons(); const res = await fetch(`${API_URL}/public/assignment/respond`, { method: 'POST', @@ -151,10 +152,10 @@ if (data.ok) { document.getElementById('loading').innerHTML = ` -
- -

${action === 'accept' ? '¡Asignado!' : 'Rechazado'}

-

${action === 'accept' ? 'Ya puedes verlo en tu lista de servicios.' : 'Gracias por avisar.'}

+
+ +

${action === 'accept' ? '¡Asignado!' : 'Rechazado'}

+

${action === 'accept' ? 'Ya puedes verlo en tu lista de servicios.' : 'Gracias por avisar. Turno liberado.'}

`; lucide.createIcons(); @@ -166,27 +167,13 @@ } } - function showError(msg, debugData = null) { + function showError(msg) { + // EN CASO DE ERROR TAMBIÉN OCULTAMOS LA CABECERA + document.getElementById('top-header').classList.add('hidden'); document.getElementById('loading').classList.add('hidden'); document.getElementById('content').classList.add('hidden'); document.getElementById('error-screen').classList.remove('hidden'); if(msg) document.getElementById('error-msg').innerText = msg; - - // BLOQUE DE DIAGNÓSTICO EN LA PANTALLA DE ERROR - if(debugData && !document.getElementById('debug-box')) { - const debugDiv = document.createElement('div'); - debugDiv.id = 'debug-box'; - debugDiv.className = "mt-8 p-4 bg-slate-100 rounded-xl text-left text-[10px] font-mono text-slate-600 overflow-x-auto border border-slate-200"; - debugDiv.innerHTML = ` - Modo Diagnóstico (Captura esto) - ESTADO BD: ${debugData.estado_en_bd}
- HORA LÍMITE BD: ${new Date(debugData.hora_limite_bd).toLocaleString()}
- HORA ACTUAL BD: ${new Date(debugData.hora_actual_bd).toLocaleString()}

- * Si ESTADO BD es "expired", el reloj interno lo mató.
- * Si HORA LÍMITE < HORA ACTUAL, es un desfase de zona horaria. - `; - document.getElementById('error-screen').appendChild(debugDiv); - } }