From 908eef21c13d29334ab35d436197988ec6169bc9 Mon Sep 17 00:00:00 2001 From: marsalva Date: Wed, 25 Feb 2026 22:39:06 +0000 Subject: [PATCH] Actualizar index.html --- index.html | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/index.html b/index.html index c0a72e8..b654233 100644 --- a/index.html +++ b/index.html @@ -137,7 +137,7 @@ } catch(e) { return dateStr; } } - function renderPortal(client, company, allServices) { + function renderPortal(client, company, allServices) { document.getElementById('companyName').innerText = company.name || "Empresa"; if (company.logo) { document.getElementById('companyLogo').src = company.logo; @@ -146,13 +146,19 @@ document.getElementById('clientName').innerText = client.name.split(' ')[0].toUpperCase(); const activeContainer = document.getElementById('activeServicesContainer'); + const historyContainerWrapper = document.getElementById('historyContainerWrapper'); const historyContainer = document.getElementById('historyServicesContainer'); + // Limpiar contenedores por si acaso (útil si hay recargas) + activeContainer.innerHTML = ''; + historyContainer.innerHTML = ''; + let hasActive = false; + let hasHistory = false; allServices.forEach(srv => { - const isFinalized = srv.status_name === 'Terminado'; - const raw = srv.raw_data || {}; + // Usamos la nueva variable booleana que nos manda el servidor + const isFinalized = srv.is_final; const descLimpia = summarizeDescription(srv.description); let statusHtml = ''; @@ -163,7 +169,7 @@ `; } else if (srv.status_name === 'Técnico de Camino') { - const fullAddr = `${raw["Dirección"] || ""}, ${raw["Código Postal"] || ""} ${raw["Población"] || ""}`; + const fullAddr = `${srv.raw_data?.["Dirección"] || ""}, ${srv.raw_data?.["Código Postal"] || ""} ${srv.raw_data?.["Población"] || ""}`; etasToInit.push({ id: srv.id, address: fullAddr }); statusHtml = ` @@ -193,7 +199,6 @@ `; } else if (srv.status_name === 'En Incidencia' || (srv.status_name || '').toLowerCase().includes('incidencia')) { - // AQUÍ ESTÁ EL BLOQUE DE INCIDENCIA AÑADIDO statusHtml = `
@@ -228,7 +233,7 @@ let cardHtml = `
- Expediente #${srv.title.replace('Expediente #', '').replace('🚨 URGENTE: ', '')} + ${srv.title} ${srv.assigned_worker && srv.assigned_worker !== 'Pendiente' ? `

Técnico

@@ -244,11 +249,27 @@
`; - if (isFinalized) historyContainer.innerHTML += cardHtml; - else { activeContainer.innerHTML += cardHtml; hasActive = true; } + if (isFinalized) { + historyContainer.innerHTML += cardHtml; + hasHistory = true; + } else { + activeContainer.innerHTML += cardHtml; + hasActive = true; + } }); - if (!hasActive) document.getElementById('noActiveServices').classList.remove('hidden'); + // Lógica para mostrar/ocultar secciones + if (!hasActive) { + document.getElementById('noActiveServices').classList.remove('hidden'); + } else { + document.getElementById('noActiveServices').classList.add('hidden'); + } + + if (hasHistory) { + historyContainerWrapper.classList.remove('hidden'); + } else { + historyContainerWrapper.classList.add('hidden'); + } lucide.createIcons();