diff --git a/configuracion.html b/configuracion.html
index 5a3000f..4ab9512 100644
--- a/configuracion.html
+++ b/configuracion.html
@@ -137,30 +137,29 @@
@@ -722,6 +715,9 @@
let cachedTemplates = {};
let currentTemplateType = null;
let localGuilds = [];
+ const API_URL = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1'
+ ? 'http://localhost:3000'
+ : 'https://integrarepara-api.integrarepara.es';
document.addEventListener("DOMContentLoaded", () => {
if (!localStorage.getItem("token")) window.location.href = "index.html";
@@ -730,7 +726,7 @@
loadWaSettings();
});
- // ==========================================
+ // ==========================================
// LÓGICA DE NAVEGACIÓN Y TABS
// ==========================================
function showTab(tabId) {
@@ -754,7 +750,7 @@
if(tabId === 'providers') {
loadProviderCredentials();
loadIaRules();
- loadRobotConfig(); // 👇 ¡AQUÍ ESTABA EL FALLO! Faltaba llamar a esta función
+ loadRobotConfig();
}
}
@@ -915,12 +911,10 @@
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;
}
- // 👇 NUEVO: Cargar el texto de las instrucciones extra
if(document.getElementById('ai_custom_prompt')) {
document.getElementById('ai_custom_prompt').value = s.ai_custom_prompt || "";
}
@@ -937,12 +931,8 @@
async function saveWaSettings() {
const settings = {
- // Guardar el valor de la IA
wa_ai_enabled: document.getElementById('cfg_ai_enabled').checked,
-
- // 👇 NUEVO: Guardar el texto de las instrucciones extra
ai_custom_prompt: document.getElementById('ai_custom_prompt') ? document.getElementById('ai_custom_prompt').value : "",
-
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,
@@ -1193,7 +1183,7 @@
}
- // ==========================================
+ // ==========================================
// LÓGICA REGLAS ROBOT HOMESERVE
// ==========================================
function toggleHsConfig(type) {
@@ -1214,7 +1204,7 @@
// Cargar Asignación
if (hsSettings.assign) {
document.getElementById('hs_cfg_assign_enabled').checked = hsSettings.assign.enabled;
- document.getElementById('hs_cfg_assign_status').value = hsSettings.assign.status || "307"; // 307: Espera profesional inicio
+ document.getElementById('hs_cfg_assign_status').value = hsSettings.assign.status || "307";
document.getElementById('hs_cfg_assign_days').value = hsSettings.assign.days_next ?? 1;
document.getElementById('hs_cfg_assign_inform').checked = hsSettings.assign.check_inform || false;
document.getElementById('hs_cfg_assign_obs').value = hsSettings.assign.obs || "";
@@ -1224,8 +1214,7 @@
// Cargar Cita
if (hsSettings.date) {
document.getElementById('hs_cfg_date_enabled').checked = hsSettings.date.enabled;
- document.getElementById('hs_cfg_date_status').value = hsSettings.date.status || "307"; // 307: Concertado
- document.getElementById('hs_cfg_date_days').value = hsSettings.date.days_next ?? 0;
+ document.getElementById('hs_cfg_date_status').value = hsSettings.date.status || "307";
document.getElementById('hs_cfg_date_inform').checked = hsSettings.date.check_inform || false;
document.getElementById('hs_cfg_date_obs').value = hsSettings.date.obs || "";
toggleHsConfig('date');
@@ -1234,7 +1223,7 @@
// Cargar No Localizado
if (hsSettings.notfound) {
document.getElementById('hs_cfg_notfound_enabled').checked = hsSettings.notfound.enabled;
- document.getElementById('hs_cfg_notfound_status').value = hsSettings.notfound.status || "348"; // 348: Espera cliente
+ document.getElementById('hs_cfg_notfound_status').value = hsSettings.notfound.status || "348";
document.getElementById('hs_cfg_notfound_days').value = hsSettings.notfound.days_next ?? 1;
document.getElementById('hs_cfg_notfound_inform').checked = hsSettings.notfound.check_inform || false;
document.getElementById('hs_cfg_notfound_obs').value = hsSettings.notfound.obs || "";
@@ -1243,7 +1232,7 @@
} catch(e) { console.error("Error cargando ajustes del robot", e); }
}
- async function saveRobotConfig() {
+ async function saveRobotConfig() {
const btn = document.querySelector('button[onclick="saveRobotConfig()"]');
const originalHtml = btn.innerHTML;
btn.innerHTML = ' Guardando...';
@@ -1261,7 +1250,6 @@
date: {
enabled: document.getElementById('hs_cfg_date_enabled').checked,
status: document.getElementById('hs_cfg_date_status').value,
- // Ya no guardamos "days_next" aquí, el servidor usará la fecha de la cita
check_inform: document.getElementById('hs_cfg_date_inform').checked,
obs: document.getElementById('hs_cfg_date_obs').value
},