This commit is contained in:
lizandrogd
2026-01-21 16:32:40 -05:00
parent 1c578b14b0
commit ac179cec98
5 changed files with 182 additions and 3 deletions
+40 -1
View File
@@ -475,7 +475,10 @@
<span id="hold-indicator" style="display:none; margin-left:8px; color:#b85; font-weight:600">EN ESPERA</span>
</h6>
<small id="chat-phone">+1234567890</small>
<div style="font-size:12px; margin-top:4px;"><button id="release-hold-btn" class="btn btn-sm btn-outline-primary" style="display:none">Liberar espera</button></div>
<div style="font-size:12px; margin-top:4px;">
<button id="attend-btn" class="btn btn-sm btn-outline-success" style="display:none; margin-right:6px;">Atender</button>
<button id="release-hold-btn" class="btn btn-sm btn-outline-primary" style="display:none">Liberar espera</button>
</div>
</div>
<div style="margin-left: auto; display:flex; gap:8px; align-items:center;">
<div id="bot-toggle-container" style="display:flex;align-items:center;gap:6px;margin-right:8px;">
@@ -886,6 +889,42 @@
alert('Error liberando espera');
}
};
// Attender (marcar 'en servicio' sin liberar)
const attendBtn = document.getElementById('attend-btn');
if (attendBtn) {
attendBtn.style.display = (conv.advisor_requested && !conv.in_service) ? 'inline-block' : 'none';
attendBtn.onclick = async () => {
try {
const resp = await fetch('api/attend.php', {
method: 'POST',
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.in_service = true;
conv.advisor_requested = 0;
holdIndicator.textContent = 'EN SERVICIO';
holdIndicator.style.color = '#28a745';
holdIndicator.style.display = 'inline';
attendBtn.style.display = 'none';
// keep release available
releaseBtn.style.display = 'inline-block';
await this.loadConversations();
} else {
alert('Error al marcar como atendida');
}
} catch (e) {
console.error('Error attending', e);
alert('Error al atender');
}
};
}
}
}
};