1import{aD as j,r as y,Q as p,j as e,B as l,a_ as g,as as f,av as b,V as d,L as N,O as v}from"./index-DVnvwKss.js";import{A as w,F as C}from"./AdminLayout-C50e_CCB.js";import{T,a as _,b as m,c as r,d as F,e as s}from"./table-C4LbsaW5.js";import{c as D}from"./invoiceUtils-AE-Mnb_L.js";import{E as I}from"./eye-BZHLZsJp.js";import"./lock-D_WmPVvn.js";import"./chart-column-4glrh6i_.js";import"./graduation-cap-B6HRXtd7.js";import"./package-CWCtnPMe.js";import"./star-DgJGUcrD.js";import"./tag-BsS18FKR.js";import"./users-Slprv71S.js";import"./send-DbAweDjN.js";import"./code-DeKqVZ0y.js";import"./link-2-FU3pAgyk.js";const k={draft:"bg-gray-500/10 text-gray-600 border-gray-500/20",sent:"bg-blue-500/10 text-blue-600 border-blue-500/20",paid:"bg-green-500/10 text-green-600 border-green-500/20",overdue:"bg-red-500/10 text-red-600 border-red-500/20",cancelled:"bg-gray-400/10 text-gray-400 border-gray-400/20"},K=()=>{const c=j(),[i,u]=y.useState("all"),{data:n,isLoading:x}=p({queryKey:["admin-invoices",i],queryFn:async()=>{let a=v.from("invoices").select("*").order("created_at",{ascending:!1});i!=="all"&&(a=a.eq("status",i));const{data:t,error:o}=await a;if(o)throw o;return t}}),h=(a,t)=>t==="NGN"?new Intl.NumberFormat("en-NG",{style:"currency",currency:"NGN",minimumFractionDigits:0}).format(a/100):new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(a/100);return e.jsx(w,{title:"Invoices",action:e.jsxs(l,{onClick:()=>c("/admin/invoices/new"),children:[e.jsx(g,{className:"mr-2 h-4 w-4"})," New Invoice"]}),children:e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex gap-2 flex-wrap",children:["all","draft","sent","paid","overdue","cancelled"].map(a=>e.jsx(l,{variant:i===a?"default":"outline",size:"sm",onClick:()=>u(a),className:"capitalize",children:a},a))}),x?e.jsx("div",{className:"flex justify-center py-16",children:e.jsx(f,{})}):n!=null&&n.length?e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(T,{children:[e.jsx(_,{children:e.jsxs(m,{children:[e.jsx(r,{children:"Invoice #"}),e.jsx(r,{children:"Client"}),e.jsx(r,{children:"Amount"}),e.jsx(r,{children:"Status"}),e.jsx(r,{children:"Due Date"}),e.jsx(r,{children:"Created"}),e.jsx(r,{className:"text-right",children:"Actions"})]})}),e.jsx(F,{children:n.map(a=>e.jsxs(m,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>c(`/admin/invoices/${a.id}`),children:[e.jsx(s,{className:"font-mono font-medium",children:a.invoice_number}),e.jsxs(s,{children:[e.jsx("div",{children:a.client_name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:a.client_email})]}),e.jsx(s,{className:"font-medium",children:h(D(a).total,a.currency)}),e.jsx(s,{children:e.jsx(b,{variant:"outline",className:k[a.status]||"",children:a.status})}),e.jsx(s,{children:a.due_date?d(new Date(a.due_date),"MMM d, yyyy"):"â"}),e.jsx(s,{children:d(new Date(a.created_at),"MMM d, yyyy")}),e.jsx(s,{className:"text-right",children:e.jsx(l,{variant:"ghost",size:"sm",asChild:!0,onClick:t=>t.stopPropagation(),children:e.jsx(N,{to:`/invoice/${a.id}`,target:"_blank",children:e.jsx(I,{className:"h-4 w-4"})})})})]},a.id))})]})}):e.jsxs("div",{className:"text-center py-16 text-muted-foreground",children:[e.jsx(C,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No invoices yet. Create your first one!"})]})]})})};export{K as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.