Actualizar configuracion.html
This commit is contained in:
@@ -727,6 +727,12 @@
|
||||
const res = await fetch(`${API_URL}/whatsapp/settings`, { headers: { "Authorization": `Bearer ${localStorage.getItem("token")}` } });
|
||||
const data = await res.json();
|
||||
const s = data.settings || {};
|
||||
|
||||
// Cargar el estado del nuevo botón de IA
|
||||
if(document.getElementById('cfg_ai_enabled')) {
|
||||
document.getElementById('cfg_ai_enabled').checked = s.wa_ai_enabled || false;
|
||||
}
|
||||
|
||||
document.getElementById('cfg_delay').checked = s.wa_delay_enabled !== false;
|
||||
document.getElementById('cfg_evt_welcome').checked = s.wa_evt_welcome || false;
|
||||
document.getElementById('cfg_evt_assigned').checked = s.wa_evt_assigned || false;
|
||||
@@ -734,11 +740,14 @@
|
||||
document.getElementById('cfg_evt_onway').checked = s.wa_evt_onway || false;
|
||||
document.getElementById('cfg_evt_finished').checked = s.wa_evt_finished || false;
|
||||
document.getElementById('cfg_evt_survey').checked = s.wa_evt_survey || false;
|
||||
} catch(e) { console.error("Error cargando ajustes WA"); }
|
||||
} catch(e) { console.error("Error cargando ajustes WA", e); }
|
||||
}
|
||||
|
||||
async function saveWaSettings() {
|
||||
const settings = {
|
||||
// Guardar el valor de la IA
|
||||
wa_ai_enabled: document.getElementById('cfg_ai_enabled').checked,
|
||||
|
||||
wa_delay_enabled: document.getElementById('cfg_delay').checked,
|
||||
wa_evt_welcome: document.getElementById('cfg_evt_welcome').checked,
|
||||
wa_evt_assigned: document.getElementById('cfg_evt_assigned').checked,
|
||||
@@ -749,12 +758,19 @@
|
||||
};
|
||||
try {
|
||||
const res = await fetch(`${API_URL}/whatsapp/settings`, {
|
||||
method: 'POST', headers: { "Content-Type": "application/json", "Authorization": `Bearer ${localStorage.getItem("token")}` },
|
||||
method: 'POST',
|
||||
headers: { "Content-Type": "application/json", "Authorization": `Bearer ${localStorage.getItem("token")}` },
|
||||
body: JSON.stringify(settings)
|
||||
});
|
||||
if (res.ok) showToast("✅ Ajustes de WhatsApp guardados");
|
||||
else showToast("❌ Error al guardar", true);
|
||||
} catch(e) { showToast("❌ Error de conexión", true); }
|
||||
if (res.ok) {
|
||||
showToast("✅ Ajustes de mensajería e IA guardados");
|
||||
} else {
|
||||
showToast("❌ Error al guardar", true);
|
||||
}
|
||||
} catch(e) {
|
||||
console.error(e);
|
||||
showToast("❌ Error de conexión", true);
|
||||
}
|
||||
}
|
||||
|
||||
async function checkWhatsappStatus() {
|
||||
|
||||
Reference in New Issue
Block a user