This commit is contained in:
lizandrogd
2026-01-21 15:12:15 -05:00
parent 75b8f469f4
commit ddc9a68a40
4 changed files with 51 additions and 6 deletions
+23 -2
View File
@@ -843,11 +843,23 @@
const releaseBtn = document.getElementById('release-hold-btn');
if (holdIndicator) {
holdIndicator.style.display = conv.on_hold ? 'inline' : 'none';
// Show different labels depending on state
if (conv.on_hold) {
holdIndicator.textContent = 'EN ESPERA';
holdIndicator.style.color = '#b85';
holdIndicator.style.display = 'inline';
} else if (conv.advisor_requested) {
holdIndicator.textContent = 'SOLICITUD PENDIENTE';
holdIndicator.style.color = '#f39c12';
holdIndicator.style.display = 'inline';
} else {
holdIndicator.style.display = 'none';
}
}
if (releaseBtn) {
releaseBtn.style.display = conv.on_hold ? 'inline-block' : 'none';
// show button when on_hold or advisor_requested
releaseBtn.style.display = (conv.on_hold || conv.advisor_requested) ? 'inline-block' : 'none';
releaseBtn.onclick = async () => {
try {
const resp = await fetch('api/release_hold.php', {
@@ -855,9 +867,14 @@
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ user_id: userId })
});
if (resp.status === 401) {
alert('Sesión expirada. Por favor inicie sesión de nuevo.');
return;
}
const json = await resp.json();
if (json && json.success) {
conv.on_hold = false;
conv.advisor_requested = 0;
holdIndicator.style.display = 'none';
releaseBtn.style.display = 'none';
await this.loadConversations();
@@ -866,6 +883,10 @@
}
} catch (e) {
console.error('Error releasing hold', e);
alert('Error liberando espera');
}
};
}
}
};
}