Update conversations.php

This commit is contained in:
Lizandro Guarnizo
2026-01-23 22:38:37 -05:00
parent c0a65451cb
commit 3c6c5d0087
+18 -2
View File
@@ -813,11 +813,15 @@
return null; return null;
} }
const text = await response.text();
if (!response.ok) { 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; if (!text || text.trim() === '') return null;
try { try {
@@ -1053,6 +1057,7 @@
}; };
} }
if (holdIndicator) {
if (conv.on_hold) { if (conv.on_hold) {
holdIndicator.textContent = 'EN ESPERA'; holdIndicator.textContent = 'EN ESPERA';
holdIndicator.style.color = '#b85'; holdIndicator.style.color = '#b85';
@@ -1064,6 +1069,9 @@
} else { } else {
holdIndicator.style.display = 'none'; holdIndicator.style.display = 'none';
} }
} else {
console.warn('holdIndicator element not found in DOM');
}
if (releaseBtn) { if (releaseBtn) {
// show button when on_hold or advisor_requested // show button when on_hold or advisor_requested
@@ -1083,7 +1091,11 @@
if (json && json.success) { if (json && json.success) {
conv.on_hold = false; conv.on_hold = false;
conv.advisor_requested = 0; conv.advisor_requested = 0;
if (holdIndicator) {
holdIndicator.style.display = 'none'; holdIndicator.style.display = 'none';
} else {
console.warn('holdIndicator missing when releasing hold');
}
releaseBtn.style.display = 'none'; releaseBtn.style.display = 'none';
await this.loadConversations(); await this.loadConversations();
} else { } else {
@@ -1115,9 +1127,13 @@
if (json && json.success) { if (json && json.success) {
conv.in_service = true; conv.in_service = true;
conv.advisor_requested = 0; conv.advisor_requested = 0;
if (holdIndicator) {
holdIndicator.textContent = 'EN SERVICIO'; holdIndicator.textContent = 'EN SERVICIO';
holdIndicator.style.color = '#28a745'; holdIndicator.style.color = '#28a745';
holdIndicator.style.display = 'inline'; holdIndicator.style.display = 'inline';
} else {
console.warn('holdIndicator missing when marking in_service');
}
attendBtn.style.display = 'none'; attendBtn.style.display = 'none';
// keep release available // keep release available
releaseBtn.style.display = 'inline-block'; releaseBtn.style.display = 'inline-block';