import{r as n,j as e,H as u,L as l,a as d}from"./app-BQEFzdw6.js";import{A as y,a as j}from"./AppLayout-kozc03ce.js";import{P as g}from"./PageHeader-Bj1OQnqr.js";import{C as f}from"./ConfirmDialog-DkDf4ypa.js";import{B as N}from"./Badge-CiLdjUlo.js";import{F as b}from"./PlusIcon-ElxOOThC.js";import{F as v}from"./EyeIcon-CkYifINe.js";import{F as w}from"./PencilIcon-BWjiauNE.js";import{F as C}from"./TrashIcon-D0d0jw01.js";import"./useThemeColor-qPCpc713.js";import"./Modal-CYT-I8ae.js";import"./with-selector-kbxKzNSf.js";function P({clients:t,filters:s}){var m;const[i,x]=n.useState((s==null?void 0:s.search)??""),[o,r]=n.useState(null);function c(a){a.preventDefault(),d.get(route("clients.index"),{search:i},{preserveState:!0,replace:!0})}function p(){d.delete(route("clients.destroy",o),{onFinish:()=>r(null)})}return e.jsxs(y,{children:[e.jsx(u,{title:"Clients"}),e.jsx(g,{title:"Clients",subtitle:`${t.total??t.length} total clients`,children:e.jsxs(l,{href:route("clients.create"),className:"btn btn-primary flex items-center gap-2",children:[e.jsx(b,{className:"w-4 h-4"})," New Client"]})}),e.jsxs("div",{className:"p-4 sm:p-6",children:[e.jsxs("form",{onSubmit:c,className:"mb-4 flex gap-2 max-w-sm",children:[e.jsx("input",{value:i,onChange:a=>x(a.target.value),placeholder:"Search clients...",className:"form-input flex-1"}),e.jsx("button",{type:"submit",className:"btn btn-primary px-3",children:e.jsx(j,{className:"w-4 h-4"})})]}),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:["Code","Name","Phone","Email","City","Status","Actions"].map(a=>e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:a},a))})}),e.jsxs("tbody",{className:"divide-y divide-gray-100",children:[(t.data??t).map(a=>e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 text-sm font-mono text-primary-600",children:a.code}),e.jsx("td",{className:"px-4 py-3 text-sm font-medium",children:a.name}),e.jsx("td",{className:"px-4 py-3 text-sm text-gray-600",children:a.phone}),e.jsx("td",{className:"px-4 py-3 text-sm text-gray-600",children:a.email}),e.jsx("td",{className:"px-4 py-3 text-sm text-gray-600",children:a.city}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(N,{variant:a.is_active?"success":"gray",children:a.is_active?"Active":"Inactive"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(l,{href:route("clients.show",a.id),className:"text-gray-400 hover:text-primary-600",children:e.jsx(v,{className:"w-4 h-4"})}),e.jsx(l,{href:route("clients.edit",a.id),className:"text-gray-400 hover:text-yellow-600",children:e.jsx(w,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>r(a.id),className:"text-gray-400 hover:text-red-600",children:e.jsx(C,{className:"w-4 h-4"})})]})})]},a.id)),(t.data??t).length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-4 py-8 text-center text-gray-400",children:"No clients found."})})]})]})}),t.last_page>1&&e.jsx("div",{className:"mt-4 flex gap-2 justify-end",children:(m=t.links)==null?void 0:m.map((a,h)=>e.jsx("button",{onClick:()=>a.url&&d.get(a.url),disabled:!a.url,className:`px-3 py-1 text-sm rounded border ${a.active?"bg-primary-600 text-white border-primary-600":"border-gray-300 text-gray-600 hover:bg-gray-50"} disabled:opacity-40`,dangerouslySetInnerHTML:{__html:a.label}},h))})]}),e.jsx(f,{open:!!o,title:"Delete Client",message:"Are you sure? This cannot be undone.",onConfirm:p,onCancel:()=>r(null)})]})}export{P as default};
