import{r as s,j as e,H as u,a as h}from"./app-BQEFzdw6.js";import{A as j}from"./AppLayout-kozc03ce.js";import{P as g}from"./PageHeader-Bj1OQnqr.js";import{b as v}from"./formatters-ClI693-F.js";import{B as N}from"./Badge-CiLdjUlo.js";import"./useThemeColor-qPCpc713.js";import"./dayjs.min-BDUBcDj6.js";const f={receipt:"success",issue:"danger",adjustment:"warning",transfer:"info"};function B({transactions:r,filters:a,items:i}){const[n,o]=s.useState((a==null?void 0:a.inventory_item_id)??""),[m,p]=s.useState((a==null?void 0:a.from)??""),[l,x]=s.useState((a==null?void 0:a.to)??"");function y(t){t.preventDefault(),h.get(route("inventory.report"),{inventory_item_id:n,from:m,to:l},{preserveState:!0,replace:!0})}return e.jsxs(j,{children:[e.jsx(u,{title:"Stock Movement Report"}),e.jsx(g,{title:"Stock Movement Report"}),e.jsxs("div",{className:"p-4 sm:p-6",children:[e.jsxs("form",{onSubmit:y,className:"flex gap-3 mb-4 flex-wrap items-end",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("label",{className:"text-xs text-gray-500",children:"Item"}),e.jsxs("select",{className:"form-input text-sm",value:n,onChange:t=>o(t.target.value),children:[e.jsx("option",{value:"",children:"All Items"}),(i??[]).map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("label",{className:"text-xs text-gray-500",children:"From"}),e.jsx("input",{type:"date",className:"form-input text-sm",value:m,onChange:t=>p(t.target.value)})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("label",{className:"text-xs text-gray-500",children:"To"}),e.jsx("input",{type:"date",className:"form-input text-sm",value:l,onChange:t=>x(t.target.value)})]}),e.jsx("button",{type:"submit",className:"btn btn-primary text-sm",children:"Filter"})]}),e.jsx("div",{className:"card overflow-hidden",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[e.jsx("thead",{className:"bg-gray-50",children:e.jsx("tr",{children:["Date","Item","Type","Qty","Reference","Notes","By"].map(t=>e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:t},t))})}),e.jsxs("tbody",{className:"divide-y divide-gray-100",children:[(r??[]).map(t=>{var c,d;return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 text-sm",children:v(t.transaction_date)}),e.jsx("td",{className:"px-4 py-3 text-sm font-medium",children:(c=t.item)==null?void 0:c.name}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(N,{variant:f[t.type]??"gray",children:t.type})}),e.jsxs("td",{className:`px-4 py-3 text-sm font-semibold ${t.type==="receipt"?"text-green-700":"text-red-700"}`,children:[t.type==="receipt"||t.type==="adjustment"&&t.quantity>0?"+":"-",Math.abs(t.quantity)]}),e.jsx("td",{className:"px-4 py-3 text-sm text-gray-500",children:t.reference??"—"}),e.jsx("td",{className:"px-4 py-3 text-sm text-gray-600",children:t.notes}),e.jsx("td",{className:"px-4 py-3 text-sm text-gray-500",children:(d=t.performedBy)==null?void 0:d.name})]},t.id)}),(r??[]).length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-4 py-8 text-center text-gray-400",children:"No transactions found."})})]})]})})]})]})}export{B as default};
