Update conversations.php
This commit is contained in:
+19
-29
@@ -553,7 +553,7 @@
|
|||||||
<i class="fas fa-user"></i>
|
<i class="fas fa-user"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="chat-header-info">
|
<div class="chat-header-info">
|
||||||
<h6 id="chat-name">Usuario <button class="btn btn-sm btn-link" id="edit-user-btn" title="Editar usuario"><i class="fas fa-user-edit"></i></button>
|
<h6 id="chat-name"><span id="chat-name-text">Usuario</span> <button class="btn btn-sm btn-link" id="edit-user-btn" title="Editar usuario"><i class="fas fa-user-edit"></i></button>
|
||||||
<span id="hold-indicator" style="display:none; margin-left:8px; color:#b85; font-weight:600">EN ESPERA</span>
|
<span id="hold-indicator" style="display:none; margin-left:8px; color:#b85; font-weight:600">EN ESPERA</span>
|
||||||
</h6>
|
</h6>
|
||||||
<small id="chat-phone">+1234567890</small>
|
<small id="chat-phone">+1234567890</small>
|
||||||
@@ -1099,7 +1099,8 @@
|
|||||||
document.getElementById('chat-area').style.display = 'flex';
|
document.getElementById('chat-area').style.display = 'flex';
|
||||||
|
|
||||||
// Actualizar header
|
// Actualizar header
|
||||||
document.getElementById('chat-name').textContent = userName;
|
const nameEl = document.getElementById('chat-name-text') || document.getElementById('chat-name');
|
||||||
|
nameEl.textContent = userName;
|
||||||
document.getElementById('chat-phone').textContent = phoneNumber;
|
document.getElementById('chat-phone').textContent = phoneNumber;
|
||||||
document.getElementById('chat-avatar').textContent = this.getInitials(userName);
|
document.getElementById('chat-avatar').textContent = this.getInitials(userName);
|
||||||
|
|
||||||
@@ -1658,6 +1659,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async sendQuickReply(text) {
|
||||||
|
if (!text) return;
|
||||||
|
const input = document.getElementById('message-input');
|
||||||
|
if (!input) return;
|
||||||
|
input.value = text;
|
||||||
|
await this.sendMessage();
|
||||||
|
}
|
||||||
|
|
||||||
scrollToBottom() {
|
scrollToBottom() {
|
||||||
const container = document.getElementById('chat-conversations');
|
const container = document.getElementById('chat-conversations');
|
||||||
container.scrollTop = container.scrollHeight;
|
container.scrollTop = container.scrollHeight;
|
||||||
@@ -1732,31 +1741,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadQuickReplies() {
|
// loadQuickReplies is implemented earlier (combined autoresponses & templates)
|
||||||
try {
|
// kept here as a no-op to avoid accidentally overriding the real implementation.
|
||||||
const resp = await fetch('api/get_templates.php?approved_only=1&limit=10');
|
|
||||||
const json = await resp.json();
|
|
||||||
const container = document.getElementById('quick-replies');
|
|
||||||
if (!container) return;
|
|
||||||
container.innerHTML = '';
|
|
||||||
if (json && json.success && Array.isArray(json.data)) {
|
|
||||||
const templates = json.data.slice(0,5);
|
|
||||||
templates.forEach(t => {
|
|
||||||
const text = (t.body_text || t.name || t.template_name || '').replace(/\n/g,' ');
|
|
||||||
const btn = document.createElement('button');
|
|
||||||
btn.className = 'btn btn-sm btn-outline-secondary';
|
|
||||||
btn.dataset.qr = text;
|
|
||||||
btn.textContent = text.length > 30 ? text.substring(0,30) + '...' : text;
|
|
||||||
container.appendChild(btn);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error('loadQuickReplies error', err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async promptEditUser() {
|
async promptEditUser() {
|
||||||
const currentName = document.getElementById('chat-name').textContent || '';
|
const nameEl = document.getElementById('chat-name-text') || document.getElementById('chat-name');
|
||||||
|
const currentName = nameEl ? nameEl.textContent.trim() : '';
|
||||||
const newName = prompt('Nombre del usuario:', currentName);
|
const newName = prompt('Nombre del usuario:', currentName);
|
||||||
if (!newName) return;
|
if (!newName) return;
|
||||||
|
|
||||||
@@ -1768,15 +1758,15 @@
|
|||||||
});
|
});
|
||||||
const json = await resp.json();
|
const json = await resp.json();
|
||||||
if (json && json.success) {
|
if (json && json.success) {
|
||||||
document.getElementById('chat-name').textContent = newName;
|
if (nameEl) nameEl.textContent = newName;
|
||||||
this.showSuccess('Usuario actualizado');
|
this.showSuccess && this.showSuccess('Usuario actualizado');
|
||||||
this.loadConversations();
|
this.loadConversations();
|
||||||
} else {
|
} else {
|
||||||
this.showError('No se pudo actualizar usuario');
|
this.showError && this.showError('No se pudo actualizar usuario');
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
this.showError('Error actualizando usuario');
|
this.showError && this.showError('Error actualizando usuario');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user