@burdenoff/microfe-billing 2026.624.2 → 2026.624.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,60 +5,61 @@ import { useBillingPermissions as n } from "../../../hooks/useBillingPermissions
5
5
  import { useDeactivateCouponMutation as r, useListCouponsQuery as i, useUpdateCouponMutation as a } from "../../../../generated/global-operations.js";
6
6
  import { useBillingNavigate as o } from "../../../hooks/useBillingNavigate.js";
7
7
  import { CouponStatus as s } from "../../../../generated/global-types.js";
8
- import { useEffect as ee, useMemo as c, useState as l } from "react";
9
- import { AlertCircle as u, CheckCircle as d, ChevronLeft as f, ChevronRight as te, DollarSign as p, Download as ne, Edit as m, Eye as h, Package as g, Percent as _, Plus as v, Power as y, PowerOff as b, Search as x, Tag as S, Trash2 as C, TrendingUp as w } from "lucide-react";
10
- import { jsx as T, jsxs as E } from "react/jsx-runtime";
8
+ import { useEffect as c, useMemo as l, useState as u } from "react";
9
+ import { AlertCircle as d, CheckCircle as f, ChevronLeft as p, ChevronRight as m, DollarSign as h, Download as ee, Edit as te, Eye as g, Package as _, Percent as ne, Plus as v, Power as y, PowerOff as b, Search as re, Tag as x, Trash2 as S, TrendingUp as C } from "lucide-react";
10
+ import { Fragment as w, jsx as T, jsxs as E } from "react/jsx-runtime";
11
11
  import { useI18n as D } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
12
+ import { ResponsiveTable as O } from "@burdenoff/fe-libs/ui";
12
13
  //#region src/billing/modules/coupons/pages/CouponsListPage.tsx
