Actualizar index.html
This commit is contained in:
38
index.html
38
index.html
@@ -35,14 +35,6 @@
|
||||
<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;">
|
||||
@@ -90,32 +82,16 @@
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
urlToken = urlParams.get('token');
|
||||
|
||||
// SOLUCIÓN AL BLOQUEO SIN TOKEN
|
||||
if (!urlToken) {
|
||||
showError();
|
||||
return;
|
||||
}
|
||||
if (!urlToken) 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);
|
||||
showError();
|
||||
}
|
||||
} catch (e) { console.error(e); }
|
||||
});
|
||||
|
||||
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, ' ');
|
||||
@@ -269,11 +245,10 @@
|
||||
// LÓGICA DE MAPA EN TIEMPO REAL
|
||||
// ==========================================
|
||||
function initLiveMap(serviceId) {
|
||||
// CORRECCIÓN APLICADA: liveMap-
|
||||
if(!document.getElementById(`liveMap-${serviceId}`)) return;
|
||||
if(!document.getElementById(`map-${serviceId}`)) return;
|
||||
|
||||
// 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]);
|
||||
|
||||
// 2. Creamos un icono HTML personalizado (un puntito azul que brilla)
|
||||
@@ -298,7 +273,7 @@
|
||||
|
||||
if (data.ok && data.location) {
|
||||
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 lng = parseFloat(data.location.lng);
|
||||
@@ -312,9 +287,6 @@
|
||||
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) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user