/* Dashboard — Hexis-driven KPIs · Charts · Micro-Apps · Games · E-Wallet */
const { useState: useStateD, useEffect: useEffectD, useRef: useRefD, useMemo: useMemoD } = React;
/* ── LINE CHART ─────────────────────────────────────────────── */
const LineChart = ({ series, labels, height = 320, formatY = v => v }) => {
const [tip, setTip] = useStateD(null);
const [muted, setMuted] = useStateD({});
const W = 800, H = height, padL = 44, padR = 12, padT = 10, padB = 28;
const innerW = W - padL - padR, innerH = H - padT - padB;
const allV = series.flatMap(s => muted[s.id] ? [] : s.data);
const max = Math.max(...allV, 1), min = 0;
const xFor = i => padL + (i / (labels.length - 1)) * innerW;
const yFor = v => padT + innerH - ((v - min) / (max - min)) * innerH;
const yTicks = [0, 0.25, 0.5, 0.75, 1].map(t => min + (max - min) * t);
const onMove = (e) => {
const rect = e.currentTarget.getBoundingClientRect();
const x = ((e.clientX - rect.left) / rect.width) * W;
const i = Math.round(((x - padL) / innerW) * (labels.length - 1));
if (i < 0 || i >= labels.length) { setTip(null); return; }
setTip({ i, x: padL + (i / (labels.length - 1)) * innerW });
};
return (
setTip(null)}>
{tip && (
{labels[tip.i]}
{series.filter(s => !muted[s.id]).map(s => (
{s.label}
{formatY(s.data[tip.i])}
))}
)}
{series.map(s => (
{ SoundFX.tap(); setMuted(m => ({ ...m, [s.id]: !m[s.id] })); }}>
{s.label}
))}
);
};
/* ── DONUT CHART ────────────────────────────────────────────── */
const DonutChart = ({ data, total }) => {
const R = 70, C = Math.PI * 2 * R;
let acc = 0;
return (
{data.map((d, i) => (
{d.name}
{d.value}
))}
);
};
/* ── KPI CARD ───────────────────────────────────────────────── */
const KPI = ({ lab, v, delta, deltaDir = 'up', icon, spark, sparkColor = '#A78BFA', label, onClick }) => (
{v} {delta && {deltaDir === 'down' ? '−' : '+'}{delta}}
{label}
);
/* ── MICRO APPS DATA ────────────────────────────────────────── */
const MICRO_APPS_DATA = [
{ id: 'DB', layer: 'green', name: 'Central Database', sub: 'PostgreSQL + pgvector', stat: '38K', meta: 'Perfis indexados', fill: 88 },
{ id: 'CP', layer: 'green', name: 'Cadastro Participantes', sub: 'LinkedIn OAuth · <30s', stat: '2,840', meta: 'Leads capturados', fill: 74 },
{ id: 'SK', layer: 'green', name: 'Stakeholders B2B', sub: 'Validação por Hexis AI', stat: '38', meta: 'Decisores ativos', fill: 62 },
{ id: 'BI', layer: 'green', name: 'Briefing Inteligente', sub: 'Diagnóstico Condicional', stat: '14', meta: 'Briefings em curso', fill: 55 },
{ id: 'CI', layer: 'blue', name: 'Check-in & Agenda', sub: 'QR Code · NFC · BLE', stat: '1,247', meta: 'Check-ins hoje', fill: 91 },
{ id: 'SF', layer: 'blue', name: 'Smart Forms & NPS', sub: 'Adaptive Logic', stat: '94%', meta: 'NPS score atual', fill: 94 },
{ id: 'QG', layer: 'blue', name: 'Quizzes & Gamification',sub: 'Knowledge Arena™', stat: '320', meta: 'Participantes ativos', fill: 67 },
{ id: 'NO', layer: 'blue', name: 'Notificações Omnicanal',sub: 'WhatsApp · Push · SMS', stat: '3 New', meta: 'Nudges pendentes', fill: 48 },
{ id: 'MQ', layer: 'purple',name: 'Matchmaking Engine', sub: 'Match Quest™ · pgvector',stat: '94%', meta: 'Match Score médio', fill: 94 },
{ id: 'AR', layer: 'purple',name: 'Analytics & Relatórios',sub: 'D3-BMC · Real-time', stat: '€1.82M', meta: 'Pipeline calculado', fill: 82 },
{ id: 'RM', layer: 'purple',name: 'Gestão de Recursos', sub: 'YOLO v8 · Ocupação', stat: '78%', meta: 'Capacidade utilizada', fill: 78 },
{ id: 'SN', layer: 'purple',name: 'Smart Notes AI', sub: 'Auto-classificação Hexis',stat: '14', meta: 'Notas geradas hoje', fill: 70 },
];
const LAYER_META = {
green: { label: '🟢 Camada Core — Capture Nodes', desc: 'Ingestão e captura de dados comportamentais', color: '#00C48C', cls: 'sn' },
blue: { label: '🔵 Camada Operacional — Execution Nodes', desc: 'Ação física e controlo de fluxo', color: '#00D1FF', cls: '' },
purple: { label: '🟣 Camada Inteligência — Decision Interfaces', desc: 'Motor de decisão e insight preditivo', color: '#7B61FF', cls: 'np' },
};
const MicroAppsLayered = ({ onOpen }) => (
{['green', 'blue', 'purple'].map(lid => {
const lm = LAYER_META[lid];
return (
{MICRO_APPS_DATA.filter(a => a.layer === lid).map(a => (
{ SoundFX.tap(); if (window.HexisEngine) HexisEngine.trackClick(`microapp_${a.id}`); onOpen(a); }}>
))}
);
})}
);
/* ── GAMIFICATION PANEL ─────────────────────────────────────── */
const GamificationPanel = ({ profile }) => {
const lp = window.HexisEngine ? HexisEngine.getLevelProgress() : { level: 7, tier: 'diamond', xp: 2340, pct: 68, xpToNext: 320 };
const achievements = [
{ ic: 'crown', nm: 'Match Master', pts: '+250', earned: profile?.badges?.includes('Match Master') },
{ ic: 'flame', nm: 'Streak 7d', pts: '+120', earned: profile?.badges?.includes('Streak 7d') },
{ ic: 'trophy', nm: 'Top Connector', pts: '+500', earned: profile?.badges?.includes('Top Connector') },
{ ic: 'medal', nm: 'Premium Match', pts: '+180', earned: profile?.badges?.includes('Premium Match') },
{ ic: 'lock', nm: 'Closer Tier', pts: '+1000', locked: true },
];
return (
Operativo · Tier {lp.tier?.toUpperCase()}
{profile?.name || 'Carolina Sá'}
{lp.xpToNext} XP até Level {lp.level + 1} · {lp.nextTier}
{(profile?.xp || 2340).toLocaleString()}
XP Acumulado
{profile?.streak || 7}d 🔥
Streak Atual
{achievements.map((a, i) => (
{ if (!a.locked && window.HexisEngine) { SoundFX.tap(); HexisEngine.awardXP(5, `Badge: ${a.nm}`); } }}>
{a.nm}
{a.pts}
))}
);
};
/* ── KNOWLEDGE ARENA™ — Interactive Quiz ───────────────────── */
const KnowledgeArenaPanel = () => {
const [cur, setCur] = useStateD(0);
const [answered, setAnswered] = useStateD(null);
const [score, setScore] = useStateD(0);
const [done, setDone] = useStateD(false);
const QUIZ = [
{ q: 'Qual a percentagem de pipeline atribuível a eventos B2B vs. cold outreach na Marcianus?', opts: ['12%', '34%', '54%', '78%'], correct: 2, xp: 40, explain: 'Eventos B2B geram 3.4× mais pipeline que cold outreach (Marcianus Data, 2025).' },
{ q: 'O Hexis AI usa qual modelo de embeddings como camada base (always-on)?', opts: ['GPT-4 Embeddings', 'nomic-embed-text · 274MB', 'Claude Haiku', 'BERT-large'], correct: 1, xp: 50, explain: 'nomic-embed-text (274MB) é always-on. Mistral 4.5GB é o modelo principal on-demand.' },
{ q: 'Qual o limiar de MIS para injeção automática no CRM (Hot Lead via Tap 3)?', opts: ['MIS > 0.65', 'MIS > 0.75', 'MIS > 0.85', 'MIS > 0.95'], correct: 2, xp: 60, explain: 'Tap3 = Hot Lead. MIS > 0.85 → CRM injection automática via EventOS Kafka.' },
{ q: 'Na fórmula DecisionScore, qual variável tem o maior peso (0.30)?', opts: ['Context', 'Behavioral Gain', 'Relevance', 'Timing'], correct: 2, xp: 50, explain: 'Relevance tem peso 0.30 — é o factor dominante na decisão do Hexis AI.' },
];
const q = QUIZ[cur];
const handle = (i) => {
if (answered !== null) return;
setAnswered(i);
if (i === q.correct) {
setScore(s => s + q.xp);
SoundFX.success();
if (window.HexisEngine) HexisEngine.awardXP(q.xp, 'Knowledge Arena™');
ToastBus.push({ kind: 'gold', icon: 'zap', title: `+${q.xp} XP · Correto!`, desc: q.explain, duration: 4000 });
} else {
SoundFX.tap();
ToastBus.push({ icon: 'x', title: 'Incorreto', desc: q.explain, duration: 4000 });
}
};
const next = () => { if (cur + 1 < QUIZ.length) { setCur(c => c + 1); setAnswered(null); } else { setDone(true); if (window.HexisEngine) HexisEngine.completeMission('ka_001', score >= 2 ? true : false); } };
const reset = () => { setCur(0); setAnswered(null); setScore(0); setDone(false); };
if (done) return (
🏆
Knowledge Arena™ · Resultado Final
Quiz Completo
+{score} XP
{score >= 150 ? 'Pontuação máxima — Insight Leader desbloqueado!' : `${Math.round((score / 200) * 100)}% de precisão`}
);
return (
Knowledge Arena™
Fintech & B2B Intelligence · Quiz
+{score} XP
{cur + 1} / {QUIZ.length}
{q.q}
{q.opts.map((opt, i) => {
let bg = 'rgba(255,255,255,0.04)', border = 'var(--border-1)', col = 'var(--text-1)';
if (answered !== null) {
if (i === q.correct) { bg = 'rgba(0,196,140,0.14)'; border = '#00C48C80'; col = '#00C48C'; }
else if (i === answered) { bg = 'rgba(255,59,92,0.10)'; border = '#FF3B5C80'; col = '#FF3B5C'; }
}
return (
);
})}
{answered !== null && (
)}
);
};
/* ── NETWORK DOMINATION™ ────────────────────────────────────── */
const NetworkDominationPanel = ({ profile }) => {
const LEADERS = [
{ rank: 1, ini: 'MT', nm: 'Miguel Tavares', co: 'Veridian VC', score: 2840, delta: '+240', badge: 'Top Connector' },
{ rank: 2, ini: 'CS', nm: profile?.name?.split(' ').slice(0,2).join(' ') || 'Carolina Sá', co: profile?.company || 'Veridian VC', score: profile?.xp || 2340, delta: '+120', badge: 'Deal Maker', isMe: true },
{ rank: 3, ini: 'AC', nm: 'Ana Cardoso', co: 'Solaris Energy', score: 1980, delta: '+80', badge: 'Insight Leader' },
{ rank: 4, ini: 'RS', nm: 'Rita Sousa', co: 'Banco Invicta', score: 1720, delta: '+60' },
{ rank: 5, ini: 'JR', nm: 'João Reis', co: 'Helix Bio', score: 1540, delta: '+45' },
{ rank: 6, ini: 'PM', nm: 'Pedro Machado', co: 'Aether RE', score: 1380, delta: '+30' },
].sort((a, b) => b.score - a.score).map((l, i) => ({ ...l, rank: i + 1 }));
const medals = ['🥇', '🥈', '🥉'];
return (
Network Domination™
Leaderboard · Veridian Tech Summit
Live
{LEADERS.map(l => (
{ SoundFX.tap(); ToastBus.push({ icon: 'users', title: l.nm, desc: `${l.co} · ${l.score.toLocaleString()} XP` }); }}>
{medals[l.rank - 1] || l.rank}
{l.ini}
{l.nm} {l.isMe && (você)}
{l.co}{l.badge && {l.badge}}
{l.score.toLocaleString()}
{l.delta} XP
))}
);
};
/* ── MISSION ENGINE™ ────────────────────────────────────────── */
const MissionEnginePanel = () => {
const [active, setActive] = useStateD(null);
const missions = window.HexisEngine ? HexisEngine.getActiveMissions() : [];
const accept = (m) => {
SoundFX.success();
if (window.HexisEngine) {
HexisEngine.acceptMission(m.id);
setTimeout(() => HexisEngine.completeMission(m.id, true), m.timeLimit * 1000 * 0.1);
}
};
return (
{missions.length === 0 && (
✓
Todas as missões foram completadas! Hexis lança novas em breve.
)}
{missions.map(m => {
const pct = Math.round((m.elapsed / m.timeLimit) * 100);
const isActive = m.status === 'active';
return (
{ SoundFX.tap(); setActive(active === m.id ? null : m.id); }}>
{m.game}
Ativa · Hexis AI
{m.title}
{active === m.id &&
{m.desc}
}
+{m.reward.xp} XP
);
})}
);
};
/* ── HEXIS CONSOLE ──────────────────────────────────────────── */
const HexisConsolePanel = ({ profile }) => {
const [activeLayer, setActiveLayer] = useStateD(null);
const [cpu, setCpu] = useStateD(42);
const [lat, setLat] = useStateD(87);
useEffectD(() => {
const t = setInterval(() => {
setCpu(c => Math.max(18, Math.min(88, c + (Math.random() * 8 - 4))));
setLat(l => Math.max(35, Math.min(260, l + (Math.random() * 18 - 9))));
}, 3500);
return () => clearInterval(t);
}, []);
const cpuWarn = cpu > 80, latWarn = lat > 200;
const mis = profile?.misScore?.toFixed(3) || '0.720';
const ds = window.HexisEngine ? HexisEngine.getDecisionScore().toFixed(3) : '0.720';
const PVA7 = [
{ id: 'L1', nm: 'Perfil Base', desc: 'Dados estruturados · Cargo · Sector · Empresa', w: 35, color: '#7B61FF', ok: true },
{ id: 'L2', nm: 'Comportamento', desc: 'MIS · Dwell · NFC Taps · Session Frequency', w: 25, color: '#A78BFA', ok: true },
{ id: 'L3', nm: 'Grafo Social', desc: 'Conexões · Graus de separação · Proximidade', w: 15, color: '#00D1FF', ok: true },
{ id: 'L4', nm: 'Histórico', desc: 'Eventos passados · Outcomes · Pipeline', w: 10, color: '#00C48C', ok: true },
{ id: 'L5', nm: 'Contexto', desc: 'Momento · Localização · Agenda · Spatial', w: 8, color: '#FFD700', ok: true },
{ id: 'L6', nm: 'Semântica NLP', desc: 'Intents · Tópicos · Sentimento · Keywords', w: 4, color: '#FF7849', ok: true },
{ id: 'L7', nm: 'Web Fallback', desc: 'Firecrawl · <10% uso · último recurso', w: 3, color: '#FF3B5C', ok: false },
];
const ROUTING = [
{ step: 1, nm: 'Redis Cache', desc: 'Decisão cached — custo ~0', time: '<2ms', hit: true },
{ step: 2, nm: 'Regras Determinísticas', desc: 'Rule engine hard-coded — sem LLM', time: '~5ms', hit: true },
{ step: 3, nm: 'pgvector Cosine Sim.', desc: 'Similaridade vetorial · nomic', time: '~40ms', hit: false },
{ step: 4, nm: 'Mistral 4.5GB', desc: 'LLM principal · último recurso', time: '~200ms', hit: false },
];
return (
{[
{ lab: 'CPU', v: `${Math.round(cpu)}%`, warn: cpuWarn, note: cpuWarn ? 'AI desativada local' : 'Normal', ic: 'cpu' },
{ lab: 'Latência', v: `${Math.round(lat)}ms`, warn: latWarn, note: latWarn ? 'Cache forçado' : 'Normal', ic: 'zap' },
{ lab: 'MIS Score', v: mis, warn: false, note: parseFloat(mis) > 0.85 ? 'Hot Lead' : 'Warm', ic: 'target' },
{ lab: 'Decision', v: ds, warn: false, note: 'DecisionScore atual', ic: 'sparkles' },
].map((m, i) => (
))}
RAG · PVA-7
Pipeline de Recuperação Aumentada
Online
{PVA7.map(l => (
{ SoundFX.tap(); setActiveLayer(activeLayer === l.id ? null : l.id); }}>
{l.id}
{l.nm}
{l.ok ? 'Ativo' : 'Standby'}
{activeLayer === l.id &&
{l.desc}
}
))}
Cost-First Routing
Hierarquia de Decisão
{ROUTING.map((r, i) => (
{r.step}
{r.time}
{r.hit &&
HIT}
))}
Hexis Decision Engine
Fórmulas de Pontuação
DecisionScore = {ds}
0.30 × Relevance + 0.20 × Context
+ 0.20 × Behavioral_Gain + 0.15 × Graph_Proximity + 0.15 × Timing
MIS = {mis}
(Tap_Intensity × Tap_Weight) + Normalized_Dwell + Session_Freq + (Semantic × Recency)
{parseFloat(mis) > 0.85 ? '✓ Hot Lead — CRM Injection elegível via Tap 3' : parseFloat(mis) > 0.70 ? '⚠ Warm Lead — continua a aumentar engajamento' : '· Cold — aumenta tapCount e dwell time'}
);
};
/* ── E-WALLET DASHBOARD PANEL ───────────────────────────────── */
const DashWallet = ({ profile }) => {
const [walletTab, setWalletTab] = useStateD('overview');
const [topupAmt, setTopupAmt] = useStateD('');
const [sendAmt, setSendAmt] = useStateD('');
const [sendTo, setSendTo] = useStateD('');
const [sending, setSending] = useStateD(false);
const balance = profile?.walletBalance ?? 2400;
const txs = profile?.walletTransactions ?? [];
const doTopup = (amt) => {
const n = parseInt(amt, 10);
if (!n || n <= 0) return;
if (window.HexisEngine) HexisEngine.walletTopUp(n);
setTopupAmt('');
SoundFX.success();
ToastBus.push({ kind: 'success', icon: 'credit-card', title: `+€${n} adicionados`, desc: 'Saldo atualizado na E-Wallet Marcianus.' });
};
const doSend = () => {
const n = parseFloat(sendAmt);
if (!n || n <= 0 || !sendTo) return;
if (n > balance) { ToastBus.push({ icon: 'alert-circle', title: 'Saldo insuficiente', desc: `Disponível: €${balance.toLocaleString()}` }); return; }
setSending(true);
setTimeout(() => {
if (window.HexisEngine) HexisEngine.walletSpend(`Transferência para ${sendTo}`, n);
setSending(false); setSendAmt(''); setSendTo('');
SoundFX.success();
ToastBus.push({ kind: 'success', icon: 'send', title: `€${n} enviados`, desc: `Para ${sendTo} · processado em <5s` });
}, 1200);
};
return (
{/* Balance card */}
Saldo disponível · Marcianus E-Wallet
€{balance.toLocaleString('pt-PT')}
{profile?.name || 'Carolina Sá'} · {profile?.company || 'Veridian VC'}
{[
{ label: 'Enviar', icon: 'send', action: () => setWalletTab('send') },
{ label: 'Receber', icon: 'download', action: () => { SoundFX.tap(); ToastBus.push({ icon: 'qr-code', title: 'QR Code gerado', desc: 'Partilha para receber pagamentos.' }); } },
{ label: 'Recarregar', icon: 'plus', action: () => setWalletTab('topup') },
{ label: 'Histórico', icon: 'clock', action: () => setWalletTab('history') },
].map(a => (
))}
{/* Stats */}
{[
{ lab: 'Cashback', v: `€${txs.filter(t => t.type === 'credit').reduce((a, t) => a + t.amount, 0).toLocaleString()}`, ic: 'zap', color: '#00C48C' },
{ lab: 'Volume 30d', v: `€${Math.abs(txs.slice(0,4).reduce((a, t) => a + t.amount, 0)).toLocaleString()}`, ic: 'chart-line', color: '#7B61FF' },
{ lab: 'Comissões', v: `€${txs.filter(t => t.label.includes('afiliado') || t.label.includes('Cashback')).reduce((a, t) => a + t.amount, 0).toLocaleString()}`, ic: 'share', color: '#FFD700' },
].map((s, i) => (
))}
{/* Tabs */}
{[['overview', 'Visão geral'], ['history', 'Histórico'], ['topup', 'Recarregar'], ['send', 'Enviar']].map(([id, label]) => (
))}
{/* Tab content */}
{walletTab === 'overview' && (
Transações recentes
{txs.slice(0, 5).map(t => (
{t.amount > 0 ? '+' : ''}€{Math.abs(t.amount).toLocaleString()}
))}
)}
{walletTab === 'history' && (
Todas as transações
{txs.map(t => (
{t.amount > 0 ? '+' : ''}€{Math.abs(t.amount).toLocaleString()}
))}
)}
{walletTab === 'topup' && (
Recarregar E-Wallet
Valores instantâneos. Sem taxas adicionais.
{[100, 250, 500, 1000].map(v => (
))}
setTopupAmt(e.target.value.replace(/\D/g, ''))} placeholder="Outro valor (€)" style={{ flex: 1, padding: '12px 16px', borderRadius: 10, background: 'rgba(255,255,255,0.04)', border: '1px solid var(--border-1)', color: '#fff', fontSize: 14, fontFamily: 'var(--font-body)' }} />
)}
{walletTab === 'send' && (
Enviar fundos
Transferência interna P2P entre membros Marcianus.
setSendTo(e.target.value)} placeholder="Email ou nome do destinatário" style={{ padding: '12px 16px', borderRadius: 10, background: 'rgba(255,255,255,0.04)', border: '1px solid var(--border-1)', color: '#fff', fontSize: 14, fontFamily: 'var(--font-body)' }} />
setSendAmt(e.target.value.replace(/[^\d.]/g, ''))} placeholder={`Valor (disponível: €${balance.toLocaleString()})`} style={{ padding: '12px 16px', borderRadius: 10, background: 'rgba(255,255,255,0.04)', border: '1px solid var(--border-1)', color: '#fff', fontSize: 14, fontFamily: 'var(--font-body)' }} />
)}
);
};
/* ── SMART NOTES ────────────────────────────────────────────── */
const SmartNotes = ({ profile }) => {
const [newNote, setNewNote] = useStateD('');
const [notes, setNotes] = useStateD([
{ who: 'Miguel Tavares · Veridian', when: '14:32', body: 'Interesse forte em ESG-linked debt. Mencionou roadshow em junho.', tags: ['Hot', 'ESG'] },
{ who: 'Rita Sousa · Banco Invicta', when: '14:18', body: 'CFO procura bridge de €2M para Q3. Pedir intro ao Pedro.', tags: ['Pipeline', 'Bridge'] },
{ who: 'Ana Cardoso · Solaris', when: '13:55', body: 'Decisora final em RFP solar — janela 3 semanas.', tags: ['Decision', 'Solar'] },
{ who: 'João Reis · Helix Bio', when: '13:40', body: 'Interesse em parceria PT-EU para clinical trials.', tags: ['Partner'] },
]);
const addNote = () => {
if (!newNote.trim()) return;
const now = new Date().toLocaleTimeString('pt-PT', { hour: '2-digit', minute: '2-digit' });
setNotes(prev => [{ who: profile?.name || 'Eu', when: now, body: newNote.trim(), tags: ['Novo'] }, ...prev]);
setNewNote('');
if (window.HexisEngine) HexisEngine.awardXP(10, 'Smart Note adicionada');
SoundFX.success();
};
return (
setNewNote(e.target.value)} onKeyDown={e => e.key === 'Enter' && addNote()} placeholder="Nova nota rápida… (Enter para guardar)" style={{ flex: 1, padding: '10px 14px', borderRadius: 10, background: 'rgba(255,255,255,0.04)', border: '1px solid var(--border-1)', color: '#fff', fontSize: 13, fontFamily: 'var(--font-body)' }} />
{notes.map((n, i) => (
{ SoundFX.tap(); ToastBus.push({ icon: 'sticky-note', title: n.who, desc: n.body }); }}>
{n.who}{n.when}
{n.body}
{n.tags.map(t => {t})}
))}
);
};
/* ── STAKEHOLDERS ───────────────────────────────────────────── */
const Stakeholders = ({ onNav }) => {
const list = [
{ ini: 'MT', nm: 'Miguel Tavares', role: 'Veridian VC · Partner', score: 98, action: () => { SoundFX.success(); if (window.HexisEngine) HexisEngine.awardXP(20, 'Contacto stakeholder'); ToastBus.push({ kind: 'success', icon: 'users', title: 'Intro enviada', desc: 'Miguel Tavares notificado. Match 98% confirmado.' }); } },
{ ini: 'RS', nm: 'Rita Sousa', role: 'Banco Invicta · CFO', score: 94, action: () => { SoundFX.tap(); ToastBus.push({ icon: 'calendar', title: 'Reunião confirmada', desc: 'Rita Sousa · Hoje 16:00 · Banco Invicta' }); } },
{ ini: 'AC', nm: 'Ana Cardoso', role: 'Solaris Energy · CEO', score: 91, action: () => { SoundFX.tap(); ToastBus.push({ icon: 'send', title: 'Follow-up enviado', desc: 'Ana Cardoso · RFP solar · Resposta em 24h' }); } },
{ ini: 'JR', nm: 'João Reis', role: 'Helix Bio · CSO', score: 88, action: () => { SoundFX.tap(); ToastBus.push({ icon: 'users', title: 'Perfil aberto', desc: 'João Reis · Interesse em clinical trials PT-EU' }); } },
{ ini: 'PM', nm: 'Pedro Machado', role: 'Aether RE · Director', score: 86, action: () => { SoundFX.tap(); ToastBus.push({ icon: 'users', title: 'Perfil aberto', desc: 'Pedro Machado · Real Estate · Pipeline €5.4M' }); } },
];
return (
{list.map((s, i) => (
))}
);
};
/* ── DASHBOARD PAGE ─────────────────────────────────────────── */
const DashboardPage = ({ onNav }) => {
const [section, setSection] = useStateD('overview');
const [period, setPeriod] = useStateD('30d');
const [chartMode, setChartMode] = useStateD('pipeline');
const [profile, setProfile] = useStateD(window.HexisEngine ? HexisEngine.getProfile() : {});
/* Subscribe to HexisEngine profile changes */
useEffectD(() => {
if (!window.HexisEngine) return;
return HexisEngine.subscribe(p => setProfile({ ...p }));
}, []);
/* Get Hexis-driven metrics */
const metrics = useMemoD(() => {
if (window.HexisEngine) return HexisEngine.getMetrics(period);
return { pipeline: 1820000, matchScore: 94, meetings: 186, connections: 186, conversion: 31.4, spark_pipeline: [0.8,1,1.2,1.4,1.6,1.7,1.8,1.82], spark_match: [80,84,88,92,94,94,94,94], spark_meetings: [40,65,90,118,145,160,175,186], spark_conversion: [18,21,24,26,28,29.5,30.8,31.4], series_pipeline: { '7d': [[], []], '30d': [[340,580,1100,1820],[42,78,124,186]], '90d': [[1200,2100,4100],[120,220,380]], '1y': [[3200,5800,8400,12400],[320,520,780,1120]] }, series_match: { '7d': [[], []], '30d': [[80,86,90,94],[12,18,28,42]], '90d': [[78,84,92],[38,52,88]], '1y': [[76,82,88,94],[80,140,220,320]] }, labels: { '7d': ['L','M','T','Q','S','S','D'], '30d': ['S1','S2','S3','S4'], '90d': ['Jan','Fev','Mar'], '1y': ['Q1','Q2','Q3','Q4'] } };
}, [period, profile.xp]);
const pip_series = metrics.series_pipeline[period] || metrics.series_pipeline['30d'];
const mch_series = metrics.series_match[period] || metrics.series_match['30d'];
const chart_labels = metrics.labels[period];
const pipeline_data = [
{ id: 'pp', label: 'Pipeline (€K)', color: '#7B61FF', data: pip_series[0] || [] },
{ id: 'mt', label: 'Meetings', color: '#00D1FF', data: pip_series[1] || [] },
];
const match_data = [
{ id: 'av', label: 'Match avg', color: '#A78BFA', data: mch_series[0] || [] },
{ id: 'pr', label: 'Premium', color: '#FFD700', data: mch_series[1] || [] },
];
const sections = [
{ id: 'overview', l: 'Visão Geral', ic: 'layout-dashboard' },
{ id: 'events', l: 'Eventos', ic: 'calendar', n: 6 },
{ id: 'pipeline', l: 'Pipeline', ic: 'chart-line', n: 12 },
{ id: 'connections', l: 'Conexões', ic: 'users' },
{ id: 'gamification', l: 'Gamification', ic: 'trophy' },
{ id: 'missions', l: 'Missões Ativas', ic: 'target', n: (window.HexisEngine ? HexisEngine.getActiveMissions().length : 4) },
{ id: 'wallet', l: 'E-Wallet', ic: 'credit-card' },
{ id: 'micro-apps', l: 'Micro-Apps', ic: 'grid' },
{ id: 'hexis', l: 'Hexis Console', ic: 'cpu' },
{ id: 'notes', l: 'Smart Notes', ic: 'sticky-note', n: 14 },
{ id: 'reports', l: 'Relatórios', ic: 'newspaper' },
];
const exportData = () => {
const data = JSON.stringify({ profile, metrics: HexisEngine?.getMetrics('30d'), exported_at: new Date().toISOString() }, null, 2);
const blob = new Blob([data], { type: 'application/json' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url; a.download = `marcianus_report_${Date.now()}.json`; a.click();
URL.revokeObjectURL(url);
ToastBus.push({ kind: 'success', icon: 'download', title: 'Relatório exportado', desc: 'JSON com métricas Hexis AI completas.' });
if (window.HexisEngine) HexisEngine.awardXP(5, 'Relatório exportado');
};
const renderSection = () => {
if (section === 'wallet') return (
Financeiro · Marcianus
E-Wallet
);
if (section === 'missions') return (
Behavioral Engine · Live
Missões Ativas · 6 Game Types
);
if (section === 'micro-apps') return (
Sistema Marcianus™
12 Micro-Apps · 3 Camadas Sistémicas
Fluxo: Micro-Apps → EventOS → BD Central → Hexis AI → D3-BMC
{ if (window.HexisEngine) HexisEngine.awardXP(8, `Micro-App: ${a.id}`); ToastBus.push({ kind: a.layer === 'purple' ? 'gold' : '', icon: 'sparkles', title: `${a.id} · ${a.name}`, desc: `${a.sub} · Módulo aberto.` }); }} />
);
if (section === 'hexis') return (
Hexis AI · Comando Central
Consola de Inteligência
Online · 24/7PVA-7
);
if (section === 'gamification') return (
Behavioral Design B2B
Gamification · XP · Ranking
);
if (section === 'notes') return (
Hexis Smart Notes
Notas · AI Auto-classificadas
);
if (section === 'reports') return (
Relatórios · D3-BMC
Analytics & Exportação
{[
{ title: 'Pipeline por Sector', icon: 'chart-bar', desc: 'Breakdown de €' + (metrics.pipeline / 1000).toFixed(0) + 'K por vertical', action: () => { SoundFX.tap(); ToastBus.push({ icon: 'chart-bar', title: 'Relatório Pipeline', desc: 'Exportando dados por sector...' }); exportData(); } },
{ title: 'Match Score Evolution', icon: 'target', desc: `Score ${metrics.matchScore}% · Evolução 90d`, action: () => { SoundFX.tap(); setSection('overview'); setChartMode('match'); } },
{ title: 'ROI por Evento', icon: 'chart-line', desc: '3.4× vs. networking tradicional', action: () => { SoundFX.tap(); ToastBus.push({ icon: 'chart-line', title: 'ROI Report', desc: '3.4× ROI confirmado em 318 eventos.' }); } },
{ title: 'Behavioral Intelligence', icon: 'cpu', desc: `MIS ${(profile.misScore || 0.72).toFixed(3)} · ${profile.tapCount || 42} taps registados`, action: () => { SoundFX.tap(); setSection('hexis'); } },
].map((r, i) => (
))}
);
/* overview (default) */
return (
<>
€K>} delta={`${metrics.pipeline > 1820000 ? '+' : ''}${Math.round((metrics.pipeline / 1820000 - 1) * 100) || 38}%`} icon="chart-line" spark={metrics.spark_pipeline} sparkColor="#7B61FF" label="Receita atribuída a eventos" onClick={() => { SoundFX.tap(); setChartMode('pipeline'); }} />
%>} delta={metrics.matchScore - 88} icon="target" spark={metrics.spark_match} sparkColor="#A78BFA" label="Média ponderada Hexis AI" onClick={() => { SoundFX.tap(); setChartMode('match'); }} />
} delta={Math.round(metrics.meetings * 0.22)} icon="users" spark={metrics.spark_meetings} sparkColor="#00D1FF" label="Agendadas no período" onClick={() => { SoundFX.tap(); setSection('connections'); }} />
%>} delta={metrics.conversion - 22} icon="zap" spark={metrics.spark_conversion} sparkColor="#FFD700" label="Conexão → Reunião" onClick={() => { SoundFX.tap(); setSection('pipeline'); }} />
Performance Temporal
Hexis AI · Dados calculados em tempo real · clica nas legendas para isolar
Sectores
{['Banca', 'Tech', 'Saúde', 'Energia', 'Real Estate'].map(s => (
{ SoundFX.tap(); ToastBus.push({ icon: 'filter', title: `Filtro: ${s}`, desc: 'Dados filtrados por sector.' }); }}>{s} ×
))}
{ SoundFX.tap(); ToastBus.push({ icon: 'plus', title: 'Adicionar sector', desc: 'Funcionalidade em breve.' }); }}> Adicionar
chartMode === 'pipeline' ? (v >= 1000 ? (v / 1000).toFixed(1) + 'M' : v + 'K') : v}
/>
Smart Notes em direto
Auto-classificadas pela Hexis
Distribuição por sector
Conexões registadas hoje
{/* Missions preview */}
Behavioral Engine · Live
Missões ativas agora
{(window.HexisEngine ? HexisEngine.getActiveMissions() : []).slice(0, 3).map((m, i) => (
{ SoundFX.tap(); HexisEngine.acceptMission(m.id); setSection('missions'); }}>
))}
Micro-apps · 12 módulos · 3 camadas
Ferramentas operacionais
{ if (window.HexisEngine) HexisEngine.awardXP(8, `App: ${a.id}`); ToastBus.push({ kind: a.layer === 'purple' ? 'gold' : '', icon: 'sparkles', title: `${a.id} · ${a.name}`, desc: `${a.sub}` }); }} />
Stakeholders prioritários
Top decisores por Match Score · clica para acionar
Próximas ações · Hexis AI
Ações sugeridas com base em comportamento
{[
{ ic: 'send', t: 'Enviar follow-up à Ana Cardoso', s: 'RFP aberto há 11 dias · janela curta', cta: 'Enviar', xp: 30 },
{ ic: 'calendar', t: 'Confirmar reunião com Rita Sousa', s: 'Hoje · 16:00 · CFO Banco Invicta', cta: 'Confirmar', xp: 20 },
{ ic: 'users', t: 'Intro Miguel Tavares ↔ João Reis', s: 'Match 96% · ESG ↔ Health-tech', cta: 'Apresentar', xp: 50 },
{ ic: 'rocket', t: 'Lançar campanha pós-evento', s: 'Drip 5 emails · ' + (metrics.meetings) + ' contactos', cta: 'Ativar', xp: 15 },
].map((a, i) => (
))}
>
);
};
return (
{/* STICKY SIDEBAR */}
Hub Operacional
Live · Veridian Tech Summit · Lisboa · MIS {(profile.misScore || 0.72).toFixed(3)}
{['7d', '30d', '90d', '1y'].map(p => (
))}
{renderSection()}
);
};
window.DashboardPage = DashboardPage;