Update conversations.php

This commit is contained in:
Lizandro Guarnizo
2026-01-23 22:38:37 -05:00
parent c0a65451cb
commit 3c6c5d0087
+31 -15
View File
@@ -813,11 +813,15 @@
return null;
}
const text = await response.text();
if (!response.ok) {
throw new Error('HTTP error! status: ' + response.status);
// Incluir el cuerpo de la respuesta (truncado) para diagnóstico
const snippet = text && text.length ? (text.length > 2000 ? text.substr(0, 2000) + '... (truncated)' : text) : '<no body>';
console.error('apiCall HTTP error', response.status, url, snippet);
throw new Error('HTTP error! status: ' + response.status + ' -- ' + snippet);
}
const text = await response.text();
if (!text || text.trim() === '') return null;
try {
@@ -1053,16 +1057,20 @@
};
}
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';
if (holdIndicator) {
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';
}
} else {
holdIndicator.style.display = 'none';
console.warn('holdIndicator element not found in DOM');
}
if (releaseBtn) {
@@ -1083,7 +1091,11 @@
if (json && json.success) {
conv.on_hold = false;
conv.advisor_requested = 0;
holdIndicator.style.display = 'none';
if (holdIndicator) {
holdIndicator.style.display = 'none';
} else {
console.warn('holdIndicator missing when releasing hold');
}
releaseBtn.style.display = 'none';
await this.loadConversations();
} else {
@@ -1115,9 +1127,13 @@
if (json && json.success) {
conv.in_service = true;
conv.advisor_requested = 0;
holdIndicator.textContent = 'EN SERVICIO';
holdIndicator.style.color = '#28a745';
holdIndicator.style.display = 'inline';
if (holdIndicator) {
holdIndicator.textContent = 'EN SERVICIO';
holdIndicator.style.color = '#28a745';
holdIndicator.style.display = 'inline';
} else {
console.warn('holdIndicator missing when marking in_service');
}
attendBtn.style.display = 'none';
// keep release available
releaseBtn.style.display = 'inline-block';