@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.
- package/dist/billing/modules/billing/pages/RefundsPage.js +143 -149
- package/dist/billing/modules/billing/pages/RefundsPage.js.map +1 -1
- package/dist/billing/modules/billing/pages/TransactionsPage.js +232 -252
- package/dist/billing/modules/billing/pages/TransactionsPage.js.map +1 -1
- package/dist/billing/modules/coupons/pages/CouponsListPage.js +206 -244
- package/dist/billing/modules/coupons/pages/CouponsListPage.js.map +1 -1
- package/package.json +1 -1
|
@@ -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
|
|
9
|
-
import { AlertCircle as
|
|
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
|
|
14
|
-
let { t:
|
|
15
|
-
let n =
|
|
14
|
+
var k = () => {
|
|
15
|
+
let { t: k } = D(), ie = (e, t) => {
|
|
16
|
+
let n = k(e);
|
|
16
17
|
return n === e ? t : n;
|
|
17
|
-
},
|
|
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:
|
|
20
|
+
offset: L * 20,
|
|
20
21
|
filter: {
|
|
21
|
-
status:
|
|
22
|
-
type:
|
|
23
|
-
scope:
|
|
24
|
-
search:
|
|
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
|
-
} }),
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
33
|
-
|
|
32
|
+
M,
|
|
33
|
+
P,
|
|
34
|
+
I
|
|
34
35
|
]);
|
|
35
|
-
let
|
|
36
|
-
totalCoupons:
|
|
37
|
-
activeCoupons:
|
|
38
|
-
totalUses:
|
|
39
|
-
totalDiscountValue:
|
|
40
|
-
}), [
|
|
41
|
-
if (!
|
|
42
|
-
let
|
|
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),
|
|
46
|
+
}).format(e), de = (e) => new Date(e).toLocaleDateString("en-US", {
|
|
46
47
|
year: "numeric",
|
|
47
48
|
month: "short",
|
|
48
49
|
day: "numeric"
|
|
49
|
-
}),
|
|
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
|
-
},
|
|
57
|
+
}, pe = (e) => {
|
|
57
58
|
switch (e) {
|
|
58
|
-
case "PERCENTAGE": return /* @__PURE__ */ T(
|
|
59
|
-
case "FIXED_AMOUNT": return /* @__PURE__ */ T(
|
|
60
|
-
case "FREE_SHIPPING": return /* @__PURE__ */ T(
|
|
61
|
-
default: return /* @__PURE__ */ T(
|
|
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:
|
|
71
|
+
title: ie("billing.coupons.title", "Coupons"),
|
|
71
72
|
description: "Manage discount codes and promotional offers",
|
|
72
|
-
icon: /* @__PURE__ */ T(
|
|
73
|
+
icon: /* @__PURE__ */ T(x, { className: "size-6" })
|
|
73
74
|
}), /* @__PURE__ */ E("button", {
|
|
74
75
|
type: "button",
|
|
75
|
-
onClick: () =>
|
|
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(
|
|
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:
|
|
99
|
+
children: Q.totalCoupons
|
|
99
100
|
}),
|
|
100
101
|
/* @__PURE__ */ E("p", {
|
|
101
102
|
className: "text-xs text-text-muted mt-1",
|
|
102
|
-
children: [
|
|
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(
|
|
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:
|
|
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(
|
|
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
|
|
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(
|
|
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: [
|
|
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
|
-
|
|
178
|
-
className:
|
|
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: [
|
|
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:
|
|
184
|
+
children: U.message
|
|
184
185
|
})]
|
|
185
186
|
}),
|
|
186
|
-
|
|
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:
|
|
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: () =>
|
|
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: () =>
|
|
213
|
-
disabled:
|
|
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:
|
|
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(
|
|
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:
|
|
233
|
-
onChange: (e) =>
|
|
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:
|
|
240
|
+
value: M,
|
|
240
241
|
onChange: (e) => {
|
|
241
|
-
|
|
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:
|
|
265
|
+
value: P,
|
|
265
266
|
onChange: (e) => {
|
|
266
|
-
|
|
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: "
|
|
295
|
-
children:
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
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
|
-
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
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
|
-
|
|
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
|
-
|
|
419
|
+
L * 20 + 1,
|
|
458
420
|
"–",
|
|
459
|
-
Math.min((
|
|
421
|
+
Math.min((L + 1) * 20, Y),
|
|
460
422
|
" of ",
|
|
461
|
-
|
|
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: () =>
|
|
471
|
-
disabled:
|
|
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(
|
|
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
|
-
|
|
440
|
+
L + 1,
|
|
479
441
|
" / ",
|
|
480
|
-
|
|
442
|
+
ce
|
|
481
443
|
]
|
|
482
444
|
}),
|
|
483
445
|
/* @__PURE__ */ T("button", {
|
|
484
446
|
type: "button",
|
|
485
|
-
onClick: () =>
|
|
486
|
-
disabled: !
|
|
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(
|
|
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:
|
|
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(
|
|
461
|
+
children: [/* @__PURE__ */ T(ee, { className: "size-4" }), "Export Coupons"]
|
|
500
462
|
})
|
|
501
463
|
})
|
|
502
464
|
]
|
|
503
465
|
});
|
|
504
|
-
async function
|
|
466
|
+
async function me(e) {
|
|
505
467
|
try {
|
|
506
|
-
await
|
|
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),
|
|
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
|
|
518
|
-
|
|
479
|
+
async function he(e, t) {
|
|
480
|
+
H(e);
|
|
519
481
|
try {
|
|
520
|
-
await
|
|
482
|
+
await ue({ variables: {
|
|
521
483
|
id: e,
|
|
522
484
|
input: { status: t }
|
|
523
|
-
} }), await
|
|
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),
|
|
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
|
-
|
|
495
|
+
H(null);
|
|
534
496
|
}
|
|
535
497
|
}
|
|
536
|
-
function
|
|
537
|
-
let 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
|
-
|
|
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),
|
|
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 {
|
|
525
|
+
export { k as CouponsListPage };
|
|
564
526
|
|
|
565
527
|
//# sourceMappingURL=CouponsListPage.js.map
|