up
This commit is contained in:
@@ -427,6 +427,11 @@ if (empty($user_id)) {
|
||||
<input type="text" class="form-control form-control-sm mt-2" id="mediaCaption"
|
||||
placeholder="Agregar caption (opcional)...">
|
||||
</div>
|
||||
|
||||
<!-- Quick replies (Respuestas rápidas) -->
|
||||
<div id="quickRepliesContainer" style="display:none; margin-bottom:10px;">
|
||||
<div class="d-flex flex-wrap" id="quickRepliesButtons" style="gap:8px;"></div>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<input type="file" id="fileInput" style="display: none;"
|
||||
@@ -444,6 +449,14 @@ if (empty($user_id)) {
|
||||
<i class="fas fa-paper-plane"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Quick replies toggle -->
|
||||
<div class="mt-2 d-flex align-items-center">
|
||||
<button class="btn btn-sm btn-outline-secondary" id="toggleQuickRepliesBtn" onclick="toggleQuickReplies()">
|
||||
<i class="fas fa-bolt"></i> Respuestas rápidas
|
||||
</button>
|
||||
<small class="ms-2 text-muted">Usa respuestas automáticas rápidas</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -555,6 +568,9 @@ if (empty($user_id)) {
|
||||
|
||||
// Cargar plantillas
|
||||
loadTemplates();
|
||||
|
||||
// Cargar respuestas rápidas (quick replies)
|
||||
loadQuickReplies();
|
||||
|
||||
} else {
|
||||
showError('Error cargando datos del usuario');
|
||||
@@ -985,6 +1001,54 @@ if (empty($user_id)) {
|
||||
}
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
// ===== Quick replies (Respuestas rápidas) =====
|
||||
async function loadQuickReplies() {
|
||||
try {
|
||||
const resp = await whatsappManager.apiCall('get_autoresponses.php');
|
||||
const container = document.getElementById('quickRepliesButtons');
|
||||
const wrapper = document.getElementById('quickRepliesContainer');
|
||||
container.innerHTML = '';
|
||||
|
||||
if (resp && resp.success && Array.isArray(resp.data)) {
|
||||
const responses = resp.data;
|
||||
// Filtrar solo respuestas tipo text y activas
|
||||
responses.forEach(r => {
|
||||
if (r.is_active && (r.response_type === 'text' || !r.response_type)) {
|
||||
const btn = document.createElement('button');
|
||||
btn.type = 'button';
|
||||
btn.className = 'btn btn-sm btn-outline-primary';
|
||||
btn.textContent = r.response_text.length > 40 ? r.response_text.substr(0, 40) + '…' : r.response_text;
|
||||
btn.title = r.response_text;
|
||||
btn.onclick = function() {
|
||||
// enviar la respuesta rápida
|
||||
sendTextMessage(r.response_text);
|
||||
// Registrar en UI
|
||||
showAlert('Respuesta rápida enviada', 'success');
|
||||
};
|
||||
container.appendChild(btn);
|
||||
}
|
||||
});
|
||||
|
||||
// Mostrar contenedor solo si hay respuestas
|
||||
if (container.children.length) {
|
||||
wrapper.style.display = 'block';
|
||||
} else {
|
||||
wrapper.style.display = 'none';
|
||||
}
|
||||
} else {
|
||||
wrapper.style.display = 'none';
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error cargando respuestas rápidas:', err);
|
||||
}
|
||||
}
|
||||
|
||||
function toggleQuickReplies() {
|
||||
const wrapper = document.getElementById('quickRepliesContainer');
|
||||
if (!wrapper) return;
|
||||
wrapper.style.display = (wrapper.style.display === 'block') ? 'none' : 'block';
|
||||
}
|
||||
|
||||
function showError(message) {
|
||||
showAlert(message, 'danger');
|
||||
|
||||
Reference in New Issue
Block a user