13
- var O = () => {
14
- let { t: O } = D(), re = (e, t) => {
15
- let n = O(e);
14
+ var k = () => {
15
+ let { t: k } = D(), ie = (e, t) => {
16
+ let n = k(e);
16
17
  return n === e ? t : n;
17
- }, k = o(), ie = n(), [A, ae] = l(""), [j, M] = l("ALL"), [N, P] = l("ALL"), [F] = l("ALL"), [I, L] = l(0), [R, z] = l(null), [B, V] = l(null), [H, U] = l(null), { data: W, loading: G, refetch: K } = i({ variables: {
18
+ }, A = o(), ae = n(), [j, oe] = u(""), [M, N] = u("ALL"), [P, F] = u("ALL"), [I] = u("ALL"), [L, R] = u(0), [z, B] = u(null), [V, H] = u(null), [U, W] = u(null), { data: G, loading: K, refetch: q } = i({ variables: {
18
19
  limit: 20,
19
- offset: I * 20,
20
+ offset: L * 20,
20
21
  filter: {
21
- status: j === "ALL" ? void 0 : j,
22
- type: N === "ALL" ? void 0 : N,
23
- scope: F === "ALL" ? void 0 : F,
24
- search: A || void 0
22
+ status: M === "ALL" ? void 0 : M,
23
+ type: P === "ALL" ? void 0 : P,
24
+ scope: I === "ALL" ? void 0 : I,
25
+ search: j || void 0
25
26
  }
26
- } }), q = c(() => W?.listCoupons?.coupons ?? [], [W?.listCoupons?.coupons]), J = W?.listCoupons?.total ?? 0, oe = W?.listCoupons?.hasMore ?? !1, se = Math.ceil(J / 20), [ce, { loading: Y }] = r(), [le] = a(), X = q;
27
- ee(() => {
28
- L(0);
27
+ } }), J = l(() => G?.listCoupons?.coupons ?? [], [G?.listCoupons?.coupons]), Y = G?.listCoupons?.total ?? 0, se = G?.listCoupons?.hasMore ?? !1, ce = Math.ceil(Y / 20), [le, { loading: X }] = r(), [ue] = a(), Z = J;
28
+ c(() => {
29
+ R(0);
29
30
  }, [
30
- A,
31
31
  j,
32
- N,
33
- F
32
+ M,
33
+ P,
34
+ I
34
35
  ]);
35
- let Z = c(() => ({
36
- totalCoupons: J,
37
- activeCoupons: q.filter((e) => e.status === "ACTIVE").length,
38
- totalUses: q.reduce((e, t) => e + t.currentUses, 0),
39
- totalDiscountValue: q.reduce((e, t) => t.type === "FIXED_AMOUNT" ? e + t.value * t.currentUses : e, 0)
40
- }), [q, J]);
41
- if (!ie.canManageDiscounts) return /* @__PURE__ */ T(e, { message: "You don't have permission to manage coupons." });
42
- let Q = (e) => new Intl.NumberFormat("en-US", {
36
+ let Q = l(() => ({
37
+ totalCoupons: Y,
38
+ activeCoupons: J.filter((e) => e.status === "ACTIVE").length,
39
+ totalUses: J.reduce((e, t) => e + t.currentUses, 0),
40
+ totalDiscountValue: J.reduce((e, t) => t.type === "FIXED_AMOUNT" ? e + t.value * t.currentUses : e, 0)
41
+ }), [J, Y]);
42
+ if (!ae.canManageDiscounts) return /* @__PURE__ */ T(e, { message: "You don't have permission to manage coupons." });
43
+ let $ = (e) => new Intl.NumberFormat("en-US", {
43
44
  style: "currency",
44
45
  currency: "USD"
45
- }).format(e), $ = (e) => new Date(e).toLocaleDateString("en-US", {
46
+ }).format(e), de = (e) => new Date(e).toLocaleDateString("en-US", {
46
47
  year: "numeric",
47
48
  month: "short",
48
49
  day: "numeric"
49
- }), ue = (e) => {
50
+ }), fe = (e) => {
50
51
  switch (e) {
51
52
  case "ACTIVE": return "text-status-success-text bg-status-success-bg-subtle";
52
53
  case "INACTIVE": return "text-text-secondary bg-bg-canvas";
53
54
  case "EXPIRED": return "text-status-error-text bg-status-error-bg-subtle";
54
55
  default: return "text-text-secondary bg-bg-canvas";
55
56
  }
56
- }, de = (e) => {
57
+ }, pe = (e) => {
57
58
  switch (e) {
58
- case "PERCENTAGE": return /* @__PURE__ */ T(_, { className: "size-4" });
59
- case "FIXED_AMOUNT": return /* @__PURE__ */ T(p, { className: "size-4" });
60
- case "FREE_SHIPPING": return /* @__PURE__ */ T(g, { className: "size-4" });
61
- default: return /* @__PURE__ */ T(S, { className: "size-4" });
59
+ case "PERCENTAGE": return /* @__PURE__ */ T(ne, { className: "size-4" });
60
+ case "FIXED_AMOUNT": return /* @__PURE__ */ T(h, { className: "size-4" });
61
+ case "FREE_SHIPPING": return /* @__PURE__ */ T(_, { className: "size-4" });
62
+ default: return /* @__PURE__ */ T(x, { className: "size-4" });
62
63
  }
63
64
  };
64
65
  return /* @__PURE__ */ E("div", {
@@ -67,12 +68,12 @@ var O = () => {
67
68
  /* @__PURE__ */ E("div", {
68
69
  className: "flex items-center justify-between",
69
70
  children: [/* @__PURE__ */ T(t, {
70
- title: re("billing.coupons.title", "Coupons"),
71
+ title: ie("billing.coupons.title", "Coupons"),
71
72
  description: "Manage discount codes and promotional offers",
72
- icon: /* @__PURE__ */ T(S, { className: "size-6" })
73
+ icon: /* @__PURE__ */ T(x, { className: "size-6" })
73
74
  }), /* @__PURE__ */ E("button", {
74
75
  type: "button",
75
- onClick: () => k("/coupons/create"),
76
+ onClick: () => A("/coupons/create"),
76
77
  className: "inline-flex items-center gap-2 rounded-button bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text transition-colors duration-200 hover:bg-action-primary-bgHover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]",
77
78
  children: [/* @__PURE__ */ T(v, { className: "size-4" }), "Create Coupon"]
78
79
  })]
@@ -90,16 +91,16 @@ var O = () => {
90
91
  children: "Total Coupons"
91
92
  }), /* @__PURE__ */ T("span", {
92
93
  className: "flex size-9 items-center justify-center rounded-lg bg-[var(--color-accent-soft)]",
93
- children: /* @__PURE__ */ T(S, { className: "size-4 text-accent-blue" })
94
+ children: /* @__PURE__ */ T(x, { className: "size-4 text-accent-blue" })
94
95
  })]
95
96
  }),
96
97
  /* @__PURE__ */ T("p", {
97
98
  className: "text-2xl font-semibold text-text-primary tabular-nums",
98
- children: Z.totalCoupons
99
+ children: Q.totalCoupons
99
100
  }),
100
101
  /* @__PURE__ */ E("p", {
101
102
  className: "text-xs text-text-muted mt-1",
102
- children: [Z.activeCoupons, " active"]
103
+ children: [Q.activeCoupons, " active"]
103
104
  })
104
105
  ]
105
106
  }),
@@ -113,12 +114,12 @@ var O = () => {
113
114
  children: "Total Uses"
114
115
  }), /* @__PURE__ */ T("span", {
115
116
  className: "flex size-9 items-center justify-center rounded-lg bg-status-success-bg-subtle",
116
- children: /* @__PURE__ */ T(w, { className: "size-4 text-status-success-text" })
117
+ children: /* @__PURE__ */ T(C, { className: "size-4 text-status-success-text" })
117
118
  })]
118
119
  }),
