/* App root — Portal Maximiano */ const { useState:aS, useEffect:aE } = React; const PAGE_META={ dashboard:{title:'Dashboard Executivo',crumb:'Visão geral consolidada'}, feed:{title:'Comunicação Interna',crumb:'Canais & comunicados'}, faturamento:{title:'Faturamento Individual',crumb:'Meu desempenho'}, juridico:{title:'Jurídico em Foco',crumb:'Novidades jurídicas'}, gestao:{title:'Gestão',crumb:'Usuários & unidades'}, config:{title:'Configurações',crumb:'Sistema'}, }; const ALLOWED={ ceo:['dashboard','feed','faturamento','juridico','gestao','config'], admin:['dashboard','feed','faturamento','juridico','gestao','config'], gestor:['dashboard','feed','faturamento','juridico','gestao'], adv:['feed','faturamento','juridico'], }; function Toast({msg}){ if(!msg) return null; return (
{msg}
); } function App(){ const [profileId,setProfileId]=aS(()=>localStorage.getItem('mx_profile')||null); const [page,setPage]=aS(()=>localStorage.getItem('mx_page')||'dashboard'); const [toast,setToast]=aS(null); const [sbOpen,setSbOpen]=aS(false); const profile = profileId? MX.perfis.find(p=>p.id===profileId) : null; aE(()=>{ if(profileId) localStorage.setItem('mx_profile',profileId); },[profileId]); aE(()=>{ localStorage.setItem('mx_page',page); },[page]); const showToast=(m)=>{ setToast(m); clearTimeout(window.__tt); window.__tt=setTimeout(()=>setToast(null),2800); }; const nav=(p)=>{ setPage(p); setSbOpen(false); }; const login=(pid)=>{ const allowed=ALLOWED[pid]; setProfileId(pid); setPage(allowed.includes(page)?page:allowed[0]); }; const switchProfile=(pid)=>{ const allowed=ALLOWED[pid]; setProfileId(pid); if(!allowed.includes(page)) setPage(allowed[0]); showToast('Perfil alterado para '+MX.perfis.find(p=>p.id===pid).papel.split('·')[0].trim()+'.'); }; const logout=()=>{ setProfileId(null); localStorage.removeItem('mx_profile'); setSbOpen(false); }; if(!profile) return ; const allowed=ALLOWED[profileId]; const meta=PAGE_META[page]||PAGE_META.dashboard; let view; if(page==='dashboard') view=; else if(page==='feed') view=; else if(page==='faturamento') view=; else if(page==='juridico') view=; else if(page==='gestao') view=; else if(page==='config') view=; return (
setSbOpen(false)}/>
setSbOpen(true)}/>
{view}
); } ReactDOM.createRoot(document.getElementById('root')).render();