feat: trading terminal live rates + fix spread negativo + fix USD→BRL

- Adiciona widget de cotações ao vivo (USD/BRL e EUR/BRL) com design
  estilo terminal de trading (dark theme, tipografia mono, glow effects)
- Proxy server-side /api/cotacao com cache 3s e token AwesomeAPI
- Auto-refresh a cada 3 segundos apenas quando a página está aberta
- Corrige cálculo de spread negativo: remove Math.abs() em USD→BRL
  e Math.max(0,...) no spread líquido
- Corrige seção USD→BRL que não aparecia (filtro status !== 'finalizado')
- Corrige valor_reais no fluxo USD→BRL: agora calcula valor * cotação
- Adiciona classe CSS spread-negative para destacar spreads negativos
- Bandeiras de fluxo (BR/US/EU) nos botões de compra e venda

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
root
2026-02-10 22:30:43 -05:00
parent 1ad28f54dd
commit 7ee15ad5e5
12 changed files with 1285 additions and 436 deletions

View File

@@ -4,9 +4,11 @@
*/
const { buildHeader, buildFooter, buildHead } = require('./ui-template');
function buildAdminHomeHTML(stats, admin) {
function buildAdminHomeHTML(stats, user) {
const now = new Date().toLocaleString('pt-BR');
const hoje = new Date().toLocaleDateString('pt-BR', { weekday: 'long', day: 'numeric', month: 'long' });
// Support both admin and corporate roles
const role = user.role || 'corporate';
const formatBRL = (v) => v.toLocaleString('pt-BR', { style: 'currency', currency: 'BRL' });
const formatUSD = (v) => v.toLocaleString('pt-BR', { style: 'currency', currency: 'USD' });
@@ -104,6 +106,31 @@ function buildAdminHomeHTML(stats, admin) {
}
@media (max-width: 768px) {
.kpi-grid, .charts-grid { grid-template-columns: 1fr; }
.date-banner {
flex-direction: column;
gap: 8px;
text-align: center;
padding: 14px 16px;
}
.date-banner h2 { font-size: 16px; }
.date-banner .time { font-size: 12px; }
.kpi-card { padding: 16px; }
.kpi-value { font-size: 28px; }
.kpi-label { font-size: 11px; }
.kpi-sub { font-size: 12px; }
.kpi-badge { font-size: 10px; padding: 3px 8px; }
.chart-card { padding: 16px; }
.chart-card h3 { font-size: 13px; margin-bottom: 14px; }
.chart-wrap { height: 220px; }
.detail-card { padding: 16px; }
.detail-card h3 { font-size: 13px; }
.detail-row { font-size: 12px; padding: 8px 0; }
}
@media (max-width: 480px) {
.kpi-value { font-size: 24px; }
.chart-wrap { height: 180px; }
.detail-card h3 .icon { width: 24px; height: 24px; font-size: 12px; }
.detail-row { font-size: 11px; }
}
`;
@@ -114,7 +141,7 @@ ${buildHead('Home', pageCSS, pageScripts)}
</head>
<body>
${buildHeader({ role: 'admin', userName: admin.nome, activePage: 'home' })}
${buildHeader({ role: role, userName: user.nome, activePage: 'home' })}
<div class="app-container">
<div class="date-banner">