import{t as e}from"./jsx-runtime-bzQ4Vb5N.js";import{t}from"./useQuery-Dt4yOFcF.js";import{x as n}from"./index-t_-MMk0R.js";import{t as r}from"./page-header-CqpDR1d0.js";import{n as i,t as a}from"./card-2XLQ4Sqm.js";import{a as o,n as s,o as c,r as l,s as u,t as d}from"./table-CVkwN17b.js";var f=e();function p(){let{data:e=[]}=t({queryKey:[`audit`],queryFn:async()=>{let{data:e,error:t}=await n.from(`audit_log`).select(`*`).order(`created_at`,{ascending:!1}).limit(500);if(t)throw t;return e??[]}});return(0,f.jsxs)(`div`,{className:`p-6 max-w-[1400px] mx-auto`,children:[(0,f.jsx)(r,{title:`Audit Log`,subtitle:`All manual edits to progress data, with reason and prior value.`}),(0,f.jsx)(a,{children:(0,f.jsx)(i,{className:`p-0`,children:(0,f.jsxs)(d,{children:[(0,f.jsx)(c,{children:(0,f.jsxs)(u,{children:[(0,f.jsx)(o,{children:`Timestamp`}),(0,f.jsx)(o,{children:`User`}),(0,f.jsx)(o,{children:`Field`}),(0,f.jsx)(o,{children:`Old`}),(0,f.jsx)(o,{children:`New`}),(0,f.jsx)(o,{children:`Reason`})]})}),(0,f.jsxs)(s,{children:[e.map(e=>(0,f.jsxs)(u,{children:[(0,f.jsx)(l,{className:`text-sm`,children:new Date(e.created_at).toLocaleString()}),(0,f.jsx)(l,{className:`text-xs text-muted-foreground`,children:e.user_id?.slice(0,8)??`—`}),(0,f.jsx)(l,{className:`text-sm`,children:e.field_name}),(0,f.jsx)(l,{className:`text-sm`,children:e.old_value}),(0,f.jsx)(l,{className:`text-sm font-medium`,children:e.new_value}),(0,f.jsx)(l,{className:`text-sm text-muted-foreground max-w-[400px] truncate`,children:e.reason})]},e.id)),e.length===0&&(0,f.jsx)(u,{children:(0,f.jsx)(l,{colSpan:6,className:`text-center text-sm text-muted-foreground py-8`,children:`No edits recorded yet.`})})]})]})})})]})}export{p as component};