import{u,j as e,H as d}from"./app-BQEFzdw6.js";import{A as m}from"./AppLayout-kozc03ce.js";import{P as p}from"./PageHeader-Bj1OQnqr.js";import{F as i}from"./FormField-HY4WrCzQ.js";import"./useThemeColor-qPCpc713.js";const x=["furniture","fabric","lighting","flooring","hardware","paint","tools","electrical","other"];function y({item:a,warehouses:h}){const{data:t,setData:s,put:o,processing:l,errors:n}=u({name:a.name,category:a.category??"other",unit:a.unit,sku:a.sku??"",reorder_level:a.reorder_level??"0",unit_cost:a.unit_cost??"",description:a.description??"",is_active:a.is_active});function c(r){r.preventDefault(),o(route("inventory.items.update",a.id))}return e.jsxs(m,{children:[e.jsx(d,{title:`Edit ${a.name}`}),e.jsx(p,{title:`Edit: ${a.name}`,back:route("inventory.items.show",a.id)}),e.jsx("div",{className:"p-4 sm:p-6 max-w-2xl mx-auto",children:e.jsxs("form",{onSubmit:c,className:"card p-6 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(i,{label:"Item Name",error:n.name,required:!0,children:e.jsx("input",{className:"form-input",value:t.name,onChange:r=>s("name",r.target.value)})}),e.jsx(i,{label:"SKU",error:n.sku,children:e.jsx("input",{className:"form-input",value:t.sku,onChange:r=>s("sku",r.target.value)})}),e.jsx(i,{label:"Category",error:n.category,children:e.jsx("select",{className:"form-input",value:t.category,onChange:r=>s("category",r.target.value),children:x.map(r=>e.jsx("option",{value:r,children:r},r))})}),e.jsx(i,{label:"Unit",error:n.unit,required:!0,children:e.jsx("input",{className:"form-input",value:t.unit,onChange:r=>s("unit",r.target.value)})}),e.jsx(i,{label:"Unit Cost (৳)",error:n.unit_cost,children:e.jsx("input",{type:"number",className:"form-input",value:t.unit_cost,onChange:r=>s("unit_cost",r.target.value)})}),e.jsx(i,{label:"Reorder Level",error:n.reorder_level,children:e.jsx("input",{type:"number",className:"form-input",value:t.reorder_level,onChange:r=>s("reorder_level",r.target.value)})})]}),e.jsx(i,{label:"Description",error:n.description,children:e.jsx("textarea",{className:"form-input",rows:2,value:t.description,onChange:r=>s("description",r.target.value)})}),e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:t.is_active,onChange:r=>s("is_active",r.target.checked),className:"rounded"}),"Active"]}),e.jsxs("div",{className:"flex gap-3 pt-2",children:[e.jsx("button",{type:"submit",disabled:l,className:"btn btn-primary",children:l?"Saving…":"Update Item"}),e.jsx("a",{href:route("inventory.items.show",a.id),className:"btn",children:"Cancel"})]})]})})]})}export{y as default};
