import{jsx as e,jsxs as t}from"react/jsx-runtime";import{T as x,a as g,b as r,c as a,d as f,e as l}from"./table-BrXe3s2z.js";import{B as s}from"./button-BvFBRYHq.js";import{Copy as c,Edit as N,Trash2 as b}from"lucide-react";import{format as C}from"date-fns";import{VoucherUsageBar as y}from"./VoucherUsageBar-iE_Hzjkx.js";import"./utils-CMbmcP35.js";import"clsx";import"tailwind-merge";import"@radix-ui/react-slot";import"class-variance-authority";function U({vouchers:d,masks:_,onEdit:m,onDelete:o,onClone:h,onCopyCode:p,isLoading:n}){return d.length===0?e("div",{className:"text-center text-muted-foreground py-8",children:"No vouchers found. Create one to get started."}):t(x,{children:[e(g,{children:t(r,{children:[e(a,{children:"Code"}),e(a,{children:"Item"}),e(a,{children:"Count"}),e(a,{children:"Usage"}),e(a,{children:"Expire Date"}),e(a,{children:"Status"}),e(a,{className:"text-right",children:"Actions"})]})}),e(f,{children:d.map(i=>t(r,{children:[e(l,{children:t("div",{className:"flex items-center gap-2",children:[e("span",{className:"font-mono",children:i.code}),e(s,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>p(i.code),title:"Copy code",children:e(c,{className:"h-3 w-3"})})]})}),t(l,{children:[i.item_name||`Item #${i.item_id}`,t("span",{className:"text-xs text-muted-foreground ml-2",children:["(ID: ",i.item_id,")"]})]}),e(l,{children:i.count}),e(l,{children:e(y,{usageCount:i.usage_count,usageLimit:i.usage_limit})}),e(l,{children:i.expire_date?C(new Date(i.expire_date),"MMM dd, yyyy"):"No expiry"}),e(l,{children:i.is_used?e("span",{className:"text-red-600",children:"Used"}):e("span",{className:"text-green-600",children:"Available"})}),e(l,{className:"text-right",children:t("div",{className:"flex justify-end gap-2",children:[e(s,{variant:"ghost",size:"icon",onClick:()=>h(i),disabled:n,title:"Clone",children:e(c,{className:"h-4 w-4"})}),e(s,{variant:"ghost",size:"icon",onClick:()=>m(i),disabled:i.is_used||n,title:"Edit",children:e(N,{className:"h-4 w-4"})}),e(s,{variant:"ghost",size:"icon",onClick:()=>o(i),disabled:i.is_used||n,title:"Delete",children:e(b,{className:"h-4 w-4"})})]})})]},i.id))})]})}export{U as VoucherTable};
