Actualizar index.html
This commit is contained in:
356
index.html
356
index.html
@@ -3,144 +3,292 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<title>Acceso Operarios - IntegraRepara</title>
|
||||
<title>Portal del Cliente - IntegraRepara</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<script src="https://unpkg.com/lucide@latest"></script>
|
||||
|
||||
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
|
||||
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
|
||||
|
||||
<style>
|
||||
body {
|
||||
background-color: #f8fafc;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
background-image: radial-gradient(#e2e8f0 1px, transparent 1px);
|
||||
background-size: 24px 24px;
|
||||
}
|
||||
.fade-in { animation: fadeIn 0.4s ease-out forwards; }
|
||||
body { background-color: #f4f7f9; background-image: radial-gradient(#e2e8f0 1px, transparent 1px); background-size: 24px 24px; }
|
||||
.fade-in { animation: fadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
|
||||
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
|
||||
.blob { position: absolute; filter: blur(60px); z-index: -1; opacity: 0.4; }
|
||||
.no-scrollbar::-webkit-scrollbar { display: none; }
|
||||
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
|
||||
|
||||
/* Ocultar marca de agua de leaflet para que quede más limpio */
|
||||
.leaflet-control-attribution { display: none !important; }
|
||||
</style>
|
||||
</head>
|
||||
<body class="text-slate-800 font-sans antialiased h-screen flex flex-col items-center justify-center p-6 relative overflow-hidden">
|
||||
<body class="text-slate-800 font-sans antialiased min-h-screen flex flex-col items-center relative overflow-x-hidden">
|
||||
|
||||
<div class="absolute top-[-10%] left-[-10%] w-64 h-64 bg-blue-400 rounded-full mix-blend-multiply filter blur-[80px] opacity-30"></div>
|
||||
<div class="absolute bottom-[-10%] right-[-10%] w-64 h-64 bg-emerald-400 rounded-full mix-blend-multiply filter blur-[80px] opacity-30"></div>
|
||||
<div class="blob bg-blue-300 w-64 h-64 rounded-full top-[-50px] left-[-50px]"></div>
|
||||
<div class="blob bg-emerald-200 w-64 h-64 rounded-full top-[20%] right-[-100px]"></div>
|
||||
|
||||
<div class="w-full max-w-sm z-10 fade-in">
|
||||
<div id="loader" class="fixed inset-0 bg-slate-50/90 backdrop-blur-md z-50 flex flex-col items-center justify-center transition-opacity duration-300">
|
||||
<div class="relative w-16 h-16 flex items-center justify-center mb-4">
|
||||
<div class="absolute inset-0 border-4 border-blue-100 border-t-blue-600 rounded-full animate-spin"></div>
|
||||
<i data-lucide="wrench" class="w-6 h-6 text-blue-600 animate-pulse"></i>
|
||||
</div>
|
||||
<p class="text-sm font-black tracking-widest uppercase text-slate-500 animate-pulse">Conectando...</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="text-center mb-10">
|
||||
<div class="w-20 h-20 bg-white rounded-[1.5rem] shadow-xl shadow-blue-500/10 border border-slate-100 flex items-center justify-center mx-auto mb-5">
|
||||
<i data-lucide="wrench" class="w-10 h-10 text-blue-600"></i>
|
||||
<div class="pt-10 pb-6 px-6 flex flex-col items-center text-center fade-in" style="animation-delay: 0.1s;">
|
||||
<div id="companyLogoContainer" class="hidden relative mb-5">
|
||||
<div class="absolute inset-0 bg-blue-500 rounded-3xl blur-xl opacity-20"></div>
|
||||
<div class="relative w-28 h-28 bg-white rounded-3xl shadow-lg border border-slate-100 flex items-center justify-center overflow-hidden p-3">
|
||||
<img id="companyLogo" src="" class="w-full h-full object-contain">
|
||||
</div>
|
||||
</div>
|
||||
<h1 class="text-3xl font-black tracking-tight text-slate-800 uppercase">App Operario</h1>
|
||||
<p class="text-sm font-medium text-slate-500 mt-2">Introduce tus credenciales de acceso</p>
|
||||
<p class="text-[10px] font-black text-blue-600 uppercase tracking-widest mb-1.5 opacity-80">Portal del Cliente</p>
|
||||
<h1 id="companyName" class="text-2xl font-black tracking-tight text-slate-900 uppercase leading-none">Empresa</h1>
|
||||
</div>
|
||||
|
||||
<form id="loginForm" onsubmit="doLogin(event)" class="bg-white/80 backdrop-blur-xl p-8 rounded-[2rem] shadow-2xl shadow-slate-200/50 border border-white space-y-6">
|
||||
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<label class="block text-[10px] font-black text-slate-400 uppercase tracking-widest mb-1.5 ml-2">Email o Teléfono</label>
|
||||
<div class="relative">
|
||||
<div class="absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none">
|
||||
<i data-lucide="user" class="w-5 h-5 text-slate-400"></i>
|
||||
</div>
|
||||
<input type="text" id="userInput" required placeholder="Ej: 600123456" class="w-full pl-12 pr-4 py-4 bg-slate-50 border border-slate-100 rounded-2xl text-sm font-bold text-slate-700 outline-none focus:bg-white focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all shadow-inner">
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-5 flex-1 flex flex-col gap-6 fade-in" style="animation-delay: 0.2s;">
|
||||
<h2 class="text-3xl font-black text-slate-800 tracking-tight pl-2">Hola, <span id="clientName" class="text-blue-600">Cliente</span></h2>
|
||||
|
||||
<div>
|
||||
<label class="block text-[10px] font-black text-slate-400 uppercase tracking-widest mb-1.5 ml-2">Contraseña</label>
|
||||
<div class="relative">
|
||||
<div class="absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none">
|
||||
<i data-lucide="lock" class="w-5 h-5 text-slate-400"></i>
|
||||
</div>
|
||||
<input type="password" id="passInput" required placeholder="••••••••" class="w-full pl-12 pr-4 py-4 bg-slate-50 border border-slate-100 rounded-2xl text-sm font-bold text-slate-700 outline-none focus:bg-white focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all shadow-inner">
|
||||
</div>
|
||||
<div id="activeServicesContainer" class="space-y-6 mt-2"></div>
|
||||
|
||||
<div id="noActiveServices" class="hidden text-center p-6 bg-white/80 backdrop-blur-xl rounded-[2.5rem] shadow-xl shadow-slate-200/40 border border-white">
|
||||
<div class="w-16 h-16 bg-slate-100 text-slate-400 rounded-full flex items-center justify-center mx-auto mb-4">
|
||||
<i data-lucide="check-circle" class="w-8 h-8"></i>
|
||||
</div>
|
||||
<h3 class="text-lg font-black text-slate-800 tracking-tight">Todo al día</h3>
|
||||
</div>
|
||||
|
||||
<div id="errorMsg" class="hidden bg-rose-50 border border-rose-200 text-rose-600 text-xs font-bold p-3 rounded-xl text-center flex items-center justify-center gap-2">
|
||||
<i data-lucide="alert-circle" class="w-4 h-4"></i> <span>Datos incorrectos</span>
|
||||
<div id="historyContainerWrapper" class="hidden mt-4">
|
||||
<h3 class="text-xs font-black text-slate-400 uppercase tracking-widest mb-3 ml-2">Historial</h3>
|
||||
<div id="historyServicesContainer" class="space-y-4"></div>
|
||||
</div>
|
||||
|
||||
<button type="submit" id="btnSubmit" class="w-full bg-blue-600 text-white font-black py-4 rounded-2xl shadow-[0_8px_20px_-6px_rgba(37,99,235,0.5)] hover:bg-blue-700 active:scale-95 transition-all uppercase tracking-widest text-xs flex justify-center items-center gap-2 mt-2">
|
||||
Entrar a mi Ruta <i data-lucide="arrow-right" class="w-4 h-4"></i>
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
<p class="text-center text-[10px] font-bold text-slate-400 mt-8 uppercase tracking-widest">
|
||||
Tecnología IntegraRepara
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<script>
|
||||
const API_URL = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1'
|
||||
? 'http://localhost:3000'
|
||||
: 'https://integrarepara-api.integrarepara.es';
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
lucide.createIcons();
|
||||
// Si ya tiene sesión iniciada, lo mandamos directo al menú
|
||||
if (localStorage.getItem("token") && localStorage.getItem("role") === "operario") {
|
||||
window.location.href = "menu.html";
|
||||
}
|
||||
});
|
||||
let urlToken = "";
|
||||
let mapsToInit = [];
|
||||
let liveMaps = {};
|
||||
let liveMarkers = {};
|
||||
|
||||
async function doLogin(e) {
|
||||
e.preventDefault();
|
||||
const btn = document.getElementById('btnSubmit');
|
||||
const err = document.getElementById('errorMsg');
|
||||
|
||||
const user = document.getElementById('userInput').value.trim();
|
||||
const pass = document.getElementById('passInput').value;
|
||||
|
||||
btn.innerHTML = '<i data-lucide="loader-2" class="w-5 h-5 animate-spin mx-auto"></i>';
|
||||
btn.disabled = true;
|
||||
err.classList.add('hidden');
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
lucide.createIcons();
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
urlToken = urlParams.get('token');
|
||||
|
||||
if (!urlToken) return;
|
||||
|
||||
try {
|
||||
const res = await fetch(`${API_URL}/auth/login`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ email: user, password: pass })
|
||||
});
|
||||
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); }
|
||||
});
|
||||
|
||||
function summarizeDescription(rawText) {
|
||||
if (!rawText) return "Avería reportada.";
|
||||
let text = rawText.replace(/\n/g, ' ');
|
||||
const regexCorte = /(\(|\bM\.O\b|\bMATERIAL\b|\bASEGURADO\b|\bTELEFONO\b|\bURGENTE\b)/i;
|
||||
let cutPos = text.search(regexCorte);
|
||||
if (cutPos > 5) text = text.substring(0, cutPos);
|
||||
text = text.trim();
|
||||
text = text.charAt(0).toUpperCase() + text.slice(1).toLowerCase();
|
||||
let words = text.split(/\s+/);
|
||||
if (words.length > 10) return words.slice(0, 10).join(" ") + "...";
|
||||
if (text.length < 5) return "Reparación general solicitada.";
|
||||
return text.endsWith('.') ? text : text + ".";
|
||||
}
|
||||
|
||||
function addOneHour(timeStr) {
|
||||
if(!timeStr) return "";
|
||||
let [h, m] = timeStr.split(':').map(Number);
|
||||
let tm = h * 60 + m + 60;
|
||||
return `${String(Math.floor(tm / 60)).padStart(2,'0')}:${String(tm % 60).padStart(2,'0')}`;
|
||||
}
|
||||
|
||||
function formatDate(dateStr) {
|
||||
if (!dateStr) return "";
|
||||
try {
|
||||
const parts = dateStr.split('-');
|
||||
if(parts.length !== 3) return dateStr;
|
||||
const d = new Date(parts[0], parts[1]-1, parts[2]);
|
||||
return d.toLocaleDateString('es-ES', { weekday: 'long', day: 'numeric', month: 'long' });
|
||||
} catch(e) { return dateStr; }
|
||||
}
|
||||
|
||||
function renderPortal(client, company, allServices) {
|
||||
document.getElementById('companyName').innerText = company.name || "Empresa";
|
||||
if (company.logo) {
|
||||
document.getElementById('companyLogo').src = company.logo;
|
||||
document.getElementById('companyLogoContainer').classList.remove('hidden');
|
||||
}
|
||||
document.getElementById('clientName').innerText = client.name.split(' ')[0].toUpperCase();
|
||||
|
||||
const activeContainer = document.getElementById('activeServicesContainer');
|
||||
const historyContainer = document.getElementById('historyServicesContainer');
|
||||
|
||||
let hasActive = false;
|
||||
|
||||
allServices.forEach(srv => {
|
||||
const isFinalized = srv.status_name === 'Terminado';
|
||||
const isPendingWorker = (!srv.assigned_worker || srv.assigned_worker === 'Pendiente');
|
||||
const descLimpia = summarizeDescription(srv.description);
|
||||
let statusHtml = '';
|
||||
|
||||
if (isFinalized) {
|
||||
statusHtml = `
|
||||
<div class="bg-slate-50 border border-slate-200 p-4 rounded-2xl flex items-center justify-between opacity-70 grayscale">
|
||||
<span class="text-[10px] font-black text-slate-500 uppercase flex items-center gap-1.5"><i data-lucide="archive" class="w-3.5 h-3.5"></i> ${srv.status_name}</span>
|
||||
</div>`;
|
||||
}
|
||||
else if (srv.status_name === 'Técnico de Camino') {
|
||||
// MODO MAPA EN VIVO
|
||||
statusHtml = `
|
||||
<div class="bg-indigo-50 border border-indigo-200 p-6 rounded-3xl relative overflow-hidden shadow-inner">
|
||||
<div class="flex items-center gap-4 mb-5 relative z-10">
|
||||
<div class="w-12 h-12 bg-indigo-500 text-white rounded-full flex items-center justify-center shadow-md animate-bounce shrink-0">
|
||||
<i data-lucide="truck" class="w-6 h-6"></i>
|
||||
</div>
|
||||
<div>
|
||||
<h4 class="font-black text-indigo-800 uppercase text-base tracking-tight">¡Técnico en camino!</h4>
|
||||
<p class="text-[10px] text-indigo-600 font-bold mt-1">Sigue su ubicación en tiempo real.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="liveMap-${srv.id}" class="w-full h-48 bg-slate-200 rounded-2xl border border-indigo-200 relative overflow-hidden z-10 shadow-inner">
|
||||
<div class="absolute inset-0 flex items-center justify-center bg-slate-100 z-[400]" id="map-loader-${srv.id}">
|
||||
<div class="text-center">
|
||||
<i data-lucide="satellite" class="w-6 h-6 mx-auto mb-2 text-indigo-400 animate-pulse"></i>
|
||||
<p class="text-[9px] font-black uppercase tracking-widest text-slate-500">Buscando satélites...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
mapsToInit.push(srv.id); // Guardamos para inicializar el mapa
|
||||
}
|
||||
else if (srv.status_name === 'En Reparación') {
|
||||
statusHtml = `
|
||||
<div class="bg-orange-50 border border-orange-200 p-6 rounded-3xl flex items-center gap-5 shadow-inner">
|
||||
<div class="w-14 h-14 bg-orange-500 text-white rounded-2xl flex items-center justify-center shadow-md shrink-0"><i data-lucide="hammer" class="w-7 h-7"></i></div>
|
||||
<div>
|
||||
<h4 class="font-black text-orange-800 uppercase text-base tracking-tight">En Reparación</h4>
|
||||
<p class="text-[10px] text-orange-600 font-bold mt-1.5 leading-tight">El técnico está trabajando en tu domicilio.</p>
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
else if (srv.status_name === 'Visita Agendada' || (srv.scheduled_date && srv.scheduled_time)) {
|
||||
const endT = addOneHour(srv.scheduled_time);
|
||||
statusHtml = `
|
||||
<div class="bg-gradient-to-br from-emerald-400 to-emerald-600 p-6 rounded-3xl flex items-center gap-5 text-white shadow-lg shadow-emerald-500/30 relative overflow-hidden">
|
||||
<div class="w-14 h-14 bg-white/20 rounded-2xl flex items-center justify-center backdrop-blur-md border border-white/30 shrink-0 relative z-10"><i data-lucide="calendar-check" class="w-7 h-7 text-white"></i></div>
|
||||
<div class="relative z-10">
|
||||
<p class="text-[9px] font-black uppercase tracking-widest text-emerald-100 mb-0.5">Visita Confirmada</p>
|
||||
<p class="font-black uppercase text-lg leading-none mb-1.5">${formatDate(srv.scheduled_date)}</p>
|
||||
<p class="text-sm font-bold text-emerald-50 flex items-center gap-1.5"><i data-lucide="clock" class="w-4 h-4"></i> Llegada aprox: ${srv.scheduled_time} - ${endT}</p>
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
else {
|
||||
statusHtml = `
|
||||
<div class="bg-slate-100 border border-slate-200 p-6 rounded-3xl text-center">
|
||||
<div class="w-12 h-12 bg-slate-200 text-slate-500 rounded-full flex items-center justify-center mx-auto mb-3"><i data-lucide="clock" class="w-6 h-6"></i></div>
|
||||
<h4 class="font-black text-slate-700 uppercase text-sm mb-1 tracking-tight">En Gestión</h4>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
let cardHtml = `
|
||||
<div class="bg-white/80 backdrop-blur-xl border border-white shadow-xl shadow-slate-200/40 rounded-[2.5rem] p-6 mb-6 relative overflow-hidden">
|
||||
<div class="flex justify-between items-start mb-5">
|
||||
<span class="text-[10px] font-black text-slate-400 uppercase tracking-widest">Expediente #${srv.title.replace('Expediente #', '').replace('🚨 URGENTE: ', '')}</span>
|
||||
${srv.assigned_worker && srv.assigned_worker !== 'Pendiente' ?
|
||||
`<div class="bg-slate-50 border border-slate-100 px-3 py-1.5 rounded-lg text-center shrink-0">
|
||||
<p class="text-[8px] uppercase font-black text-slate-400 mb-0.5">Técnico</p>
|
||||
<p class="text-[10px] font-bold text-blue-600">${srv.assigned_worker.split(' ')[0]}</p>
|
||||
</div>` : ''
|
||||
}
|
||||
</div>
|
||||
<div class="mb-6">${statusHtml}</div>
|
||||
<div class="pt-5 border-t border-slate-100">
|
||||
<p class="text-[10px] font-black text-slate-400 uppercase tracking-widest mb-1.5">Motivo de la Visita</p>
|
||||
<h3 class="font-black text-slate-800 text-sm leading-snug">${descLimpia}</h3>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
if (isFinalized) historyContainer.innerHTML += cardHtml;
|
||||
else { activeContainer.innerHTML += cardHtml; hasActive = true; }
|
||||
});
|
||||
|
||||
if (!hasActive) document.getElementById('noActiveServices').classList.remove('hidden');
|
||||
|
||||
lucide.createIcons();
|
||||
|
||||
document.getElementById('loader').classList.add('opacity-0', 'pointer-events-none');
|
||||
setTimeout(() => {
|
||||
document.getElementById('loader').classList.add('hidden');
|
||||
document.getElementById('mainContent').classList.remove('hidden');
|
||||
|
||||
// INICIALIZAMOS LOS MAPAS
|
||||
mapsToInit.forEach(id => initLiveMap(id));
|
||||
}, 300);
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// LÓGICA DE MAPA EN TIEMPO REAL
|
||||
// ==========================================
|
||||
function initLiveMap(serviceId) {
|
||||
if(!document.getElementById(`map-${serviceId}`)) return;
|
||||
|
||||
// 1. Configuramos el mapa de Leaflet
|
||||
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)
|
||||
const carIcon = L.divIcon({
|
||||
className: 'custom-div-icon',
|
||||
html: `<div style="position:relative;"><div style="background-color:#6366f1; width:20px; height:20px; border-radius:50%; border:3px solid white; box-shadow: 0 4px 6px rgba(0,0,0,0.3); position:relative; z-index:2;"></div><div style="position:absolute; top:-5px; left:-5px; width:30px; height:30px; background-color:#6366f1; border-radius:50%; opacity:0.4; animation: ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite; z-index:1;"></div></div>`,
|
||||
iconSize: [20, 20],
|
||||
iconAnchor: [10, 10]
|
||||
});
|
||||
|
||||
liveMarkers[serviceId] = L.marker([40.416775, -3.703790], {icon: carIcon});
|
||||
|
||||
// 3. Ejecutamos la búsqueda de coordenadas cada 10 segundos
|
||||
fetchWorkerLocation(serviceId);
|
||||
setInterval(() => fetchWorkerLocation(serviceId), 10000);
|
||||
}
|
||||
|
||||
async function fetchWorkerLocation(serviceId) {
|
||||
try {
|
||||
const res = await fetch(`${API_URL}/public/portal/${urlToken}/location/${serviceId}`);
|
||||
const data = await res.json();
|
||||
|
||||
if (res.ok && data.ok) {
|
||||
// Guardamos la llave de acceso
|
||||
localStorage.setItem('token', data.token);
|
||||
localStorage.setItem('role', data.role);
|
||||
localStorage.setItem('userName', data.name); // Guardamos el nombre para saludarle
|
||||
if (data.ok && data.location) {
|
||||
const loader = document.getElementById(`map-loader-${serviceId}`);
|
||||
if(loader) loader.classList.add('hidden'); // Ocultar pantalla de "Buscando satélites"
|
||||
|
||||
// Comprobamos que sea un operario
|
||||
if(data.role === 'operario') {
|
||||
btn.innerHTML = '<i data-lucide="check" class="w-5 h-5 mx-auto"></i>';
|
||||
lucide.createIcons();
|
||||
btn.classList.replace('bg-blue-600', 'bg-emerald-500');
|
||||
|
||||
// Redirigimos al MENU
|
||||
setTimeout(() => { window.location.href = "menu.html"; }, 800);
|
||||
const lat = parseFloat(data.location.lat);
|
||||
const lng = parseFloat(data.location.lng);
|
||||
|
||||
// Si el marcador no está en el mapa, lo añadimos
|
||||
if (!liveMaps[serviceId].hasLayer(liveMarkers[serviceId])) {
|
||||
liveMarkers[serviceId].addTo(liveMaps[serviceId]);
|
||||
liveMaps[serviceId].setView([lat, lng], 15);
|
||||
} else {
|
||||
// Si se cuela un administrador, le avisamos o lo mandamos a su panel
|
||||
err.querySelector('span').innerText = "Esta app es solo para operarios";
|
||||
err.classList.remove('hidden');
|
||||
localStorage.clear();
|
||||
// Si ya está, lo movemos suavemente
|
||||
liveMarkers[serviceId].setLatLng([lat, lng]);
|
||||
liveMaps[serviceId].flyTo([lat, lng], 16, { animate: true, duration: 1.5 });
|
||||
}
|
||||
} else {
|
||||
err.querySelector('span').innerText = data.error || "Credenciales incorrectas";
|
||||
err.classList.remove('hidden');
|
||||
}
|
||||
} catch (error) {
|
||||
err.querySelector('span').innerText = "Error de conexión con el servidor";
|
||||
err.classList.remove('hidden');
|
||||
} finally {
|
||||
if(!res?.ok || !data?.ok) {
|
||||
btn.disabled = false;
|
||||
btn.innerHTML = 'Entrar a mi Ruta <i data-lucide="arrow-right" class="w-4 h-4"></i>';
|
||||
lucide.createIcons();
|
||||
}
|
||||
}
|
||||
} catch(e) {}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user