From 4ba3c914b64e95828c513a5aa5c30f9dc9771bd0 Mon Sep 17 00:00:00 2001 From: marsalva Date: Fri, 27 Feb 2026 21:33:01 +0000 Subject: [PATCH] Actualizar aceptar.html --- aceptar.html | 96 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 73 insertions(+), 23 deletions(-) diff --git a/aceptar.html b/aceptar.html index 5c2b1bf..4c982b8 100644 --- a/aceptar.html +++ b/aceptar.html @@ -29,42 +29,43 @@

Gremio

-

--

+

--

-
+

Referencia

-

--

+

--

-
+
-
+
-
-

Ubicación / CP

-

--

+
+

Ubicación / CP

+

--

+

--

-
- +
+
-

Descripción del Daño

-

--

+

Resumen del Siniestro

+

--

- -
@@ -74,11 +75,14 @@

¡Lo sentimos!

Este enlace ha caducado o el servicio ya ha sido asignado a otro compañero.

- +
- +
+ +

Obteniendo datos...

+
@@ -97,6 +101,32 @@ lucide.createIcons(); }); + // ========================================== + // LÓGICA DE RESUMEN INTELIGENTE (IA JS) + // ========================================== + function smartSummarize(text) { + if (!text || text.trim() === "") return "REVISAR AVERÍA"; + + // 1. Quitamos saltos de línea y forzamos minúsculas + let clean = text.replace(/(\r\n|\n|\r)/gm, " ").toLowerCase(); + + // 2. Cortamos si detectamos que empiezan las notas administrativas + const cutIndex = clean.search(/(\bmo\b|\bm\.o\b|\bmaterial\b|\basegurado\b|\btelefono\b|\burgente\b|\bobservaciones\b)/i); + if (cutIndex > 5) clean = clean.substring(0, cutIndex); + + // 3. Separamos por palabras y filtramos las palabras vacías/comunes + const stopWords = ['el', 'la', 'los', 'las', 'un', 'una', 'unos', 'unas', 'de', 'del', 'a', 'ante', 'con', 'para', 'por', 'y', 'e', 'o', 'u', 'en', 'que', 'su', 'se', 'ha', 'al', 'es']; + + let words = clean.replace(/[^\w\sáéíóúüñ]/gi, '').split(/\s+/); // Quitamos comas y puntos + let keywords = words.filter(w => w.length > 2 && !stopWords.includes(w)); + + // 4. Tomamos solo las primeras 5 palabras clave + if (keywords.length > 5) { + return keywords.slice(0, 5).join(' ') + "..."; + } + return keywords.join(' ') || "REVISAR AVERÍA"; + } + async function loadAssignmentData() { try { const res = await fetch(`${API_URL}/public/assignment/${token}`); @@ -104,11 +134,32 @@ if (data.ok) { const raw = data.service; + + // 1. GREMIO Y REFERENCIA document.getElementById('guild').innerText = raw["Gremio"] || "Servicio General"; document.getElementById('ref').innerText = raw["Expediente"] || "Sin Ref"; - document.getElementById('location').innerText = `${raw["Población"] || 'Zona'} (CP: ${raw["Código Postal"] || '---'})`; - document.getElementById('desc').innerText = raw["Descripción"] || "Revisar en el lugar."; + // 2. PROCESADO DE DIRECCIÓN (Solo calle, corta antes del número) + const fullAddress = raw["Dirección"] || raw["DOMICILIO"] || ""; + let streetOnly = fullAddress; + + // Busca el primer dígito y corta el string justo antes + const streetMatch = fullAddress.match(/^([^0-9]+)/); + if (streetMatch && streetMatch[1]) { + streetOnly = streetMatch[1].replace(/[,/-]+$/, '').trim(); // Quita comas finales + } + if(!streetOnly) streetOnly = "Dirección Oculta"; + + const city = raw["Población"] || "Ciudad sin especificar"; + const cp = raw["Código Postal"] || "---"; + + document.getElementById('location-street').innerText = streetOnly; + document.getElementById('location-city').innerText = `${city} (CP: ${cp})`; + + // 3. RESUMEN INTELIGENTE + document.getElementById('desc').innerText = smartSummarize(raw["Descripción"]); + + // TEMPORIZADOR if (data.debug) { const limitDate = new Date(data.debug.hora_limite_bd); const timeStr = limitDate.toLocaleTimeString('es-ES', { hour: '2-digit', minute: '2-digit' }); @@ -135,11 +186,10 @@ if(!confirm(`¿Seguro que quieres ${action === 'accept' ? 'ACEPTAR' : 'RECHAZAR'} este servicio?`)) return; try { - // 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').innerHTML = `

Procesando...

`; document.getElementById('loading').classList.remove('hidden'); lucide.createIcons(); @@ -153,9 +203,9 @@ if (data.ok) { document.getElementById('loading').innerHTML = `
- +

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

-

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

+

${action === 'accept' ? 'Ya puedes ver todos los datos del cliente en tu aplicación.' : 'Gracias por avisar. Turno liberado para otro compañero.'}

`; lucide.createIcons(); @@ -168,12 +218,12 @@ } 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; + lucide.createIcons(); }