PageSourceSearch

https://mgw-service-desk.lovable.app/assets/_authenticated.admin.volumetria-CsC-dd2a.js

js mgw-service-desk.lovable.app collected 2026-10-03 03:35:18 UTC 3,615 bytes, 1 lines download raw bytes

1import{q as C,a0 as N,v as _,a1 as v,s as M,e as k,g as T,r as m,j as e,w as y,z as p,x as q,y as A,D as S,E as B,F as h,G as d,H as P,J as u}from"./index-26Acqbp3.js";import{S as b}from"./skeleton-DN2pgy0G.js";const I=v({type:"function"}).client(async({next:r})=>{if(typeof window>"u")return r();const{data:t}=await M.auth.getSession(),n=t.session?.access_token;return n?r({headers:{Authorization:`Bearer ${n}`}}):r()}),L=C({method:"POST"}).middleware([I]).middleware([N]).handler(_("ac59cbdf9af153ec39b8a487e5ead17258143fc8e4d9fe64670456fbf77382b2")),R=[{key:"cad_clientes",label:"Empresa + Filial",type:"qty"},{key:"cad_clientes_proj",label:"Clientes Cadastrados",type:"qty"},{key:"cad_usuarios",label:"Usuários",type:"qty"},{key:"api_calls",label:"Consumo de API (chamadas)",type:"qty"},{key:"storage_bytes",label:"Consumo de Storage",type:"bytes"}],E="2026-05";function F(r){const t=r.replace(/^api:/,"").replace(/_/g," ").trim();return t?t.toLowerCase()==="cnpja"?"API — CNPJA":t.toLowerCase()==="brasilapi"?"API — BrasilAPI":t.toLowerCase()==="receitaws"?"API — ReceitaWS":`API — ${t.replace(/\b\w/g,n=>n.toUpperCase())}`:"API — Geral"}function f(r){return(r??0).toLocaleString("pt-BR")}function x(r){if(!r)return"0 B";const t=["B","KB","MB","GB","TB"];let n=0,o=r;for(;o>=1024&&n<t.length-1;)o/=1024,n++;return`${o.toFixed(o>=100?0:o>=10?1:2)} ${t[n]}`}function $(r){const[t,n]=r.split("-");return`${n}/${t.slice(2)}`}function G(){const r=k(L),{data:t,isLoading:n}=T({queryKey:["admin-volumetria","my-tenant",12],queryFn:()=>r({data:{months:12}}),refetchOnMount:"always"}),o=m.useMemo(()=>{const s=new Map;for(const a of t?.rows??[]){const c=a.period_month.slice(0,7);s.has(a.metric_key)||s.set(a.metric_key,new Map);const l=s.get(a.metric_key),i=l.get(c)??{qty:0,bytes:0};l.set(c,{qty:i.qty+Number(a.qty),bytes:i.bytes+Number(a.bytes)})}return s},[t]),w=m.useMemo(()=>{const s=Array.from(new Set((t?.rows??[]).map(a=>a.metric_key).filter(a=>a.startsWith("api:")))).sort().map(a=>({key:a,label:F(a),type:"qty"}));return R.flatMap(a=>a.key==="api_calls"?[a,...s]:[a])},[t]);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-eyebrow",children:"Configurações"}),e.jsx("h1",{className:"text-h1 mt-1",children:"Volumetria da Minha Empresa"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Consolidado dos últimos 12 meses para a Empresa/Tenant à qual você tem acesso."})]}),n&&e.jsx(y,{children:e.jsxs(p,{className:"p-6 space-y-3",children:[e.jsx(b,{className:"h-6 w-1/3"}),e.jsx(b,{className:"h-40 w-full"})]})}),!n&&e.jsxs(y,{children:[e.jsx(q,{children:e.jsx(A,{children:t?.tenant?.name??"—"})}),e.jsx(p,{className:"overflow-x-auto",children:e.jsxs(S,{children:[e.jsx(B,{children:e.jsxs(h,{children:[e.jsx(d,{className:"min-w-[260px]",children:"Métrica"}),(t?.months??[]).map(s=>e.jsx(d,{className:"text-right whitespace-nowrap",children:$(s)},s)),e.jsx(d,{className:"text-right font-semibold",children:"Total"})]})}),e.jsx(P,{children:w.map(s=>{const a=(t?.months??[]).map(l=>{const i=o.get(s.key)?.get(l),j=s.type==="bytes"?i?.bytes??0:i?.qty??0,g=s.key==="storage_bytes"&&l<E?0:j;return{ym:l,value:g}}),c=s.key.startsWith("cad_")?a.at(-1)?.value??0:a.reduce((l,i)=>l+i.value,0);return e.jsxs(h,{children:[e.jsx(u,{className:"font-medium",children:s.label}),a.map(l=>e.jsx(u,{className:"text-right tabular-nums",children:s.type==="bytes"?x(l.value):f(l.value)},l.ym)),e.jsx(u,{className:"text-right tabular-nums font-semibold",children:s.type==="bytes"?x(c):f(c)})]},s.key)})})]})})]})]})}export{G as component};

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.