PageSourceSearch

https://camaraaraci.ba.gov.br/assets/Estatisticas-BkrkU1pM.js

js camaraaraci.ba.gov.br collected 2026-09-25 10:20:31 UTC 6,247 bytes, 1 lines download raw bytes

1import{c as M,u as I,b as v,j as e}from"./vendor-query-CAW0R6Fd.js";import{r as y}from"./vendor-react-BIBNHc4z.js";import{bq as K,g as O,ah as z,a1 as B,c1 as Q,B as d,au as H,a2 as R,a3 as V,a4 as L,ay as U,L as C,az as G,b6 as J,aS as _,aw as W,ax as X,aE as r,q as u}from"./index-DxX8Lkqr.js";import{I as S}from"./input-CeFgxTaw.js";import{T as Y,a as Z,b as D,c as o,d as $,e as n}from"./table-DcAvJ9Te.js";import{S as ee,a as ae,b as se,c as te,d as ie}from"./select-BXEbz950.js";import{D as le,C as re,P as oe}from"./react-beautiful-dnd.esm-CCXwC5WM.js";import"./ui-radix-CMPBktV5.js";import"./utils-objBp_8x.js";import"./charts-DbJut-2U.js";const ne=[{value:"FileCheck",label:"Arquivo Check"},{value:"Users",label:"Usuários"},{value:"MessageSquare",label:"Mensagens"},{value:"TrendingUp",label:"Crescimento"},{value:"Activity",label:"Atividade"},{value:"Award",label:"Prêmio"},{value:"Gavel",label:"Martelo (Justiça)"},{value:"Scale",label:"Balança (Jurídico)"},{value:"Landmark",label:"Prédio Público"},{value:"ScrollText",label:"Documento Oficial"},{value:"FileSignature",label:"Contrato"},{value:"Handshake",label:"Parcerias"},{value:"Megaphone",label:"Comunicados"},{value:"BadgeCheck",label:"Certificados"},{value:"FileSpreadsheet",label:"Relatórios"},{value:"Building2",label:"Órgãos"}],fe=()=>{const{user:j}=K(),{toast:m}=O(),h=M(),[N,g]=y.useState(!1),[x,b]=y.useState(null),[l,c]=y.useState({titulo:"",valor:"",icone:"FileCheck"}),{data:p=[],isLoading:ce}=I({queryKey:u.estatisticas.all,queryFn:async()=>{const{data:a,error:s}=await r.from("estatisticas").select("*").order("ordem");if(s)throw s;return a}}),f=v({mutationFn:async a=>{if(x){const{error:s}=await r.from("estatisticas").update(a).eq("id",x);if(s)throw s}else{const s=p.length>0?Math.max(...p.map(i=>i.ordem)):0,{error:t}=await r.from("estatisticas").insert([{...a,ordem:s+1,created_by:j==null?void 0:j.id}]);if(t)throw t}},onSuccess:()=>{h.invalidateQueries({queryKey:u.estatisticas.all}),m({title:x?"Estatística atualizada":"Estatística criada",description:"As alterações foram salvas com sucesso."}),w()},onError:a=>{m({title:"Erro",description:"Não foi possível salvar a estatística.",variant:"destructive"}),console.error(a)}}),E=v({mutationFn:async a=>{const{error:s}=await r.from("estatisticas").delete().eq("id",a);if(s)throw s},onSuccess:()=>{h.invalidateQueries({queryKey:u.estatisticas.all}),m({title:"Estatística removida",description:"A estatística foi removida com sucesso."})}}),q=v({mutationFn:async({id:a,ativo:s})=>{const{error:t}=await r.from("estatisticas").update({ativo:s}).eq("id",a);if(t)throw t},onSuccess:()=>{h.invalidateQueries({queryKey:u.estatisticas.all})}}),T=v({mutationFn:async a=>{const s=a.map((t,i)=>({id:t.id,ordem:i+1}));for(const t of s){const{error:i}=await r.from("estatisticas").update({ordem:t.ordem}).eq("id",t.id);if(i)throw i}},onSuccess:()=>{h.invalidateQueries({queryKey:u.estatisticas.all}),m({title:"Ordem atualizada",description:"A ordem das estatísticas foi atualizada."})}}),F=a=>{if(!a.destination)return;const s=Array.from(p),[t]=s.splice(a.source.index,1);s.splice(a.destination.index,0,t),T.mutate(s)},P=a=>{b(a.id),c({titulo:a.titulo,valor:a.valor,icone:a.icone}),g(!0)},w=()=>{g(!1),b(null),c({titulo:"",valor:"",icone:"FileCheck"})},k=a=>{a.preventDefault(),f.mutate(l)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{className:"h-6 w-6"}),e.jsx("h1",{className:"text-3xl font-bold",children:"Estatísticas"})]}),e.jsxs(B,{open:N,onOpenChange:g,children:[e.jsx(Q,{asChild:!0,children:e.jsxs(d,{onClick:()=>b(null),children:[e.jsx(H,{className:"h-4 w-4 mr-2"}),"Nova Estatística"]})}),e.jsx(R,{children:e.jsxs("form",{onSubmit:k,children:[e.jsxs(V,{children:[e.jsx(L,{children:x?"Editar Estatística":"Nova Estatística"}),e.jsx(U,{children:"Configure os dados do indicador de transparência"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"titulo",children:"Título"}),e.jsx(S,{id:"titulo",value:l.titulo,onChange:a=>c({...l,titulo:a.target.value}),placeholder:"Ex: Publicações Cadastradas",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"valor",children:"Valor"}),e.jsx(S,{id:"valor",value:l.valor,onChange:a=>c({...l,valor:a.target.value}),placeholder:"Ex: 2,847 ou 89.3K",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"icone",children:"Ícone"}),e.jsxs(ee,{value:l.icone,onValueChange:a=>c({...l,icone:a}),children:[e.jsx(ae,{children:e.jsx(se,{})}),e.jsx(te,{children:ne.map(a=>e.jsx(ie,{value:a.value,children:a.label},a.value))})]})]})]}),e.jsxs(G,{children:[e.jsx(d,{type:"button",variant:"outline",onClick:w,children:"Cancelar"}),e.jsx(d,{type:"submit",disabled:f.isPending,children:f.isPending?"Salvando...":"Salvar"})]})]})})]})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Y,{children:[e.jsx(Z,{children:e.jsxs(D,{children:[e.jsx(o,{className:"w-[50px]"}),e.jsx(o,{children:"Título"}),e.jsx(o,{children:"Valor"}),e.jsx(o,{children:"Ícone"}),e.jsx(o,{className:"w-[100px]",children:"Status"}),e.jsx(o,{className:"w-[100px]",children:"Ações"})]})}),e.jsx($,{children:e.jsx(le,{onDragEnd:F,children:e.jsx(re,{droppableId:"estatisticas",children:a=>e.jsxs("tbody",{ref:a.innerRef,...a.droppableProps,children:[p.map((s,t)=>e.jsx(oe,{draggableId:s.id,index:t,children:i=>e.jsxs(D,{ref:i.innerRef,...i.draggableProps,children:[e.jsx(n,{...i.dragHandleProps,children:e.jsx(J,{className:"h-4 w-4 text-muted-foreground cursor-grab"})}),e.jsx(n,{className:"font-medium",children:s.titulo}),e.jsx(n,{children:s.valor}),e.jsx(n,{children:s.icone}),e.jsx(n,{children:e.jsx(_,{checked:s.ativo,onCheckedChange:A=>q.mutate({id:s.id,ativo:A})})}),e.jsx(n,{children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(d,{variant:"ghost",size:"icon",onClick:()=>P(s),children:e.jsx(W,{className:"h-4 w-4"})}),e.jsx(d,{variant:"ghost",size:"icon",onClick:()=>E.mutate(s.id),children:e.jsx(X,{className:"h-4 w-4"})})]})})]})},s.id)),a.placeholder]})})})})]})})]})};export{fe 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.