Correções
This commit is contained in:
+23
-1
@@ -986,7 +986,8 @@ function renderInfoConversa(conv) {
|
||||
(c.matricula ? '<div class="field"><div class="label">Matrícula</div><div class="value">' + esc(c.matricula) + '</div></div>' : '') +
|
||||
(c.plano ? '<div class="field"><div class="label">Plano</div><div class="value">' + esc(c.plano) + '</div></div>' : '') +
|
||||
'<div class="field"><div class="label">Contato</div><div class="value">' + esc(c.celular || c.telefone || conv.numero || '-') + '</div></div>' +
|
||||
'<div class="field"><div class="label ' + inadClass + '">' + inadLabel + '</div></div>';
|
||||
'<div class="field"><div class="label ' + inadClass + '">' + inadLabel + '</div></div>' +
|
||||
'<button id="btnAtualizarFoto" onclick="atualizarFotoCliente()" style="margin-top:8px;padding:6px 10px;border:1px solid #e5e7eb;border-radius:6px;background:#f9fafb;cursor:pointer;font-size:12px;color:#374151">🔄 Atualizar foto (WhatsApp)</button>';
|
||||
} else if (conv.dependente) {
|
||||
var dep = conv.dependente;
|
||||
fotoContainer.textContent = (dep.nome || '?').charAt(0).toUpperCase();
|
||||
@@ -1487,6 +1488,27 @@ window.toggleInfo = function() {
|
||||
document.body.classList.toggle('info-aberto');
|
||||
};
|
||||
|
||||
// Busca a foto do cliente via Evolution (fetchProfile) e atualiza o painel
|
||||
window.atualizarFotoCliente = async function() {
|
||||
if (!conversaAtiva) return;
|
||||
var btn = document.getElementById('btnAtualizarFoto');
|
||||
if (btn) { btn.disabled = true; btn.textContent = '⏳ Buscando...'; }
|
||||
try {
|
||||
var r = await (await fetch('/api/' + alias + '/evolution/refresh-photo/' + conversaAtiva, {
|
||||
method: 'POST', headers: { 'Authorization': 'Bearer ' + token }
|
||||
})).json();
|
||||
if (r.success && r.atualizada) {
|
||||
abrirConversa(conversaAtiva); // recarrega para exibir a nova foto
|
||||
} else if (btn) {
|
||||
btn.disabled = false;
|
||||
btn.textContent = r.message || 'Nenhuma foto encontrada';
|
||||
setTimeout(function(){ btn.textContent = '🔄 Atualizar foto (WhatsApp)'; }, 2500);
|
||||
}
|
||||
} catch(e) {
|
||||
if (btn) { btn.disabled = false; btn.textContent = '🔄 Atualizar foto (WhatsApp)'; }
|
||||
}
|
||||
};
|
||||
|
||||
window.togglePrivada = function() {
|
||||
document.getElementById('privadaToggle').classList.toggle('ativa');
|
||||
var btn = document.getElementById('privadaToggle');
|
||||
|
||||
@@ -452,8 +452,8 @@ window.darkModeIsDark=function(){return localStorage.getItem('chatc2_dark_mode')
|
||||
} else {
|
||||
html += '<div id="conteudoCarnes_' + c.id + '" style="display:none"></div>';
|
||||
}
|
||||
// Conteudo Itens
|
||||
html += '<div id="conteudoItens_' + c.id + '" style="' + (temCarnes && !temItens ? 'display:none' : '') + ';overflow-x:auto">';
|
||||
// Conteudo Itens (oculto por padrão quando há boletos — Boletos é a aba ativa)
|
||||
html += '<div id="conteudoItens_' + c.id + '" style="' + (temCarnes ? 'display:none;' : '') + 'overflow-x:auto">';
|
||||
if (temItens) {
|
||||
html += '<table style="font-size:12px"><thead><tr>' +
|
||||
'<th>Produto</th><th style="text-align:center">Quantidade</th>' +
|
||||
@@ -492,19 +492,64 @@ window.darkModeIsDark=function(){return localStorage.getItem('chatc2_dark_mode')
|
||||
if (cItens) cItens.style.display = prefixo === 'itens' ? '' : 'none';
|
||||
};
|
||||
|
||||
// Edição INLINE do telefone do dependente (sem prompt/alert)
|
||||
window.editarTelDep = function(id) {
|
||||
var btn = document.querySelector('button[onclick="editarTelDep(' + id + ')"]');
|
||||
var telAtual = btn ? (btn.getAttribute('data-tel') || '') : '';
|
||||
var novo = prompt('Editar telefone do dependente:', telAtual || '');
|
||||
if (novo === null || novo.trim() === telAtual) return;
|
||||
var span = document.getElementById('depTel_' + id);
|
||||
if (!span || span.getAttribute('data-editing') === '1') return;
|
||||
var btnEdit = document.querySelector('button[onclick="editarTelDep(' + id + ')"]');
|
||||
var telAtual = btnEdit ? (btnEdit.getAttribute('data-tel') || '') : '';
|
||||
span.setAttribute('data-editing', '1');
|
||||
span.setAttribute('data-original', span.innerHTML);
|
||||
if (btnEdit) btnEdit.style.display = 'none';
|
||||
span.innerHTML =
|
||||
'<input type="text" id="depTelInput_' + id + '" value="' + telAtual.replace(/"/g, '"') + '" style="width:120px;padding:2px 6px;border:1px solid #667eea;border-radius:4px;font-size:12px;outline:none">' +
|
||||
' <button onclick="confirmarTelDep(' + id + ')" title="Confirmar" style="padding:1px 7px;border:1px solid #059669;border-radius:4px;background:#059669;color:#fff;cursor:pointer;font-size:11px">✔</button>' +
|
||||
' <button onclick="cancelarTelDep(' + id + ')" title="Cancelar" style="padding:1px 7px;border:1px solid #d1d5db;border-radius:4px;background:#fff;cursor:pointer;font-size:11px">✖</button>';
|
||||
var inp = document.getElementById('depTelInput_' + id);
|
||||
if (inp) {
|
||||
inp.focus();
|
||||
inp.addEventListener('keydown', function(e) {
|
||||
if (e.key === 'Enter') { e.preventDefault(); confirmarTelDep(id); }
|
||||
else if (e.key === 'Escape') { cancelarTelDep(id); }
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
window.cancelarTelDep = function(id) {
|
||||
var span = document.getElementById('depTel_' + id);
|
||||
if (!span) return;
|
||||
span.innerHTML = span.getAttribute('data-original') || '-';
|
||||
span.setAttribute('data-editing', '');
|
||||
var btnEdit = document.querySelector('button[onclick="editarTelDep(' + id + ')"]');
|
||||
if (btnEdit) btnEdit.style.display = '';
|
||||
};
|
||||
|
||||
window.confirmarTelDep = function(id) {
|
||||
var inp = document.getElementById('depTelInput_' + id);
|
||||
var span = document.getElementById('depTel_' + id);
|
||||
if (!inp || !span) return;
|
||||
var novo = (inp.value || '').trim();
|
||||
var btnEdit = document.querySelector('button[onclick="editarTelDep(' + id + ')"]');
|
||||
inp.disabled = true;
|
||||
fetch('/api/' + alias + '/dependents/' + id + '/phone', {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + token },
|
||||
body: JSON.stringify({ telefone: novo.trim() })
|
||||
body: JSON.stringify({ telefone: novo })
|
||||
}).then(function(r) { return r.json(); }).then(function(d) {
|
||||
if (d.success) { document.getElementById('depTel_' + id).textContent = novo.trim(); alert('Telefone atualizado!'); }
|
||||
else alert('Erro: ' + d.error);
|
||||
}).catch(function(e) { alert('Erro: ' + e.message); });
|
||||
if (d.success) {
|
||||
span.setAttribute('data-editing', '');
|
||||
span.textContent = novo || '-';
|
||||
if (btnEdit) { btnEdit.setAttribute('data-tel', novo); btnEdit.style.display = ''; }
|
||||
} else {
|
||||
inp.disabled = false;
|
||||
inp.style.borderColor = '#ef4444';
|
||||
inp.title = d.error || 'Erro ao salvar';
|
||||
}
|
||||
}).catch(function(e) {
|
||||
inp.disabled = false;
|
||||
inp.style.borderColor = '#ef4444';
|
||||
inp.title = e.message;
|
||||
});
|
||||
};
|
||||
|
||||
// ============================================================
|
||||
|
||||
Reference in New Issue
Block a user