119
120
  /* @__PURE__ */ T("p", {
120
121
  className: "text-2xl font-semibold text-text-primary tabular-nums",
121
- children: Z.totalUses
122
+ children: Q.totalUses
122
123
  }),
123
124
  /* @__PURE__ */ T("p", {
124
125
  className: "text-xs text-text-muted mt-1",
@@ -136,12 +137,12 @@ var O = () => {
136
137
  children: "Total Discount"
137
138
  }), /* @__PURE__ */ T("span", {
138
139
  className: "flex size-9 items-center justify-center rounded-lg bg-[var(--color-accent-soft)]",
139
- children: /* @__PURE__ */ T(p, { className: "size-4 text-accent-purple" })
140
+ children: /* @__PURE__ */ T(h, { className: "size-4 text-accent-purple" })
140
141
  })]
141
142
  }),
142
143
  /* @__PURE__ */ T("p", {
143
144
  className: "text-2xl font-semibold text-text-primary tabular-nums",
144
- children: Q(Z.totalDiscountValue)
145
+ children: $(Q.totalDiscountValue)
145
146
  }),
146
147
  /* @__PURE__ */ T("p", {
147
148
  className: "text-xs text-text-muted mt-1",
@@ -159,12 +160,12 @@ var O = () => {
159
160
  children: "Active Rate"
160
161
  }), /* @__PURE__ */ T("span", {
161
162
  className: "flex size-9 items-center justify-center rounded-lg bg-status-success-bg-subtle",
162
- children: /* @__PURE__ */ T(d, { className: "size-4 text-status-success-text" })
163
+ children: /* @__PURE__ */ T(f, { className: "size-4 text-status-success-text" })
163
164
  })]
164
165
  }),
165
166
  /* @__PURE__ */ E("p", {
166
167
  className: "text-2xl font-semibold text-text-primary tabular-nums",
167
- children: [Z.totalCoupons > 0 ? Math.round(Z.activeCoupons / Z.totalCoupons * 100) : 0, "%"]
168
+ children: [Q.totalCoupons > 0 ? Math.round(Q.activeCoupons / Q.totalCoupons * 100) : 0, "%"]
168
169
  }),
169
170
  /* @__PURE__ */ T("p", {
170
171
  className: "text-xs text-text-muted mt-1",
@@ -174,16 +175,16 @@ var O = () => {
174
175
  })
175
176
  ]
176
177
  }),
