From 6b509be3c42258cfd5ddbfb667188633578cffe1 Mon Sep 17 00:00:00 2001 From: marsalva Date: Tue, 24 Mar 2026 19:52:20 +0000 Subject: [PATCH] Actualizar js/layout.js --- js/layout.js | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/js/layout.js b/js/layout.js index 035b328..df47642 100644 --- a/js/layout.js +++ b/js/layout.js @@ -2,6 +2,47 @@ 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)