PageSourceSearch

https://sentinel-365-c9d4f.web.app/assets/AuditPage-DCKkaNH0.js

js sentinel-365-c9d4f.web.app collected 2026-10-03 12:39:12 UTC 9,864 bytes, 1 lines download raw bytes

1import{r as m,j as e}from"./react-vendor-pafHdoJx.js";import{b as v,d as h,c as n}from"./index-Db0fDLGN.js";import{d as w,t as U,c as b,F,K as I,S as O,J as $,W as q,U as P,bd as _,L as y,k as B,al as Q,aq as z,a4 as u,aL as H,o as W,a7 as G}from"./ui-vendor-DLXJn6s3.js";import"./map-vendor-Dr8zbd0c.js";import"./firebase-vendor-D3UzkAhn.js";const A=[{key:"fuel",label:"Abastecimento",icon:F,color:"text-amber-400",bg:"bg-amber-500/15"},{key:"tires",label:"Pneus",icon:I,color:"text-blue-400",bg:"bg-blue-500/15"},{key:"infractions",label:"Multas",icon:O,color:"text-red-400",bg:"bg-red-500/15"},{key:"vehicles",label:"Veículos",icon:$,color:"text-emerald-400",bg:"bg-emerald-500/15"},{key:"maintenance",label:"Manutenção",icon:q,color:"text-purple-400",bg:"bg-purple-500/15"},{key:"team",label:"Equipe",icon:P,color:"text-cyan-400",bg:"bg-cyan-500/15"},{key:"fnol",label:"Sinistros",icon:_,color:"text-orange-400",bg:"bg-orange-500/15"}],p=Object.fromEntries(A.map(r=>[r.key,r])),k={create:{label:"Criou",icon:u,color:"text-emerald-400",bg:"bg-emerald-500/10"},update:{label:"Atualizou",icon:u,color:"text-blue-400",bg:"bg-blue-500/10"},delete:{label:"Excluiu",icon:b,color:"text-red-400",bg:"bg-red-500/10"},restore:{label:"Restaurou",icon:H,color:"text-amber-400",bg:"bg-amber-500/10"},status_change:{label:"Mudou status",icon:u,color:"text-purple-400",bg:"bg-purple-500/10"},role_change:{label:"Mudou papel",icon:z,color:"text-cyan-400",bg:"bg-cyan-500/10"},deactivate:{label:"Desativou",icon:Q,color:"text-orange-400",bg:"bg-orange-500/10"},reactivate:{label:"Reativou",icon:B,color:"text-emerald-400",bg:"bg-emerald-500/10"}};function C(r){if(!r)return"—";const o=new Date(r),i=new Date().getTime()-o.getTime();return i<6e4?"Agora":i<36e5?`${Math.floor(i/6e4)} min atrás`:i<864e5?`${Math.floor(i/36e5)}h atrás`:i<1728e5?"Ontem "+o.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"}):o.toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit",year:"2-digit",hour:"2-digit",minute:"2-digit"})}function Z(){var N;const[r,o]=m.useState("log"),[l,i]=m.useState(""),[L,g]=m.useState(null),{data:c,loading:M,refetch:R}=v(m.useCallback(()=>h.auditLog(l||void 0),[l]),[l]),{data:d,loading:D,refetch:S}=v(m.useCallback(()=>h.auditTrash(),[]),[]),T=async(t,a)=>{if(confirm("Deseja restaurar este registro? Ele voltará a aparecer no módulo original.")){g(t);try{await h.auditRestore(t,a),S(),R()}catch(s){alert(s.message||"Erro ao restaurar")}finally{g(null)}}},j=(d==null?void 0:d.length)||0,f=(c==null?void 0:c.length)||0;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[e.jsx("div",{className:"p-2.5 rounded-xl bg-gradient-to-br from-brand-500/20 to-purple-500/20 border border-brand-500/20",children:e.jsx(w,{className:"w-6 h-6 text-brand-400"})}),"Auditoria"]}),e.jsx("p",{className:"text-slate-400 text-sm mt-1 ml-14",children:"Histórico completo de ações e lixeira com restauração."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"flex gap-1 bg-slate-800/60 rounded-xl p-1 border border-slate-700/50",children:[e.jsxs("button",{onClick:()=>o("log"),className:n("px-4 py-2 rounded-lg text-sm font-medium transition-all flex items-center gap-2",r==="log"?"bg-slate-700/80 text-white shadow-sm":"text-slate-400 hover:text-slate-200"),children:[e.jsx(U,{className:"w-4 h-4"}),"Atividades",f>0&&e.jsx("span",{className:"bg-brand-500/20 text-brand-300 px-1.5 py-0.5 rounded-full text-xs font-medium",children:f})]}),e.jsxs("button",{onClick:()=>o("trash"),className:n("px-4 py-2 rounded-lg text-sm font-medium transition-all flex items-center gap-2",r==="trash"?"bg-slate-700/80 text-white shadow-sm":"text-slate-400 hover:text-slate-200"),children:[e.jsx(b,{className:"w-4 h-4"}),"Lixeira",j>0&&e.jsx("span",{className:"bg-red-500/20 text-red-300 px-1.5 py-0.5 rounded-full text-xs font-medium",children:j})]})]}),r==="log"&&e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx("button",{onClick:()=>i(""),className:n("px-3 py-1.5 rounded-lg text-xs font-medium transition-all border",l?"bg-slate-800/50 border-slate-700/50 text-slate-400 hover:text-white hover:border-slate-600":"bg-brand-500/15 border-brand-500/30 text-brand-300"),children:"Todos"}),A.map(t=>{const a=t.icon,s=l===t.key;return e.jsxs("button",{onClick:()=>i(s?"":t.key),className:n("px-3 py-1.5 rounded-lg text-xs font-medium transition-all border flex items-center gap-1.5",s?`${t.bg} border-current ${t.color}`:"bg-slate-800/50 border-slate-700/50 text-slate-400 hover:text-white hover:border-slate-600"),children:[e.jsx(a,{className:"w-3 h-3"}),t.label]},t.key)})]})]}),r==="log"&&e.jsx("div",{children:M?e.jsxs("div",{className:"flex items-center justify-center py-20",children:[e.jsx(y,{className:"w-6 h-6 text-brand-400 animate-spin"}),e.jsx("span",{className:"ml-3 text-slate-400 text-sm",children:"Carregando log..."})]}):!c||c.length===0?e.jsxs("div",{className:"card p-16 text-center",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-2xl bg-slate-800 border border-slate-700/50 mb-4",children:e.jsx(w,{className:"w-8 h-8 text-slate-500"})}),e.jsx("h3",{className:"text-white font-semibold mb-1",children:"Nenhuma atividade registrada"}),e.jsx("p",{className:"text-slate-500 text-sm max-w-md mx-auto",children:l?`Nenhuma ação de ${((N=p[l])==null?void 0:N.label)||l} foi registrada ainda.`:"Quando você criar, editar ou excluir registros, as ações aparecerão aqui automaticamente."})]}):e.jsx("div",{className:"card overflow-hidden border border-slate-700/50",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-slate-700/50",children:[e.jsx("th",{className:"text-left text-xs font-medium uppercase  tracking-wider px-4 py-3",children:"Ação"}),e.jsx("th",{className:"text-left text-xs font-medium uppercase  tracking-wider px-4 py-3",children:"Descrição"}),e.jsx("th",{className:"text-left text-xs font-medium uppercase  tracking-wider px-4 py-3 hidden md:table-cell",children:"Módulo"}),e.jsx("th",{className:"text-left text-xs font-medium uppercase  tracking-wider px-4 py-3 hidden lg:table-cell",children:"Usuário"}),e.jsx("th",{className:"text-right text-xs font-medium uppercase  tracking-wider px-4 py-3",children:"Quando"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-800/80",children:c.map(t=>{const a=k[t.action]||k.update,s=p[t.module],x=a.icon,E=(s==null?void 0:s.icon)||u;return e.jsxs("tr",{className:"hover:bg-slate-800/30 transition-colors",children:[e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:n("inline-flex items-center gap-1.5 px-2 py-1 rounded-md text-xs font-medium",a.bg,a.color),children:[e.jsx(x,{className:"w-3 h-3"}),a.label]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("p",{className:"text-sm text-white truncate max-w-xs",children:t.summary})}),e.jsx("td",{className:"px-4 py-3 hidden md:table-cell",children:e.jsxs("div",{className:n("inline-flex items-center gap-1.5 text-xs",(s==null?void 0:s.color)||"text-slate-400"),children:[e.jsx(E,{className:"w-3.5 h-3.5"}),(s==null?void 0:s.label)||t.module]})}),e.jsx("td",{className:"px-4 py-3 hidden lg:table-cell",children:e.jsx("span",{className:"text-xs",style:{color:"var(--page-text-secondary)"},children:t.userName})}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsx("span",{className:"text-xs text-slate-500 
1whitespace-nowrap",children:C(t.timestamp)})})]},t.id)})})]})})}),r==="trash"&&e.jsx("div",{children:D?e.jsxs("div",{className:"flex items-center justify-center py-20",children:[e.jsx(y,{className:"w-6 h-6 text-red-400 animate-spin"}),e.jsx("span",{className:"ml-3 text-slate-400 text-sm",children:"Carregando lixeira..."})]}):!d||d.length===0?e.jsxs("div",{className:"card p-16 text-center",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-2xl bg-slate-800 border border-slate-700/50 mb-4",children:e.jsx(b,{className:"w-8 h-8 text-slate-500"})}),e.jsx("h3",{className:"text-white font-semibold mb-1",children:"Lixeira vazia"}),e.jsx("p",{className:"text-slate-500 text-sm max-w-md mx-auto",children:"Quando registros forem excluídos, eles aparecerão aqui para restauração. Dados ficam disponíveis por 90 dias."})]}):e.jsx("div",{className:"space-y-2",children:d.map(t=>{const a=p[t.module],s=(a==null?void 0:a.icon)||u,x=L===t.id;return e.jsxs("div",{className:"card px-4 py-3 flex items-center gap-4 border border-slate-700/50 hover:border-slate-600/50 transition-colors",children:[e.jsx("div",{className:"p-2 rounded-xl bg-red-500/10 border border-red-500/15",children:e.jsx(b,{className:"w-4 h-4 text-red-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-white truncate",children:t.summary}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsxs("span",{className:n("inline-flex items-center gap-1 text-xs",(a==null?void 0:a.color)||"text-slate-400"),children:[e.jsx(s,{className:"w-3 h-3"}),(a==null?void 0:a.label)||t.module]}),e.jsx("span",{className:"text-slate-600",children:"·"}),e.jsxs("span",{className:"text-xs text-slate-500 flex items-center gap-1",children:[e.jsx(W,{className:"w-3 h-3"}),C(t.deletedAt)]})]})]}),e.jsxs("button",{onClick:()=>T(t.id,t.module),disabled:x,className:n("flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium transition-all border",x?"bg-slate-800 border-slate-700 text-slate-500 cursor-wait":"bg-emerald-500/10 border-emerald-500/20 text-emerald-400 hover:bg-emerald-500/20 hover:border-emerald-500/40"),children:[e.jsx(G,{className:n("w-3.5 h-3.5",x&&"animate-spin")}),x?"Restaurando...":"Restaurar"]})]},t.id)})})})]})}export{Z as AuditPage};

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.