atualizacoes

This commit is contained in:
2026-06-25 12:30:47 +00:00
parent bb80be896f
commit 1ddf9b7def
21 changed files with 679 additions and 180 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ body { background:var(--surface-3); display:flex; min-height:100vh; }
.loading { text-align:center; padding:40px; color:var(--text-faint); }
</style>
<link rel="stylesheet" href="/css/dark-mode.css">
<script>if(localStorage.getItem("chatc2_dark_mode")==="true")document.documentElement.classList.add("dark-mode-pending")</script>
<script>(function(){var m=localStorage.getItem("chatc2_dark_mode_manual");var d=m!==null?m==="true":window.matchMedia("(prefers-color-scheme: dark)").matches;if(d)document.documentElement.className="dark"})()</script>
</head>
<body>
<aside class="sidebar" role="navigation" aria-label="Navegação principal">
+16 -3
View File
@@ -816,7 +816,7 @@ body.dark-mode .msg.erro .btn-reenviar:hover { background: #8b0000; color: #fff;
body.dark-mode .msg.enviando { opacity: 0.4; }
</style>
<link rel="stylesheet" href="/css/dark-mode.css">
<script>if(localStorage.getItem("chatc2_dark_mode")==="true")document.documentElement.classList.add("dark-mode-pending")</script>
<script>(function(){var m=localStorage.getItem("chatc2_dark_mode_manual");var d=m!==null?m==="true":window.matchMedia("(prefers-color-scheme: dark)").matches;if(d)document.documentElement.className="dark"})()</script>
</head>
<body>
@@ -1284,8 +1284,21 @@ function renderInfoConversa(conv) {
'<div class="field"><div class="label">Contato</div><div class="value">' + esc(dep.telefone || conv.numero || '-') + '</div></div>' +
'<div class="field"><div class="label">' + inads + '</div></div>';
} else {
fotoContainer.textContent = (conv.nomeContato || '?').charAt(0).toUpperCase();
infoContainer.innerHTML = '<div style="color:#9ca3af;font-size:13px;text-align:center;padding:20px 0">Contato não cadastrado como cliente</div>';
// Sem cliente vinculado: mostra o número e nome do contato WhatsApp
var numeroExibir = (conv.numero || '').replace(/^(\d{2})(\d{2})(\d{5})(\d{4})$/, '($1) $2 $3-$4').replace(/^(\d{2})(\d{5})(\d{4})$/, '($1) $2-$3');
if (!numeroExibir) numeroExibir = conv.numero || '-';
var nomeContato = (conv.nomeContato || '').trim();
// Se o nome do contato for igual ao número (formato puro), mostra só o número formatado
var nomeLimpo = nomeContato.replace(/\D/g, '');
var numLimpo = (conv.numero || '').replace(/\D/g, '');
if (nomeLimpo === numLimpo) nomeContato = '';
fotoContainer.innerHTML = '<span style="font-weight:600">?</span>';
infoContainer.innerHTML =
'<div style="font-size:13px;font-weight:600;color:#d97706;margin-bottom:6px">⚠️ Número não identificado</div>' +
'<div style="font-size:14px;font-weight:600;color:var(--text-primary);margin-bottom:4px">' + esc(nomeContato || numeroExibir) + '</div>' +
(nomeContato ? '<div class="field"><div class="label">WhatsApp</div><div class="value">' + esc(numeroExibir) + '</div></div>' : '') +
'<div class="field"><div class="label">Status</div><div class="value" style="color:var(--text-muted)">Sem cadastro no sistema</div></div>';
}
// Botão "Enviar boleto" (aparece se a empresa habilitar e houver titular)
+26 -2
View File
@@ -92,7 +92,7 @@ table { font-size:13px; }
}
</style>
<link rel="stylesheet" href="/css/dark-mode.css">
<script>if(localStorage.getItem("chatc2_dark_mode")==="true")document.documentElement.classList.add("dark-mode-pending")</script>
<script>(function(){var m=localStorage.getItem("chatc2_dark_mode_manual");var d=m!==null?m==="true":window.matchMedia("(prefers-color-scheme: dark)").matches;if(d)document.documentElement.className="dark"})()</script>
</head>
<body>
@@ -637,6 +637,28 @@ table { font-size:13px; }
return tipos;
}
// Editar data de agendamento de cobrança
window.editarAgendamento = function(carneId, el) {
var dataAtual = el.textContent.trim();
var novaData = prompt('Nova data de agendamento (AAAA-MM-DD):', dataAtual !== '-' ? dataAtual : '');
if (novaData === null) return; // cancelou
if (!novaData.trim()) {
novaData = null; // limpar agendamento
}
fetch('/api/' + alias + '/clients/' + id_cliente + '/carne/' + carneId + '/agendamento', {
method: 'PUT',
headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + token },
body: JSON.stringify({ dataAgendamento: novaData })
}).then(function(r) { return r.json(); }).then(function(data) {
if (data.success) {
el.textContent = novaData ? novaData.split('-').reverse().join('/') : '-';
} else {
alert(data.error || 'Erro ao atualizar');
}
}).catch(function() { alert('Erro de conexão'); });
};
// Torna global para os onclick dos botões de paginação
window.loadCarnes = function(page) {
if (page) carnesPage = page;
@@ -697,7 +719,9 @@ table { font-size:13px; }
'<td>' + vencDot + fmtDate(c.vencimento) + '</td>' +
'<td class="valor">' + fmtMoney(c.valorParcela) + '</td>' +
'<td>' + fmtDate(c.dataPagamento) + '</td>' +
'<td style="font-size:11px">' + fmtDate(c.agendamentoCobranca) + '</td>' +
'<td style="font-size:11px">' +
'<span class="agendamento-cell" onclick="editarAgendamento(' + c.id + ',this)" title="Clique para alterar" style="cursor:pointer;border-bottom:1px dashed #9ca3af">' +
fmtDate(c.agendamentoCobranca) + '</span></td>' +
'<td>' + (c.nossoNumero || '-') + '</td>' +
'<td class="centro">' + (c.parcela || '-') + '/' + (c.totalParcelas || '-') + '</td>' +
'</tr>';
+1 -1
View File
@@ -12,7 +12,7 @@
.container { flex: 1; padding: 24px; overflow-y: auto; }
</style>
<link rel="stylesheet" href="/css/dark-mode.css">
<script>if(localStorage.getItem("chatc2_dark_mode")==="true")document.documentElement.classList.add("dark-mode-pending")</script>
<script>(function(){var m=localStorage.getItem("chatc2_dark_mode_manual");var d=m!==null?m==="true":window.matchMedia("(prefers-color-scheme: dark)").matches;if(d)document.documentElement.className="dark"})()</script>
</head>
<body>
<aside class="sidebar" role="navigation" aria-label="Navegação principal">
+192 -83
View File
@@ -3,102 +3,187 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Avalie seu Atendimento</title>
<title>Avalie seu Atendimento - Chatc2</title>
<style>
:root {
--primary: #667eea;
--primary-dark: #5a67d8;
--secondary: #764ba2;
--surface: #ffffff;
--surface-2: #f9fafb;
--surface-3: #f3f4f6;
--border: #e5e7eb;
--text-primary: #111827;
--text-secondary: #374151;
--text-muted: #6b7280;
--text-faint: #9ca3af;
--success: #059669;
--success-bg: #d1fae5;
--success-text: #065f46;
--danger: #ef4444;
--danger-bg: #fef2f2;
--danger-text: #991b1b;
--warning: #f59e0b;
}
* { margin:0; padding:0; box-sizing:border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: linear-gradient(135deg, var(--primary) 0%, #764ba2 100%);
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
-webkit-font-smoothing: antialiased;
background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
background-size: 400% 400%;
animation: gradientShift 12s ease infinite;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
color: var(--text-primary);
}
@keyframes gradientShift {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
.container {
background: #fff;
background: var(--surface);
border-radius: 20px;
padding: 40px;
max-width: 480px;
padding: 44px 40px 36px;
max-width: 440px;
width: 100%;
text-align: center;
box-shadow: 0 20px 60px rgba(0,0,0,0.15);
box-shadow: 0 32px 80px rgba(0,0,0,0.28), 0 0 0 1px rgba(255,255,255,0.1);
}
.logo { font-size: 48px; margin-bottom: 16px; }
h1 { font-size: 24px; color: var(--text-primary); margin-bottom: 8px; }
.subtitle { font-size: 14px; color: var(--text-muted); margin-bottom: 32px; }
.stars {
display: flex;
.logo {
width: 76px; height: 76px;
background: linear-gradient(135deg, var(--primary), var(--secondary));
border-radius: 20px;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 8px;
margin-bottom: 18px;
font-size: 32px;
color: #fff;
}
h1 {
font-size: 24px; font-weight: 800;
color: var(--text-primary);
margin-bottom: 6px;
letter-spacing: -0.5px;
}
.subtitle {
font-size: 14px; color: var(--text-muted);
margin-bottom: 32px;
line-height: 1.5;
}
/* Stars */
.stars {
display: flex; justify-content: center; gap: 8px;
margin-bottom: 32px;
direction: rtl;
}
.stars input { display: none; }
.stars label {
font-size: 48px;
cursor: pointer;
font-size: 48px; cursor: pointer;
color: #d1d5db;
transition: color .2s, transform .15s;
user-select: none;
}
.stars label:hover,
.stars label:hover ~ label,
.stars input:checked ~ label {
color: #f59e0b;
transform: scale(1.1);
}
.stars input:checked + label {
color: #f59e0b;
}
textarea {
width: 100%;
padding: 14px 16px;
border: 2px solid var(--border);
border-radius: 12px;
font-size: 14px;
font-family: inherit;
resize: vertical;
min-height: 80px;
outline: none;
transition: border-color .2s;
margin-bottom: 20px;
}
textarea:focus { border-color: var(--primary); }
.btn {
width: 100%;
padding: 14px;
background: linear-gradient(135deg, var(--primary) 0%, #764ba2 100%);
color: #fff;
border: none;
border-radius: 12px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: opacity .2s;
}
.btn:hover { opacity: .9; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.stars label:hover { transform: scale(1.15); }
.stars input:checked ~ label { color: var(--warning); }
.stars input:checked + label { color: var(--warning); }
.rating-text {
font-size: 14px;
color: var(--text-muted);
margin-bottom: 24px;
min-height: 20px;
font-size: 14px; color: var(--text-muted);
margin-bottom: 24px; min-height: 20px;
font-weight: 500;
}
/* Textarea */
textarea {
width: 100%; padding: 10px 14px;
border: 2px solid var(--border);
border-radius: 8px;
font-size: 14px; font-family: inherit;
resize: vertical; min-height: 80px;
outline: none; background: var(--surface-2);
color: var(--text-primary);
transition: all .15s;
margin-bottom: 20px;
}
textarea:focus {
border-color: var(--primary);
background: var(--surface);
box-shadow: 0 0 0 3px rgba(102,126,234,0.12);
}
textarea::placeholder {
color: var(--text-faint);
}
/* Button */
.btn {
width: 100%; padding: 12px 20px;
background: var(--primary);
color: #fff;
border: none; border-radius: 8px;
font-size: 15px; font-weight: 600;
cursor: pointer;
transition: all .15s;
font-family: inherit;
}
.btn:hover { background: var(--primary-dark); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
/* Success */
.success { display: none; }
.success .icon { font-size: 64px; margin-bottom: 16px; }
.success h2 { color: var(--success); margin-bottom: 8px; }
.success p { color: var(--text-muted); }
.success h2 { color: var(--success); margin-bottom: 8px; font-size: 20px; font-weight: 700; }
.success p { color: var(--text-muted); font-size: 14px; }
/* Error */
.erro {
color: var(--danger);
font-size: 14px;
margin-top: 12px;
display: none;
background: var(--danger-bg); color: var(--danger-text);
padding: 8px 14px; border-radius: 6px;
font-size: 13px; margin-top: 12px;
display: none; font-weight: 500;
}
/* ===== DARK MODE ===== */
body.dark-mode { background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4c1d95 100%); }
body.dark-mode .container {
background: #16213e;
box-shadow: 0 32px 80px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05);
color: #e0e0e0;
}
body.dark-mode h1 { color: #e0e0e0; }
body.dark-mode .subtitle { color: #9ca3af; }
body.dark-mode .rating-text { color: #9ca3af; }
body.dark-mode textarea {
background: #1a1a2e; border-color: #0f3460;
color: #e0e0e0;
}
body.dark-mode textarea:focus {
border-color: #818cf8;
background: #1a1a2e;
box-shadow: 0 0 0 3px rgba(129,140,248,0.15);
}
body.dark-mode textarea::placeholder { color: #6b7280; }
body.dark-mode .erro { background: #3b1515; color: #fca5a5; }
body.dark-mode .success h2 { color: #4ade80; }
body.dark-mode .success p { color: #9ca3af; }
/* Responsivo */
@media (max-width: 480px) {
.container { padding: 32px 24px 28px; border-radius: 16px; }
h1 { font-size: 20px; }
.stars label { font-size: 40px; }
}
</style>
</head>
@@ -135,7 +220,13 @@ textarea:focus { border-color: var(--primary); }
</div>
<script>
var alias, conversaId, empresaId;
(function(){
var alias, conversaId, empresaId, nota = 0;
// Detecta dark mode
var m = localStorage.getItem('chatc2_dark_mode_manual');
var d = m !== null ? m === 'true' : window.matchMedia('(prefers-color-scheme: dark)').matches;
if (d) document.body.classList.add('dark-mode');
function getParams() {
var params = new URLSearchParams(window.location.search);
@@ -144,27 +235,45 @@ function getParams() {
empresaId = params.get('empresa');
if (!alias || !conversaId || !empresaId) {
document.getElementById('erro').textContent = 'Link inválido. Entre em contato conosco.';
document.getElementById('erro').style.display = 'block';
document.querySelector('.stars').style.display = 'none';
document.querySelector('textarea').style.display = 'none';
var erro = document.getElementById('erro');
erro.textContent = 'Link inválido. Contate o suporte.';
erro.style.display = 'block';
document.getElementById('starContainer').style.display = 'none';
document.getElementById('comentario').style.display = 'none';
document.getElementById('btnEnviar').style.display = 'none';
document.getElementById('ratingText').style.display = 'none';
}
}
var nota = 0;
document.querySelectorAll('.stars input').forEach(function(input) {
input.addEventListener('change', function() {
nota = parseInt(this.value);
var textos = ['', 'Péssimo', 'Ruim', 'Regular', 'Bom', 'Excelente!'];
var textos = ['', 'Péssimo 😞', 'Ruim 😕', 'Regular 😐', 'Bom 😊', 'Excelente! 🤩'];
document.getElementById('ratingText').textContent = textos[nota] || '';
});
});
async function enviar() {
// Verifica se ja foi avaliado
async function verificarAvaliacao() {
if (!alias || !conversaId) return;
try {
var resp = await fetch('/api/' + alias + '/csat/check?conversa=' + conversaId);
var data = await resp.json();
if (data.success && data.avaliado) {
document.getElementById('starContainer').style.display = 'none';
document.getElementById('comentario').style.display = 'none';
document.getElementById('btnEnviar').style.display = 'none';
document.getElementById('ratingText').style.display = 'none';
document.getElementById('success').style.display = 'block';
}
} catch(e) { /* ignora erro de rede */ }
}
window.enviar = async function() {
if (nota === 0) {
document.getElementById('erro').textContent = 'Selecione uma avaliação de 1 a 5 estrelas.';
document.getElementById('erro').style.display = 'block';
var erro = document.getElementById('erro');
erro.textContent = 'Selecione uma avaliação de 1 a 5 estrelas.';
erro.style.display = 'block';
return;
}
@@ -186,8 +295,8 @@ async function enviar() {
});
var data = await resp.json();
if (data.success) {
document.getElementById('app').querySelector('.stars').style.display = 'none';
document.querySelector('textarea').style.display = 'none';
document.getElementById('starContainer').style.display = 'none';
document.getElementById('comentario').style.display = 'none';
document.getElementById('btnEnviar').style.display = 'none';
document.getElementById('ratingText').style.display = 'none';
document.getElementById('success').style.display = 'block';
@@ -195,17 +304,17 @@ async function enviar() {
throw new Error(data.error || 'Erro ao enviar');
}
} catch(e) {
document.getElementById('erro').textContent = 'Erro ao enviar: ' + e.message;
document.getElementById('erro').style.display = 'block';
var erro = document.getElementById('erro');
erro.textContent = 'Erro ao enviar: ' + e.message;
erro.style.display = 'block';
btn.disabled = false;
btn.textContent = 'Enviar Avaliação';
}
}
};
getParams();
verificarAvaliacao();
})();
</script>
<!-- impeccable-live-start -->
<script src="http://localhost:8400/live.js"></script>
<!-- impeccable-live-end -->
</body>
</html>
+95 -13
View File
@@ -1,5 +1,21 @@
/* Anti-flash: aplicado antes do JS (via script inline no <head>) */
html.dark body { background: #1a1a2e; color: #e0e0e0; }
/* Override de variáveis CSS para dark mode */
body.dark-mode {
--surface: #16213e;
--surface-2: #1a1a2e;
--surface-3: #0f0f23;
--border: #0f3460;
--text-primary: #e0e0e0;
--text-secondary: #d1d5db;
--text-muted: #9ca3af;
--text-faint: #6b7280;
--primary: #818cf8;
--primary-dark: #667eea;
}
/* ===== DARK MODE - Estilos completos ===== */
html.dark-mode-pending body { visibility: hidden; }
body.dark-mode {
background: #1a1a2e;
color: #e0e0e0;
@@ -146,13 +162,13 @@ body.dark-mode ::placeholder {
/* ===== BUTTONS ===== */
body.dark-mode .btn-primary {
background: #533483;
border-color: #533483;
background: #667eea;
border-color: #667eea;
color: #fff;
}
body.dark-mode .btn-primary:hover {
background: #6a4c9c;
border-color: #6a4c9c;
background: #5a67d8;
border-color: #5a67d8;
}
body.dark-mode .btn-secondary {
background: #0f3460;
@@ -234,6 +250,7 @@ body.dark-mode .badge-primary {
/* ===== MODAL ===== */
body.dark-mode .modal,
body.dark-mode .modal-box,
body.dark-mode .modal-content,
body.dark-mode .modal-overlay > div {
background: #16213e;
@@ -989,26 +1006,91 @@ body.dark-mode .login-dark-toggle button {
}
/* Modal no dark mode */
body.dark-mode .modal {
body.dark-mode .modal,
body.dark-mode .modal-box {
background: #16213e;
border: 1px solid #0f3460;
color: #e0e0e0;
}
body.dark-mode .modal h3 { color: #e0e0e0; }
body.dark-mode .modal h3,
body.dark-mode .modal-box h3 { color: #e0e0e0; }
body.dark-mode .modal input,
body.dark-mode .modal select {
body.dark-mode .modal-box input,
body.dark-mode .modal select,
body.dark-mode .modal-box select,
body.dark-mode .modal textarea,
body.dark-mode .modal-box textarea {
background: #1a1a2e;
border-color: #0f3460;
color: #e0e0e0;
}
body.dark-mode .modal .btn-group button {
body.dark-mode .modal .btn-group button,
body.dark-mode .modal-box .btn-group button {
background: #1a1a2e;
border-color: #0f3460;
color: #e0e0e0;
color: #c0c0c0;
}
body.dark-mode .modal .btn-group .btn-primary {
background: #533483;
border-color: #533483;
/* Settings: tabs no dark mode */
body.dark-mode .tabs { background: #16213e; border-color: #0f3460; }
body.dark-mode .tabs button { background: #16213e; color: #9ca3af; }
body.dark-mode .tabs button:hover { background: #1a1a2e; color: #c0c0c0; }
body.dark-mode .tabs button.active { background: #1a2744; color: #818cf8; border-bottom-color: #818cf8; }
/* Botoes do painel direito no dark mode */
body.dark-mode [style*="background:#eef2ff"] {
background: #1e1b4b !important;
border-color: #4c1d95 !important;
color: #a78bfa !important;
}
body.dark-mode [style*="border:1px solid #c7d2fe"] {
border-color: #4c1d95 !important;
}
/* Confirm modal input no dark mode */
body.dark-mode #confirmarInput { background: #1a1a2e !important; border-color: #0f3460 !important; color: #e0e0e0 !important; }
body.dark-mode #confirmarInput:focus { border-color: #818cf8 !important; background: #1a1a2e !important; box-shadow: 0 0 0 3px rgba(129,140,248,0.15) !important; }
/* Tables no dark mode */
body.dark-mode table { color: #e0e0e0; }
body.dark-mode thead { background: #0f3460; }
body.dark-mode th { color: #9ca3af; border-color: #1a1a2e; }
body.dark-mode td { border-color: #1a1a2e; color: #d1d5db; }
body.dark-mode tr:hover td { background: #1a1a2e; }
/* Tags no dark mode */
body.dark-mode .tag {
display: inline-block; padding: 1px 8px;
border-radius: 10px; font-size: 11px; font-weight: 600;
color: #fff !important;
}
/* Flow cards e headers de seção no dark mode */
body.dark-mode [style*="background:var(--surface-2)"] {
background: #1a1a2e !important;
}
body.dark-mode [style*="background:#e0e7ff"] {
background: #312e81 !important;
color: #c4b5fd !important;
}
/* btn-secondary no dark mode */
body.dark-mode .btn-secondary {
background: #1a1a2e !important;
border-color: #0f3460 !important;
color: #d1d5db !important;
}
body.dark-mode .btn-secondary:hover {
background: #0f3460 !important;
}
/* Input focus no dark mode */
body.dark-mode input:focus,
body.dark-mode select:focus,
body.dark-mode textarea:focus {
background: #1a1a2e !important;
box-shadow: 0 0 0 3px rgba(129,140,248,0.15) !important;
}
body.dark-mode .modal .btn-group .btn-primary,
body.dark-mode .modal-box .btn-primary {
background: #667eea;
border-color: #667eea;
color: #fff;
}
+3 -3
View File
@@ -482,7 +482,7 @@ tr:last-child td { border-bottom: none; }
.modal-overlay.show { display: flex; }
.modal-box {
.modal-box, .modal {
background: var(--surface);
border-radius: var(--radius-lg);
padding: 28px;
@@ -497,14 +497,14 @@ tr:last-child td { border-bottom: none; }
to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-box h3 {
.modal-box h3, .modal h3 {
margin-bottom: 18px;
font-size: 17px;
font-weight: 700;
color: var(--text-primary);
}
.modal-footer {
.modal-footer, .modal .modal-footer {
display: flex;
gap: 8px;
justify-content: flex-end;
+10 -2
View File
@@ -37,10 +37,18 @@
.hm-cell.l3 { background:#30a14e; } .hm-cell.l4 { background:#216e39; }
.hm-months { display:flex; gap:3px; font-size:10px; color:var(--text-faint); margin-bottom:4px; height:12px; }
.hm-legend { display:flex; align-items:center; gap:4px; font-size:11px; color:var(--text-faint); margin-top:8px; justify-content:flex-end; }
body.dark-mode .hm-cell { background:#161b22; }
body.dark-mode .hm-cell { background:#1e293b; }
body.dark-mode .hm-cell.l1 { background:#0e4429; }
body.dark-mode .hm-cell.l2 { background:#006d32; }
body.dark-mode .hm-cell.l3 { background:#26a641; }
body.dark-mode .hm-cell.l4 { background:#39d353; }
body.dark-mode .stat-card { background: #16213e !important; box-shadow: none !important; }
body.dark-mode .stat-card .num { color: #e0e0e0 !important; }
body.dark-mode .stat-card .lbl { color: #c0c0c0 !important; }
body.dark-mode .section-title { color: #9ca3af !important; }
</style>
<link rel="stylesheet" href="/css/dark-mode.css">
<script>if(localStorage.getItem("chatc2_dark_mode")==="true")document.documentElement.classList.add("dark-mode-pending")</script>
<script>(function(){var m=localStorage.getItem("chatc2_dark_mode_manual");var d=m!==null?m==="true":window.matchMedia("(prefers-color-scheme: dark)").matches;if(d)document.documentElement.className="dark"})()</script>
</head>
<body>
<!-- SIDEBAR -->
+7 -18
View File
@@ -1,22 +1,14 @@
// Dark Mode Controller — Unified for all Chatc2 pages
(function() {
// Detecta preferência do sistema
var osPrefersDark = window.matchMedia('(prefers-color-scheme: dark)');
var manualOverride = localStorage.getItem('chatc2_dark_mode_manual');
// Decide tema inicial: manual > preferência OS > claro
function getInitialTheme() {
if (manualOverride !== null) return manualOverride === 'true';
return osPrefersDark.matches;
}
// Apply on load immediately (FOUC prevention)
if (getInitialTheme()) {
document.documentElement.classList.add('dark-mode-pending');
}
function applyTheme(enable, isManual) {
document.documentElement.classList.remove('dark-mode-pending');
if (document.body) {
document.body.classList.toggle('dark-mode', enable);
}
@@ -31,7 +23,7 @@
window.darkModeToggle = function() {
var isDark = localStorage.getItem('chatc2_dark_mode') === 'true';
applyTheme(!isDark, true); // toggle manual
applyTheme(!isDark, true);
};
window.darkModeApply = function(enable) { applyTheme(enable, false); };
@@ -40,19 +32,16 @@
return localStorage.getItem('chatc2_dark_mode') === 'true';
};
// Reage a mudanças no tema do sistema (só quando não há override manual)
// Reage a mudanças no SO (só sem override manual)
osPrefersDark.addEventListener('change', function(e) {
if (localStorage.getItem('chatc2_dark_mode_manual') === null) {
applyTheme(e.matches, false);
}
});
// Apply after DOM ready
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', function() {
applyTheme(getInitialTheme(), false);
});
} else {
applyTheme(getInitialTheme(), false);
}
// Aplica imediatamente (sem esperar DOMContentLoaded)
// Sincroniza html.dark (setado pelo script inline no <head>) com body.dark-mode
var htmlDark = document.documentElement.classList.contains('dark');
applyTheme(htmlDark || getInitialTheme(), false);
document.documentElement.classList.remove('dark');
})();
+1 -1
View File
@@ -196,7 +196,7 @@
}
</style>
<link rel="stylesheet" href="/css/dark-mode.css">
<script>if(localStorage.getItem("chatc2_dark_mode")==="true")document.documentElement.classList.add("dark-mode-pending")</script>
<script>(function(){var m=localStorage.getItem("chatc2_dark_mode_manual");var d=m!==null?m==="true":window.matchMedia("(prefers-color-scheme: dark)").matches;if(d)document.documentElement.className="dark"})()</script>
</head>
<body>
<div class="login-container">
+1 -1
View File
@@ -83,7 +83,7 @@ body { background:var(--surface-3); display:flex; min-height:100vh; }
.empty { text-align:center; padding:50px; color:var(--text-faint); font-size:14px; }
</style>
<link rel="stylesheet" href="/css/dark-mode.css">
<script>if(localStorage.getItem("chatc2_dark_mode")==="true")document.documentElement.classList.add("dark-mode-pending")</script>
<script>(function(){var m=localStorage.getItem("chatc2_dark_mode_manual");var d=m!==null?m==="true":window.matchMedia("(prefers-color-scheme: dark)").matches;if(d)document.documentElement.className="dark"})()</script>
</head>
<body>
<aside class="sidebar" role="navigation" aria-label="Navegação principal">
+143 -38
View File
@@ -26,8 +26,17 @@ body { background:var(--surface-3); display:flex; min-height:100vh; }
.btn { display:inline-flex; align-items:center; gap:6px; padding:10px 20px; border:none; border-radius:8px; font-size:14px; font-weight:600; cursor:pointer; transition:all .15s; }
.btn-primary { background:var(--primary); color:#fff; }
.btn-primary:hover { background:var(--primary-dark); }
.btn-secondary {
display: inline-flex; align-items: center; gap: 6px;
padding: 10px 20px; border: 1px solid var(--border);
border-radius: 8px; font-size: 14px; font-weight: 600;
cursor: pointer; transition: all .15s;
background: var(--surface); color: var(--text-secondary);
}
.btn-secondary:hover { background: var(--surface-2); border-color: #d1d5db; }
.btn-danger { background:var(--danger); color:#fff; }
.btn-danger:hover { background:var(--danger-text); }
.btn-danger:hover { background:#dc2626; }
.btn-danger:disabled { opacity:0.5; cursor:not-allowed; background:var(--danger); }
.btn-sm { padding:6px 12px; font-size:12px; border-radius:6px; }
.badge { display:inline-block; padding:2px 9px; border-radius:10px; font-size:11px; font-weight:600; }
.badge-success { background:var(--success-bg); color:var(--success-text); }
@@ -51,7 +60,7 @@ body { background:var(--surface-3); display:flex; min-height:100vh; }
}
</style>
<link rel="stylesheet" href="/css/dark-mode.css">
<script>if(localStorage.getItem("chatc2_dark_mode")==="true")document.documentElement.classList.add("dark-mode-pending")</script>
<script>(function(){var m=localStorage.getItem("chatc2_dark_mode_manual");var d=m!==null?m==="true":window.matchMedia("(prefers-color-scheme: dark)").matches;if(d)document.documentElement.className="dark"})()</script>
</head>
<body>
<aside class="sidebar" role="navigation" aria-label="Navegação principal">
@@ -169,12 +178,34 @@ body { background:var(--surface-3); display:flex; min-height:100vh; }
<!-- Modal Equipe -->
<div class="modal-overlay" id="modalEquipe">
<div class="modal" style="max-width:400px">
<div class="modal-box" style="max-width:480px">
<h3 id="modalEquipeTitle">Nova Equipe</h3>
<input type="hidden" id="editEquipeId">
<div class="form-group"><label for="equipeNome">Nome da Equipe</label><input type="text" id="equipeNome" placeholder="Ex: Atendimento"></div>
<div class="form-group"><label for="equipeOrdem">Ordem</label><input type="number" id="equipeOrdem" value="0" min="0" style="width:80px"><span style="font-size:12px;color:var(--text-faint);margin-left:8px">(menor = aparece primeiro)</span></div>
<div class="form-group"><label>Membros</label><div id="equipeMembros"></div></div>
<div class="form-group">
<label for="equipeNome">Nome da Equipe</label>
<input type="text" id="equipeNome" placeholder="Ex: Atendimento">
</div>
<div class="form-group">
<label for="equipeOrdem">Ordem</label>
<div style="display:flex;align-items:center;gap:8px">
<input type="number" id="equipeOrdem" value="0" min="0" style="width:80px">
<span style="font-size:12px;color:var(--text-faint)">Menor = aparece primeiro</span>
</div>
</div>
<div class="form-group">
<label for="equipeMensagem">Mensagem automática</label>
<textarea id="equipeMensagem" rows="2" placeholder="Mensagem enviada quando o cliente escolhe esta equipe..."></textarea>
<span style="font-size:11px;color:var(--text-faint);margin-top:4px;display:block">Opcional. Se preenchida, será enviada ao cliente após escolher esta opção.</span>
</div>
<div class="form-group">
<label for="equipeEtiqueta">Etiqueta automática</label>
<select id="equipeEtiqueta"><option value="">Nenhuma</option></select>
<span style="font-size:11px;color:var(--text-faint);margin-top:4px;display:block">Opcional. Etiqueta adicionada automaticamente à conversa.</span>
</div>
<div class="form-group">
<label>Membros</label>
<div id="equipeMembros"></div>
</div>
<div id="equipeFeedback" class="feedback-msg"></div>
<div class="modal-footer">
<button class="btn-secondary" onclick="fecharModal('modalEquipe')">Cancelar</button>
@@ -185,7 +216,7 @@ body { background:var(--surface-3); display:flex; min-height:100vh; }
<!-- Modal Etiqueta -->
<div class="modal-overlay" id="modalEtiqueta">
<div class="modal" style="max-width:400px">
<div class="modal-box" style="max-width:400px">
<h3 id="modalEtiquetaTitle">Nova Etiqueta</h3>
<input type="hidden" id="editEtiquetaId">
<div class="form-group"><label for="etiquetaNome">Nome</label><input type="text" id="etiquetaNome" placeholder="Ex: Cliente VIP"></div>
@@ -200,7 +231,7 @@ body { background:var(--surface-3); display:flex; min-height:100vh; }
<!-- Modal Menu -->
<div class="modal-overlay" id="modalMenu">
<div class="modal" style="max-width:500px">
<div class="modal-box" style="max-width:520px">
<h3 id="modalMenuTitle">Novo Submenu</h3>
<input type="hidden" id="editMenuId">
<input type="hidden" id="editMenuEquipeId">
@@ -241,7 +272,7 @@ body { background:var(--surface-3); display:flex; min-height:100vh; }
<!-- Modal Conexão -->
<div class="modal-overlay" id="modalConexao">
<div class="modal" style="max-width:500px">
<div class="modal-box" style="max-width:520px">
<h3 id="modalConexaoTitle">Nova Conexão WhatsApp</h3>
<input type="hidden" id="editConexaoId">
<div class="form-group"><label for="conNome">Nome da Instância</label><input type="text" id="conNome" placeholder="Ex: WhatsApp Comercial"></div>
@@ -311,6 +342,41 @@ window.ativarAba = function(aba, btn) {
document.getElementById('tab' + aba.charAt(0).toUpperCase() + aba.slice(1)).classList.add('active');
};
// ===== MODAL DE CONFIRMAÇÃO =====
let _confirmarCallback = null;
window.mostrarConfirmacao = function(titulo, mensagem, nomeConfirmar, callback) {
document.getElementById('confirmarTitulo').textContent = titulo;
document.getElementById('confirmarMensagem').textContent = mensagem;
document.getElementById('confirmarInput').value = '';
document.getElementById('confirmarInput').placeholder = 'Digite: ' + nomeConfirmar;
document.getElementById('btnConfirmarExclusao').disabled = true;
_confirmarCallback = callback;
_initConfirmModal();
document.getElementById('modalConfirmar').classList.add('show');
document.getElementById('confirmarInput').focus();
};
// Event listeners do modal de confirmação (inicializados após DOM pronto)
function _initConfirmModal() {
var inp = document.getElementById('confirmarInput');
if (!inp || inp._confirmInit) return;
inp._confirmInit = true;
inp.addEventListener('input', function() {
var esperado = this.placeholder.replace('Digite: ', '');
document.getElementById('btnConfirmarExclusao').disabled = this.value.trim() !== esperado;
});
inp.addEventListener('keydown', function(e) {
if (e.key === 'Enter' && !document.getElementById('btnConfirmarExclusao').disabled) {
document.getElementById('btnConfirmarExclusao').click();
}
});
document.getElementById('btnConfirmarExclusao').addEventListener('click', function() {
if (_confirmarCallback) { _confirmarCallback(); _confirmarCallback = null; }
fecharModal('modalConfirmar');
});
}
// ===== EQUIPES =====
async function carregarEquipes() {
var data = await api('/teams?empresaId=' + empresaId);
@@ -322,9 +388,10 @@ async function carregarEquipes() {
div.innerHTML = '<table><thead><tr><th>Ordem</th><th>Nome</th><th>Membros</th><th>Ações</th></tr></thead><tbody>' +
data.data.map(function(eq) {
var membros = (eq.membros || []).map(function(m) { return m.nome; }).join(', ') || '-';
var mensagemEsc = (eq.mensagem || '').replace(/\\/g,'\\\\').replace(/'/g,"\\'");
return '<tr><td>' + (eq.ordem || 0) + '</td><td><strong>' + eq.nome + '</strong></td><td>' + membros + '</td><td>' +
'<button class="btn btn-sm" onclick="editarEquipe(' + eq.id + ',' + (eq.ordem || 0) + ',\'' + eq.nome.replace(/'/g,"\\'") + '\')" style="background:var(--surface-3);margin-right:4px">✏️</button>' +
'<button class="btn btn-sm btn-danger" onclick="excluirEquipe(' + eq.id + ')">🗑️</button></td></tr>';
'<button class="btn btn-sm" onclick="editarEquipe(' + eq.id + ',' + (eq.ordem || 0) + ',\'' + eq.nome.replace(/'/g,"\\'") + '\',\'' + mensagemEsc + '\',' + (eq.etiquetaId || 'null') + ')" style="background:var(--surface-3);margin-right:4px">✏️</button>' +
'<button class="btn btn-sm btn-danger" onclick="excluirEquipe(' + eq.id + ',\'' + eq.nome.replace(/'/g,"\\'") + '\')">🗑️</button></td></tr>';
}).join('') + '</tbody></table>';
}
@@ -332,16 +399,22 @@ window.mostrarModalEquipe = function() {
document.getElementById('editEquipeId').value = '';
document.getElementById('equipeOrdem').value = 0;
document.getElementById('equipeNome').value = '';
document.getElementById('equipeMensagem').value = '';
document.getElementById('equipeEtiqueta').value = '';
document.getElementById('modalEquipeTitle').textContent = 'Nova Equipe';
carregarUsuariosCheckbox();
carregarEtiquetasDropdown();
document.getElementById('modalEquipe').classList.add('show');
};
window.editarEquipe = function(id, ordem, nome) {
window.editarEquipe = async function(id, ordem, nome, mensagem, etiquetaId) {
document.getElementById('editEquipeId').value = id;
document.getElementById('equipeOrdem').value = ordem;
document.getElementById('equipeNome').value = nome;
document.getElementById('equipeMensagem').value = mensagem || '';
document.getElementById('equipeEtiqueta').value = etiquetaId || '';
document.getElementById('modalEquipeTitle').textContent = 'Editar Equipe';
await carregarEtiquetasDropdown();
carregarUsuariosCheckbox(id);
document.getElementById('modalEquipe').classList.add('show');
};
@@ -364,27 +437,41 @@ async function carregarUsuariosCheckbox(equipeId) {
}).join('');
}
async function carregarEtiquetasDropdown() {
var sel = document.getElementById('equipeEtiqueta');
var data = await api('/labels?empresaId=' + empresaId);
sel.innerHTML = '<option value="">Nenhuma</option>';
if (data.success && data.data) {
data.data.forEach(function(l) {
sel.innerHTML += '<option value="' + l.id + '">' + l.nome + '</option>';
});
}
}
window.salvarEquipe = async function() {
var id = document.getElementById('editEquipeId').value;
var nome = document.getElementById('equipeNome').value.trim();
var ordem = parseInt(document.getElementById('equipeOrdem').value) || 0;
var membros = Array.from(document.querySelectorAll('#equipeMembros input:checked')).map(function(cb) { return parseInt(cb.value); });
var mensagem = document.getElementById('equipeMensagem').value.trim();
var etiquetaId = document.getElementById('equipeEtiqueta').value || null;
if (!nome) { mostrarFeedbackModal('equipeFeedback', 'Informe o nome da equipe', 'erro'); return; }
if (id) {
var r = await api('/teams/' + id, { method: 'PUT', body: JSON.stringify({ nome: nome, ordem: ordem, membros: membros }) });
var r = await api('/teams/' + id, { method: 'PUT', body: JSON.stringify({ nome: nome, ordem: ordem, membros: membros, mensagem: mensagem, etiquetaId: etiquetaId }) });
if (r.success) { fecharModal('modalEquipe'); carregarEquipes(); }
} else {
var r = await api('/teams', { method: 'POST', body: JSON.stringify({ nome: nome, ordem: ordem, membros: membros, empresaId: empresaId }) });
var r = await api('/teams', { method: 'POST', body: JSON.stringify({ nome: nome, ordem: ordem, membros: membros, empresaId: empresaId, mensagem: mensagem, etiquetaId: etiquetaId }) });
if (r.success) { fecharModal('modalEquipe'); carregarEquipes(); }
}
};
window.excluirEquipe = async function(id) {
if (!confirm('Excluir esta equipe?')) return;
var r = await api('/teams/' + id, { method: 'DELETE' });
if (r.success) carregarEquipes();
window.excluirEquipe = async function(id, nome) {
mostrarConfirmacao('Excluir Equipe', 'Esta ação não pode ser desfeita. Todos os submenus vinculados serão perdidos.', nome || 'equipe', async function() {
var r = await api('/teams/' + id, { method: 'DELETE' });
if (r.success) carregarEquipes();
});
};
// ===== USUÁRIOS =====
@@ -649,9 +736,10 @@ window.salvarMenu = async function() {
};
window.excluirMenu = async function(id, titulo) {
if (!confirm('Excluir o submenu "' + titulo + '" e todos os seus sub-itens?')) return;
var r = await api('/menus/' + id, { method: 'DELETE' });
if (r.success) carregarMenus();
mostrarConfirmacao('Excluir Submenu', 'O submenu "' + titulo + '" e todos os seus sub-itens serão removidos.', titulo, async function() {
var r = await api('/menus/' + id, { method: 'DELETE' });
if (r.success) carregarMenus();
});
};
// ===== ETIQUETAS =====
@@ -666,7 +754,7 @@ async function carregarEtiquetas() {
data.data.map(function(l) {
return '<tr><td><strong>' + l.nome + '</strong></td><td><span class="tag" style="background:' + l.cor + '">' + l.cor + '</span></td><td>' +
'<button class="btn btn-sm" onclick="editarEtiqueta(' + l.id + ',\'' + l.nome.replace(/'/g,"\\'") + '\',\'' + l.cor + '\')" style="background:var(--surface-3);margin-right:4px">✏️</button>' +
'<button class="btn btn-sm btn-danger" onclick="excluirEtiqueta(' + l.id + ')">🗑️</button></td></tr>';
'<button class="btn btn-sm btn-danger" onclick="excluirEtiqueta(' + l.id + ',\'' + l.nome.replace(/'/g,"\\'") + '\')">🗑️</button></td></tr>';
}).join('') + '</tbody></table>';
}
@@ -701,10 +789,11 @@ window.salvarEtiqueta = async function() {
}
};
window.excluirEtiqueta = async function(id) {
if (!confirm('Excluir esta etiqueta?')) return;
var r = await api('/labels/' + id, { method: 'DELETE' });
if (r.success) carregarEtiquetas();
window.excluirEtiqueta = async function(id, nome) {
mostrarConfirmacao('Excluir Etiqueta', 'A etiqueta será removida permanentemente.', nome, async function() {
var r = await api('/labels/' + id, { method: 'DELETE' });
if (r.success) carregarEtiquetas();
});
};
// ===== CONFIGURAÇÕES EMPRESA =====
@@ -784,7 +873,7 @@ async function carregarResolucao() {
? md.data.map(function(m) {
return '<div style="display:flex;justify-content:space-between;align-items:center;padding:6px 10px;border:1px solid var(--border);border-radius:6px;margin-bottom:4px">' +
'<span style="font-size:13px">' + escc(m.descricao) + '</span>' +
'<button class="btn btn-sm" style="color:#dc2626;background:none;border:none;cursor:pointer" onclick="removerMotivo(' + m.id + ')">🗑️</button></div>';
'<button class="btn btn-sm" style="color:#dc2626;background:none;border:none;cursor:pointer" onclick="removerMotivo(' + m.id + ',\'' + escc(m.descricao).replace(/'/g,"\\'") + '\')">🗑️</button></div>';
}).join('')
: '<p style="color:var(--text-faint);font-size:13px">Nenhum motivo cadastrado.</p>';
}
@@ -806,10 +895,11 @@ window.adicionarMotivo = async function() {
if (r.success) { inp.value = ''; carregarResolucao(); } else mostrarFeedbackResolucao(r.error || 'Erro ao adicionar motivo', 'erro');
};
window.removerMotivo = async function(id) {
if (!confirm('Remover este motivo?')) return;
var r = await api('/motivos/' + id, { method: 'DELETE' });
if (r.success) carregarResolucao(); else mostrarFeedbackResolucao(r.error || 'Erro ao remover', 'erro');
window.removerMotivo = async function(id, descricao) {
mostrarConfirmacao('Remover Motivo', 'O motivo será removido permanentemente.', descricao, async function() {
var r = await api('/motivos/' + id, { method: 'DELETE' });
if (r.success) carregarResolucao(); else mostrarFeedbackResolucao(r.error || 'Erro ao remover', 'erro');
});
};
function mostrarFeedbackResolucao(msg, tipo) {
@@ -899,13 +989,11 @@ window.editarConexao = async function(id) {
// ===== EXCLUIR CONEXÃO =====
window.excluirConexao = async function(id, nome) {
if (!confirm('Excluir a conexão "' + nome + '"?')) return;
var r = await api('/evolution/instances/' + id, { method: 'DELETE' });
if (r.success) {
carregarConexoes();
} else {
mostrarFeedbackModal('conexaoFeedback', 'Erro: ' + r.error, 'erro');
}
mostrarConfirmacao('Excluir Conexao', 'A conexao WhatsApp "' + nome + '" sera removida.', nome, async function() {
var r = await api('/evolution/instances/' + id, { method: 'DELETE' });
if (r.success) carregarConexoes();
else mostrarFeedbackModal('conexaoFeedback', 'Erro: ' + r.error, 'erro');
});
};
window.salvarConexao = async function() {
@@ -969,6 +1057,23 @@ carregarResolucao();
})();
</script>
<!-- Modal Confirmação de Exclusão -->
<div class="modal-overlay" id="modalConfirmar">
<div class="modal-box" style="max-width:420px">
<h3 id="confirmarTitulo">Confirmar exclusão</h3>
<p id="confirmarMensagem" style="font-size:14px;color:var(--text-secondary);margin-bottom:14px;line-height:1.5"></p>
<div class="form-group">
<label for="confirmarInput" style="font-size:13px;font-weight:600;color:var(--text-secondary);margin-bottom:5px">Digite o nome para confirmar:</label>
<input type="text" id="confirmarInput" placeholder="Digite exatamente o nome..." style="width:100%;padding:10px 14px;border:2px solid var(--border);border-radius:8px;font-size:14px;outline:none;background:var(--surface-2);color:var(--text-primary);transition:all .15s" onfocus="this.style.borderColor='var(--primary)';this.style.background='var(--surface)'" onblur="this.style.borderColor='var(--border)';this.style.background='var(--surface-2)'">
</div>
<div id="confirmarFeedback" class="feedback-msg"></div>
<div class="modal-footer">
<button class="btn-secondary" onclick="fecharModal('modalConfirmar')">Cancelar</button>
<button class="btn-danger" id="btnConfirmarExclusao" disabled>Excluir</button>
</div>
</div>
</div>
<script src="/js/dark-mode.js"></script>
<!-- impeccable-live-start -->
<script src="http://localhost:8400/live.js"></script>