177
- H && /* @__PURE__ */ E("div", {
178
- className: H.tone === "success" ? "flex items-start gap-3 rounded-lg border border-status-success-border bg-status-success-bg-subtle p-4 text-status-success-text" : "flex items-start gap-3 rounded-lg border border-status-error-border bg-status-error-bg-subtle p-4 text-status-error-text",
178
+ U && /* @__PURE__ */ E("div", {
179
+ className: U.tone === "success" ? "flex items-start gap-3 rounded-lg border border-status-success-border bg-status-success-bg-subtle p-4 text-status-success-text" : "flex items-start gap-3 rounded-lg border border-status-error-border bg-status-error-bg-subtle p-4 text-status-error-text",
179
180
  role: "status",
180
181
  "aria-live": "polite",
181
- children: [H.tone === "success" ? /* @__PURE__ */ T(d, { className: "mt-0.5 size-4 shrink-0" }) : /* @__PURE__ */ T(u, { className: "mt-0.5 size-4 shrink-0" }), /* @__PURE__ */ T("p", {
182
+ children: [U.tone === "success" ? /* @__PURE__ */ T(f, { className: "mt-0.5 size-4 shrink-0" }) : /* @__PURE__ */ T(d, { className: "mt-0.5 size-4 shrink-0" }), /* @__PURE__ */ T("p", {
182
183
  className: "text-sm font-medium",
183
- children: H.message
184
+ children: U.message
184
185
  })]
185
186
  }),
186
- R && /* @__PURE__ */ T("div", {
187
+ z && /* @__PURE__ */ T("div", {
187
188
  className: "rounded-lg border border-status-error-border bg-status-error-bg-subtle p-4",
188
189
  children: /* @__PURE__ */ E("div", {
189
190
  className: "flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",
@@ -193,7 +194,7 @@ var O = () => {
193
194
  "Deactivate coupon ",
194
195
  /* @__PURE__ */ T("span", {
195
196
  className: "font-mono",
196
- children: R.code
197
+ children: z.code
197
198
  }),
198
199
  "?"
199
200
  ]
@@ -204,15 +205,15 @@ var O = () => {
204
205
  className: "flex gap-2 self-end sm:self-auto",
205
206
  children: [/* @__PURE__ */ T("button", {
206
207
  type: "button",
207
- onClick: () => z(null),
208
+ onClick: () => B(null),
208
209
  className: "rounded-button border border-border-subtle bg-bg-surface px-3 py-2 text-sm font-medium text-text-primary transition-colors hover:bg-bg-sunken",
209
210
  children: "Cancel"
210
211
  }), /* @__PURE__ */ T("button", {
211
212
  type: "button",
212
- onClick: () => fe(R.id),
213
- disabled: Y,
213
+ onClick: () => me(z.id),
214
+ disabled: X,
214
215
  className: "rounded-button bg-action-danger-bg px-3 py-2 text-sm font-medium text-action-danger-text transition-colors hover:bg-action-danger-bgHover disabled:cursor-not-allowed disabled:opacity-50",
215
- children: Y ? "Deactivating…" : "Deactivate"
216
+ children: X ? "Deactivating…" : "Deactivate"
216
217
  })]
217
218
  })]
218
219
  })
@@ -226,19 +227,19 @@ var O = () => {
226
227
  className: "md:col-span-2",
227
228
  children: /* @__PURE__ */ E("div", {
228
229
  className: "relative",
229
- children: [/* @__PURE__ */ T(x, { className: "absolute left-3 top-1/2 -translate-y-1/2 size-4 text-text-muted" }), /* @__PURE__ */ T("input", {
230
+ children: [/* @__PURE__ */ T(re, { className: "absolute left-3 top-1/2 -translate-y-1/2 size-4 text-text-muted" }), /* @__PURE__ */ T("input", {
230
231
  type: "text",
231
232
  placeholder: "Search coupons...",
232
- value: A,
233
- onChange: (e) => ae(e.target.value),
233
+ value: j,
234
+ onChange: (e) => oe(e.target.value),
234
235
  className: "w-full pl-10 pr-4 py-2 rounded-input border border-border-subtle bg-bg-surface text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]"
235
236
  })]
236
237
  })
237
238
  }),
238
239
  /* @__PURE__ */ E("select", {
239
- value: j,
240
+ value: M,
240
241
  onChange: (e) => {
241
- M(e.target.value), L(0);
242
+ N(e.target.value), R(0);
242
243
  },
243
244
  className: "px-4 py-2 rounded-input border border-border-subtle bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]",
244
245
  children: [
@@ -261,9 +262,9 @@ var O = () => {
261
262
  ]
262
263
  }),
263
264
  /* @__PURE__ */ E("select", {
264
- value: N,
265
+ value: P,
265
266
  onChange: (e) => {
266
- P(e.target.value), L(0);
267
+ F(e.target.value), R(0);
267
268
  },
268
269
  className: "px-4 py-2 rounded-input border border-border-subtle bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]",
269
270
  children: [
@@ -290,175 +291,136 @@ var O = () => {
290
291
  }),
291
292
  /* @__PURE__ */ T("div", {
292
293
  className: "bg-bg-surface border border-border-subtle rounded-card overflow-hidden shadow-[var(--shadow-elevation-1)]",
293
- children: /* @__PURE__ */ T("div", {
294
- className: "overflow-x-auto",
295
- children: /* @__PURE__ */ E("table", {
296
- className: "w-full",
297
- children: [/* @__PURE__ */ T("thead", {
298
- className: "sticky top-0 z-10 bg-bg-sunken border-b border-border-subtle",
299
- children: /* @__PURE__ */ E("tr", { children: [
300
- /* @__PURE__ */ T("th", {
301
- className: "text-left px-4 py-3 text-xs font-medium uppercase tracking-wide text-text-muted",
302
- children: "Code"
303
- }),
304
- /* @__PURE__ */ T("th", {
305
- className: "text-left px-4 py-3 text-xs font-medium uppercase tracking-wide text-text-muted",
306
- children: "Type"
307
- }),
308
- /* @__PURE__ */ T("th", {
309
- className: "text-left px-4 py-3 text-xs font-medium uppercase tracking-wide text-text-muted",
310
- children: "Value"
311
- }),
312
- /* @__PURE__ */ T("th", {
313
- className: "text-left px-4 py-3 text-xs font-medium uppercase tracking-wide text-text-muted",
314
- children: "Status"
315
- }),
316
- /* @__PURE__ */ T("th", {
317
- className: "text-left px-4 py-3 text-xs font-medium uppercase tracking-wide text-text-muted",
318
- children: "Usage"
319
- }),
320
- /* @__PURE__ */ T("th", {
321
- className: "text-left px-4 py-3 text-xs font-medium uppercase tracking-wide text-text-muted",
322
- children: "Valid Until"
323
- }),
324
- /* @__PURE__ */ T("th", {
325
- className: "text-right px-4 py-3 text-xs font-medium uppercase tracking-wide text-text-muted",
326
- children: "Actions"
294
+ children: K ? /* @__PURE__ */ T("div", {
295
+ className: "p-8 text-center text-text-muted",
296
+ children: "Loading coupons…"
297
+ }) : /* @__PURE__ */ T(O, {
298
+ columns: [
299
+ {
300
+ key: "code",
301
+ header: "Code",
302
+ priority: "primary",
303
+ cell: (e) => /* @__PURE__ */ E("div", { children: [/* @__PURE__ */ T("p", {
304
+ className: "font-medium text-text-primary font-mono",
305
+ children: e.code
306
+ }), /* @__PURE__ */ T("p", {
307
+ className: "text-sm text-text-muted",
308
+ children: e.name
309
+ })] })
310
+ },
311
+ {
312
+ key: "type",
313
+ header: "Type",
314
+ cell: (e) => /* @__PURE__ */ E("div", {
315
+ className: "flex items-center gap-2",
316
+ children: [pe(e.type), /* @__PURE__ */ T("span", {
317
+ className: "text-sm text-text-primary capitalize",
318
+ children: e.type.replace("_", " ").toLowerCase()
319
+ })]
320
+ })
321
+ },
322
+ {
323
+ key: "value",
324
+ header: "Value",
325
+ cell: (e) => /* @__PURE__ */ T("span", {
326
+ className: "text-sm font-medium text-text-primary tabular-nums",
327
+ children: e.type === "PERCENTAGE" ? `${e.value}%` : $(e.value)
328
+ })
329
+ },
330
+ {
331
+ key: "status",
332
+ header: "Status",
333
+ cell: (e) => /* @__PURE__ */ T("span", {
334
+ className: `inline-flex px-2 py-1 rounded-full text-xs font-medium ${fe(e.status)}`,
335
+ children: e.status
336
+ })
337
+ },
338
+ {
339
+ key: "usage",
340
+ header: "Usage",
341
+ cell: (e) => /* @__PURE__ */ E(w, { children: [/* @__PURE__ */ E("div", {
342
+ className: "text-sm text-text-primary tabular-nums",
343
+ children: [/* @__PURE__ */ T("span", {
344
+ className: "font-medium",
345
+ children: e.currentUses
346
+ }), e.maxTotalUses && /* @__PURE__ */ E("span", {
347
+ className: "text-text-muted",
348
+ children: [" / ", e.maxTotalUses]
349
+ })]
350
+ }), e.maxTotalUses && /* @__PURE__ */ T("div", {
351
+ className: "w-full bg-bg-sunken rounded-full h-1.5 mt-1",
352
+ children: /* @__PURE__ */ T("div", {
353
+ className: "bg-action-primary-bg h-1.5 rounded-full",
354
+ style: { width: `${Math.min(e.currentUses / e.maxTotalUses * 100, 100)}%` }
327
355
  })
328
- ] })
329
- }), /* @__PURE__ */ T("tbody", {
330
- className: "divide-y divide-border-subtle",
331
- children: G ? /* @__PURE__ */ T("tr", { children: /* @__PURE__ */ T("td", {
332
- colSpan: 7,
333
- className: "p-8 text-center text-text-muted",
334
- children: "Loading coupons…"
335
- }) }) : X.length === 0 ? /* @__PURE__ */ T("tr", { children: /* @__PURE__ */ T("td", {
336
- colSpan: 7,
337
- className: "p-8 text-center text-text-muted",
338
- children: "No coupons found"
339
- }) }) : X.map((e) => /* @__PURE__ */ E("tr", {
340
- className: "hover:bg-bg-sunken/50",
341
- children: [
342
- /* @__PURE__ */ T("td", {
343
- className: "p-4",
344
- children: /* @__PURE__ */ E("div", { children: [/* @__PURE__ */ T("p", {
345
- className: "font-medium text-text-primary font-mono",
346
- children: e.code
347
- }), /* @__PURE__ */ T("p", {
348
- className: "text-sm text-text-muted",
349
- children: e.name
350
- })] })
351
- }),
352
- /* @__PURE__ */ T("td", {
353
- className: "p-4",
354
- children: /* @__PURE__ */ E("div", {
355
- className: "flex items-center gap-2",
356
- children: [de(e.type), /* @__PURE__ */ T("span", {
357
- className: "text-sm text-text-primary capitalize",
358
- children: e.type.replace("_", " ").toLowerCase()
359
- })]
360
- })
361
- }),
362
- /* @__PURE__ */ T("td", {
363
- className: "p-4",
364
- children: /* @__PURE__ */ T("span", {
365
- className: "text-sm font-medium text-text-primary",
366
- children: e.type === "PERCENTAGE" ? `${e.value}%` : Q(e.value)
367
- })
368
- }),
369
- /* @__PURE__ */ T("td", {
370
- className: "p-4",
371
- children: /* @__PURE__ */ T("span", {
372
- className: `inline-flex px-2 py-1 rounded-full text-xs font-medium ${ue(e.status)}`,
373
- children: e.status
374
- })
375
- }),
376
- /* @__PURE__ */ E("td", {
377
- className: "p-4",
378
- children: [/* @__PURE__ */ E("div", {
379
- className: "text-sm text-text-primary",
380
- children: [/* @__PURE__ */ T("span", {
381
- className: "font-medium",
382
- children: e.currentUses
383
- }), e.maxTotalUses && /* @__PURE__ */ E("span", {
384
- className: "text-text-muted",
385
- children: [" / ", e.maxTotalUses]
386
- })]
387
- }), e.maxTotalUses && /* @__PURE__ */ T("div", {
388
- className: "w-full bg-bg-sunken rounded-full h-1.5 mt-1",
389
- children: /* @__PURE__ */ T("div", {
390
- className: "bg-action-primary-bg h-1.5 rounded-full",
391
- style: { width: `${Math.min(e.currentUses / e.maxTotalUses * 100, 100)}%` }
392
- })
393
- })]
394
- }),
395
- /* @__PURE__ */ T("td", {
396
- className: "p-4",
397
- children: /* @__PURE__ */ T("span", {
398
- className: "text-sm text-text-muted",
399
- children: e.validUntil ? $(e.validUntil) : "No expiry"
400
- })
401
- }),
402
- /* @__PURE__ */ T("td", {
403
- className: "p-4",
404
- children: /* @__PURE__ */ E("div", {
405
- className: "flex items-center justify-end gap-2",
406
- children: [
407
- /* @__PURE__ */ T("button", {
408
- type: "button",
409
- onClick: () => k(`/coupons/${e.id}`),
410
- className: "p-2 rounded-lg hover:bg-bg-sunken text-text-muted hover:text-text-primary",
411
- title: "View details",
412
- children: /* @__PURE__ */ T(h, { className: "size-4" })
413
- }),
414
- /* @__PURE__ */ T("button", {
415
- type: "button",
416
- onClick: () => k(`/coupons/${e.id}/edit`),
417
- className: "p-2 rounded-lg hover:bg-bg-sunken text-text-muted hover:text-text-primary",
418
- title: "Edit coupon",
419
- children: /* @__PURE__ */ T(m, { className: "size-4" })
420
- }),
421
- e.status === "ACTIVE" ? /* @__PURE__ */ T("button", {
422
- type: "button",
423
- onClick: () => z(e),
424
- disabled: Y || B === e.id,
425
- className: "p-2 rounded-lg hover:bg-status-error-bg-subtle text-text-muted hover:text-status-error-text disabled:opacity-50 disabled:cursor-not-allowed",
426
- title: "Deactivate coupon",
427
- children: /* @__PURE__ */ T(b, { className: "size-4" })
428
- }) : e.status === "INACTIVE" ? /* @__PURE__ */ T("button", {
429
- type: "button",
430
- onClick: () => pe(e.id, s.Active),
431
- disabled: B === e.id,
432
- className: "p-2 rounded-lg hover:bg-status-success-bg-subtle text-text-muted hover:text-status-success-text disabled:opacity-50 disabled:cursor-not-allowed",
433
- title: "Activate coupon",
434
- children: /* @__PURE__ */ T(y, { className: "size-4" })
435
- }) : /* @__PURE__ */ T("button", {
436
- type: "button",
437
- disabled: !0,
438
- className: "p-2 rounded-lg text-text-muted/40 cursor-not-allowed",
439
- title: `Cannot change status (${e.status.toLowerCase()})`,
440
- children: /* @__PURE__ */ T(C, { className: "size-4" })
441
- })
442
- ]
443
- })
444
- })
445
- ]
446
- }, e.id))
447
- })]
356
+ })] })
357
+ },
358
+ {
359
+ key: "validUntil",
360
+ header: "Valid Until",
361
+ priority: "hidden-on-mobile",
362
+ cell: (e) => /* @__PURE__ */ T("span", {
363
+ className: "text-sm text-text-muted",
364
+ children: e.validUntil ? de(e.validUntil) : "No expiry"
365
+ })
366
+ }
367
+ ],
368
+ data: Z,
369
+ rowKey: (e) => e.id,
370
+ rowActions: (e) => /* @__PURE__ */ E(w, { children: [
371
+ /* @__PURE__ */ T("button", {
372
+ type: "button",
373
+ onClick: () => A(`/coupons/${e.id}`),
374
+ className: "p-2 rounded-lg hover:bg-bg-sunken text-text-muted hover:text-text-primary",
375
+ title: "View details",
376
+ children: /* @__PURE__ */ T(g, { className: "size-4" })
377
+ }),
378
+ /* @__PURE__ */ T("button", {
379
+ type: "button",
380
+ onClick: () => A(`/coupons/${e.id}/edit`),
381
+ className: "p-2 rounded-lg hover:bg-bg-sunken text-text-muted hover:text-text-primary",
382
+ title: "Edit coupon",
383
+ children: /* @__PURE__ */ T(te, { className: "size-4" })
384
+ }),
385
+ e.status === "ACTIVE" ? /* @__PURE__ */ T("button", {
386
+ type: "button",
387
+ onClick: () => B(e),
388
+ disabled: X || V === e.id,
389
+ className: "p-2 rounded-lg hover:bg-status-error-bg-subtle text-text-muted hover:text-status-error-text disabled:opacity-50 disabled:cursor-not-allowed",
390
+ title: "Deactivate coupon",
391
+ children: /* @__PURE__ */ T(b, { className: "size-4" })
392
+ }) : e.status === "INACTIVE" ? /* @__PURE__ */ T("button", {
393
+ type: "button",
394
+ onClick: () => he(e.id, s.Active),
395
+ disabled: V === e.id,
396
+ className: "p-2 rounded-lg hover:bg-status-success-bg-subtle text-text-muted hover:text-status-success-text disabled:opacity-50 disabled:cursor-not-allowed",
397
+ title: "Activate coupon",
398
+ children: /* @__PURE__ */ T(y, { className: "size-4" })
399
+ }) : /* @__PURE__ */ T("button", {
400
+ type: "button",
401
+ disabled: !0,
402
+ className: "p-2 rounded-lg text-text-muted/40 cursor-not-allowed",
403
+ title: `Cannot change status (${e.status.toLowerCase()})`,
404
+ children: /* @__PURE__ */ T(S, { className: "size-4" })
405
+ })
406
+ ] }),
407
+ emptyState: /* @__PURE__ */ T("div", {
408
+ className: "p-8 text-center text-text-muted",
409
+ children: "No coupons found"
448
410
  })
449
411
  })
450
412
  }),
451
- J > 20 && /* @__PURE__ */ E("div", {
413
+ Y > 20 && /* @__PURE__ */ E("div", {
452
414
  className: "flex items-center justify-between px-2",
453
415
  children: [/* @__PURE__ */ E("p", {
454
416
  className: "text-sm text-text-muted",
455
417
  children: [
456
418
  "Showing ",
457
- I * 20 + 1,
419
+ L * 20 + 1,
458
420
  "–",
459
- Math.min((I + 1) * 20, J),
421
+ Math.min((L + 1) * 20, Y),
460
422
  " of ",
461
- J,
423
+ Y,
462
424
  " ",
463
425
  "coupons"
464
426
  ]
@@ -467,25 +429,25 @@ var O = () => {
467
429
  children: [
468
430
  /* @__PURE__ */ T("button", {
469
431
  type: "button",
470
- onClick: () => L((e) => Math.max(0, e - 1)),
471
- disabled: I === 0,
432
+ onClick: () => R((e) => Math.max(0, e - 1)),
433
+ disabled: L === 0,
472
434
  className: "p-2 rounded-lg border border-border-subtle hover:bg-bg-sunken disabled:opacity-40 disabled:cursor-not-allowed",
473
- children: /* @__PURE__ */ T(f, { className: "size-4" })
435
+ children: /* @__PURE__ */ T(p, { className: "size-4" })
474
436
  }),
475
437
  /* @__PURE__ */ E("span", {
476
438
  className: "text-sm text-text-primary font-medium",
477
439
  children: [
478
- I + 1,
440
+ L + 1,
479
441
  " / ",
480
- se
442
+ ce
481
443
  ]
482
444
  }),
483
445
  /* @__PURE__ */ T("button", {
484
446
  type: "button",
485
- onClick: () => L((e) => e + 1),
486
- disabled: !oe,
447
+ onClick: () => R((e) => e + 1),
448
+ disabled: !se,
487
449
  className: "p-2 rounded-lg border border-border-subtle hover:bg-bg-sunken disabled:opacity-40 disabled:cursor-not-allowed",
488
- children: /* @__PURE__ */ T(te, { className: "size-4" })
450
+ children: /* @__PURE__ */ T(m, { className: "size-4" })
489
451
  })
490
452
  ]
491
453
  })]
@@ -494,47 +456,47 @@ var O = () => {
494
456
  className: "flex justify-end",
495
457
  children: /* @__PURE__ */ E("button", {
496
458
  type: "button",
497
- onClick: me,
459
+ onClick: ge,
498
460
  className: "px-4 py-2 rounded-lg border border-border-subtle text-text-primary hover:bg-bg-sunken flex items-center gap-2",
499
- children: [/* @__PURE__ */ T(ne, { className: "size-4" }), "Export Coupons"]
461
+ children: [/* @__PURE__ */ T(ee, { className: "size-4" }), "Export Coupons"]
500
462
  })
501
463
  })
502
464
  ]
503
465
  });
504
- async function fe(e) {
466
+ async function me(e) {
505
467
  try {
506
- await ce({ variables: { id: e } }), await K(), z(null), U({
468
+ await le({ variables: { id: e } }), await q(), B(null), W({
507
469
  tone: "success",
508
470
  message: "Coupon deactivated successfully."
509
471
  });
510
472
  } catch (e) {
511
- console.error("Failed to deactivate coupon:", e), U({
473
+ console.error("Failed to deactivate coupon:", e), W({
512
474
  tone: "error",
513
475
  message: `Failed to deactivate coupon: ${e instanceof Error ? e.message : "Unknown error"}`
514
476
  });
515
477
  }
516
478
  }
517
- async function pe(e, t) {
518
- V(e);
479
+ async function he(e, t) {
480
+ H(e);
519
481
  try {
520
- await le({ variables: {
482
+ await ue({ variables: {
521
483
  id: e,
522
484
  input: { status: t }
523
- } }), await K(), U({
485
+ } }), await q(), W({
524
486
  tone: "success",
525
487
  message: `Coupon ${t === s.Active ? "activated" : "deactivated"} successfully.`
526
488
  });
527
489
  } catch (e) {
528
- console.error("Failed to update coupon status:", e), U({
490
+ console.error("Failed to update coupon status:", e), W({
529
491
  tone: "error",
530
492
  message: `Failed to update status: ${e instanceof Error ? e.message : "Unknown error"}`
531
493
  });
532
494
  } finally {
533
- V(null);
495
+ H(null);
534
496
  }
535
497
  }
536
- function me() {
537
- let e = X.map((e) => ({
498
+ function ge() {
499
+ let e = Z.map((e) => ({
538
500
  code: e.code,
539
501
  name: e.name,
540
502
  description: e.description ?? "",
@@ -546,20 +508,20 @@ var O = () => {
546
508
  validUntil: e.validUntil ?? ""
547
509
  }));
548
510
  if (e.length === 0) {
549
- U({
511
+ W({
550
512
  tone: "error",
551
513
  message: "There are no coupons to export for the current filters."
552
514
  });
553
515
  return;
554
516
  }
555
517
  let t = Object.keys(e[0]).join(","), n = e.map((e) => Object.values(e).map((e) => `"${String(e).replaceAll("\"", "\"\"")}"`).join(",")).join("\n"), r = new Blob([`${t}\n${n}`], { type: "text/csv;charset=utf-8" }), i = URL.createObjectURL(r), a = document.createElement("a");
556
- a.href = i, a.download = "billing-coupons.csv", a.click(), URL.revokeObjectURL(i), U({
518
+ a.href = i, a.download = "billing-coupons.csv", a.click(), URL.revokeObjectURL(i), W({
557
519
  tone: "success",
558
520
  message: `Exported ${e.length} coupon${e.length === 1 ? "" : "s"} to CSV.`
559
521
  });
560
522
  }
561
523
  };
562
524
  //#endregion
563
- export { O as CouponsListPage };
525
+ export { k as CouponsListPage };
564
526
 
565
527
  //# sourceMappingURL=CouponsListPage.js.map