Actualizar js/layout.js

This commit is contained in:
2026-03-24 20:49:35 +00:00
parent 6b509be3c4
commit 14c59bc5c2

View File

@@ -2,47 +2,6 @@
AQUÍ ARRIBA ESTÁ TODO TU CÓDIGO ORIGINAL DEL LAYOUT
(El que dibuja el sidebar, el header, el menú, etc.)
... */
// ==========================================
// 🎨 INYECTOR DE LOGO CORPORATIVO (APP)
// ==========================================
setTimeout(async () => {
if (!localStorage.getItem("token")) return;
try {
// Pedimos la configuración de la empresa a tu servidor
const TRACK_API = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1'
? 'http://localhost:3000'
: 'https://integrarepara-api.integrarepara.es';
const res = await fetch(`${TRACK_API}/config/company`, {
headers: { "Authorization": `Bearer ${localStorage.getItem("token")}` }
});
const data = await res.json();
if (data.ok && data.config && data.config.company_logo) {
// Buscamos el cuadradito de la cabecera (el que tiene la inicial)
// Normalmente en tu plantilla es el div naranja con flex center
const headerIcon = document.querySelector('header .w-10.h-10.rounded-xl, #header-container .w-10.h-10');
if (headerIcon) {
// Vaciamos la letra inicial
headerIcon.innerHTML = '';
// Le quitamos el fondo de color
headerIcon.className = "w-10 h-10 flex shrink-0";
headerIcon.style.background = "transparent";
headerIcon.style.boxShadow = "none";
// Le inyectamos la imagen del logo
const img = document.createElement('img');
img.src = data.config.company_logo;
img.className = "w-full h-full object-contain drop-shadow-sm";
headerIcon.appendChild(img);
}
}
} catch (e) {
console.error("No se pudo cargar el logo de la empresa", e);
}
}, 300); // Le damos 300ms de ventaja para que el HTML se dibuje primero
// ==========================================
// RASTREADOR FANTASMA GPS (MODO DE CAMINO)
@@ -84,4 +43,4 @@ setInterval(async () => {
}, () => {}, { enableHighAccuracy: false, timeout: 10000, maximumAge: 30000 });
}
} catch (e) { }
}, 15000); // Se ejecuta cada 15 segundos
}, 15000); // Se ejecuta cada 15 segundos