@burdenoff/microfe-billing 2026.916.1 → 2026.917.2
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/checkout/hooks/useCheckout.js +16 -13
- package/dist/billing/modules/checkout/hooks/useCheckout.js.map +1 -1
- package/dist/billing/modules/coupons/pages/CouponDetailPage.js +8 -0
- package/dist/billing/modules/coupons/pages/CouponDetailPage.js.map +1 -1
- package/dist/billing/modules/coupons/pages/CreateCouponPage.js +184 -116
- package/dist/billing/modules/coupons/pages/CreateCouponPage.js.map +1 -1
- package/dist/generated/global-operations.js +4 -0
- package/dist/generated/global-operations.js.map +1 -1
- package/dist/generated/global-types.js.map +1 -1
- package/package.json +1 -1
|
@@ -86,11 +86,24 @@ var y = [
|
|
|
86
86
|
symbol: "₩",
|
|
87
87
|
name: "South Korean Won"
|
|
88
88
|
}
|
|
89
|
-
], b = ()
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
], b = /* @__PURE__ */ "workspaces.bigconsole.botlit.fluidgrids.vibecontrols.healthybowl.adaptercloud.atheletebridge.coolandlovely.hookmovies.labsofscience.subscriberbot.artistrybase.assethandler.brainyrich.buildmyiq.collabkin.comradecircle.cosmicintersection.crewfoundry.ecoimpacthub.eventfullymanaged.ggnomad.govcitizenhub.headshotmarketing.housingvista.intelwatchtower.kadaikodi.manufacturedops.movethewheels.mybodyshield.planmagnet.proserviceworld.semanticfed.technospam.theculturepost.theglobalfuel.timecampus".split("."), x = [
|
|
90
|
+
{
|
|
91
|
+
value: "PLAN",
|
|
92
|
+
label: "Plan purchases"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
value: "ADD_ON",
|
|
96
|
+
label: "Add-on purchases"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
value: "STORE",
|
|
100
|
+
label: "Store purchases"
|
|
101
|
+
}
|
|
102
|
+
], S = () => {
|
|
103
|
+
let { t: S } = _(), C = (e, t) => {
|
|
104
|
+
let n = S(e);
|
|
92
105
|
return n === e ? t : n;
|
|
93
|
-
},
|
|
106
|
+
}, w = i(), T = n(), [E, D] = o(""), O = a(null), [k, A] = o({
|
|
94
107
|
code: "",
|
|
95
108
|
name: "",
|
|
96
109
|
description: "",
|
|
@@ -107,25 +120,31 @@ var y = [
|
|
|
107
120
|
restrictedToUserIds: [],
|
|
108
121
|
applicableProducts: [],
|
|
109
122
|
applicableServices: [],
|
|
123
|
+
applicableProductIds: [],
|
|
124
|
+
applicableEntityTypes: [],
|
|
110
125
|
campaignName: ""
|
|
111
|
-
}), [
|
|
112
|
-
if (!
|
|
113
|
-
let
|
|
114
|
-
|
|
126
|
+
}), [j, M] = o({}), [N, P] = o(!1), F = y.find((e) => e.code === k.currency)?.symbol ?? k.currency, [I] = r({ refetchQueries: ["ListCoupons"] });
|
|
127
|
+
if (!T.canManageDiscounts) return /* @__PURE__ */ h(e, { message: "You don't have permission to create coupons." });
|
|
128
|
+
let L = (e, t) => {
|
|
129
|
+
A((n) => ({
|
|
115
130
|
...n,
|
|
116
131
|
[e]: t
|
|
117
|
-
})),
|
|
132
|
+
})), j[e] && M((t) => {
|
|
118
133
|
let n = { ...t };
|
|
119
134
|
return delete n[e], n;
|
|
120
135
|
});
|
|
121
|
-
},
|
|
136
|
+
}, R = () => {
|
|
122
137
|
let e = {};
|
|
123
|
-
return
|
|
124
|
-
},
|
|
138
|
+
return k.code.trim() ? /^[A-Z0-9-_]+$/.test(k.code) ? k.code.length < 3 ? e.code = "Code must be at least 3 characters" : k.code.length > 50 && (e.code = "Code must be at most 50 characters") : e.code = "Code must contain only uppercase letters, numbers, hyphens, and underscores" : e.code = "Coupon code is required", k.name.trim() || (e.name = "Coupon name is required"), k.value <= 0 && (e.value = "Value must be greater than 0"), k.type === "PERCENTAGE" && k.value > 100 && (e.value = "Percentage cannot exceed 100%"), k.scope === "USER_SPECIFIC" && k.restrictedToUserIds.length === 0 && (e.restrictedToUserIds = "Add at least one user email or ID"), k.validFrom || (e.validFrom = "Start date is required"), k.validUntil && k.validUntil < k.validFrom && (e.validUntil = "End date must be after start date"), M(e), Object.keys(e).length === 0;
|
|
139
|
+
}, z = (e) => {
|
|
125
140
|
let t = e.trim();
|
|
126
|
-
t && (
|
|
127
|
-
},
|
|
128
|
-
|
|
141
|
+
t && (k.restrictedToUserIds.includes(t) || L("restrictedToUserIds", [...k.restrictedToUserIds, t]), D(""));
|
|
142
|
+
}, B = (e) => {
|
|
143
|
+
L("restrictedToUserIds", k.restrictedToUserIds.filter((t) => t !== e));
|
|
144
|
+
}, V = (e) => {
|
|
145
|
+
L("applicableProductIds", k.applicableProductIds.includes(e) ? k.applicableProductIds.filter((t) => t !== e) : [...k.applicableProductIds, e]);
|
|
146
|
+
}, H = (e) => {
|
|
147
|
+
L("applicableEntityTypes", k.applicableEntityTypes.includes(e) ? k.applicableEntityTypes.filter((t) => t !== e) : [...k.applicableEntityTypes, e]);
|
|
129
148
|
};
|
|
130
149
|
return /* @__PURE__ */ g("div", {
|
|
131
150
|
className: "max-w-4xl mx-auto p-4 sm:p-6 space-y-6",
|
|
@@ -134,47 +153,49 @@ var y = [
|
|
|
134
153
|
className: "flex items-center gap-4",
|
|
135
154
|
children: [/* @__PURE__ */ h("button", {
|
|
136
155
|
type: "button",
|
|
137
|
-
onClick: () =>
|
|
156
|
+
onClick: () => w("/coupons"),
|
|
138
157
|
className: "p-2 rounded-lg hover:bg-bg-sunken text-text-muted hover:text-text-primary",
|
|
139
158
|
children: /* @__PURE__ */ h(s, { className: "size-5" })
|
|
140
159
|
}), /* @__PURE__ */ h(t, {
|
|
141
|
-
title:
|
|
160
|
+
title: C("billing.coupons.createTitle", "Create Coupon"),
|
|
142
161
|
description: "Create a new discount code or promotional offer",
|
|
143
162
|
icon: /* @__PURE__ */ h(d, { className: "size-6" })
|
|
144
163
|
})]
|
|
145
164
|
}),
|
|
146
|
-
/* @__PURE__ */ h(v, { children:
|
|
165
|
+
/* @__PURE__ */ h(v, { children: C("billing.coupons.createPurpose", "Define a new discount code customers can redeem at checkout. Choose whether it takes a percentage or fixed amount off, set any usage limit and expiry, and pick which products it applies to.") }),
|
|
147
166
|
/* @__PURE__ */ g("form", {
|
|
148
167
|
onSubmit: async (e) => {
|
|
149
|
-
if (e.preventDefault(),
|
|
150
|
-
|
|
168
|
+
if (e.preventDefault(), R()) {
|
|
169
|
+
P(!0);
|
|
151
170
|
try {
|
|
152
|
-
if ((await
|
|
153
|
-
code:
|
|
154
|
-
name:
|
|
155
|
-
description:
|
|
156
|
-
scope:
|
|
157
|
-
type:
|
|
158
|
-
value:
|
|
159
|
-
currency:
|
|
160
|
-
minPurchaseAmount:
|
|
161
|
-
maxDiscountAmount:
|
|
162
|
-
maxTotalUses:
|
|
163
|
-
maxUsesPerUser:
|
|
164
|
-
validFrom: new Date(
|
|
165
|
-
validUntil:
|
|
166
|
-
restrictedToUserIds:
|
|
167
|
-
applicableProducts:
|
|
168
|
-
applicableServices:
|
|
171
|
+
if ((await I({ variables: { input: {
|
|
172
|
+
code: k.code,
|
|
173
|
+
name: k.name,
|
|
174
|
+
description: k.description,
|
|
175
|
+
scope: k.scope,
|
|
176
|
+
type: k.type,
|
|
177
|
+
value: k.value,
|
|
178
|
+
currency: k.currency,
|
|
179
|
+
minPurchaseAmount: k.minPurchaseAmount,
|
|
180
|
+
maxDiscountAmount: k.maxDiscountAmount,
|
|
181
|
+
maxTotalUses: k.maxTotalUses,
|
|
182
|
+
maxUsesPerUser: k.maxUsesPerUser,
|
|
183
|
+
validFrom: new Date(k.validFrom).toISOString(),
|
|
184
|
+
validUntil: k.validUntil ? new Date(k.validUntil).toISOString() : void 0,
|
|
185
|
+
restrictedToUserIds: k.restrictedToUserIds,
|
|
186
|
+
applicableProducts: k.applicableProducts,
|
|
187
|
+
applicableServices: k.applicableServices,
|
|
188
|
+
applicableProductIds: k.applicableProductIds,
|
|
189
|
+
applicableEntityTypes: k.applicableEntityTypes,
|
|
169
190
|
excludedProducts: [],
|
|
170
191
|
excludedServices: [],
|
|
171
|
-
campaignName:
|
|
172
|
-
} } })).data?.createCoupon)
|
|
192
|
+
campaignName: k.campaignName || void 0
|
|
193
|
+
} } })).data?.createCoupon) w("/coupons");
|
|
173
194
|
else throw Error("Failed to create coupon");
|
|
174
195
|
} catch (e) {
|
|
175
|
-
console.error("Error creating coupon:", e),
|
|
196
|
+
console.error("Error creating coupon:", e), M({ code: e instanceof Error ? e.message : "Failed to create coupon. Please try again." });
|
|
176
197
|
} finally {
|
|
177
|
-
|
|
198
|
+
P(!1);
|
|
178
199
|
}
|
|
179
200
|
}
|
|
180
201
|
},
|
|
@@ -194,14 +215,14 @@ var y = [
|
|
|
194
215
|
}),
|
|
195
216
|
/* @__PURE__ */ h("input", {
|
|
196
217
|
type: "text",
|
|
197
|
-
value:
|
|
198
|
-
onChange: (e) =>
|
|
218
|
+
value: k.code,
|
|
219
|
+
onChange: (e) => L("code", e.target.value.toUpperCase()),
|
|
199
220
|
placeholder: "e.g., WELCOME20",
|
|
200
|
-
className: `w-full px-4 py-2 rounded-input border ${
|
|
221
|
+
className: `w-full px-4 py-2 rounded-input border ${j.code ? "border-status-error-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)]`
|
|
201
222
|
}),
|
|
202
|
-
|
|
223
|
+
j.code && /* @__PURE__ */ h("p", {
|
|
203
224
|
className: "text-sm text-status-error-text mt-1",
|
|
204
|
-
children:
|
|
225
|
+
children: j.code
|
|
205
226
|
}),
|
|
206
227
|
/* @__PURE__ */ h("p", {
|
|
207
228
|
className: "text-xs text-text-muted mt-1",
|
|
@@ -215,22 +236,22 @@ var y = [
|
|
|
215
236
|
}),
|
|
216
237
|
/* @__PURE__ */ h("input", {
|
|
217
238
|
type: "text",
|
|
218
|
-
value:
|
|
219
|
-
onChange: (e) =>
|
|
239
|
+
value: k.name,
|
|
240
|
+
onChange: (e) => L("name", e.target.value),
|
|
220
241
|
placeholder: "e.g., Welcome 20% Off",
|
|
221
|
-
className: `w-full px-4 py-2 rounded-input border ${
|
|
242
|
+
className: `w-full px-4 py-2 rounded-input border ${j.name ? "border-status-error-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)]`
|
|
222
243
|
}),
|
|
223
|
-
|
|
244
|
+
j.name && /* @__PURE__ */ h("p", {
|
|
224
245
|
className: "text-sm text-status-error-text mt-1",
|
|
225
|
-
children:
|
|
246
|
+
children: j.name
|
|
226
247
|
})
|
|
227
248
|
] }),
|
|
228
249
|
/* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h("label", {
|
|
229
250
|
className: "block text-sm font-medium text-text-primary mb-1",
|
|
230
251
|
children: "Description"
|
|
231
252
|
}), /* @__PURE__ */ h("textarea", {
|
|
232
|
-
value:
|
|
233
|
-
onChange: (e) =>
|
|
253
|
+
value: k.description,
|
|
254
|
+
onChange: (e) => L("description", e.target.value),
|
|
234
255
|
placeholder: "Optional description for internal use",
|
|
235
256
|
rows: 3,
|
|
236
257
|
className: "w-full px-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)]"
|
|
@@ -250,8 +271,8 @@ var y = [
|
|
|
250
271
|
children: "Coupon Currency *"
|
|
251
272
|
}),
|
|
252
273
|
/* @__PURE__ */ h("select", {
|
|
253
|
-
value:
|
|
254
|
-
onChange: (e) =>
|
|
274
|
+
value: k.currency,
|
|
275
|
+
onChange: (e) => L("currency", e.target.value),
|
|
255
276
|
className: "w-full 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)]",
|
|
256
277
|
children: y.map(({ code: e, symbol: t, name: n }) => /* @__PURE__ */ g("option", {
|
|
257
278
|
value: e,
|
|
@@ -282,7 +303,7 @@ var y = [
|
|
|
282
303
|
},
|
|
283
304
|
{
|
|
284
305
|
value: "FIXED_AMOUNT",
|
|
285
|
-
label: `Fixed (${
|
|
306
|
+
label: `Fixed (${F})`,
|
|
286
307
|
icon: null
|
|
287
308
|
},
|
|
288
309
|
{
|
|
@@ -292,11 +313,11 @@ var y = [
|
|
|
292
313
|
}
|
|
293
314
|
].map(({ value: e, label: t, icon: n }) => /* @__PURE__ */ g("button", {
|
|
294
315
|
type: "button",
|
|
295
|
-
onClick: () =>
|
|
296
|
-
className: `p-4 rounded-lg border-2 transition-colors ${
|
|
316
|
+
onClick: () => L("type", e),
|
|
317
|
+
className: `p-4 rounded-lg border-2 transition-colors ${k.type === e ? "border-action-primary-bg bg-[var(--color-accent-soft)]" : "border-border-subtle hover:border-action-primary-bg/50"}`,
|
|
297
318
|
children: [n ? /* @__PURE__ */ h(n, { className: "size-5 mx-auto mb-2" }) : /* @__PURE__ */ h("span", {
|
|
298
319
|
className: "block text-lg font-bold mb-2",
|
|
299
|
-
children:
|
|
320
|
+
children: F
|
|
300
321
|
}), /* @__PURE__ */ h("p", {
|
|
301
322
|
className: "text-sm font-medium",
|
|
302
323
|
children: t
|
|
@@ -310,29 +331,29 @@ var y = [
|
|
|
310
331
|
}),
|
|
311
332
|
/* @__PURE__ */ h("div", {
|
|
312
333
|
className: "relative",
|
|
313
|
-
children:
|
|
334
|
+
children: k.type === "PERCENTAGE" ? /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h(l, { className: "absolute left-3 top-1/2 -translate-y-1/2 size-4 text-text-muted" }), /* @__PURE__ */ h("input", {
|
|
314
335
|
type: "number",
|
|
315
|
-
value:
|
|
316
|
-
onChange: (e) =>
|
|
336
|
+
value: k.value,
|
|
337
|
+
onChange: (e) => L("value", parseFloat(e.target.value)),
|
|
317
338
|
min: "0",
|
|
318
339
|
max: "100",
|
|
319
340
|
step: "0.01",
|
|
320
|
-
className: `w-full pl-10 pr-4 py-2 rounded-input border ${
|
|
341
|
+
className: `w-full pl-10 pr-4 py-2 rounded-input border ${j.value ? "border-status-error-border" : "border-border-subtle"} bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]`
|
|
321
342
|
})] }) : /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("span", {
|
|
322
343
|
className: "absolute left-3 top-1/2 -translate-y-1/2 text-sm text-text-muted font-medium",
|
|
323
|
-
children:
|
|
344
|
+
children: F
|
|
324
345
|
}), /* @__PURE__ */ h("input", {
|
|
325
346
|
type: "number",
|
|
326
|
-
value:
|
|
327
|
-
onChange: (e) =>
|
|
347
|
+
value: k.value,
|
|
348
|
+
onChange: (e) => L("value", parseFloat(e.target.value)),
|
|
328
349
|
min: "0",
|
|
329
350
|
step: "0.01",
|
|
330
|
-
className: `w-full pl-10 pr-4 py-2 rounded-input border ${
|
|
351
|
+
className: `w-full pl-10 pr-4 py-2 rounded-input border ${j.value ? "border-status-error-border" : "border-border-subtle"} bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]`
|
|
331
352
|
})] })
|
|
332
353
|
}),
|
|
333
|
-
|
|
354
|
+
j.value && /* @__PURE__ */ h("p", {
|
|
334
355
|
className: "text-sm text-status-error-text mt-1",
|
|
335
|
-
children:
|
|
356
|
+
children: j.value
|
|
336
357
|
})
|
|
337
358
|
] }),
|
|
338
359
|
/* @__PURE__ */ g("div", { children: [
|
|
@@ -340,7 +361,7 @@ var y = [
|
|
|
340
361
|
className: "block text-sm font-medium text-text-primary mb-1",
|
|
341
362
|
children: [
|
|
342
363
|
"Minimum Purchase Amount (",
|
|
343
|
-
|
|
364
|
+
k.currency,
|
|
344
365
|
")"
|
|
345
366
|
]
|
|
346
367
|
}),
|
|
@@ -348,11 +369,11 @@ var y = [
|
|
|
348
369
|
className: "relative",
|
|
349
370
|
children: [/* @__PURE__ */ h("span", {
|
|
350
371
|
className: "absolute left-3 top-1/2 -translate-y-1/2 text-sm text-text-muted font-medium",
|
|
351
|
-
children:
|
|
372
|
+
children: F
|
|
352
373
|
}), /* @__PURE__ */ h("input", {
|
|
353
374
|
type: "number",
|
|
354
|
-
value:
|
|
355
|
-
onChange: (e) =>
|
|
375
|
+
value: k.minPurchaseAmount || "",
|
|
376
|
+
onChange: (e) => L("minPurchaseAmount", e.target.value ? parseFloat(e.target.value) : null),
|
|
356
377
|
min: "0",
|
|
357
378
|
step: "0.01",
|
|
358
379
|
placeholder: "No minimum",
|
|
@@ -363,17 +384,17 @@ var y = [
|
|
|
363
384
|
className: "text-xs text-text-muted mt-1",
|
|
364
385
|
children: [
|
|
365
386
|
"Order must be at least this amount in ",
|
|
366
|
-
|
|
387
|
+
k.currency,
|
|
367
388
|
" (auto-converted for other currencies)"
|
|
368
389
|
]
|
|
369
390
|
})
|
|
370
391
|
] }),
|
|
371
|
-
|
|
392
|
+
k.type === "PERCENTAGE" && /* @__PURE__ */ g("div", { children: [
|
|
372
393
|
/* @__PURE__ */ g("label", {
|
|
373
394
|
className: "block text-sm font-medium text-text-primary mb-1",
|
|
374
395
|
children: [
|
|
375
396
|
"Maximum Discount Amount (",
|
|
376
|
-
|
|
397
|
+
k.currency,
|
|
377
398
|
")"
|
|
378
399
|
]
|
|
379
400
|
}),
|
|
@@ -381,11 +402,11 @@ var y = [
|
|
|
381
402
|
className: "relative",
|
|
382
403
|
children: [/* @__PURE__ */ h("span", {
|
|
383
404
|
className: "absolute left-3 top-1/2 -translate-y-1/2 text-sm text-text-muted font-medium",
|
|
384
|
-
children:
|
|
405
|
+
children: F
|
|
385
406
|
}), /* @__PURE__ */ h("input", {
|
|
386
407
|
type: "number",
|
|
387
|
-
value:
|
|
388
|
-
onChange: (e) =>
|
|
408
|
+
value: k.maxDiscountAmount || "",
|
|
409
|
+
onChange: (e) => L("maxDiscountAmount", e.target.value ? parseFloat(e.target.value) : null),
|
|
389
410
|
min: "0",
|
|
390
411
|
step: "0.01",
|
|
391
412
|
placeholder: "No maximum",
|
|
@@ -396,7 +417,7 @@ var y = [
|
|
|
396
417
|
className: "text-xs text-text-muted mt-1",
|
|
397
418
|
children: [
|
|
398
419
|
"Cap the discount in ",
|
|
399
|
-
|
|
420
|
+
k.currency,
|
|
400
421
|
" — auto-converted to the user's payment currency"
|
|
401
422
|
]
|
|
402
423
|
})
|
|
@@ -417,8 +438,8 @@ var y = [
|
|
|
417
438
|
}),
|
|
418
439
|
/* @__PURE__ */ h("input", {
|
|
419
440
|
type: "number",
|
|
420
|
-
value:
|
|
421
|
-
onChange: (e) =>
|
|
441
|
+
value: k.maxTotalUses || "",
|
|
442
|
+
onChange: (e) => L("maxTotalUses", e.target.value ? parseInt(e.target.value) : null),
|
|
422
443
|
min: "1",
|
|
423
444
|
placeholder: "Unlimited",
|
|
424
445
|
className: "w-full px-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)]"
|
|
@@ -435,8 +456,8 @@ var y = [
|
|
|
435
456
|
}),
|
|
436
457
|
/* @__PURE__ */ h("input", {
|
|
437
458
|
type: "number",
|
|
438
|
-
value:
|
|
439
|
-
onChange: (e) =>
|
|
459
|
+
value: k.maxUsesPerUser,
|
|
460
|
+
onChange: (e) => L("maxUsesPerUser", parseInt(e.target.value)),
|
|
440
461
|
min: "1",
|
|
441
462
|
className: "w-full 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)]"
|
|
442
463
|
}),
|
|
@@ -461,13 +482,13 @@ var y = [
|
|
|
461
482
|
}),
|
|
462
483
|
/* @__PURE__ */ h("input", {
|
|
463
484
|
type: "date",
|
|
464
|
-
value:
|
|
465
|
-
onChange: (e) =>
|
|
466
|
-
className: `w-full px-4 py-2 rounded-input border ${
|
|
485
|
+
value: k.validFrom,
|
|
486
|
+
onChange: (e) => L("validFrom", e.target.value),
|
|
487
|
+
className: `w-full px-4 py-2 rounded-input border ${j.validFrom ? "border-status-error-border" : "border-border-subtle"} bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]`
|
|
467
488
|
}),
|
|
468
|
-
|
|
489
|
+
j.validFrom && /* @__PURE__ */ h("p", {
|
|
469
490
|
className: "text-sm text-status-error-text mt-1",
|
|
470
|
-
children:
|
|
491
|
+
children: j.validFrom
|
|
471
492
|
})
|
|
472
493
|
] }), /* @__PURE__ */ g("div", { children: [
|
|
473
494
|
/* @__PURE__ */ h("label", {
|
|
@@ -476,13 +497,13 @@ var y = [
|
|
|
476
497
|
}),
|
|
477
498
|
/* @__PURE__ */ h("input", {
|
|
478
499
|
type: "date",
|
|
479
|
-
value:
|
|
480
|
-
onChange: (e) =>
|
|
481
|
-
className: `w-full px-4 py-2 rounded-input border ${
|
|
500
|
+
value: k.validUntil,
|
|
501
|
+
onChange: (e) => L("validUntil", e.target.value),
|
|
502
|
+
className: `w-full px-4 py-2 rounded-input border ${j.validUntil ? "border-status-error-border" : "border-border-subtle"} bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]`
|
|
482
503
|
}),
|
|
483
|
-
|
|
504
|
+
j.validUntil && /* @__PURE__ */ h("p", {
|
|
484
505
|
className: "text-sm text-status-error-text mt-1",
|
|
485
|
-
children:
|
|
506
|
+
children: j.validUntil
|
|
486
507
|
}),
|
|
487
508
|
/* @__PURE__ */ h("p", {
|
|
488
509
|
className: "text-xs text-text-muted mt-1",
|
|
@@ -491,6 +512,53 @@ var y = [
|
|
|
491
512
|
] })]
|
|
492
513
|
})]
|
|
493
514
|
}),
|
|
515
|
+
/* @__PURE__ */ g("div", {
|
|
516
|
+
className: "bg-bg-surface border border-border-subtle rounded-lg p-6 space-y-4",
|
|
517
|
+
children: [
|
|
518
|
+
/* @__PURE__ */ h("h3", {
|
|
519
|
+
className: "text-lg font-semibold text-text-primary",
|
|
520
|
+
children: "Applicability"
|
|
521
|
+
}),
|
|
522
|
+
/* @__PURE__ */ g("div", { children: [
|
|
523
|
+
/* @__PURE__ */ h("label", {
|
|
524
|
+
className: "block text-sm font-medium text-text-primary mb-2",
|
|
525
|
+
children: "Applicable Products"
|
|
526
|
+
}),
|
|
527
|
+
/* @__PURE__ */ h("div", {
|
|
528
|
+
className: "flex flex-wrap gap-2",
|
|
529
|
+
children: b.map((e) => /* @__PURE__ */ h("button", {
|
|
530
|
+
type: "button",
|
|
531
|
+
onClick: () => V(e),
|
|
532
|
+
className: `px-3 py-1.5 rounded-lg border text-sm transition-colors ${k.applicableProductIds.includes(e) ? "border-action-primary-bg bg-[var(--color-accent-soft)] text-text-link font-medium" : "border-border-subtle hover:border-action-primary-bg/50"}`,
|
|
533
|
+
children: e
|
|
534
|
+
}, e))
|
|
535
|
+
}),
|
|
536
|
+
/* @__PURE__ */ h("p", {
|
|
537
|
+
className: "text-xs text-text-muted mt-1",
|
|
538
|
+
children: k.applicableProductIds.length === 0 ? "No selection = applies to all products" : `Applies to: ${k.applicableProductIds.join(", ")}`
|
|
539
|
+
})
|
|
540
|
+
] }),
|
|
541
|
+
/* @__PURE__ */ g("div", { children: [
|
|
542
|
+
/* @__PURE__ */ h("label", {
|
|
543
|
+
className: "block text-sm font-medium text-text-primary mb-2",
|
|
544
|
+
children: "Applicable Purchase Types"
|
|
545
|
+
}),
|
|
546
|
+
/* @__PURE__ */ h("div", {
|
|
547
|
+
className: "flex flex-wrap gap-2",
|
|
548
|
+
children: x.map(({ value: e, label: t }) => /* @__PURE__ */ h("button", {
|
|
549
|
+
type: "button",
|
|
550
|
+
onClick: () => H(e),
|
|
551
|
+
className: `px-3 py-1.5 rounded-lg border text-sm transition-colors ${k.applicableEntityTypes.includes(e) ? "border-action-primary-bg bg-[var(--color-accent-soft)] text-text-link font-medium" : "border-border-subtle hover:border-action-primary-bg/50"}`,
|
|
552
|
+
children: t
|
|
553
|
+
}, e))
|
|
554
|
+
}),
|
|
555
|
+
/* @__PURE__ */ h("p", {
|
|
556
|
+
className: "text-xs text-text-muted mt-1",
|
|
557
|
+
children: k.applicableEntityTypes.length === 0 ? "No selection = applies to plan, add-on, and store purchases" : `Applies to: ${k.applicableEntityTypes.join(", ")}`
|
|
558
|
+
})
|
|
559
|
+
] })
|
|
560
|
+
]
|
|
561
|
+
}),
|
|
494
562
|
/* @__PURE__ */ g("div", {
|
|
495
563
|
className: "bg-bg-surface border border-border-subtle rounded-lg p-6 space-y-4",
|
|
496
564
|
children: [
|
|
@@ -502,8 +570,8 @@ var y = [
|
|
|
502
570
|
className: "block text-sm font-medium text-text-primary mb-2",
|
|
503
571
|
children: "Who can use this coupon? *"
|
|
504
572
|
}), /* @__PURE__ */ g("select", {
|
|
505
|
-
value:
|
|
506
|
-
onChange: (e) =>
|
|
573
|
+
value: k.scope,
|
|
574
|
+
onChange: (e) => L("scope", e.target.value),
|
|
507
575
|
className: "w-full 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)]",
|
|
508
576
|
children: [
|
|
509
577
|
/* @__PURE__ */ h("option", {
|
|
@@ -524,17 +592,17 @@ var y = [
|
|
|
524
592
|
})
|
|
525
593
|
]
|
|
526
594
|
})] }),
|
|
527
|
-
|
|
595
|
+
k.scope === "CAMPAIGN" && /* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h("label", {
|
|
528
596
|
className: "block text-sm font-medium text-text-primary mb-1",
|
|
529
597
|
children: "Campaign Name"
|
|
530
598
|
}), /* @__PURE__ */ h("input", {
|
|
531
599
|
type: "text",
|
|
532
|
-
value:
|
|
533
|
-
onChange: (e) =>
|
|
600
|
+
value: k.campaignName,
|
|
601
|
+
onChange: (e) => L("campaignName", e.target.value),
|
|
534
602
|
placeholder: "e.g., Summer Sale 2024",
|
|
535
603
|
className: "w-full px-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)]"
|
|
536
604
|
})] }),
|
|
537
|
-
|
|
605
|
+
k.scope === "USER_SPECIFIC" && /* @__PURE__ */ g("div", { children: [
|
|
538
606
|
/* @__PURE__ */ h("label", {
|
|
539
607
|
className: "block text-sm font-medium text-text-primary mb-1",
|
|
540
608
|
children: /* @__PURE__ */ g("span", {
|
|
@@ -543,34 +611,34 @@ var y = [
|
|
|
543
611
|
})
|
|
544
612
|
}),
|
|
545
613
|
/* @__PURE__ */ g("div", {
|
|
546
|
-
className: `min-h-[42px] flex flex-wrap gap-2 px-3 py-2 rounded-lg border ${
|
|
547
|
-
onClick: () =>
|
|
548
|
-
children: [
|
|
614
|
+
className: `min-h-[42px] flex flex-wrap gap-2 px-3 py-2 rounded-lg border ${j.restrictedToUserIds ? "border-status-error-border" : "border-border-subtle"} bg-bg-surface cursor-text`,
|
|
615
|
+
onClick: () => O.current?.focus(),
|
|
616
|
+
children: [k.restrictedToUserIds.map((e) => /* @__PURE__ */ g("span", {
|
|
549
617
|
className: "inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-[var(--color-accent-soft)] text-text-link text-sm font-medium",
|
|
550
618
|
children: [e, /* @__PURE__ */ h("button", {
|
|
551
619
|
type: "button",
|
|
552
620
|
onClick: (t) => {
|
|
553
|
-
t.stopPropagation(),
|
|
621
|
+
t.stopPropagation(), B(e);
|
|
554
622
|
},
|
|
555
623
|
className: "hover:text-status-error-text",
|
|
556
624
|
children: /* @__PURE__ */ h(p, { className: "size-3" })
|
|
557
625
|
})]
|
|
558
626
|
}, e)), /* @__PURE__ */ h("input", {
|
|
559
|
-
ref:
|
|
627
|
+
ref: O,
|
|
560
628
|
type: "text",
|
|
561
|
-
value:
|
|
562
|
-
onChange: (e) =>
|
|
629
|
+
value: E,
|
|
630
|
+
onChange: (e) => D(e.target.value),
|
|
563
631
|
onKeyDown: (e) => {
|
|
564
|
-
e.key === "Enter" || e.key === "," ? (e.preventDefault(),
|
|
632
|
+
e.key === "Enter" || e.key === "," ? (e.preventDefault(), z(E)) : e.key === "Backspace" && !E && k.restrictedToUserIds.length > 0 && B(k.restrictedToUserIds[k.restrictedToUserIds.length - 1]);
|
|
565
633
|
},
|
|
566
|
-
onBlur: () =>
|
|
567
|
-
placeholder:
|
|
634
|
+
onBlur: () => z(E),
|
|
635
|
+
placeholder: k.restrictedToUserIds.length === 0 ? "Enter user email or ID, press Enter to add" : "Add another…",
|
|
568
636
|
className: "flex-1 min-w-[200px] bg-transparent text-text-primary placeholder:text-text-muted text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]"
|
|
569
637
|
})]
|
|
570
638
|
}),
|
|
571
|
-
|
|
639
|
+
j.restrictedToUserIds && /* @__PURE__ */ h("p", {
|
|
572
640
|
className: "text-sm text-status-error-text mt-1",
|
|
573
|
-
children:
|
|
641
|
+
children: j.restrictedToUserIds
|
|
574
642
|
}),
|
|
575
643
|
/* @__PURE__ */ h("p", {
|
|
576
644
|
className: "text-xs text-text-muted mt-1",
|
|
@@ -583,14 +651,14 @@ var y = [
|
|
|
583
651
|
className: "flex items-center justify-end gap-3",
|
|
584
652
|
children: [/* @__PURE__ */ h("button", {
|
|
585
653
|
type: "button",
|
|
586
|
-
onClick: () =>
|
|
654
|
+
onClick: () => w("/coupons"),
|
|
587
655
|
className: "px-6 py-3 rounded-lg border border-border-subtle text-text-primary hover:bg-bg-sunken",
|
|
588
656
|
children: "Cancel"
|
|
589
657
|
}), /* @__PURE__ */ h("button", {
|
|
590
658
|
type: "submit",
|
|
591
|
-
disabled:
|
|
659
|
+
disabled: N,
|
|
592
660
|
className: "px-6 py-3 rounded-lg bg-action-primary-bg text-action-primary-text hover:bg-action-primary-bgHover flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",
|
|
593
|
-
children:
|
|
661
|
+
children: N ? /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("div", { className: "size-4 border-2 border-action-primary-text border-t-transparent rounded-full animate-spin" }), "Creating…"] }) : /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h(u, { className: "size-4" }), "Create Coupon"] })
|
|
594
662
|
})]
|
|
595
663
|
})
|
|
596
664
|
]
|
|
@@ -599,6 +667,6 @@ var y = [
|
|
|
599
667
|
});
|
|
600
668
|
};
|
|
601
669
|
//#endregion
|
|
602
|
-
export {
|
|
670
|
+
export { S as CreateCouponPage };
|
|
603
671
|
|
|
604
672
|
//# sourceMappingURL=CreateCouponPage.js.map
|