Actualizar index.html

This commit is contained in:
2026-02-25 20:17:10 +00:00
parent 3c1a81bef7
commit e84fca59af

View File

@@ -35,14 +35,6 @@
<p class="text-sm font-black tracking-widest uppercase text-slate-500 animate-pulse">Conectando...</p> <p class="text-sm font-black tracking-widest uppercase text-slate-500 animate-pulse">Conectando...</p>
</div> </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"> <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;"> <div class="pt-10 pb-6 px-6 flex flex-col items-center text-center fade-in" style="animation-delay: 0.1s;">
@@ -90,32 +82,16 @@
const urlParams = new URLSearchParams(window.location.search); const urlParams = new URLSearchParams(window.location.search);
urlToken = urlParams.get('token'); urlToken = urlParams.get('token');
// SOLUCIÓN AL BLOQUEO SIN TOKEN if (!urlToken) return;
if (!urlToken) {
showError();
return;
}
try { try {
const res = await fetch(`${API_URL}/public/portal/${urlToken}`); const res = await fetch(`${API_URL}/public/portal/${urlToken}`);
const data = await res.json(); const data = await res.json();
if (!data.ok) throw new Error("Token inválido"); if (!data.ok) throw new Error("Token inválido");
renderPortal(data.client, data.company, data.services); renderPortal(data.client, data.company, data.services);
} catch (e) { } catch (e) { console.error(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) { function summarizeDescription(rawText) {
if (!rawText) return "Avería reportada."; if (!rawText) return "Avería reportada.";
let text = rawText.replace(/\n/g, ' '); let text = rawText.replace(/\n/g, ' ');
@@ -269,11 +245,10 @@
// LÓGICA DE MAPA EN TIEMPO REAL // LÓGICA DE MAPA EN TIEMPO REAL
// ========================================== // ==========================================
function initLiveMap(serviceId) { function initLiveMap(serviceId) {
// CORRECCIÓN APLICADA: liveMap- if(!document.getElementById(`map-${serviceId}`)) return;
if(!document.getElementById(`liveMap-${serviceId}`)) return;
// 1. Configuramos el mapa de Leaflet // 1. Configuramos el mapa de Leaflet
liveMaps[serviceId] = L.map(`liveMap-${serviceId}`, { zoomControl: false, attributionControl: false }).setView([40.416775, -3.703790], 6); liveMaps[serviceId] = L.map(`map-${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]); 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) // 2. Creamos un icono HTML personalizado (un puntito azul que brilla)
@@ -298,7 +273,7 @@
if (data.ok && data.location) { if (data.ok && data.location) {
const loader = document.getElementById(`map-loader-${serviceId}`); const loader = document.getElementById(`map-loader-${serviceId}`);
if(loader) loader.classList.add('hidden'); // Ocultar pantalla de carga if(loader) loader.classList.add('hidden'); // Ocultar pantalla de "Buscando satélites"
const lat = parseFloat(data.location.lat); const lat = parseFloat(data.location.lat);
const lng = parseFloat(data.location.lng); const lng = parseFloat(data.location.lng);
@@ -312,9 +287,6 @@
liveMarkers[serviceId].setLatLng([lat, lng]); liveMarkers[serviceId].setLatLng([lat, lng]);
liveMaps[serviceId].flyTo([lat, lng], 16, { animate: true, duration: 1.5 }); 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) {} } catch(e) {}
} }