1import{r,G as _,j as e,al as w,B as h,aa as A}from"./index-Bx5zKZla.js";import{I as o}from"./input-HfBP5UWT.js";import{S as k,a as C,b as I,d as E,e as F}from"./select-D5k-GzJ7.js";import{S as P}from"./skeleton-C_gz9L-M.js";import{S as T}from"./search-C0Dxc_zm.js";import"./index-B-Hrw_6V.js";import"./Combination-DOJZjW34.js";import"./index-Dp3b-ot_.js";import"./index-D7VZJbUs.js";import"./chevron-down-Cudi7XHl.js";import"./check-Da0Q540f.js";const $=["all","user.suspended","user.restored","user.deleted","user.content_deleted","user.password_reset_triggered","user.verification_resent","user.subscription_cancel_requested","user.plan_updated","user.note_added","user.tags_updated","item.capture_retried","item.deleted","item.marked_for_investigation","item.content_viewed","feedback.status_updated","users.export_csv"];function Q(){const[n,g]=r.useState(""),[c,j]=r.useState("all"),[m,f]=r.useState(""),[i,v]=r.useState(""),[l,N]=r.useState(""),[d,a]=r.useState(1),u=r.useMemo(()=>({search:n.trim()||void 0,actionName:c,adminEmail
1:m.trim()||void 0,from:i?new Date(i).toISOString():void 0,to:l?new Date(`${l}T23:59:59`).toISOString():void 0,page:d,pageSize:50}),[n,c,m,i,l,d]),{data:s,isLoading:b,error:x,isFetching:y}=_({queryKey:["admin","audit",u],queryFn:()=>A("audit.list",u),placeholderData:t=>t}),p=Math.max(1,Math.ceil(((s==null?void 0:s.total)||0)/50));return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold tracking-tight sm:text-2xl",children:"Audit log"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Immutable record of admin actions."})]}),e.jsxs("div",{className:"grid gap-2 rounded-xl border border-border/60 bg-background p-3 md:grid-cols-2 xl:grid-cols-5",children:[e.jsxs("div",{className:"relative xl:col-span-2",children:[e.jsx(T,{className:"absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx(o,{value:n,onChange:t=>{a(1),g(t.target.value)},placeholder:"Search action, admin, or target",className:"h-8 pl-8 text-sm"})]}),e.jsxs(k,{value:c,onValueChange:t=>{a(1),j(t)},children:[e.jsx(C,{className:"h-8 text-xs",children:e.jsx(I,{placeholder:"Action"})}),e.jsx(E,{children:$.map(t=>e.jsx(F,{value:t,children:t==="all"?"All actions":t},t))})]}),e.jsx(o,{value:m,onChange:t=>{a(1),f(t.target.value)},placeholder:"Admin email",className:"h-8 text-sm"}),e.jsx(o,{type:"date",value:i,onChange:t=>{a(1),v(t.target.value)},className:"h-8 text-xs"}),e.jsx(o,{type:"date",value:l,onChange:t=>{a(1),N(t.target.value)},className:"h-8 text-xs"})]}),b&&!s?e.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((t,S)=>e.jsx(P,{className:"h-12"},S))}):x?e.jsx("div",{className:"rounded-lg border border-destructive/30 bg-destructive/5 p-4 text-sm text-destructive",children:x instanceof Error?x.message:"Failed to load audit log"}):s!=null&&s.entries.length?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`overflow-x-auto rounded-xl border border-border/60 bg-background ${y?"o
1pacity-70":""}`,children:e.jsxs("table",{className:"w-full min-w-[900px] text-left text-sm",children:[e.jsx("thead",{className:"border-b border-border/60 bg-muted/40 text-[11px] uppercase tracking-wide text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2.5 font-medium",children:"When"}),e.jsx("th",{className:"px-3 py-2.5 font-medium",children:"Admin"}),e.jsx("th",{className:"px-3 py-2.5 font-medium",children:"Action"}),e.jsx("th",{className:"px-3 py-2.5 font-medium",children:"Target"}),e.jsx("th",{className:"px-3 py-2.5 font-medium",children:"Status"}),e.jsx("th",{className:"px-3 py-2.5 font-medium",children:"Metadata"})]})}),e.jsx("tbody",{children:s.entries.map(t=>e.jsxs("tr",{className:"border-b border-border/40 align-top",children:[e.jsx("td",{className:"px-3 py-2.5 text-xs whitespace-nowrap",children:w(t.created_at)}),e.jsx("td",{className:"px-3 py-2.5 text-xs",children:t.admin_email}),e.jsx("td",{className:"px-3 py-2.5 font-medium",children:t.action}),e.jsxs("td",{className:"px-3 py-2.5 font-mono text-[11px]",children:[t.target_type||"â",t.target_id?` · ${t.target_id.slice(0,12)}â¦`:""]}),e.jsx("td",{className:"px-3 py-2.5 text-xs",children:t.previous_status||t.new_status?`${t.previous_status||"â"} â ${t.new_status||"â"}`:"â"}),e.jsx("td",{className:"px-3 py-2.5 max-w-[240px] truncate text-[11px] text-muted-foreground",children:JSON.stringify(t.metadata||{})})]},t.id))})]})}),e.jsxs("div",{className:"flex items-center justify-between gap-2 text-sm",children:[e.jsxs("p",{className:"text-muted-foreground",children:["Page ",d," of ",p]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(h,{variant:"outline",size:"sm",disabled:d<=1,onClick:()=>a(t=>t-1),children:"Previous"}),e.jsx(h,{variant:"outline",size:"sm",disabled:d>=p,onClick:()=>a(t=>t+1),children:"Next"})]})]})]}):e.jsx("div",{className:"rounded-xl border border-dashed border-border p-10 text-center text-sm text-muted-foreground",children:"No audit entries match these filters."})]})}export{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.