import{jsxs as a,jsx as e}from"react/jsx-runtime";import{B as o,g as l}from"./ui-components-B24mpb8o.js";import{format as n,parseISO as t,isPast as c,isFuture as p}from"date-fns";import{Copy as u,Pencil as g}from"lucide-react";import v from"./coupon-form-Viqs_2Jy.js";import"next-themes";import"sonner";import"react";import"@radix-ui/react-label";import"class-variance-authority";import"@radix-ui/react-checkbox";import"@radix-ui/react-avatar";import"@radix-ui/react-dropdown-menu";import"@radix-ui/react-scroll-area";import"@radix-ui/react-popover";import"@radix-ui/react-radio-group";import"@radix-ui/react-dialog";import"@radix-ui/react-slot";import"clsx";import"@radix-ui/react-separator";import"@radix-ui/react-tooltip";import"@radix-ui/react-tabs";import"@radix-ui/react-accordion";import"@radix-ui/react-progress";import"@radix-ui/react-select";import"cmdk";import"@radix-ui/react-switch";import"react-day-picker";import"@radix-ui/react-slider";import"embla-carousel-react";import"@radix-ui/react-toggle-group";import"vaul";import"tailwind-merge";import"./input-error-BbsDx4-P.js";import"./loading-button-B_LaGOAp.js";import"./date-BZvGgr5q.js";import"./inertia-FIn3q7f1.js";import"@inertiajs/react";const ii=({exams:s})=>{const m=i=>i.is_active?i.valid_to&&c(t(i.valid_to))?{label:"Expired",variant:"destructive"}:i.valid_from&&p(t(i.valid_from))?{label:"Scheduled",variant:"secondary"}:i.usage_limit&&i.used_count>=i.usage_limit?{label:"Used Up",variant:"destructive"}:{label:"Active",variant:"default"}:{label:"Inactive",variant:"secondary"},d=i=>{navigator.clipboard.writeText(i),alert("Coupon code copied to clipboard!")};return[{accessorKey:"code",header:()=>e("p",{className:"pl-4",children:"Coupon Code"}),cell:({row:i})=>a("div",{className:"flex items-center gap-2 pl-4",children:[e("code",{className:"rounded bg-gray-100 px-2 py-1 font-bold",children:i.original.code}),e(o,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>d(i.original.code),children:e(u,{className:"h-3 w-3"})})]})},{accessorKey:"discount",header:"Discount",cell:({row:i})=>e(l,{variant:"outline",children:i.original.discount_type==="percentage"?`${i.original.discount}% OFF`:`$${i.original.discount} OFF`})},{accessorKey:"exam",header:"Exam",cell:({row:i})=>i.original.exam?e("span",{className:"font-medium",children:i.original.exam.title}):e("span",{className:"text-primary font-medium",children:"Global Coupon"})},{accessorKey:"usage",header:"Usage",cell:({row:i})=>i.original.usage_type==="limited"?a("span",{children:[i.original.used_count," / ",i.original.usage_limit]}):e("span",{children:"Unlimited"})},{accessorKey:"valid_from",header:"Valid From",cell:({row:i})=>i.original.valid_from?n(t(i.original.valid_from),"MMM dd, yyyy HH:mm"):"-"},{accessorKey:"valid_to",header:"Valid To",cell:({row:i})=>i.original.valid_to?n(t(i.original.valid_to),"MMM dd, yyyy HH:mm"):"-"},{accessorKey:"status",header:"Status",cell:({row:i})=>{const r=m(i.original);return e(l,{variant:r.variant,children:r.label})}},{id:"actions",header:()=>e("p",{className:"pr-4 text-end",children:"Actions"}),cell:({row:i})=>{const r=i.original;return e("div",{className:"flex items-center justify-end py-2 pr-4",children:e(v,{title:"Edit Coupon",coupon:r,exams:s,handler:e(o,{size:"icon",variant:"secondary",className:"h-8 w-8",children:e(g,{})})})})}}]};export{ii as default};
