import{c as b,b as g,f as p,j as e}from"./index-D9pJRAs5.js";import{r as i}from"./vendor-D6aTFYy9.js";import{a2 as f,F as N,C as j,G as v,E as y}from"./ui-CtYVlq7P.js";import{f as w}from"./utils-BowMT5us.js";import"./pdf-Bz_mU5mG.js";const L=()=>{const{deliveryNotes:d,markDelivered:c}=b(),{theme:o}=g(),{showToast:k}=p(),s=o.mode==="dark",[a,n]=i.useState(""),[r,m]=i.useState("all"),l=d.filter(t=>{const u=t.deliveryNumber.toLowerCase().includes(a.toLowerCase())||t.orderNumber.toLowerCase().includes(a.toLowerCase())||t.customerName.toLowerCase().includes(a.toLowerCase()),h=r==="all"||t.status===r;return u&&h}),x=t=>{switch(t){case"delivered":return"text-green-600 bg-green-100 dark:bg-green-900/30 dark:text-green-400";case"pending":return"text-amber-600 bg-amber-100 dark:bg-amber-900/30 dark:text-amber-400";case"draft":return"text-slate-600 bg-slate-100 dark:bg-slate-800 dark:text-slate-400";default:return"text-gray-600 bg-gray-100 dark:bg-gray-800 dark:text-gray-400"}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-between items-center",children:[e.jsxs("div",{className:"relative w-full sm:w-64",children:[e.jsx(f,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-400",size:18}),e.jsx("input",{type:"text",placeholder:"Search delivery notes...",value:a,onChange:t=>n(t.target.value),className:`w-full pl-10 pr-4 py-2 rounded-lg border outline-none focus:ring-2 focus:ring-blue-500 transition-all ${s?"bg-slate-800 border-slate-700 text-white":"bg-white border-slate-200 text-slate-900"}`})]}),e.jsx("div",{className:"flex gap-2 w-full sm:w-auto",children:["all","draft","pending","delivered"].map(t=>e.jsx("button",{onClick:()=>m(t),className:`px-3 py-1.5 rounded-lg text-sm font-medium capitalize transition-colors ${r===t?"bg-blue-600 text-white":s?"bg-slate-800 text-slate-400 hover:bg-slate-700":"bg-white text-slate-600 border border-slate-200 hover:bg-slate-50"}`,children:t},t))})]}),e.jsx("div",{className:`rounded-xl border overflow-hidden ${s?"border-slate-700 bg-slate-800/50":"border-slate-200 bg-white"}`,children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{className:`${s?"bg-slate-800 text-slate-400":"bg-slate-50 text-slate-600"}`,children:e.jsxs("tr",{children:[e.jsx("th",{className:"p-4 font-medium",children:"DO Number"}),e.jsx("th",{className:"p-4 font-medium",children:"Date"}),e.jsx("th",{className:"p-4 font-medium",children:"Customer"}),e.jsx("th",{className:"p-4 font-medium",children:"Order Ref"}),e.jsx("th",{className:"p-4 font-medium",children:"Status"}),e.jsx("th",{className:"p-4 font-medium text-right",children:"Actions"})]})}),e.jsx("tbody",{className:`divide-y ${s?"divide-slate-700":"divide-slate-200"}`,children:l.length>0?l.map(t=>e.jsxs("tr",{className:`group ${s?"hover:bg-slate-800":"hover:bg-slate-50"} transition-colors`,children:[e.jsxs("td",{className:"p-4 font-medium flex items-center gap-2",children:[e.jsx(N,{size:16,className:"text-blue-500"}),e.jsx("span",{className:s?"text-white":"text-slate-900",children:t.deliveryNumber})]}),e.jsx("td",{className:`p-4 ${s?"text-slate-400":"text-slate-600"}`,children:w(new Date(t.date),"MMM dd, yyyy")}),e.jsx("td",{className:`p-4 font-medium ${s?"text-slate-300":"text-slate-700"}`,children:t.customerName}),e.jsxs("td",{className:`p-4 ${s?"text-slate-400":"text-slate-600"}`,children:["#",t.orderNumber]}),e.jsx("td",{className:"p-4",children:e.jsx("span",{className:`px-2.5 py-1 rounded-full text-xs font-medium capitalize ${x(t.status)}`,children:t.status})}),e.jsx("td",{className:"p-4 text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[t.status!=="delivered"&&e.jsx("button",{onClick:()=>c(t.id),className:"p-1.5 hover:bg-green-50 text-green-600 rounded-md transition-colors",title:"Mark as Delivered",children:e.jsx(j,{size:16})}),e.jsx("button",{className:"p-1.5 hover:bg-blue-50 text-blue-600 rounded-md transition-colors",title:"View Details",children:e.jsx(v,{size:16})})]})})]},t.id)):e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"p-12 text-center text-slate-400",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(y,{size:32,className:"opacity-20"}),e.jsx("p",{children:"No delivery notes found matching your criteria."})]})})})})]})})})]})};export{L as default};
