import{j as a,bd as r,dc as c,be as s,d8 as m,dd as u,de as p}from"./react-vendor-xYZnmIII.js";import{B as t,g as l}from"./ui-components-CQM92IK3.js";import g from"./coupon-form-Ch96ilzC.js";import"./inertia-vendor-cBbDTmhJ.js";import"./ui-vendor-Ds9iwIxa.js";import"./interactive-vendor-B1OgcAgP.js";import"./input-error-_LAmvivg.js";import"./loading-button-D7aXR3K4.js";import"./date-Burj_6Bf.js";import"./inertia-FIn3q7f1.js";const F=({courses:o})=>{const n=e=>e.is_active?e.valid_to&&u(s(e.valid_to))?{label:"Expired",variant:"destructive"}:e.valid_from&&p(s(e.valid_from))?{label:"Scheduled",variant:"secondary"}:e.usage_limit&&e.used_count>=e.usage_limit?{label:"Used Up",variant:"destructive"}:{label:"Active",variant:"default"}:{label:"Inactive",variant:"secondary"},d=e=>{navigator.clipboard.writeText(e),alert("Coupon code copied to clipboard!")};return[{accessorKey:"code",header:()=>a.jsx("p",{className:"pl-4",children:"Coupon Code"}),cell:({row:e})=>a.jsxs("div",{className:"flex items-center gap-2 pl-4",children:[a.jsx("code",{className:"rounded bg-gray-100 px-2 py-1 font-bold",children:e.original.code}),a.jsx(t,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>d(e.original.code),children:a.jsx(c,{className:"h-3 w-3"})})]})},{accessorKey:"discount",header:"Discount",cell:({row:e})=>a.jsx(l,{variant:"outline",children:e.original.discount_type==="percentage"?`${e.original.discount}% OFF`:`$${e.original.discount} OFF`})},{accessorKey:"course",header:"Course",cell:({row:e})=>e.original.course?a.jsx("span",{className:"font-medium",children:e.original.course.title}):a.jsx("span",{className:"text-primary font-medium",children:"Global Coupon"})},{accessorKey:"usage",header:"Usage",cell:({row:e})=>e.original.usage_type==="limited"?a.jsxs("span",{children:[e.original.used_count," / ",e.original.usage_limit]}):a.jsx("span",{children:"Unlimited"})},{accessorKey:"valid_from",header:"Valid From",cell:({row:e})=>e.original.valid_from?r(s(e.original.valid_from),"MMM dd, yyyy HH:mm"):"-"},{accessorKey:"valid_to",header:"Valid To",cell:({row:e})=>e.original.valid_to?r(s(e.original.valid_to),"MMM dd, yyyy HH:mm"):"-"},{accessorKey:"status",header:"Status",cell:({row:e})=>{const i=n(e.original);return a.jsx(l,{variant:i.variant,children:i.label})}},{id:"actions",header:()=>a.jsx("p",{className:"pr-4 text-end",children:"Actions"}),cell:({row:e})=>{const i=e.original;return a.jsx("div",{className:"flex items-center justify-end py-2 pr-4",children:a.jsx(g,{title:"Edit Coupon",coupon:i,courses:o,handler:a.jsx(t,{size:"icon",variant:"secondary",className:"h-8 w-8",children:a.jsx(m,{})})})})}}]};export{F as default};
