up
This commit is contained in:
@@ -477,6 +477,7 @@
|
||||
<small id="chat-phone">+1234567890</small>
|
||||
<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="finish-attend-btn" class="btn btn-sm btn-outline-warning" style="display:none; margin-right:6px;">Finalizar atención</button>
|
||||
<button id="release-hold-btn" class="btn btn-sm btn-outline-primary" style="display:none">Liberar espera</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -892,6 +893,7 @@
|
||||
|
||||
// Attender (marcar 'en servicio' sin liberar)
|
||||
const attendBtn = document.getElementById('attend-btn');
|
||||
const finishBtn = document.getElementById('finish-attend-btn');
|
||||
if (attendBtn) {
|
||||
attendBtn.style.display = (conv.advisor_requested && !conv.in_service) ? 'inline-block' : 'none';
|
||||
attendBtn.onclick = async () => {
|
||||
@@ -915,6 +917,8 @@
|
||||
attendBtn.style.display = 'none';
|
||||
// keep release available
|
||||
releaseBtn.style.display = 'inline-block';
|
||||
// show finish button
|
||||
if (finishBtn) finishBtn.style.display = 'inline-block';
|
||||
await this.loadConversations();
|
||||
} else {
|
||||
alert('Error al marcar como atendida');
|
||||
@@ -925,6 +929,40 @@
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Finalizar atención: enviar encuesta y limpiar estado
|
||||
if (finishBtn) {
|
||||
finishBtn.style.display = conv.in_service ? 'inline-block' : 'none';
|
||||
finishBtn.onclick = async () => {
|
||||
if (!confirm('¿Finalizar atención y enviar encuesta al usuario?')) return;
|
||||
try {
|
||||
const resp = await fetch('api/finish_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 = false;
|
||||
conv.advisor_requested = 0;
|
||||
holdIndicator.style.display = 'none';
|
||||
finishBtn.style.display = 'none';
|
||||
releaseBtn.style.display = 'none';
|
||||
attendBtn.style.display = 'none';
|
||||
await this.loadConversations();
|
||||
} else {
|
||||
alert('Error al finalizar la atención');
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error finalizing attend', e);
|
||||
alert('Error al finalizar la atención');
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user