From 3c1a81bef70a82fec0b8a8e8e9f9a0adf383eda2 Mon Sep 17 00:00:00 2001 From: marsalva Date: Wed, 25 Feb 2026 20:12:32 +0000 Subject: [PATCH] Actualizar index.html --- index.html | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 932fc48..ffa9efb 100644 --- a/index.html +++ b/index.html @@ -35,6 +35,14 @@

Conectando...

+ +
@@ -82,16 +90,32 @@ const urlParams = new URLSearchParams(window.location.search); urlToken = urlParams.get('token'); - if (!urlToken) return; + // SOLUCIÓN AL BLOQUEO SIN TOKEN + if (!urlToken) { + showError(); + return; + } try { const res = await fetch(`${API_URL}/public/portal/${urlToken}`); const data = await res.json(); if (!data.ok) throw new Error("Token inválido"); renderPortal(data.client, data.company, data.services); - } catch (e) { console.error(e); } + } catch (e) { + console.error(e); + showError(); + } }); + function showError() { + document.getElementById('loader').classList.add('opacity-0', 'pointer-events-none'); + setTimeout(() => { + document.getElementById('loader').classList.add('hidden'); + document.getElementById('errorScreen').classList.remove('hidden'); + document.getElementById('errorScreen').classList.add('flex'); + }, 300); + } + function summarizeDescription(rawText) { if (!rawText) return "Avería reportada."; let text = rawText.replace(/\n/g, ' '); @@ -245,10 +269,11 @@ // LÓGICA DE MAPA EN TIEMPO REAL // ========================================== function initLiveMap(serviceId) { - if(!document.getElementById(`map-${serviceId}`)) return; + // CORRECCIÓN APLICADA: liveMap- + if(!document.getElementById(`liveMap-${serviceId}`)) return; // 1. Configuramos el mapa de Leaflet - liveMaps[serviceId] = L.map(`map-${serviceId}`, { zoomControl: false, attributionControl: false }).setView([40.416775, -3.703790], 6); + liveMaps[serviceId] = L.map(`liveMap-${serviceId}`, { zoomControl: false, attributionControl: false }).setView([40.416775, -3.703790], 6); L.tileLayer('https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png').addTo(liveMaps[serviceId]); // 2. Creamos un icono HTML personalizado (un puntito azul que brilla) @@ -273,7 +298,7 @@ if (data.ok && data.location) { const loader = document.getElementById(`map-loader-${serviceId}`); - if(loader) loader.classList.add('hidden'); // Ocultar pantalla de "Buscando satélites" + if(loader) loader.classList.add('hidden'); // Ocultar pantalla de carga const lat = parseFloat(data.location.lat); const lng = parseFloat(data.location.lng); @@ -287,6 +312,9 @@ liveMarkers[serviceId].setLatLng([lat, lng]); liveMaps[serviceId].flyTo([lat, lng], 16, { animate: true, duration: 1.5 }); } + } else { + const p = document.querySelector(`#map-loader-${serviceId} p`); + if(p) p.innerText = "ESPERANDO SEÑAL GPS DEL TÉCNICO..."; } } catch(e) {} }