up
This commit is contained in:
+23
-2
@@ -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');
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user