import{r as i,j as t,e as s,C as g}from"./index-B1H8BCL7.js";import{n as x}from"./stockApi-D1nxeMJU.js";import{R as S}from"./ReportPageShell-B7ORyOeG.js";import{G as a}from"./Grid-CTEl0Elf.js";import"./FileDownloadOutlined-B1TjRPKt.js";import"./Refresh-942gtAB1.js";import"./Stack-BIAbaqpj.js";import"./useThemeProps-DL_l3A7P.js";import"./TableContainer-CXAjhAg6.js";import"./TableRow-BfKE_xn9.js";import"./TableCell-D8CotAsC.js";const R=[{key:"changedDate",header:"When",width:150,format:e=>e?new Date(e).toLocaleString("en-IN",{day:"2-digit",month:"short",year:"2-digit",hour:"2-digit",minute:"2-digit"}):"—"},{key:"entityName",header:"Entity",width:140},{key:"entityId",header:"Entity ID",width:100},{key:"action",header:"Action",width:120,format:e=>e?t.jsx(g,{size:"small",label:e,sx:{height:18,fontSize:"0.6rem",fontWeight:700,backgroundColor:"#f5f3ff",color:"#6d28d9",borderRadius:"4px"}}):"—"},{key:"reason",header:"Reason"},{key:"changedBy",header:"By",width:120},{key:"referenceType",header:"Ref Type",width:120},{key:"referenceId",header:"Ref ID",width:90}],z=()=>{const[e,u]=i.useState(E()),[o,h]=i.useState(T()),[l,c]=i.useState(""),[d,m]=i.useState(""),{data:n,isFetching:p,refetch:f}=x({from:e,to:o,entityName:l,referenceType:d}),y=(n==null?void 0:n.list)??[];return t.jsx(S,{title:"Audit Trail",subtitle:"Cross-cutting audit log. Includes HQ-elevated transfer receipts (reason TRANSFER_RECEIPT_HQ_ELEVATION), batch overrides, manual reversals.",filters:t.jsxs(a,{container:!0,spacing:1.5,children:[t.jsx(a,{item:!0,xs:6,sm:3,children:t.jsx(s,{label:"From",type:"date",size:"small",fullWidth:!0,InputLabelProps:{shrink:!0},value:e,onChange:r=>u(r.target.value)})}),t.jsx(a,{item:!0,xs:6,sm:3,children:t.jsx(s,{label:"To",type:"date",size:"small",fullWidth:!0,InputLabelProps:{shrink:!0},value:o,onChange:r=>h(r.target.value)})}),t.jsx(a,{item:!0,xs:6,sm:3,children:t.jsx(s,{label:"Entity name",size:"small",fullWidth:!0,value:l,onChange:r=>c(r.target.value),placeholder:"StockTransfer / GoodsReceipt / …"})}),t.jsx(a,{item:!0,xs:6,sm:3,children:t.jsx(s,{label:"Reference type",size:"small",fullWidth:!0,value:d,onChange:r=>m(r.target.value),placeholder:"STOCK_TRANSFER / SALES_INVOICE / …"})})]}),columns:R,rows:y,isFetching:p,refetch:f,csvFilenameStem:"audit-trail"})};function T(){return new Date().toISOString().slice(0,10)}function E(){const e=new Date;return e.setDate(e.getDate()-30),e.toISOString().slice(0,10)}export{z as default};
