diff --git a/menu.html b/menu.html index 7826fb4..5ae0af4 100644 --- a/menu.html +++ b/menu.html @@ -7,7 +7,14 @@ -
+
-

HOY

+

HOY

Hola,

@@ -80,7 +91,27 @@ ? 'http://localhost:3000' : 'https://integrarepara-api.integrarepara.es'; - document.addEventListener("DOMContentLoaded", () => { + // --- SISTEMA DE TEMA DINÁMICO --- + async function applyTheme() { + try { + let theme = JSON.parse(localStorage.getItem('app_theme')); + const res = await fetch(`${API_URL}/config/company`, { + headers: { "Authorization": `Bearer ${localStorage.getItem("token")}` } + }); + const data = await res.json(); + if(data.ok && data.config && data.config.portal_settings && data.config.portal_settings.app_settings) { + theme = data.config.portal_settings.app_settings; + localStorage.setItem('app_theme', JSON.stringify(theme)); + } + if(theme) { + document.documentElement.style.setProperty('--primary', theme.primary); + document.documentElement.style.setProperty('--secondary', theme.secondary); + document.documentElement.style.setProperty('--app-bg', theme.bg); + } + } catch (e) { console.warn("Usando tema por defecto"); } + } + + document.addEventListener("DOMContentLoaded", async () => { const token = localStorage.getItem("token"); const role = localStorage.getItem("role"); @@ -89,6 +120,9 @@ return; } + // Aplicamos los colores corporativos de la empresa + await applyTheme(); + lucide.createIcons(); const rawName = localStorage.getItem("userName") || "Operario";