feat: design system unificado com template e cores CambioReal

- Cria src/ui-template.js com header, footer e estilos compartilhados
- Atualiza admin-home.js e admin-panel.js para usar template
- Atualiza dashboard.js com logo e cores CambioReal (#7600be)
- Atualiza login.html com novo branding BI-CCC
- Adiciona public/logo.png (CambioReal original)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
root
2026-02-08 13:20:05 -05:00
parent 2bf38c28c9
commit 1321b949e4
6 changed files with 390 additions and 255 deletions

View File

@@ -1,68 +1,13 @@
/**
* Admin Panel - HTML builder for agent management
* Admin Panel - HTML builder for user management
*/
const { buildHeader, buildFooter, buildHead } = require('./ui-template');
function buildAdminHTML(agentes, admin) {
const now = new Date().toLocaleString('pt-BR');
return `<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BI - CCC - CambioReal Central Command</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
<style>
:root {
--primary: #6C3FA0;
--primary-light: #8B5FBF;
--primary-dark: #4A2570;
--primary-bg: #F3EEFA;
--bg: #F0F2F5;
--card: #FFFFFF;
--text: #1A1D23;
--text-secondary: #5F6368;
--text-muted: #9AA0A6;
--border: #E8EAED;
--green: #1E8E3E;
--green-bg: #E6F4EA;
--blue: #1A73E8;
--blue-bg: #E8F0FE;
--orange: #E8710A;
--orange-bg: #FEF3E8;
--red: #D93025;
--red-bg: #FDE7E7;
--admin-accent: #2E7D32;
--admin-bg: #E8F5E9;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
background: var(--bg); color: var(--text); line-height: 1.5;
-webkit-font-smoothing: antialiased;
}
.header {
background: linear-gradient(135deg, var(--admin-accent) 0%, #1B5E20 100%);
color: white; padding: 24px 40px;
display: flex; justify-content: space-between; align-items: center;
box-shadow: 0 2px 8px rgba(27,94,32,0.3);
}
.header h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.5px; }
.header .subtitle { font-size: 13px; opacity: 0.8; margin-top: 4px; font-weight: 400; }
.header-right { display: flex; align-items: center; gap: 16px; }
.header .badge {
background: rgba(255,255,255,0.15); backdrop-filter: blur(10px);
padding: 8px 16px; border-radius: 24px; font-size: 12px; font-weight: 600;
border: 1px solid rgba(255,255,255,0.2);
}
.btn-logout {
background: rgba(255,255,255,0.15); color: white; border: 1px solid rgba(255,255,255,0.3);
padding: 8px 16px; border-radius: 8px; font-size: 12px; font-weight: 600;
cursor: pointer; text-decoration: none; font-family: inherit; transition: all 0.15s;
}
.btn-logout:hover { background: rgba(255,255,255,0.25); }
.container { padding: 28px 40px; max-width: 1200px; margin: 0 auto; }
const pageCSS = `
<style>
.toolbar {
display: flex; justify-content: space-between; align-items: center;
margin-bottom: 20px;
@@ -118,8 +63,6 @@ function buildAdminHTML(agentes, admin) {
.btn-toggle:hover { background: #FDE7D8; }
.btn-password { background: var(--primary-bg); color: var(--primary); }
.btn-password:hover { background: #E8DCFA; }
.btn-delete { background: var(--red-bg); color: var(--red); }
.btn-delete:hover { background: #FBD5D5; }
/* Modal */
.modal-overlay {
@@ -149,28 +92,17 @@ function buildAdminHTML(agentes, admin) {
color: var(--text-secondary); text-transform: uppercase;
letter-spacing: 0.3px; margin-bottom: 6px;
}
.form-group input {
.form-group input, .form-group select {
width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
border-radius: 8px; font-size: 14px; font-family: inherit;
color: var(--text); transition: all 0.15s; background: white;
}
.form-group input:focus {
outline: none; border-color: var(--admin-accent);
box-shadow: 0 0 0 3px rgba(46,125,50,0.12);
}
.form-group input:disabled {
background: #F5F5F5; color: var(--text-muted);
}
.form-group select {
width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
border-radius: 8px; font-size: 14px; font-family: inherit;
color: var(--text); transition: all 0.15s; background: white;
cursor: pointer;
}
.form-group select:focus {
.form-group select { cursor: pointer; }
.form-group input:focus, .form-group select:focus {
outline: none; border-color: var(--admin-accent);
box-shadow: 0 0 0 3px rgba(46,125,50,0.12);
}
.form-group input:disabled { background: #F5F5F5; color: var(--text-muted); }
.modal-footer {
padding: 16px 24px; border-top: 1px solid var(--border);
display: flex; justify-content: flex-end; gap: 10px;
@@ -197,31 +129,22 @@ function buildAdminHTML(agentes, admin) {
.alert.error { background: var(--red-bg); color: var(--red); }
.alert.show { display: block; }
.footer { text-align: center; padding: 20px; font-size: 12px; color: var(--text-muted); }
@media (max-width: 768px) {
.container { padding: 20px; }
.header { padding: 20px; flex-direction: column; gap: 12px; }
.header-right { width: 100%; justify-content: space-between; }
.toolbar { flex-direction: column; gap: 12px; align-items: flex-start; }
}
</style>
</style>
`;
return `<!DOCTYPE html>
<html lang="pt-BR">
<head>
${buildHead('Usuarios', pageCSS)}
</head>
<body>
<div class="header">
<div>
<h1>BI - CCC</h1>
<div class="subtitle">CambioReal Central Command</div>
</div>
<div class="header-right">
<div class="badge">Admin: ${admin.nome}</div>
<a href="/admin/dashboard" class="btn-logout" style="background:#1A73E8;margin-right:8px;">Dashboard Geral</a>
<a href="/logout" class="btn-logout">Sair</a>
</div>
</div>
${buildHeader({ role: 'admin', userName: admin.nome, activePage: 'users' })}
<div class="container">
<div class="app-container">
<div id="alertBox" class="alert"></div>
<div class="toolbar">
@@ -268,13 +191,13 @@ function buildAdminHTML(agentes, admin) {
</div>
</div>
<div class="footer">BI - CCC - CambioReal Central Command - ${now}</div>
${buildFooter()}
<!-- Create/Edit Modal -->
<div class="modal-overlay" id="agentModal">
<div class="modal">
<div class="modal-header">
<h3 id="modalTitle">Novo Agente</h3>
<h3 id="modalTitle">Novo Usuario</h3>
<button class="modal-close" onclick="closeModal('agentModal')">&times;</button>
</div>
<form id="agentForm" onsubmit="submitAgentForm(event)">
@@ -306,7 +229,7 @@ function buildAdminHTML(agentes, admin) {
</div>
<div class="modal-footer">
<button type="button" class="btn-cancel" onclick="closeModal('agentModal')">Cancelar</button>
<button type="submit" class="btn-submit" id="submitBtn">Criar Agente</button>
<button type="submit" class="btn-submit" id="submitBtn">Criar Usuario</button>
</div>
</form>
</div>
@@ -486,7 +409,7 @@ async function submitPasswordForm(e) {
async function toggleAgente(id, currentStatus) {
const action = currentStatus ? 'desativar' : 'ativar';
if (!confirm('Deseja ' + action + ' este agente?')) return;
if (!confirm('Deseja ' + action + ' este usuario?')) return;
try {
const res = await fetch('/admin/agentes/' + id, {
@@ -496,7 +419,7 @@ async function toggleAgente(id, currentStatus) {
});
const result = await res.json();
if (res.ok) {
showAlert('Agente ' + (currentStatus ? 'desativado' : 'ativado') + ' com sucesso!', 'success');
showAlert('Usuario ' + (currentStatus ? 'desativado' : 'ativado') + ' com sucesso!', 'success');
setTimeout(() => location.reload(), 1000);
} else {
showAlert(result.error || 'Erro ao alterar status', 'error');
@@ -506,20 +429,16 @@ async function toggleAgente(id, currentStatus) {
}
}
// Close modal on overlay click (not on modal content)
// Close modal on overlay click
document.querySelectorAll('.modal-overlay').forEach(overlay => {
overlay.addEventListener('click', (e) => {
if (e.target === overlay) {
overlay.classList.remove('active');
}
if (e.target === overlay) overlay.classList.remove('active');
});
});
// Prevent clicks inside modal from closing it
document.querySelectorAll('.modal').forEach(modal => {
modal.addEventListener('click', (e) => {
e.stopPropagation();
});
modal.addEventListener('click', (e) => e.stopPropagation());
});
// Close modal on Escape key