import{r as d,u as N,j as e,H as b}from"./app-BQEFzdw6.js";import{A as v}from"./AppLayout-kozc03ce.js";import{P as y}from"./PageHeader-Bj1OQnqr.js";import{F as i}from"./FormField-HY4WrCzQ.js";import{M as C}from"./Modal-CYT-I8ae.js";import{F}from"./PlusIcon-ElxOOThC.js";import{F as S}from"./PencilIcon-BWjiauNE.js";import"./useThemeColor-qPCpc713.js";import"./with-selector-kbxKzNSf.js";function L({warehouses:c}){const[p,t]=d.useState(!1),[a,m]=d.useState(null),{data:r,setData:o,post:x,put:h,processing:u,errors:n,reset:l}=N({name:"",location:"",notes:""});function f(){l(),m(null),t(!0)}function j(s){o({name:s.name,location:s.location??"",notes:s.notes??""}),m(s),t(!0)}function g(s){s.preventDefault(),a?h(route("inventory.warehouses.update",a.id),{onSuccess:()=>{t(!1),l()}}):x(route("inventory.warehouses.store"),{onSuccess:()=>{t(!1),l()}})}return e.jsxs(v,{children:[e.jsx(b,{title:"Warehouses"}),e.jsx(y,{title:"Warehouses",children:e.jsxs("button",{onClick:f,className:"btn btn-primary flex items-center gap-2",children:[e.jsx(F,{className:"w-4 h-4"})," New Warehouse"]})}),e.jsx("div",{className:"p-4 sm:p-6",children:e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[(c??[]).map(s=>e.jsxs("div",{className:"card p-4 flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium",children:s.name}),s.location&&e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:s.location}),s.notes&&e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:s.notes})]}),e.jsx("button",{onClick:()=>j(s),className:"text-gray-400 hover:text-yellow-600",children:e.jsx(S,{className:"w-4 h-4"})})]},s.id)),(c??[]).length===0&&e.jsx("p",{className:"col-span-3 text-center text-gray-400 py-8",children:"No warehouses configured."})]})}),e.jsx(C,{open:p,onClose:()=>t(!1),title:a?"Edit Warehouse":"New Warehouse",children:e.jsxs("form",{onSubmit:g,className:"space-y-4",children:[e.jsx(i,{label:"Name",error:n.name,required:!0,children:e.jsx("input",{className:"form-input",value:r.name,onChange:s=>o("name",s.target.value)})}),e.jsx(i,{label:"Location",error:n.location,children:e.jsx("input",{className:"form-input",value:r.location,onChange:s=>o("location",s.target.value)})}),e.jsx(i,{label:"Notes",error:n.notes,children:e.jsx("textarea",{className:"form-input",rows:2,value:r.notes,onChange:s=>o("notes",s.target.value)})}),e.jsxs("div",{className:"flex gap-3 pt-2",children:[e.jsx("button",{type:"submit",disabled:u,className:"btn btn-primary",children:u?"Saving…":a?"Update":"Create"}),e.jsx("button",{type:"button",onClick:()=>t(!1),className:"btn",children:"Cancel"})]})]})})]})}export{L as default};
