Actualizar index.html

This commit is contained in:
2026-02-25 20:12:32 +00:00
parent 113b7c8a1e
commit 3c1a81bef7

View File

@@ -35,6 +35,14 @@
<p class="text-sm font-black tracking-widest uppercase text-slate-500 animate-pulse">Conectando...</p>
</div>
<div id="errorScreen" class="hidden w-full max-w-md mx-auto p-6 flex-col items-center justify-center min-h-screen text-center fade-in z-10 relative">
<div class="w-24 h-24 bg-red-50 text-red-500 rounded-full flex items-center justify-center mb-6 shadow-xl shadow-red-500/20 border border-red-100">
<i data-lucide="shield-alert" class="w-12 h-12"></i>
</div>
<h2 class="text-3xl font-black text-slate-800 mb-3 tracking-tight">Enlace no válido</h2>
<p class="text-slate-500 font-medium leading-relaxed">Parece que este enlace ha caducado o no es correcto. Por favor, solicita un nuevo acceso a tu empresa reparadora.</p>
</div>
<main id="mainContent" class="hidden w-full max-w-md mx-auto min-h-screen flex flex-col relative pb-10 z-10">
<div class="pt-10 pb-6 px-6 flex flex-col items-center text-center fade-in" style="animation-delay: 0.1s;">
@@ -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) {}
}