import{u as m,j as e,H as d}from"./app-BQEFzdw6.js";import{A as p}from"./AppLayout-kozc03ce.js";import{P as x}from"./PageHeader-Bj1OQnqr.js";import{F as n}from"./FormField-HY4WrCzQ.js";import"./useThemeColor-qPCpc713.js";const v=["furniture","fabric","lighting","flooring","hardware","paint","tools","electrical","other"];function y({warehouses:s}){var o;const{data:t,setData:a,post:u,processing:l,errors:i}=m({name:"",category:"other",unit:"",sku:"",reorder_level:"0",initial_stock:"0",unit_cost:"",warehouse_id:((o=s==null?void 0:s[0])==null?void 0:o.id)??"",description:""});function c(r){r.preventDefault(),u(route("inventory.items.store"))}return e.jsxs(p,{children:[e.jsx(d,{title:"New Inventory Item"}),e.jsx(x,{title:"New Inventory Item",back:route("inventory.items.index")}),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(n,{label:"Item Name",error:i.name,required:!0,children:e.jsx("input",{className:"form-input",value:t.name,onChange:r=>a("name",r.target.value)})}),e.jsx(n,{label:"SKU",error:i.sku,children:e.jsx("input",{className:"form-input",value:t.sku,onChange:r=>a("sku",r.target.value)})}),e.jsx(n,{label:"Category",error:i.category,children:e.jsx("select",{className:"form-input",value:t.category,onChange:r=>a("category",r.target.value),children:v.map(r=>e.jsx("option",{value:r,children:r},r))})}),e.jsx(n,{label:"Unit",error:i.unit,required:!0,children:e.jsx("input",{className:"form-input",value:t.unit,placeholder:"pcs, kg, m…",onChange:r=>a("unit",r.target.value)})}),e.jsx(n,{label:"Unit Cost (৳)",error:i.unit_cost,children:e.jsx("input",{type:"number",className:"form-input",value:t.unit_cost,onChange:r=>a("unit_cost",r.target.value)})}),e.jsx(n,{label:"Reorder Level",error:i.reorder_level,children:e.jsx("input",{type:"number",className:"form-input",value:t.reorder_level,onChange:r=>a("reorder_level",r.target.value)})}),e.jsx(n,{label:"Initial Stock",error:i.initial_stock,children:e.jsx("input",{type:"number",className:"form-input",value:t.initial_stock,onChange:r=>a("initial_stock",r.target.value)})}),e.jsx(n,{label:"Warehouse",error:i.warehouse_id,children:e.jsxs("select",{className:"form-input",value:t.warehouse_id,onChange:r=>a("warehouse_id",r.target.value),children:[e.jsx("option",{value:"",children:"-- Select --"}),(s??[]).map(r=>e.jsx("option",{value:r.id,children:r.name},r.id))]})})]}),e.jsx(n,{label:"Description",error:i.description,children:e.jsx("textarea",{className:"form-input",rows:2,value:t.description,onChange:r=>a("description",r.target.value)})}),e.jsxs("div",{className:"flex gap-3 pt-2",children:[e.jsx("button",{type:"submit",disabled:l,className:"btn btn-primary",children:l?"Saving…":"Save Item"}),e.jsx("a",{href:route("inventory.items.index"),className:"btn",children:"Cancel"})]})]})})]})}export{y as default};
