From 71ca6247a6925bf85a7fdea2e9c93ee40830d744 Mon Sep 17 00:00:00 2001 From: marsalva Date: Sun, 15 Feb 2026 21:41:00 +0000 Subject: [PATCH] Actualizar automatizaciones.html --- automatizaciones.html | 120 ++++++++++++++++++++++-------------------- 1 file changed, 64 insertions(+), 56 deletions(-) diff --git a/automatizaciones.html b/automatizaciones.html index a71c128..e2f0238 100644 --- a/automatizaciones.html +++ b/automatizaciones.html @@ -28,7 +28,7 @@

Servicios buscando operario vía WhatsApp

- + En Vivo
@@ -45,7 +45,7 @@ Expediente / Cliente Dirección y Contacto - Motivo + Estado Acción @@ -61,36 +61,36 @@

- Rescate Manual: #-- + Rescate Manual: #--

- +
- Asegurado -

--

- -- + Asegurado +

--

+ --
Ubicación -

--

+

--

- -
--
+ +
--
-

Operarios que no cogieron (Llamar para forzar)

+

Operarios contactados (Llamar para forzar)

- - +
@@ -120,8 +120,16 @@ activeIntervals.forEach(clearInterval); activeIntervals = []; - const inQueue = scrapedData.filter(s => s.automation_status === 'in_progress' && s.current_worker_name !== null); - const failed = scrapedData.filter(s => s.automation_status === 'failed' || (s.automation_status === 'in_progress' && s.current_worker_name === null)); + // FILTRO CORREGIDO: Solo mostramos lo que está en 'in_progress' o 'failed' + // Al pasarlo a 'manual' con el botón de la papelera, desaparece de ambos filtros + const inQueue = scrapedData.filter(s => + s.automation_status === 'in_progress' && s.current_worker_name !== null + ); + + const failed = scrapedData.filter(s => + s.automation_status === 'failed' || + (s.automation_status === 'in_progress' && s.current_worker_name === null) + ); renderCards(inQueue); renderFailedTable(failed); @@ -132,8 +140,8 @@ function renderCards(activeServices) { const container = document.getElementById('automation-list'); if (activeServices.length === 0) { - container.innerHTML = `
- + container.innerHTML = `
+

No hay automatismos en curso

`; lucide.createIcons(); @@ -142,37 +150,36 @@ container.innerHTML = activeServices.map(s => { const raw = s.raw_data; - const cardId = `card-${s.id}`; return ` -
+
-
- ${s.provider} - Ref: ${s.service_ref} +
+ ${s.provider} + Ref: ${s.service_ref}
-

${raw["Nombre Cliente"] || raw["CLIENTE"] || 'Sin nombre'}

-

📍 CP: ${raw["Código Postal"] || raw["C.P."] || '---'}

+

${raw["Nombre Cliente"] || raw["CLIENTE"] || 'Sin nombre'}

+

📍 CP: ${raw["Código Postal"] || raw["C.P."] || '---'}

-
-
-
-

Turno actual:

-

${s.current_worker_name || 'Buscando...'}

+
+
+
+

Turno actual:

+

${s.current_worker_name || 'Buscando...'}

-
-
+
+
Caduca en --:--
-
-
+
+
-
- +
+
`; }).join(''); @@ -207,29 +214,26 @@ function renderFailedTable(failedServices) { const tbody = document.getElementById('failed-list'); if (failedServices.length === 0) { - tbody.innerHTML = `No hay fallidos ahora.`; + tbody.innerHTML = `No hay fallidos ahora.`; return; } tbody.innerHTML = failedServices.map(s => { const raw = s.raw_data || {}; const name = raw["Nombre Cliente"] || raw["CLIENTE"] || "Asegurado Desconocido"; - const address = raw["Dirección"] || raw["DOMICILIO"] || "Sin dirección"; return ` -
- #${s.service_ref} - ${name} +
+ #${s.service_ref} + ${name}
- -
- ${address} - ${raw["Población"] || ''} ${raw["Código Postal"] ? '| CP: '+raw["Código Postal"] : ''} -
+ + ${raw["Dirección"] || 'S/D'}
+ ${raw["Población"] || ''} ${raw["Código Postal"] || ''} - Nadie respondió - + Ronda Finalizada + `; }).join(''); lucide.createIcons(); @@ -253,16 +257,16 @@ const workers = svc.attempted_workers_data || []; if (workers.length === 0) { - list.innerHTML = `

Sin registros de intentos WhatsApp.

`; + list.innerHTML = `

Sin registros de intentos WhatsApp.

`; } else { list.innerHTML = workers.map(w => ` -
-
-
- ${w.name} +
+
+
+ ${w.name}
- - Llamar + + Llamar
`).join(''); @@ -275,14 +279,18 @@ function closeRescueModal() { document.getElementById('rescueModal').classList.add('hidden'); } async function resetToManual() { - if(!confirm("¿Deseas quitar este servicio de automatización y devolverlo al Buzón de Proveedores?")) return; + if(!confirm("¿Deseas devolver este servicio a Proveedores? (Desaparecerá de esta lista)")) return; try { const res = await fetch(`${API_URL}/providers/scraped/${currentRescueId}`, { method: 'PUT', headers: { "Content-Type": "application/json", "Authorization": `Bearer ${localStorage.getItem("token")}` }, body: JSON.stringify({ automation_status: 'manual' }) }); - if (res.ok) { closeRescueModal(); loadAutomations(); showToast("Enviado al Buzón de Proveedores"); } + if (res.ok) { + closeRescueModal(); + loadAutomations(); // Esto recarga y aplica el filtro nuevo + showToast("Devuelto al Buzón de Proveedores"); + } } catch(e) { showToast("Error al resetear", true); } }