import{u as m,j as t,H as p}from"./app-BQEFzdw6.js";import{A as x}from"./AppLayout-kozc03ce.js";import{P as j}from"./PageHeader-Bj1OQnqr.js";import{F as i}from"./FormField-HY4WrCzQ.js";import"./useThemeColor-qPCpc713.js";function f({items:o,projects:c}){const{data:r,setData:a,post:u,processing:l,errors:s}=m({inventory_item_id:"",project_id:"",quantity:"",notes:"",transaction_date:new Date().toISOString().substring(0,10)});function d(e){e.preventDefault(),u(route("inventory.issue.store"))}const n=(o??[]).find(e=>e.id===r.inventory_item_id);return t.jsxs(x,{children:[t.jsx(p,{title:"Issue Stock"}),t.jsx(j,{title:"Issue Stock to Project",back:route("inventory.items.index")}),t.jsx("div",{className:"p-4 sm:p-6 max-w-xl",children:t.jsxs("form",{onSubmit:d,className:"card p-6 space-y-4",children:[t.jsx(i,{label:"Item",error:s.inventory_item_id,required:!0,children:t.jsxs("select",{className:"form-input",value:r.inventory_item_id,onChange:e=>a("inventory_item_id",e.target.value),children:[t.jsx("option",{value:"",children:"Select Item…"}),(o??[]).filter(e=>e.is_active).map(e=>t.jsxs("option",{value:e.id,children:[e.name," (Stock: ",e.current_stock," ",e.unit,")"]},e.id))]})}),t.jsx(i,{label:"Project",error:s.project_id,children:t.jsxs("select",{className:"form-input",value:r.project_id,onChange:e=>a("project_id",e.target.value),children:[t.jsx("option",{value:"",children:"-- No Project --"}),(c??[]).map(e=>t.jsx("option",{value:e.id,children:e.name},e.id))]})}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[t.jsx(i,{label:`Quantity${n?` (max: ${n.current_stock})`:""}`,error:s.quantity,required:!0,children:t.jsx("input",{type:"number",className:"form-input",value:r.quantity,max:n==null?void 0:n.current_stock,onChange:e=>a("quantity",e.target.value)})}),t.jsx(i,{label:"Date",error:s.transaction_date,children:t.jsx("input",{type:"date",className:"form-input",value:r.transaction_date,onChange:e=>a("transaction_date",e.target.value)})})]}),t.jsx(i,{label:"Notes",error:s.notes,children:t.jsx("textarea",{className:"form-input",rows:2,value:r.notes,onChange:e=>a("notes",e.target.value)})}),t.jsxs("div",{className:"flex gap-3 pt-2",children:[t.jsx("button",{type:"submit",disabled:l,className:"btn btn-primary",children:l?"Issuing…":"Issue Stock"}),t.jsx("a",{href:route("inventory.items.index"),className:"btn",children:"Cancel"})]})]})})]})}export{f as default};
