PageSourceSearch

https://radreport.com.br/assets/AuditTab-CJvPPIor.js

js radreport.com.br collected 2026-10-02 01:22:28 UTC 4,206 bytes, 2 lines download raw bytes

1import{u as w,j as e}from"./vendor-query-CmFN4-M1.js";import{av as r,aG as i,aS as c,aD as v,aE as D,aF as L,p as j,at as T,aR as C,ab as _,c as E,b as R,X as S}from"./index-BZSaBQD0.js";import{T as H,a as A,b as u,c as n,d as M,e as d}from"./table-BEgIk-tI.js";import{r as B,aa as k,s as F,D as P,bP as U}from"./vendor-ui-DjI1iuvA.js";import"./vendor-react-7PyNDetJ.js";import"./vendor-supabase-BfoV2C50.js";const K=()=>{var h;const p=async()=>{try{const{data:s,count:l,error:o}=await R.from("auditoria_log").select("id, timestamp, acao, tabela_nome, usuario_id, registro_id",{count:"exact"}).order("timestamp",{ascending:!1}).limit(50);if(o)throw o;return{logs:s||[],totalLogs:l??0}}catch(s){throw S.error("Error fetching logs:",s),s}},{data:x={logs:[],totalLogs:0},isLoading:g}=w({queryKey:["admin-settings-audit"],queryFn:p,staleTime:6e4,refetchOnWindowFocus:!1}),t=x.logs,f=x.totalLogs,b=()=>{const s=["Data/Hora","Ação","Tabela","Registro ID","Usuário ID"],l=t.map(a=>[c(new Date(a.timestamp),"dd/MM/yyyy HH:mm:ss"),a.acao,a.tabela_nome,a.registro_id,a.usuario_id||"Sistema"]),o=[s.join(","),...l.map(a=>a.join(","))].join(`
2`),N=new Blob([o],{type:"text/csv;charset=utf-8;"}),y=URL.createObjectURL(N),m=document.createElement("a");m.href=y,m.download=`audit_log_${c(new Date,"yyyy-MM-dd")}.csv`,m.click(),E.success("Logs exportados com sucesso")};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(r,{children:e.jsxs(i,{className:"p-4 text-center",children:[e.jsx(B,{className:"h-8 w-8 mx-auto mb-2 text-green-500"}),e.jsx("div",{className:"text-lg font-semibold text-green-500",children:"LGPD Compliance"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Dados protegidos"})]})}),e.jsx(r,{children:e.jsxs(i,{className:"p-4 text-center",children:[e.jsx(k,{className:"h-8 w-8 mx-auto mb-2 text-primary"}),e.jsx("div",{className:"text-lg font-semibold",children:(h=t[0])!=null&&h.timestamp?c(new Date(t[0].timestamp),"dd/MM/yyyy"):"—"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Última verificação"})]})}),e.jsx(r,{children:e.jsxs(i,{className:"p-4 text-center",children:[e.jsx(F,{className:"h-8 w-8 mx-auto mb-2 text-primary"}),e.jsx("div",{className:"text-lg font-semibold",children:f.toLocaleString("pt-BR")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Logs registrados"})]})})]}),e.jsxs(r,{children:[e.jsx(v,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(D,{children:"Logs de Auditoria"}),e.jsx(L,{children:"Últimas 50 ações registradas"})]}),e.jsxs(j,{variant:"outline",size:"sm",onClick:b,children:[e.jsx(P,{className:"h-4 w-4 mr-2"}),"Exportar CSV"]})]})}),e.jsx(i,{children:g?e.jsx("div",{className:"space-y-2",children:[1,2,3,4,5].map(s=>e.jsx(T,{className:"h-12"},s))}):t.length>0?e.jsx(C,{className:"h-[400px]",children:e.jsxs(H,{children:[e.jsx(A,{children:e.jsxs(u,{children:[e.jsx(n,{children:"Data/Hora"}),e.jsx(n,{children:"Ação"}),e.jsx(n,{children:"Tabela"}),e.jsx(n,{children:"Registro"})]})}),e.jsx(M,{children:t.map(s=>e.jsxs(u,{children:[e.jsx(d,{className:"font-mono text-xs",children:c(new Date(s.timestamp),"dd/MM HH:mm")}),e.jsx(d,{children:e.jsx(_,{variant:s.acao==="INSERT"?"default":s.acao==="UPDATE"?"secondary":s.acao==="DELETE"?"destructive":"outline",children:s.acao})}),e.jsx(d,{className:"font-mono text-xs",children:s.tabela_nome}),e.jsxs(d,{className:"font-mono text-xs truncate max-w-[100px]",children:[s.registro_id.slice(0,8),"..."]})]},s.id))})]})}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Nenhum log de auditoria encontrado"})})]}),e.jsx(r,{className:"bg-muted/50",children:e.jsx(i,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(U,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Política de Retenção: ",e.jsx("strong",{children:"12 meses"})]})]}),e.jsx(j,{variant:"outline",size:"sm",disabled:!0,children:"Limpar Logs Antigos"})]})})})]})};export{K 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.