diff --git a/configuracion.html b/configuracion.html index 977a7f5..5140af6 100644 --- a/configuracion.html +++ b/configuracion.html @@ -11,6 +11,11 @@ .fade-in { animation: fadeIn 0.3s ease-in-out; } .scroller::-webkit-scrollbar { width: 6px; } .scroller::-webkit-scrollbar-thumb { background-color: #cbd5e1; border-radius: 4px; } + /* Toggle Switch CSS */ + .toggle-checkbox:checked { right: 0; border-color: #2563eb; } + .toggle-checkbox:checked + .toggle-label { background-color: #2563eb; } + .toggle-checkbox { right: 0; z-index: 1; border-color: #e2e8f0; transition: all 0.3s; } + .toggle-label { background-color: #e2e8f0; transition: all 0.3s; } @@ -86,16 +91,31 @@

Conexión con WhatsApp

Escanea el código QR para vincular tu número de empresa.

+
Iniciando instancia segura...
- -

Instancia segura gestionada automáticamente por el servidor.

+ +
+
+

+ Modo "Escribiendo..." +

+

Simula que un humano está tecleando el mensaje. Si lo desactivas, los mensajes llegarán de forma instantánea.

+
+ +
+ + +
+
@@ -203,6 +223,17 @@ if (!localStorage.getItem("token")) window.location.href = "index.html"; showTab('templates'); loadTemplates(); + + // Cargar preferencia de delay de WhatsApp + const toggle = document.getElementById('waDelayToggle'); + const savedSetting = localStorage.getItem('wa_delay_enabled'); + // Por defecto activo si no hay ajuste guardado + toggle.checked = savedSetting === null ? true : savedSetting === 'true'; + + toggle.addEventListener('change', (e) => { + localStorage.setItem('wa_delay_enabled', e.target.checked); + showToast(`Modo "Escribiendo" ${e.target.checked ? 'Activado' : 'Desactivado'}`); + }); }); function showTab(tabId) { @@ -219,10 +250,9 @@ if(tabId === 'others') { loadCompanies(); loadStatusesConfig(); } if(tabId === 'whatsapp') { checkWhatsappStatus(); } - if(tabId === 'providers') { loadProviderCredentials(); } // Cargar credenciales + if(tabId === 'providers') { loadProviderCredentials(); } } - // --- GESTIÓN DE PROVEEDORES (NUEVO) --- async function loadProviderCredentials() { try { const res = await fetch(`${API_URL}/providers/credentials`, { @@ -235,7 +265,6 @@ const inputUser = document.getElementById(`user_${cred.provider}`); const inputPass = document.getElementById(`pass_${cred.provider}`); if(inputUser) inputUser.value = cred.username; - // No rellenamos la contraseña por seguridad, solo el usuario if(inputPass) inputPass.placeholder = "•••••••• (Guardada)"; }); } @@ -267,7 +296,6 @@ } catch(e) { showToast("Error de conexión", true); } } - // --- WHATSAPP STATUS (AUTOMÁTICO) --- async function checkWhatsappStatus() { const container = document.getElementById('waStatusContainer'); container.innerHTML = `
Verificando instancia...
`; @@ -292,7 +320,6 @@ lucide.createIcons(); } - // --- GESTIÓN DE PLANTILLAS --- async function loadTemplates() { try { const res = await fetch(`${API_URL}/templates`, { headers: { "Authorization": `Bearer ${localStorage.getItem("token")}` } }); @@ -338,7 +365,6 @@ } catch(e) { showToast("Error", true); } } - // --- GESTIÓN DE COMPAÑÍAS Y ESTADOS (MANTENIDO) --- async function loadCompanies() { const list = document.getElementById('listCompanies'); list.innerHTML = '

Cargando...

';