1import{r as m,j as e}from"./react-vendor-pafHdoJx.js";import{b as h,d as g,c as j}from"./index-Db0fDLGN.js";import b from"./FinanceiroPage-COYS9LDe.js";import v from"./AcertoPage-CVmIMLuu.js";import N from"./DREPage-89bZ7mTW.js";import{ContratosAgregadosPage as y}from"./ExtrattaPages-DFiYn7hQ.js";import{bk as w,n as p,l as C,a6 as A,f as k,p as f,a2 as u,a3 as T,aM as F}from"./ui-vendor-DLXJn6s3.js";import"./map-vendor-Dr8zbd0c.js";import"./firebase-vendor-D3UzkAhn.js";import"./ErrorState-B9i6eo2M.js";import"./EntityList-DHyuL9ql.js";import"./ObjectDrawer-DyT69DrE.js";import"./NumeroComBase-CssBMGes.js";import"./primitives-DOiVg4wH.js";import"./errors-SShhAJmM.js";function B(){const{data:t}=h(()=>g.extrattaConfig(),[]),{data:o,loading:a}=h(()=>g.extrattaListarCiots(),[]),l=m.useMemo(()=>{const r=(o==null?void 0:o.ciots)||[],i=new Date,n=new Date(i.getFullYear(),i.getMonth(),1),c=r.filter(s=>s.dataDeclaracao?new Date(s.dataDeclaracao)>=n:!1);return{total:r.length,totalMes:c.length,padrao:c.filter(s=>s.tipoCiot==="padrao").length,tacAgregado:c.filter(s=>s.tipoCiot==="tac_agregado").length,contingencia:r.filter(s=>s.emContingencia).length,fiscalizados:r.filter(s=>s.consultadoPelaFiscalizacao).length,cancelados:r.filter(s=>s.cancelado).length}},[o]);return t!=null&&t.configured?a?null:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--page-text)"},children:"Saúde da emissão de CIOT"}),e.jsx("p",{className:"text-sm",style:{color:"var(--page-text-muted)"},children:"Métricas consolidadas dos últimos CIOTs emitidos"})]})}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsx(d,{icon:w,iconColor:"#10B981",label:"CIOTs no mês",value:l.totalMes,hint:`${l.padrao} Padrão · ${l.tacAgregado} TAC Agregado`}),e.jsx(d,{icon:p,iconColor:"#3B82F6",label:"Total histórico",value:l.total,hint:"CIOTs já emitidos"}),e.jsx(d,{icon:C,iconColor:l.contingencia>0?"#F59E0B":"#6B7280",label:"Em contingência",value:l.contingencia,hint:l.contingencia>0?"ANTT operando fallback":"Tudo normal"}),e.jsx(d,{icon:A,iconColor:"#8B5CF6",label:"Fiscalizados",value:l.fiscalizados,hint:"Consultados pela ANTT"})]})]}):e.jsx("div",{className:"rounded-xl p-6 text-sm",style:{background:"var(--surface-secondary)",color:"var(--page-text-muted)"},children:"Emissão automática de CIOT ainda não habilitada. Peça ao administrador da plataforma para habilitar em Admin â Integrações."})}function d({icon:t,iconColor:o,label:a,value:l,hint:r}){return e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(t,{className:"w-4 h-4",style:{color:o}}),e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:"var(--page-text-muted)"},children:a})]}),e.jsx("p",{className:"text-2xl font-bold",style:{color:"var(--page-text)"},children:l}),r&&e.jsx("p",{className:"text-xs mt-1",style:{color:"var(--page-text-muted)"},children:r})]})}function x(t){return new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL"}).format(t)}const R=[{key:"resumo",label:"Resumo",icon:k},{key:"contas",label:"Contas",icon:f},{key:"acerto",label:"Acerto de Frete",icon:u},{key:"resultado",label:"Resultado",icon:p},{key:"agregados",label:"Contratos Agregados",icon:f}];function q(){const[t,o]=m.useState("resumo"),[a,l]=m.useState(null);m.useEffect(()=>{g.dashboard().then(l).catch(()=>{})},[]);const r=(a==null?void 0:a.faturamentoMes)||0,i=(a==null?void 0:a.aReceber)||(a==null?void 0:a.receivable)||0,n=(a==null?void 0:a.aPagar)||(a==null?void 0:a.payable)||0,c=r-n;return e.jsxs("div",{className:"max-w-7xl",children:[e.jsx("div",{className:"flex items-center justify-between mb-4",children:e.jsx("h1",{className:"text-2xl font-bold",style:{color:"var(--page-text)"},children:"Dinheiro"})}),e.jsx("div",{className:"flex gap-1 mb-6 overflow-x-auto pb-1 scrollbar-hide",children:R.map(s=>e.jsxs("button",{onClick:()=>o(s.key),className:j("flex items-center gap-1.5 px-4 py-2 rounded-lg text-sm font-medium whitespace-nowrap transition-colors",t===s.key?"shadow-sm":"hover-surface"),style:t===s.key?{background:"var(--accent-brand)",color:"#ffffff"}:{color:"var(--page-text-secondary)"},children:[e.jsx(s.icon,{className:"w-4 h-4"}),s.label]},s.key))}),t==="resumo"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-emerald-500/15 flex items-center justify-center",children:e.jsx(T,{className:"w-4 h-4 text-emerald-400"})}),e.jsx("span",{className:"text-xs",style:{color:"var(--page-text-muted)"},children:"Faturado (mês)"})]}),e.jsx("p",{className:"text-xl font-bold",style:{color:"var(--page-text)"},children:x(r)})]}),e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-blue-500/15 flex items-center justify-center",children:e.jsx(u,{className:"w-4 h-4 text-blue-400"})}),e.jsx("span",{className:"text-xs",style:{color:"var(--page-text-muted)"},children:"A receber"})]}),e.jsx("p",{className:"text-xl font-bold",style:{color:"var(--page-text)"},children:x(i)})]}),e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-red-500/15 flex items-center justify-center",children:e.jsx(F,{className:"w-4 h-4 text-red-400"})}),e.jsx("span",{className:"text-xs",style:{color:"var(--page-text-muted)"},children:"A pagar"})]}),e.jsx("p",{className:"text-xl font-bold",style:{color:"var(--page-text)"},children:x(n)})]}),e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-violet-500/15 flex items-center justify-center",children:e.jsx(p,{className:"w-4 h-4 text-violet-400"})}),e.jsx("span",{className:"text-xs",style:{color:"var(--page-text-muted)"},children:"Resultado"})]}),e.jsx("p",{className:"text-xl font-bold",style:{color:c>=0?"#10B981":"#EF4444"},children:x(c)})]})]}),e.jsx(B,{})]}),t==="contas"&&e.jsx(b,{}),t==="acerto"&&e.jsx(v,{}),t==="resultado"&&e.jsx(N,{}),t==="agregados"&&e.jsx(y,{})]})}
1export{q as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.