From 3c6c5d008728203f51f1928ab8246ea63140216a Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Fri, 23 Jan 2026 22:38:37 -0500 Subject: [PATCH] Update conversations.php --- conversations.php | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/conversations.php b/conversations.php index 4811211..750ec9d 100644 --- a/conversations.php +++ b/conversations.php @@ -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) : ''; + 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';