@carlonicora/nextjs-jsonapi 5.6.0 → 5.7.1
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/{BlockNoteEditor-AE3ZTEEH.js → BlockNoteEditor-ARUXU5AV.js} +19 -19
- package/dist/{BlockNoteEditor-AE3ZTEEH.js.map → BlockNoteEditor-ARUXU5AV.js.map} +1 -1
- package/dist/{BlockNoteEditor-NEYG5L6W.mjs → BlockNoteEditor-MNNISNVN.mjs} +4 -4
- package/dist/{BlockNoteViewer-3OUT5UFY.mjs → BlockNoteViewer-BVVN6D3T.mjs} +2 -2
- package/dist/{BlockNoteViewer-4CFKQM7U.js → BlockNoteViewer-SD3ZFIXD.js} +3 -3
- package/dist/{BlockNoteViewer-4CFKQM7U.js.map → BlockNoteViewer-SD3ZFIXD.js.map} +1 -1
- package/dist/billing/index.d.mts +33 -43
- package/dist/billing/index.d.ts +33 -43
- package/dist/billing/index.js +591 -574
- package/dist/billing/index.js.map +1 -1
- package/dist/billing/index.mjs +30 -13
- package/dist/billing/index.mjs.map +1 -1
- package/dist/{chunk-SFYPXCK4.mjs → chunk-2FNSDBJG.mjs} +641 -536
- package/dist/chunk-2FNSDBJG.mjs.map +1 -0
- package/dist/{chunk-3I5AAJXV.js → chunk-2TXE57LE.js} +3 -3
- package/dist/{chunk-3I5AAJXV.js.map → chunk-2TXE57LE.js.map} +1 -1
- package/dist/{chunk-LQ4DK4JF.js → chunk-2WK35GO2.js} +1317 -1212
- package/dist/chunk-2WK35GO2.js.map +1 -0
- package/dist/{chunk-HKZAESS6.js → chunk-5TH2DSAH.js} +17 -12
- package/dist/chunk-5TH2DSAH.js.map +1 -0
- package/dist/{chunk-EYA2F6AN.mjs → chunk-FK26NX3S.mjs} +16 -11
- package/dist/chunk-FK26NX3S.mjs.map +1 -0
- package/dist/{chunk-53BAULDP.js → chunk-IJME5SAM.js} +4 -4
- package/dist/{chunk-53BAULDP.js.map → chunk-IJME5SAM.js.map} +1 -1
- package/dist/{chunk-KQHBONL4.mjs → chunk-OKCV4GPJ.mjs} +2 -2
- package/dist/{chunk-BTPUYUQ3.mjs → chunk-RGQYFSJF.mjs} +2 -2
- package/dist/{chunk-Y7RR57EW.mjs → chunk-WCHLCOZG.mjs} +2 -2
- package/dist/{chunk-RL3PL3KV.js → chunk-XOSC3FFP.js} +8 -8
- package/dist/{chunk-RL3PL3KV.js.map → chunk-XOSC3FFP.js.map} +1 -1
- package/dist/client/index.js +4 -4
- package/dist/client/index.mjs +3 -3
- package/dist/components/index.js +4 -4
- package/dist/components/index.mjs +3 -3
- package/dist/contexts/index.js +4 -4
- package/dist/contexts/index.mjs +3 -3
- package/dist/core/index.d.mts +9 -3
- package/dist/core/index.d.ts +9 -3
- package/dist/core/index.js +10 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +9 -1
- package/dist/{format-options-D6c7FNDi.d.mts → currency-DT_dveBx.d.mts} +41 -8
- package/dist/{format-options-BtX3o0Yu.d.ts → currency-pK9eRYRC.d.ts} +41 -8
- package/dist/email-automations/index.js +92 -92
- package/dist/email-automations/index.mjs +3 -3
- package/dist/features/analytics/index.js +121 -121
- package/dist/features/analytics/index.mjs +4 -4
- package/dist/features/analytics/server.js +4 -4
- package/dist/features/analytics/server.mjs +2 -2
- package/dist/features/blog/index.js +150 -150
- package/dist/features/blog/index.mjs +3 -3
- package/dist/features/blog/server.js +16 -16
- package/dist/features/blog/server.mjs +1 -1
- package/dist/features/help/index.js +37 -37
- package/dist/features/help/index.mjs +3 -3
- package/dist/features/tokenusage/index.js +124 -124
- package/dist/features/tokenusage/index.mjs +4 -4
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -2
- package/dist/server/index.js +3 -3
- package/dist/server/index.mjs +2 -2
- package/package.json +1 -1
- package/src/core/index.ts +3 -0
- package/src/features/billing/contexts/CouponContext.tsx +0 -2
- package/src/features/billing/stripe-coupon/components/containers/CouponContainer.tsx +2 -2
- package/src/features/billing/stripe-coupon/components/details/CouponDetails.tsx +5 -2
- package/src/features/billing/stripe-coupon/components/forms/CouponCodeEditor.tsx +6 -5
- package/src/features/billing/stripe-coupon/components/forms/CouponCodeFields.tsx +67 -45
- package/src/features/billing/stripe-coupon/components/forms/CouponEditor.tsx +294 -212
- package/src/features/billing/stripe-coupon/components/widgets/CouponCodeActions.tsx +4 -3
- package/src/features/billing/stripe-coupon/data/stripe-coupon.interface.ts +11 -7
- package/src/features/billing/stripe-coupon/data/stripe-coupon.ts +6 -4
- package/src/features/billing/stripe-coupon/hooks/useStripeCouponCodeTableStructure.tsx +14 -7
- package/src/features/billing/stripe-coupon/hooks/useStripeCouponTableStructure.tsx +2 -2
- package/src/features/billing/stripe-coupon/stripe-coupon-code.module.ts +3 -2
- package/src/features/billing/stripe-coupon/stripe-coupon.module.ts +11 -4
- package/src/features/billing/stripe-coupon/utils/__tests__/coupon-page-module.spec.ts +32 -0
- package/src/features/billing/stripe-coupon/utils/coupon-page-module.ts +13 -0
- package/src/features/billing/stripe-promotion-code/components/PromoCodeInput.tsx +1 -1
- package/src/features/billing/stripe-subscription/hooks/wizard-promotion.ts +15 -8
- package/dist/chunk-EYA2F6AN.mjs.map +0 -1
- package/dist/chunk-HKZAESS6.js.map +0 -1
- package/dist/chunk-LQ4DK4JF.js.map +0 -1
- package/dist/chunk-SFYPXCK4.mjs.map +0 -1
- /package/dist/{BlockNoteEditor-NEYG5L6W.mjs.map → BlockNoteEditor-MNNISNVN.mjs.map} +0 -0
- /package/dist/{BlockNoteViewer-3OUT5UFY.mjs.map → BlockNoteViewer-BVVN6D3T.mjs.map} +0 -0
- /package/dist/{chunk-KQHBONL4.mjs.map → chunk-OKCV4GPJ.mjs.map} +0 -0
- /package/dist/{chunk-BTPUYUQ3.mjs.map → chunk-RGQYFSJF.mjs.map} +0 -0
- /package/dist/{chunk-Y7RR57EW.mjs.map → chunk-WCHLCOZG.mjs.map} +0 -0
package/dist/billing/index.js
CHANGED
|
@@ -78,10 +78,13 @@
|
|
|
78
78
|
|
|
79
79
|
|
|
80
80
|
|
|
81
|
-
var _chunkLQ4DK4JFjs = require('../chunk-LQ4DK4JF.js');
|
|
82
81
|
|
|
83
82
|
|
|
84
|
-
|
|
83
|
+
|
|
84
|
+
var _chunk2WK35GO2js = require('../chunk-2WK35GO2.js');
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
var _chunkXOSC3FFPjs = require('../chunk-XOSC3FFP.js');
|
|
85
88
|
|
|
86
89
|
|
|
87
90
|
var _chunkG4JR3SFVjs = require('../chunk-G4JR3SFV.js');
|
|
@@ -109,7 +112,7 @@ var _chunkG4JR3SFVjs = require('../chunk-G4JR3SFV.js');
|
|
|
109
112
|
|
|
110
113
|
|
|
111
114
|
|
|
112
|
-
var
|
|
115
|
+
var _chunk5TH2DSAHjs = require('../chunk-5TH2DSAH.js');
|
|
113
116
|
require('../chunk-GHE4VT2R.js');
|
|
114
117
|
require('../chunk-LXKSUWAV.js');
|
|
115
118
|
require('../chunk-JTPRJNT2.js');
|
|
@@ -122,7 +125,7 @@ var _chunk7QVYU63Ejs = require('../chunk-7QVYU63E.js');
|
|
|
122
125
|
var _nextintl = require('next-intl');
|
|
123
126
|
var _lucidereact = require('lucide-react');
|
|
124
127
|
var _jsxruntime = require('react/jsx-runtime');
|
|
125
|
-
var SUBSCRIPTION_STATUSES = Object.values(
|
|
128
|
+
var SUBSCRIPTION_STATUSES = Object.values(_chunk5TH2DSAHjs.SubscriptionStatus);
|
|
126
129
|
function getStatusBadgeVariant(status) {
|
|
127
130
|
switch (status) {
|
|
128
131
|
case "active" /* ACTIVE */:
|
|
@@ -154,43 +157,43 @@ function SubscriptionSummaryCard({
|
|
|
154
157
|
onManageClick
|
|
155
158
|
}) {
|
|
156
159
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
157
|
-
const fmt =
|
|
160
|
+
const fmt = _chunk2WK35GO2js.useBillingFormatOptions.call(void 0, );
|
|
158
161
|
if (loading) {
|
|
159
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
160
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
161
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
162
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Card, { children: [
|
|
163
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
164
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardTitle, { children: t("billing.ui.subscriptions.title") }),
|
|
162
165
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-4 w-4 text-muted-foreground" })
|
|
163
166
|
] }),
|
|
164
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
165
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
166
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
167
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
167
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.CardContent, { children: [
|
|
168
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Skeleton, { className: "h-6 w-32 mb-2" }),
|
|
169
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Skeleton, { className: "h-4 w-24 mb-1" }),
|
|
170
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Skeleton, { className: "h-4 w-40" })
|
|
168
171
|
] })
|
|
169
172
|
] });
|
|
170
173
|
}
|
|
171
174
|
if (error) {
|
|
172
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
173
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
174
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
175
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Card, { children: [
|
|
176
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
177
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardTitle, { children: t("billing.ui.subscriptions.title") }),
|
|
175
178
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-4 w-4 text-muted-foreground" })
|
|
176
179
|
] }),
|
|
177
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
180
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive text-xs/relaxed", children: error }) })
|
|
178
181
|
] });
|
|
179
182
|
}
|
|
180
183
|
const activeSubscriptions = subscriptions.filter(
|
|
181
184
|
(sub) => sub.status === "active" /* ACTIVE */ || sub.status === "trialing" /* TRIALING */
|
|
182
185
|
);
|
|
183
186
|
const primarySubscription = activeSubscriptions[0];
|
|
184
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
185
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
186
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
187
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Card, { className: "cursor-pointer hover:bg-accent/50 transition-colors", onClick: onManageClick, children: [
|
|
188
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
189
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardTitle, { children: t("billing.ui.subscriptions.title") }),
|
|
187
190
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-4 w-4 text-muted-foreground" })
|
|
188
191
|
] }),
|
|
189
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
192
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardContent, { children: !primarySubscription ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
190
193
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold text-muted-foreground", children: t("billing.ui.cards.subscriptions.empty_title") }),
|
|
191
194
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: t("billing.ui.cards.subscriptions.empty_description") }),
|
|
192
195
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
193
|
-
|
|
196
|
+
_chunk2WK35GO2js.Button,
|
|
194
197
|
{
|
|
195
198
|
variant: "outline",
|
|
196
199
|
size: "sm",
|
|
@@ -209,7 +212,7 @@ function SubscriptionSummaryCard({
|
|
|
209
212
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
|
|
210
213
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold", children: formatPlanName(primarySubscription, t("billing.ui.cards.subscriptions.fallback_name")) }),
|
|
211
214
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
212
|
-
|
|
215
|
+
_chunk2WK35GO2js.Badge,
|
|
213
216
|
{
|
|
214
217
|
variant: primarySubscription.cancelAtPeriodEnd ? "secondary" : getStatusBadgeVariant(primarySubscription.status),
|
|
215
218
|
children: primarySubscription.cancelAtPeriodEnd ? t("billing.ui.cards.subscriptions.canceling") : SUBSCRIPTION_STATUSES.includes(primarySubscription.status) ? t(`billing.ui.subscription_status.${primarySubscription.status}`) : primarySubscription.status
|
|
@@ -217,11 +220,11 @@ function SubscriptionSummaryCard({
|
|
|
217
220
|
)
|
|
218
221
|
] }),
|
|
219
222
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: !_optionalChain([primarySubscription, 'access', _8 => _8.price, 'optionalAccess', _9 => _9.isTrial]) ? t("billing.ui.cards.subscriptions.ends_on", {
|
|
220
|
-
date:
|
|
223
|
+
date: _chunk2WK35GO2js.formatDate.call(void 0, primarySubscription.currentPeriodEnd, fmt)
|
|
221
224
|
}) : primarySubscription.cancelAtPeriodEnd ? t("billing.ui.cards.subscriptions.cancels_on", {
|
|
222
|
-
date:
|
|
225
|
+
date: _chunk2WK35GO2js.formatDate.call(void 0, primarySubscription.currentPeriodEnd, fmt)
|
|
223
226
|
}) : t("billing.ui.cards.subscriptions.renews_on", {
|
|
224
|
-
date:
|
|
227
|
+
date: _chunk2WK35GO2js.formatDate.call(void 0, primarySubscription.currentPeriodEnd, fmt)
|
|
225
228
|
}) }),
|
|
226
229
|
activeSubscriptions.length > 1 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: t("billing.ui.cards.subscriptions.more", { count: activeSubscriptions.length - 1 }) })
|
|
227
230
|
] }) })
|
|
@@ -255,37 +258,37 @@ function PaymentMethodSummaryCard({
|
|
|
255
258
|
}) {
|
|
256
259
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
257
260
|
if (loading) {
|
|
258
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
259
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
260
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
261
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Card, { children: [
|
|
262
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
263
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardTitle, { children: t("billing.ui.payment_method.title") }),
|
|
261
264
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Wallet, { className: "h-4 w-4 text-muted-foreground" })
|
|
262
265
|
] }),
|
|
263
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
264
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
265
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
266
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.CardContent, { children: [
|
|
267
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Skeleton, { className: "h-6 w-32 mb-2" }),
|
|
268
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Skeleton, { className: "h-4 w-24" })
|
|
266
269
|
] })
|
|
267
270
|
] });
|
|
268
271
|
}
|
|
269
272
|
if (error) {
|
|
270
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
271
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
272
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
273
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Card, { children: [
|
|
274
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
275
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardTitle, { children: t("billing.ui.payment_method.title") }),
|
|
273
276
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Wallet, { className: "h-4 w-4 text-muted-foreground" })
|
|
274
277
|
] }),
|
|
275
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
278
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive text-xs/relaxed", children: error }) })
|
|
276
279
|
] });
|
|
277
280
|
}
|
|
278
281
|
const defaultMethod = paymentMethods.find((pm) => pm.id === defaultPaymentMethodId) || paymentMethods[0];
|
|
279
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
280
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
281
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
282
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Card, { className: "cursor-pointer hover:bg-accent/50 transition-colors", onClick: onManageClick, children: [
|
|
283
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
284
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardTitle, { children: t("billing.ui.payment_method.title") }),
|
|
282
285
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Wallet, { className: "h-4 w-4 text-muted-foreground" })
|
|
283
286
|
] }),
|
|
284
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
287
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardContent, { children: paymentMethods.length === 0 ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
285
288
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold text-muted-foreground", children: t("billing.ui.cards.payment_method.empty_title") }),
|
|
286
289
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: t("billing.ui.cards.payment_method.empty_description") }),
|
|
287
290
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
288
|
-
|
|
291
|
+
_chunk2WK35GO2js.Button,
|
|
289
292
|
{
|
|
290
293
|
variant: "outline",
|
|
291
294
|
size: "sm",
|
|
@@ -334,13 +337,13 @@ function formatBalance(balance, currency, locale) {
|
|
|
334
337
|
_chunk7QVYU63Ejs.__name.call(void 0, formatBalance, "formatBalance");
|
|
335
338
|
function CustomerInfoCard({ customer, loading, error }) {
|
|
336
339
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
337
|
-
const locale =
|
|
340
|
+
const locale = _chunk5TH2DSAHjs.useI18nLocale.call(void 0, );
|
|
338
341
|
const [portalLoading, setPortalLoading] = _react.useState.call(void 0, false);
|
|
339
342
|
const handlePortalClick = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async (e) => {
|
|
340
343
|
e.stopPropagation();
|
|
341
344
|
setPortalLoading(true);
|
|
342
345
|
try {
|
|
343
|
-
const { url } = await
|
|
346
|
+
const { url } = await _chunk5TH2DSAHjs.StripeCustomerService.createPortalSession();
|
|
344
347
|
window.open(url, "_blank");
|
|
345
348
|
} catch (err) {
|
|
346
349
|
console.error("[CustomerInfoCard] Failed to create portal session:", err);
|
|
@@ -349,45 +352,45 @@ function CustomerInfoCard({ customer, loading, error }) {
|
|
|
349
352
|
}
|
|
350
353
|
}, "handlePortalClick");
|
|
351
354
|
if (loading) {
|
|
352
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
353
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
354
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
355
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Card, { children: [
|
|
356
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
357
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardTitle, { children: t("billing.ui.cards.customer.title") }),
|
|
355
358
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.User, { className: "h-4 w-4 text-muted-foreground" })
|
|
356
359
|
] }),
|
|
357
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
358
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
359
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
360
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
360
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.CardContent, { children: [
|
|
361
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Skeleton, { className: "h-6 w-32 mb-2" }),
|
|
362
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Skeleton, { className: "h-4 w-48 mb-1" }),
|
|
363
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Skeleton, { className: "h-4 w-24" })
|
|
361
364
|
] })
|
|
362
365
|
] });
|
|
363
366
|
}
|
|
364
367
|
if (error) {
|
|
365
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
366
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
367
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
368
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Card, { children: [
|
|
369
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
370
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardTitle, { children: t("billing.ui.cards.customer.title") }),
|
|
368
371
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.User, { className: "h-4 w-4 text-muted-foreground" })
|
|
369
372
|
] }),
|
|
370
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
373
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive text-xs/relaxed", children: error }) })
|
|
371
374
|
] });
|
|
372
375
|
}
|
|
373
376
|
if (!customer) {
|
|
374
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
375
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
376
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
377
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Card, { children: [
|
|
378
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
379
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardTitle, { children: t("billing.ui.cards.customer.title") }),
|
|
377
380
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.User, { className: "h-4 w-4 text-muted-foreground" })
|
|
378
381
|
] }),
|
|
379
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
382
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.CardContent, { children: [
|
|
380
383
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold text-muted-foreground", children: t("billing.ui.cards.customer.not_set_up") }),
|
|
381
384
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: t("billing.ui.cards.customer.not_set_up_description") })
|
|
382
385
|
] })
|
|
383
386
|
] });
|
|
384
387
|
}
|
|
385
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
386
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
387
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
388
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Card, { children: [
|
|
389
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
390
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardTitle, { children: t("billing.ui.cards.customer.title") }),
|
|
388
391
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.User, { className: "h-4 w-4 text-muted-foreground" })
|
|
389
392
|
] }),
|
|
390
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
393
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
391
394
|
customer.name && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold", children: customer.name }),
|
|
392
395
|
customer.email && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: customer.email }),
|
|
393
396
|
customer.balance !== void 0 && customer.balance !== 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-sm", children: [
|
|
@@ -397,7 +400,7 @@ function CustomerInfoCard({ customer, loading, error }) {
|
|
|
397
400
|
] }),
|
|
398
401
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: customer.balance < 0 ? "text-success" : "text-destructive", children: formatBalance(customer.balance, customer.currency, locale) })
|
|
399
402
|
] }),
|
|
400
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
403
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Button, { variant: "outline", size: "sm", className: "mt-2", onClick: handlePortalClick, disabled: portalLoading, children: [
|
|
401
404
|
portalLoading ? t("common.loading") : t("billing.ui.cards.customer.manage_portal"),
|
|
402
405
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ExternalLink, { className: "h-4 w-4 ms-1" })
|
|
403
406
|
] })
|
|
@@ -410,7 +413,7 @@ _chunk7QVYU63Ejs.__name.call(void 0, CustomerInfoCard, "CustomerInfoCard");
|
|
|
410
413
|
|
|
411
414
|
|
|
412
415
|
|
|
413
|
-
var INVOICE_STATUSES = Object.values(
|
|
416
|
+
var INVOICE_STATUSES = Object.values(_chunk5TH2DSAHjs.InvoiceStatus);
|
|
414
417
|
function getStatusBadgeVariant2(status) {
|
|
415
418
|
switch (status) {
|
|
416
419
|
case "paid" /* PAID */:
|
|
@@ -435,46 +438,46 @@ function formatAmount(amount, currency, locale) {
|
|
|
435
438
|
_chunk7QVYU63Ejs.__name.call(void 0, formatAmount, "formatAmount");
|
|
436
439
|
function InvoicesSummaryCard({ invoices, loading, error, onViewAllClick }) {
|
|
437
440
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
438
|
-
const fmt =
|
|
441
|
+
const fmt = _chunk2WK35GO2js.useBillingFormatOptions.call(void 0, );
|
|
439
442
|
if (loading) {
|
|
440
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
441
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
442
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
443
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Card, { children: [
|
|
444
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
445
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardTitle, { children: t("billing.ui.cards.invoices.title") }),
|
|
443
446
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ReceiptIcon, { className: "h-4 w-4 text-muted-foreground" })
|
|
444
447
|
] }),
|
|
445
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
446
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
447
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
448
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
448
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.CardContent, { children: [
|
|
449
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Skeleton, { className: "h-6 w-24 mb-2" }),
|
|
450
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Skeleton, { className: "h-4 w-32 mb-1" }),
|
|
451
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Skeleton, { className: "h-4 w-20" })
|
|
449
452
|
] })
|
|
450
453
|
] });
|
|
451
454
|
}
|
|
452
455
|
if (error) {
|
|
453
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
454
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
455
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
456
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Card, { children: [
|
|
457
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
458
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardTitle, { children: t("billing.ui.cards.invoices.title") }),
|
|
456
459
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ReceiptIcon, { className: "h-4 w-4 text-muted-foreground" })
|
|
457
460
|
] }),
|
|
458
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
461
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive text-xs/relaxed", children: error }) })
|
|
459
462
|
] });
|
|
460
463
|
}
|
|
461
464
|
const latestInvoice = _nullishCoalesce(invoices.find((inv) => inv.status !== "void" /* VOID */), () => ( invoices[0]));
|
|
462
465
|
const paidInvoices = invoices.filter((inv) => inv.status === "paid" /* PAID */);
|
|
463
466
|
const openInvoices = invoices.filter((inv) => inv.status === "open" /* OPEN */);
|
|
464
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
465
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
466
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
467
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Card, { className: "cursor-pointer hover:bg-accent/50 transition-colors", onClick: onViewAllClick, children: [
|
|
468
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
469
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardTitle, { children: t("billing.ui.cards.invoices.title") }),
|
|
467
470
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ReceiptIcon, { className: "h-4 w-4 text-muted-foreground" })
|
|
468
471
|
] }),
|
|
469
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
472
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardContent, { children: invoices.length === 0 ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
470
473
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold text-muted-foreground", children: t("billing.ui.invoices.empty_title") }),
|
|
471
474
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: t("billing.ui.cards.invoices.empty_description") })
|
|
472
475
|
] }) : latestInvoice ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
473
476
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
|
|
474
477
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold", children: formatAmount(latestInvoice.total, latestInvoice.currency, fmt.locale) }),
|
|
475
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
478
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Badge, { variant: getStatusBadgeVariant2(latestInvoice.status), children: INVOICE_STATUSES.includes(latestInvoice.status) ? t(`billing.ui.invoice_status.${latestInvoice.status}`) : latestInvoice.status })
|
|
476
479
|
] }),
|
|
477
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: latestInvoice.stripeInvoiceNumber || t("billing.ui.cards.invoices.invoice_from", { date:
|
|
480
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: latestInvoice.stripeInvoiceNumber || t("billing.ui.cards.invoices.invoice_from", { date: _chunk2WK35GO2js.formatDate.call(void 0, latestInvoice.periodStart, fmt) }) }),
|
|
478
481
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-4 text-xs text-muted-foreground", children: [
|
|
479
482
|
paidInvoices.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: t("billing.ui.cards.invoices.paid_count", { count: paidInvoices.length }) }),
|
|
480
483
|
openInvoices.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-warning", children: t("billing.ui.cards.invoices.open_count", { count: openInvoices.length }) }),
|
|
@@ -507,26 +510,26 @@ function BillingUsageSummaryCard({
|
|
|
507
510
|
onViewDetailsClick
|
|
508
511
|
}) {
|
|
509
512
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
510
|
-
const locale =
|
|
513
|
+
const locale = _chunk5TH2DSAHjs.useI18nLocale.call(void 0, );
|
|
511
514
|
if (loading) {
|
|
512
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
513
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
514
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
515
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Card, { children: [
|
|
516
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
517
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardTitle, { children: t("billing.ui.cards.usage.title") }),
|
|
515
518
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Activity, { className: "h-4 w-4 text-muted-foreground" })
|
|
516
519
|
] }),
|
|
517
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
518
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
519
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
520
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.CardContent, { children: [
|
|
521
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Skeleton, { className: "h-6 w-24 mb-2" }),
|
|
522
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Skeleton, { className: "h-4 w-32" })
|
|
520
523
|
] })
|
|
521
524
|
] });
|
|
522
525
|
}
|
|
523
526
|
if (error) {
|
|
524
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
525
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
526
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
527
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Card, { children: [
|
|
528
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
529
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardTitle, { children: t("billing.ui.cards.usage.title") }),
|
|
527
530
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Activity, { className: "h-4 w-4 text-muted-foreground" })
|
|
528
531
|
] }),
|
|
529
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
532
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive text-xs/relaxed", children: error }) })
|
|
530
533
|
] });
|
|
531
534
|
}
|
|
532
535
|
const totalUsage = Object.values(summaries).reduce((acc, summary) => {
|
|
@@ -534,12 +537,12 @@ function BillingUsageSummaryCard({
|
|
|
534
537
|
}, 0);
|
|
535
538
|
const primaryMeter = meters.find((m) => _optionalChain([summaries, 'access', _17 => _17[m.id], 'optionalAccess', _18 => _18.aggregatedValue]));
|
|
536
539
|
const primarySummary = primaryMeter ? summaries[primaryMeter.id] : null;
|
|
537
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
538
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
539
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
540
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Card, { className: "cursor-pointer hover:bg-accent/50 transition-colors", onClick: onViewDetailsClick, children: [
|
|
541
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
542
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardTitle, { children: t("billing.ui.cards.usage.title") }),
|
|
540
543
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Activity, { className: "h-4 w-4 text-muted-foreground" })
|
|
541
544
|
] }),
|
|
542
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
545
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardContent, { children: meters.length === 0 ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
543
546
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold text-muted-foreground", children: t("billing.ui.cards.usage.no_meters") }),
|
|
544
547
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: t("billing.ui.cards.usage.no_meters_description") })
|
|
545
548
|
] }) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
@@ -596,7 +599,7 @@ function PaymentMethodForm({
|
|
|
596
599
|
const fetchSetupIntent = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
597
600
|
setLoading(true);
|
|
598
601
|
try {
|
|
599
|
-
const intent = await
|
|
602
|
+
const intent = await _chunk5TH2DSAHjs.StripeCustomerService.createSetupIntent();
|
|
600
603
|
setSetupIntent(intent);
|
|
601
604
|
} catch (err) {
|
|
602
605
|
console.error("[PaymentMethodForm] Failed to create setup intent:", err);
|
|
@@ -634,7 +637,7 @@ function PaymentMethodForm({
|
|
|
634
637
|
return;
|
|
635
638
|
}
|
|
636
639
|
if ((alwaysSetDefault || setAsDefault) && _optionalChain([confirmedSetupIntent, 'optionalAccess', _19 => _19.payment_method])) {
|
|
637
|
-
await
|
|
640
|
+
await _chunk5TH2DSAHjs.StripeCustomerService.setDefaultPaymentMethod({
|
|
638
641
|
paymentMethodId: typeof confirmedSetupIntent.payment_method === "string" ? confirmedSetupIntent.payment_method : confirmedSetupIntent.payment_method.id
|
|
639
642
|
});
|
|
640
643
|
}
|
|
@@ -650,7 +653,7 @@ function PaymentMethodForm({
|
|
|
650
653
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex items-center justify-center py-8", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-muted-foreground", children: t("billing.ui.payment_form.loading") }) });
|
|
651
654
|
}
|
|
652
655
|
if (!setupIntent && error) {
|
|
653
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
656
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Alert, { variant: "destructive", className: "bg-red-50 border-red-200", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.AlertDescription, { children: error }) });
|
|
654
657
|
}
|
|
655
658
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { onSubmit: handleSubmit, className: "flex flex-col gap-y-4", children: [
|
|
656
659
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rounded-md border border-gray-300 p-3", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -674,19 +677,19 @@ function PaymentMethodForm({
|
|
|
674
677
|
) }),
|
|
675
678
|
!alwaysSetDefault && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-2", children: [
|
|
676
679
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
677
|
-
|
|
680
|
+
_chunk2WK35GO2js.Checkbox,
|
|
678
681
|
{
|
|
679
682
|
id: "setAsDefault",
|
|
680
683
|
checked: setAsDefault,
|
|
681
684
|
onCheckedChange: (checked) => setSetAsDefault(!!checked)
|
|
682
685
|
}
|
|
683
686
|
),
|
|
684
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
687
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Label, { htmlFor: "setAsDefault", className: "cursor-pointer font-normal", children: t("billing.ui.payment_form.set_default") })
|
|
685
688
|
] }),
|
|
686
|
-
error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
689
|
+
error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Alert, { variant: "destructive", className: "bg-red-50 border-red-200", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.AlertDescription, { children: error }) }),
|
|
687
690
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-end gap-x-2", children: [
|
|
688
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
689
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
691
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Button, { type: "button", variant: "outline", onClick: onCancel, disabled: isSubmitting || isLoading, children: t("ui.buttons.cancel") }),
|
|
692
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Button, { type: "submit", disabled: !stripe || isSubmitting || isLoading, children: isSubmitting ? t("billing.ui.wizard.review.processing") : t("billing.ui.cards.payment_method.add_card") })
|
|
690
693
|
] })
|
|
691
694
|
] });
|
|
692
695
|
}
|
|
@@ -703,10 +706,10 @@ function PaymentMethodEditor({ open, onOpenChange, onSuccess }) {
|
|
|
703
706
|
const handleCancel = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => {
|
|
704
707
|
onOpenChange(false);
|
|
705
708
|
}, "handleCancel");
|
|
706
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
707
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
708
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
709
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
709
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.DialogContent, { className: "max-w-md", children: [
|
|
710
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.DialogHeader, { children: [
|
|
711
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.DialogTitle, { children: t("billing.ui.payment_methods.add") }),
|
|
712
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.DialogDescription, { children: t("billing.ui.payment_methods.add_description") })
|
|
710
713
|
] }),
|
|
711
714
|
open && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PaymentMethodForm, { onSuccess: handleSuccess, onCancel: handleCancel })
|
|
712
715
|
] }) });
|
|
@@ -732,7 +735,7 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
732
735
|
_react.useEffect.call(void 0, () => {
|
|
733
736
|
const loadCustomer = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
734
737
|
try {
|
|
735
|
-
const fetchedCustomer = await
|
|
738
|
+
const fetchedCustomer = await _chunk5TH2DSAHjs.StripeCustomerService.getCustomer();
|
|
736
739
|
setCustomer(fetchedCustomer);
|
|
737
740
|
} catch (error) {
|
|
738
741
|
console.error("[PaymentMethodCard] Failed to load customer:", error);
|
|
@@ -749,7 +752,7 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
749
752
|
const handleSetDefault = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
750
753
|
setLoading(true);
|
|
751
754
|
try {
|
|
752
|
-
await
|
|
755
|
+
await _chunk5TH2DSAHjs.StripeCustomerService.setDefaultPaymentMethod({ paymentMethodId: paymentMethod.id });
|
|
753
756
|
onUpdate();
|
|
754
757
|
} catch (error) {
|
|
755
758
|
console.error("[PaymentMethodCard] Failed to set as default:", error);
|
|
@@ -760,7 +763,7 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
760
763
|
const handleRemove = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
761
764
|
setLoading(true);
|
|
762
765
|
try {
|
|
763
|
-
await
|
|
766
|
+
await _chunk5TH2DSAHjs.StripeCustomerService.removePaymentMethod({ paymentMethodId: paymentMethod.id });
|
|
764
767
|
setShowRemoveDialog(false);
|
|
765
768
|
onUpdate();
|
|
766
769
|
} catch (error) {
|
|
@@ -769,16 +772,16 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
769
772
|
}
|
|
770
773
|
}, "handleRemove");
|
|
771
774
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
772
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
773
|
-
isDefault && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
774
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
775
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Card, { className: "relative", children: [
|
|
776
|
+
isDefault && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Badge, { variant: "softGreen", className: "absolute end-2 top-2", children: t("billing.ui.payment_methods.default") }),
|
|
777
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.CardHeader, { className: "flex flex-row items-center justify-between pb-2", children: [
|
|
775
778
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-2", children: [
|
|
776
779
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-2xl", children: brandIcon }),
|
|
777
780
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-medium capitalize", children: brand })
|
|
778
781
|
] }),
|
|
779
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
780
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
781
|
-
|
|
782
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.DropdownMenu, { children: [
|
|
783
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.DropdownMenuTrigger, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
784
|
+
_chunk2WK35GO2js.Button,
|
|
782
785
|
{
|
|
783
786
|
render: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {}),
|
|
784
787
|
nativeButton: false,
|
|
@@ -789,10 +792,10 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
789
792
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.MoreVertical, { className: "h-4 w-4" })
|
|
790
793
|
}
|
|
791
794
|
) }),
|
|
792
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
793
|
-
!isDefault && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
795
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.DropdownMenuContent, { align: "end", children: [
|
|
796
|
+
!isDefault && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.DropdownMenuItem, { onClick: handleSetDefault, disabled: loading, children: t("billing.ui.payment_methods.set_default") }),
|
|
794
797
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
795
|
-
|
|
798
|
+
_chunk2WK35GO2js.DropdownMenuItem,
|
|
796
799
|
{
|
|
797
800
|
onClick: () => setShowRemoveDialog(true),
|
|
798
801
|
disabled: loading,
|
|
@@ -803,7 +806,7 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
803
806
|
] })
|
|
804
807
|
] })
|
|
805
808
|
] }),
|
|
806
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
809
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-y-1", children: [
|
|
807
810
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-lg font-semibold", children: [
|
|
808
811
|
"\u2022\u2022\u2022\u2022 ",
|
|
809
812
|
last4
|
|
@@ -811,17 +814,17 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
811
814
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: t("billing.ui.payment_method.expires", { date: `${String(expMonth).padStart(2, "0")}/${expYear}` }) })
|
|
812
815
|
] }) })
|
|
813
816
|
] }),
|
|
814
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
815
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
816
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
817
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
817
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.AlertDialog, { open: showRemoveDialog, onOpenChange: setShowRemoveDialog, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.AlertDialogContent, { children: [
|
|
818
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.AlertDialogHeader, { children: [
|
|
819
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.AlertDialogTitle, { children: t("billing.ui.payment_methods.remove_title") }),
|
|
820
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.AlertDialogDescription, { children: [
|
|
818
821
|
t("billing.ui.payment_methods.remove_description"),
|
|
819
822
|
isDefault && ` ${t("billing.ui.payment_methods.remove_default_warning")}`
|
|
820
823
|
] })
|
|
821
824
|
] }),
|
|
822
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
823
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
824
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
825
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.AlertDialogFooter, { children: [
|
|
826
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.AlertDialogCancel, { disabled: loading, children: t("ui.buttons.cancel") }),
|
|
827
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.AlertDialogAction, { onClick: handleRemove, disabled: loading, className: "bg-red-600 hover:bg-red-700", children: loading ? t("billing.ui.payment_methods.removing") : t("ui.buttons.remove") })
|
|
825
828
|
] })
|
|
826
829
|
] }) })
|
|
827
830
|
] });
|
|
@@ -845,7 +848,7 @@ function PaymentMethodsContainer() {
|
|
|
845
848
|
const loadPaymentMethods = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
846
849
|
setLoading(true);
|
|
847
850
|
try {
|
|
848
|
-
const fetchedPaymentMethods = await
|
|
851
|
+
const fetchedPaymentMethods = await _chunk5TH2DSAHjs.StripeCustomerService.listPaymentMethods();
|
|
849
852
|
setPaymentMethods(fetchedPaymentMethods);
|
|
850
853
|
} catch (error) {
|
|
851
854
|
console.error("[PaymentMethodsContainer] Failed to load payment methods:", error);
|
|
@@ -865,14 +868,14 @@ function PaymentMethodsContainer() {
|
|
|
865
868
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-8 w-8" }),
|
|
866
869
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h1", { className: "text-primary text-3xl font-semibold", children: t("billing.ui.payment_methods.title") })
|
|
867
870
|
] }),
|
|
868
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
871
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Button, { onClick: () => setShowAddPaymentMethod(true), children: t("billing.ui.payment_methods.add") })
|
|
869
872
|
] }),
|
|
870
873
|
paymentMethods.length === 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col items-center justify-center gap-y-4 rounded-lg border-2 border-dashed border-gray-300 bg-muted/50 p-12", children: [
|
|
871
874
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-16 w-16 text-muted-foreground" }),
|
|
872
875
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "text-center", children: [
|
|
873
876
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "mb-2 text-sm font-medium", children: t("billing.ui.payment_methods.empty_title") }),
|
|
874
877
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "mb-4 text-muted-foreground", children: t("billing.ui.payment_methods.empty_description") }),
|
|
875
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
878
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Button, { onClick: () => setShowAddPaymentMethod(true), children: t("billing.ui.payment_methods.add_first") })
|
|
876
879
|
] })
|
|
877
880
|
] }),
|
|
878
881
|
paymentMethods.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PaymentMethodsList, { paymentMethods, onUpdate: loadPaymentMethods }),
|
|
@@ -928,7 +931,7 @@ var statusConfig = {
|
|
|
928
931
|
function InvoiceStatusBadge({ status }) {
|
|
929
932
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
930
933
|
const config = statusConfig[status] || statusConfig["draft" /* DRAFT */];
|
|
931
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
934
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Badge, { variant: config.variant, children: t(config.label) });
|
|
932
935
|
}
|
|
933
936
|
_chunk7QVYU63Ejs.__name.call(void 0, InvoiceStatusBadge, "InvoiceStatusBadge");
|
|
934
937
|
|
|
@@ -941,7 +944,7 @@ function InvoiceDetails({
|
|
|
941
944
|
onInvoiceChange: _onInvoiceChange
|
|
942
945
|
}) {
|
|
943
946
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
944
|
-
const fmt =
|
|
947
|
+
const fmt = _chunk2WK35GO2js.useBillingFormatOptions.call(void 0, );
|
|
945
948
|
const handleDownloadPDF = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => {
|
|
946
949
|
if (invoice.stripePdfUrl) {
|
|
947
950
|
window.open(invoice.stripePdfUrl, "_blank");
|
|
@@ -961,10 +964,10 @@ function InvoiceDetails({
|
|
|
961
964
|
return invoice.stripeInvoiceId.slice(-8);
|
|
962
965
|
}, "getInvoiceNumber");
|
|
963
966
|
const productName = _optionalChain([invoice, 'access', _29 => _29.subscription, 'optionalAccess', _30 => _30.price, 'optionalAccess', _31 => _31.product, 'optionalAccess', _32 => _32.name]) || t("billing.ui.cards.subscriptions.fallback_name");
|
|
964
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
965
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
966
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
967
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
967
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.DialogContent, { className: "max-w-2xl", children: [
|
|
968
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.DialogHeader, { children: [
|
|
969
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.DialogTitle, { children: t("billing.ui.invoice.title", { number: getInvoiceNumber() }) }),
|
|
970
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.DialogDescription, { children: _chunk2WK35GO2js.formatDate.call(void 0, invoice.periodStart, fmt) })
|
|
968
971
|
] }),
|
|
969
972
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-6", children: [
|
|
970
973
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-3", children: [
|
|
@@ -975,18 +978,18 @@ function InvoiceDetails({
|
|
|
975
978
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
976
979
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("billing.ui.invoice.billing_period") }),
|
|
977
980
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-sm", children: [
|
|
978
|
-
|
|
981
|
+
_chunk2WK35GO2js.formatDate.call(void 0, invoice.periodStart, fmt),
|
|
979
982
|
" - ",
|
|
980
|
-
|
|
983
|
+
_chunk2WK35GO2js.formatDate.call(void 0, invoice.periodEnd, fmt)
|
|
981
984
|
] })
|
|
982
985
|
] }),
|
|
983
986
|
invoice.dueDate && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
984
987
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("billing.ui.invoice.due_date") }),
|
|
985
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm", children:
|
|
988
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm", children: _chunk2WK35GO2js.formatDate.call(void 0, invoice.dueDate, fmt) })
|
|
986
989
|
] }),
|
|
987
990
|
invoice.paidAt && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
988
991
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("billing.ui.invoice.paid_date") }),
|
|
989
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm", children:
|
|
992
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm", children: _chunk2WK35GO2js.formatDate.call(void 0, invoice.paidAt, fmt) })
|
|
990
993
|
] }),
|
|
991
994
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
992
995
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("billing.ui.invoice.attempt_count") }),
|
|
@@ -1002,42 +1005,42 @@ function InvoiceDetails({
|
|
|
1002
1005
|
] }) }),
|
|
1003
1006
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "tbody", { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "tr", { className: "border-t", children: [
|
|
1004
1007
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "td", { className: "p-3", children: productName }),
|
|
1005
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "td", { className: "p-3 text-end", children:
|
|
1008
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "td", { className: "p-3 text-end", children: _chunk5TH2DSAHjs.formatCurrency.call(void 0, invoice.subtotal, invoice.currency, fmt) })
|
|
1006
1009
|
] }) })
|
|
1007
1010
|
] }) })
|
|
1008
1011
|
] }),
|
|
1009
1012
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2 border-t pt-4", children: [
|
|
1010
1013
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between", children: [
|
|
1011
1014
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("billing.ui.invoice.subtotal") }),
|
|
1012
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm", children:
|
|
1015
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm", children: _chunk5TH2DSAHjs.formatCurrency.call(void 0, invoice.subtotal, invoice.currency, fmt) })
|
|
1013
1016
|
] }),
|
|
1014
1017
|
invoice.tax !== void 0 && invoice.tax > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between", children: [
|
|
1015
1018
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("billing.ui.invoice.tax") }),
|
|
1016
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm", children:
|
|
1019
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm", children: _chunk5TH2DSAHjs.formatCurrency.call(void 0, invoice.tax, invoice.currency, fmt) })
|
|
1017
1020
|
] }),
|
|
1018
1021
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between text-lg font-semibold border-t pt-2", children: [
|
|
1019
1022
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: t("billing.ui.invoice.total") }),
|
|
1020
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children:
|
|
1023
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: _chunk5TH2DSAHjs.formatCurrency.call(void 0, invoice.total, invoice.currency, fmt) })
|
|
1021
1024
|
] }),
|
|
1022
1025
|
invoice.amountPaid > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between", children: [
|
|
1023
1026
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("billing.ui.invoice.amount_paid") }),
|
|
1024
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm text-success", children:
|
|
1027
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm text-success", children: _chunk5TH2DSAHjs.formatCurrency.call(void 0, invoice.amountPaid, invoice.currency, fmt) })
|
|
1025
1028
|
] }),
|
|
1026
1029
|
invoice.amountRemaining > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between", children: [
|
|
1027
1030
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("billing.ui.invoice.amount_due") }),
|
|
1028
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm text-destructive", children:
|
|
1031
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm text-destructive", children: _chunk5TH2DSAHjs.formatCurrency.call(void 0, invoice.amountRemaining, invoice.currency, fmt) })
|
|
1029
1032
|
] })
|
|
1030
1033
|
] }),
|
|
1031
1034
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-wrap gap-2 pt-4 border-t", children: [
|
|
1032
|
-
invoice.stripePdfUrl && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1035
|
+
invoice.stripePdfUrl && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Button, { variant: "outline", onClick: handleDownloadPDF, children: [
|
|
1033
1036
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Download, { className: "me-2 h-4 w-4" }),
|
|
1034
1037
|
t("billing.ui.invoice.download_pdf")
|
|
1035
1038
|
] }),
|
|
1036
|
-
invoice.status === "open" /* OPEN */ && invoice.attempted && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1039
|
+
invoice.status === "open" /* OPEN */ && invoice.attempted && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Button, { variant: "default", onClick: handleRetryPayment, children: [
|
|
1037
1040
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.RefreshCw, { className: "me-2 h-4 w-4" }),
|
|
1038
1041
|
t("billing.ui.invoice.retry_payment")
|
|
1039
1042
|
] }),
|
|
1040
|
-
invoice.stripeHostedInvoiceUrl && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1043
|
+
invoice.stripeHostedInvoiceUrl && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Button, { variant: "outline", onClick: handleViewInStripe, children: [
|
|
1041
1044
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ExternalLink, { className: "me-2 h-4 w-4" }),
|
|
1042
1045
|
t("billing.ui.invoice.view_in_stripe")
|
|
1043
1046
|
] })
|
|
@@ -1051,7 +1054,7 @@ _chunk7QVYU63Ejs.__name.call(void 0, InvoiceDetails, "InvoiceDetails");
|
|
|
1051
1054
|
|
|
1052
1055
|
function InvoicesList({ invoices, onInvoicesChange }) {
|
|
1053
1056
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
1054
|
-
const fmt =
|
|
1057
|
+
const fmt = _chunk2WK35GO2js.useBillingFormatOptions.call(void 0, );
|
|
1055
1058
|
const [selectedInvoice, setSelectedInvoice] = _react.useState.call(void 0, null);
|
|
1056
1059
|
const handleRowClick = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (invoice) => {
|
|
1057
1060
|
setSelectedInvoice(invoice);
|
|
@@ -1063,30 +1066,30 @@ function InvoicesList({ invoices, onInvoicesChange }) {
|
|
|
1063
1066
|
return invoice.stripeInvoiceId.slice(-8);
|
|
1064
1067
|
}, "getInvoiceNumber");
|
|
1065
1068
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1066
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border rounded-lg overflow-clip", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1067
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1068
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1069
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1070
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1071
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1072
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1069
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border rounded-lg overflow-clip", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Table, { children: [
|
|
1070
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableHeader, { className: "bg-muted", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.TableRow, { children: [
|
|
1071
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableHead, { children: t("billing.ui.columns.invoice_number") }),
|
|
1072
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableHead, { children: t("billing.ui.columns.date") }),
|
|
1073
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableHead, { children: t("billing.ui.columns.status") }),
|
|
1074
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableHead, { className: "text-end", children: t("billing.ui.columns.amount") }),
|
|
1075
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableHead, { children: t("billing.ui.columns.period") })
|
|
1073
1076
|
] }) }),
|
|
1074
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1077
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableBody, { children: invoices.map((invoice) => {
|
|
1075
1078
|
const invoiceNumber = getInvoiceNumber(invoice);
|
|
1076
|
-
const date =
|
|
1077
|
-
const amount =
|
|
1078
|
-
const period = `${
|
|
1079
|
+
const date = _chunk2WK35GO2js.formatDate.call(void 0, invoice.periodStart, fmt);
|
|
1080
|
+
const amount = _chunk5TH2DSAHjs.formatCurrency.call(void 0, invoice.total, invoice.currency, fmt);
|
|
1081
|
+
const period = `${_chunk2WK35GO2js.formatDate.call(void 0, invoice.periodStart, fmt)} - ${_chunk2WK35GO2js.formatDate.call(void 0, invoice.periodEnd, fmt)}`;
|
|
1079
1082
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1080
|
-
|
|
1083
|
+
_chunk2WK35GO2js.TableRow,
|
|
1081
1084
|
{
|
|
1082
1085
|
onClick: () => handleRowClick(invoice),
|
|
1083
1086
|
className: "cursor-pointer hover:bg-muted/50",
|
|
1084
1087
|
children: [
|
|
1085
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1086
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1087
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1088
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1089
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1088
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableCell, { className: "font-medium", children: invoiceNumber }),
|
|
1089
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableCell, { className: "text-muted-foreground text-xs", children: date }),
|
|
1090
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableCell, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, InvoiceStatusBadge, { status: invoice.status }) }),
|
|
1091
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableCell, { className: "text-end font-medium", children: amount }),
|
|
1092
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableCell, { className: "text-muted-foreground text-xs", children: period })
|
|
1090
1093
|
]
|
|
1091
1094
|
},
|
|
1092
1095
|
invoice.id
|
|
@@ -1120,7 +1123,7 @@ function InvoicesContainer() {
|
|
|
1120
1123
|
setLoading(true);
|
|
1121
1124
|
try {
|
|
1122
1125
|
const params = statusFilter !== "all" ? { status: statusFilter } : void 0;
|
|
1123
|
-
const data = await
|
|
1126
|
+
const data = await _chunk5TH2DSAHjs.StripeInvoiceService.listInvoices(params);
|
|
1124
1127
|
setInvoices(data);
|
|
1125
1128
|
} catch (error) {
|
|
1126
1129
|
console.error("[InvoicesContainer] Failed to load invoices:", error);
|
|
@@ -1136,12 +1139,12 @@ function InvoicesContainer() {
|
|
|
1136
1139
|
setStatusFilter(value);
|
|
1137
1140
|
}, "handleFilterChange");
|
|
1138
1141
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-4", children: [
|
|
1139
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1140
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1141
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1142
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1143
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1144
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1142
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Tabs, { value: statusFilter, onValueChange: handleFilterChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.TabsList, { children: [
|
|
1143
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TabsTrigger, { value: "all", children: t("billing.ui.invoices.filter_all") }),
|
|
1144
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TabsTrigger, { value: "paid" /* PAID */, children: t("billing.ui.invoice_status.paid") }),
|
|
1145
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TabsTrigger, { value: "open" /* OPEN */, children: t("billing.ui.invoice_status.open") }),
|
|
1146
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TabsTrigger, { value: "void" /* VOID */, children: t("billing.ui.invoice_status.void") }),
|
|
1147
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TabsTrigger, { value: "uncollectible" /* UNCOLLECTIBLE */, children: t("billing.ui.invoice_status.uncollectible") })
|
|
1145
1148
|
] }) }),
|
|
1146
1149
|
loading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-center py-8 text-muted-foreground", children: t("billing.ui.invoices.loading") }),
|
|
1147
1150
|
!loading && invoices.length === 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "border border-dashed border-gray-300 rounded-lg p-8 text-center", children: [
|
|
@@ -1183,7 +1186,7 @@ function CancelSubscriptionDialog({
|
|
|
1183
1186
|
onSuccess
|
|
1184
1187
|
}) {
|
|
1185
1188
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
1186
|
-
const fmt =
|
|
1189
|
+
const fmt = _chunk2WK35GO2js.useBillingFormatOptions.call(void 0, );
|
|
1187
1190
|
const [isSubmitting, setIsSubmitting] = _react.useState.call(void 0, false);
|
|
1188
1191
|
const form = _reacthookform.useForm.call(void 0, {
|
|
1189
1192
|
resolver: _zod.zodResolver.call(void 0, formSchema),
|
|
@@ -1194,7 +1197,7 @@ function CancelSubscriptionDialog({
|
|
|
1194
1197
|
const onSubmit = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async (_values) => {
|
|
1195
1198
|
setIsSubmitting(true);
|
|
1196
1199
|
try {
|
|
1197
|
-
await
|
|
1200
|
+
await _chunk5TH2DSAHjs.StripeSubscriptionService.cancelSubscription({
|
|
1198
1201
|
id: subscription.id,
|
|
1199
1202
|
cancelImmediately: false
|
|
1200
1203
|
});
|
|
@@ -1206,16 +1209,16 @@ function CancelSubscriptionDialog({
|
|
|
1206
1209
|
setIsSubmitting(false);
|
|
1207
1210
|
}
|
|
1208
1211
|
}, "onSubmit");
|
|
1209
|
-
const periodEndDate =
|
|
1210
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1211
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1212
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1213
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1212
|
+
const periodEndDate = _chunk2WK35GO2js.formatDate.call(void 0, subscription.currentPeriodEnd, fmt);
|
|
1213
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.DialogContent, { className: "max-w-md", children: [
|
|
1214
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.DialogHeader, { children: [
|
|
1215
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.DialogTitle, { children: t("billing.ui.subscription.cancel.title") }),
|
|
1216
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.DialogDescription, { children: t("billing.ui.subscription.cancel.description") })
|
|
1214
1217
|
] }),
|
|
1215
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1218
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Form, { ...form, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { onSubmit: form.handleSubmit(onSubmit), className: "flex flex-col gap-y-4", children: [
|
|
1216
1219
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "bg-primary/10 border-primary/30 text-foreground rounded-lg border p-3 text-sm", children: t("billing.ui.subscription.cancel.remains_active", { date: periodEndDate }) }),
|
|
1217
1220
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1218
|
-
|
|
1221
|
+
_chunk2WK35GO2js.FormTextarea,
|
|
1219
1222
|
{
|
|
1220
1223
|
form,
|
|
1221
1224
|
id: "reason",
|
|
@@ -1225,8 +1228,8 @@ function CancelSubscriptionDialog({
|
|
|
1225
1228
|
}
|
|
1226
1229
|
),
|
|
1227
1230
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex gap-x-2 justify-end pt-2", children: [
|
|
1228
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1229
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1231
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Button, { type: "button", variant: "outline", onClick: () => onOpenChange(false), disabled: isSubmitting, children: t("billing.ui.subscription.cancel.keep") }),
|
|
1232
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Button, { type: "submit", variant: "destructive", disabled: isSubmitting, children: isSubmitting ? t("billing.ui.subscription.cancel.canceling") : t("billing.ui.subscription.cancel.confirm") })
|
|
1230
1233
|
] })
|
|
1231
1234
|
] }) })
|
|
1232
1235
|
] }) });
|
|
@@ -1277,7 +1280,7 @@ var cancelingConfig = {
|
|
|
1277
1280
|
function SubscriptionStatusBadge({ status, cancelAtPeriodEnd }) {
|
|
1278
1281
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
1279
1282
|
const config = cancelAtPeriodEnd ? cancelingConfig : statusConfig2[status] || statusConfig2["canceled" /* CANCELED */];
|
|
1280
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1283
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Badge, { variant: config.variant, children: t(config.label) });
|
|
1281
1284
|
}
|
|
1282
1285
|
_chunk7QVYU63Ejs.__name.call(void 0, SubscriptionStatusBadge, "SubscriptionStatusBadge");
|
|
1283
1286
|
|
|
@@ -1304,7 +1307,7 @@ function formatPlanName2(price, t) {
|
|
|
1304
1307
|
_chunk7QVYU63Ejs.__name.call(void 0, formatPlanName2, "formatPlanName");
|
|
1305
1308
|
function formatBillingAmount(price, notAvailable, fmt) {
|
|
1306
1309
|
if (!_optionalChain([price, 'optionalAccess', _37 => _37.unitAmount])) return notAvailable;
|
|
1307
|
-
return
|
|
1310
|
+
return _chunk5TH2DSAHjs.formatCurrency.call(void 0, price.unitAmount, price.currency, fmt);
|
|
1308
1311
|
}
|
|
1309
1312
|
_chunk7QVYU63Ejs.__name.call(void 0, formatBillingAmount, "formatBillingAmount");
|
|
1310
1313
|
function SubscriptionDetails({
|
|
@@ -1315,13 +1318,13 @@ function SubscriptionDetails({
|
|
|
1315
1318
|
onChangePlan
|
|
1316
1319
|
}) {
|
|
1317
1320
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
1318
|
-
const fmt =
|
|
1321
|
+
const fmt = _chunk2WK35GO2js.useBillingFormatOptions.call(void 0, );
|
|
1319
1322
|
const [showCancel, setShowCancel] = _react.useState.call(void 0, false);
|
|
1320
1323
|
const [isProcessing, setIsProcessing] = _react.useState.call(void 0, false);
|
|
1321
1324
|
const handlePause = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
1322
1325
|
setIsProcessing(true);
|
|
1323
1326
|
try {
|
|
1324
|
-
await
|
|
1327
|
+
await _chunk5TH2DSAHjs.StripeSubscriptionService.pauseSubscription({ subscriptionId: subscription.id });
|
|
1325
1328
|
onSubscriptionChange();
|
|
1326
1329
|
} catch (error) {
|
|
1327
1330
|
console.error("[SubscriptionDetails] Failed to pause subscription:", error);
|
|
@@ -1332,7 +1335,7 @@ function SubscriptionDetails({
|
|
|
1332
1335
|
const handleResume = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
1333
1336
|
setIsProcessing(true);
|
|
1334
1337
|
try {
|
|
1335
|
-
await
|
|
1338
|
+
await _chunk5TH2DSAHjs.StripeSubscriptionService.resumeSubscription({ subscriptionId: subscription.id });
|
|
1336
1339
|
onSubscriptionChange();
|
|
1337
1340
|
} catch (error) {
|
|
1338
1341
|
console.error("[SubscriptionDetails] Failed to resume subscription:", error);
|
|
@@ -1342,7 +1345,7 @@ function SubscriptionDetails({
|
|
|
1342
1345
|
}, "handleResume");
|
|
1343
1346
|
const handleManageViaPortal = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
1344
1347
|
try {
|
|
1345
|
-
const { url } = await
|
|
1348
|
+
const { url } = await _chunk5TH2DSAHjs.StripeCustomerService.createPortalSession();
|
|
1346
1349
|
window.open(url, "_blank");
|
|
1347
1350
|
} catch (error) {
|
|
1348
1351
|
console.error("[SubscriptionDetails] Failed to create portal session:", error);
|
|
@@ -1352,10 +1355,10 @@ function SubscriptionDetails({
|
|
|
1352
1355
|
const canResume = subscription.status === "paused" /* PAUSED */;
|
|
1353
1356
|
const canCancel = subscription.status === "active" /* ACTIVE */ || subscription.status === "trialing" /* TRIALING */ || subscription.status === "paused" /* PAUSED */;
|
|
1354
1357
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1355
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1356
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1357
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1358
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1358
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.DialogContent, { className: "max-w-2xl", children: [
|
|
1359
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.DialogHeader, { children: [
|
|
1360
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.DialogTitle, { children: t("billing.ui.subscription.details_title") }),
|
|
1361
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.DialogDescription, { children: t("billing.ui.subscription.details_description") })
|
|
1359
1362
|
] }),
|
|
1360
1363
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-6", children: [
|
|
1361
1364
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-3", children: [
|
|
@@ -1381,24 +1384,24 @@ function SubscriptionDetails({
|
|
|
1381
1384
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "space-y-2", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between", children: [
|
|
1382
1385
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("billing.ui.subscription.current_period") }),
|
|
1383
1386
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "text-sm", children: [
|
|
1384
|
-
|
|
1387
|
+
_chunk2WK35GO2js.formatDate.call(void 0, subscription.currentPeriodStart, fmt),
|
|
1385
1388
|
" - ",
|
|
1386
|
-
|
|
1389
|
+
_chunk2WK35GO2js.formatDate.call(void 0, subscription.currentPeriodEnd, fmt)
|
|
1387
1390
|
] })
|
|
1388
1391
|
] }) }),
|
|
1389
1392
|
subscription.trialEnd && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between", children: [
|
|
1390
1393
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("billing.ui.subscription.trial_ends") }),
|
|
1391
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm", children:
|
|
1394
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm", children: _chunk2WK35GO2js.formatDate.call(void 0, subscription.trialEnd, fmt) })
|
|
1392
1395
|
] }),
|
|
1393
1396
|
subscription.cancelAtPeriodEnd && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "bg-warning/15 border-warning/30 rounded-lg border p-3", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-warning text-xs/relaxed", children: t("billing.ui.subscription.cancel_at_period_end", {
|
|
1394
|
-
date:
|
|
1397
|
+
date: _chunk2WK35GO2js.formatDate.call(void 0, subscription.currentPeriodEnd, fmt)
|
|
1395
1398
|
}) }) }),
|
|
1396
1399
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-wrap gap-2 pt-4 border-t", children: [
|
|
1397
|
-
onChangePlan && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1398
|
-
canPause && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1399
|
-
canResume && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1400
|
-
canCancel && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1401
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1400
|
+
onChangePlan && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Button, { variant: "default", onClick: () => onChangePlan(subscription), children: t("billing.ui.subscription.change_plan") }),
|
|
1401
|
+
canPause && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Button, { variant: "outline", onClick: handlePause, disabled: isProcessing, children: isProcessing ? t("billing.ui.subscription.pausing") : t("billing.ui.subscription.pause") }),
|
|
1402
|
+
canResume && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Button, { variant: "outline", onClick: handleResume, disabled: isProcessing, children: isProcessing ? t("billing.ui.subscription.resuming") : t("billing.ui.subscription.resume") }),
|
|
1403
|
+
canCancel && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Button, { variant: "destructive", onClick: () => setShowCancel(true), children: t("ui.buttons.cancel") }),
|
|
1404
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Button, { variant: "outline", onClick: handleManageViaPortal, children: t("billing.ui.subscription.manage_portal") })
|
|
1402
1405
|
] })
|
|
1403
1406
|
] })
|
|
1404
1407
|
] }) }),
|
|
@@ -1441,46 +1444,46 @@ function formatPlanName3(price, t) {
|
|
|
1441
1444
|
_chunk7QVYU63Ejs.__name.call(void 0, formatPlanName3, "formatPlanName");
|
|
1442
1445
|
function SubscriptionsList({ subscriptions, onSubscriptionsChange, onChangePlan }) {
|
|
1443
1446
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
1444
|
-
const fmt =
|
|
1447
|
+
const fmt = _chunk2WK35GO2js.useBillingFormatOptions.call(void 0, );
|
|
1445
1448
|
const [selectedSub, setSelectedSub] = _react.useState.call(void 0, null);
|
|
1446
1449
|
const handleRowClick = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (subscription) => {
|
|
1447
1450
|
setSelectedSub(subscription);
|
|
1448
1451
|
}, "handleRowClick");
|
|
1449
1452
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1450
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border rounded-lg overflow-clip", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1451
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1452
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1453
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1454
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1455
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1456
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1453
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border rounded-lg overflow-clip", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Table, { children: [
|
|
1454
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableHeader, { className: "bg-muted", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.TableRow, { children: [
|
|
1455
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableHead, { children: t("billing.ui.columns.status") }),
|
|
1456
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableHead, { children: t("billing.ui.columns.plan") }),
|
|
1457
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableHead, { children: t("billing.ui.columns.period") }),
|
|
1458
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableHead, { className: "text-end", children: t("billing.ui.columns.amount") }),
|
|
1459
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableHead, { className: "text-end", children: t("billing.ui.columns.actions") })
|
|
1457
1460
|
] }) }),
|
|
1458
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1461
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableBody, { children: subscriptions.map((subscription) => {
|
|
1459
1462
|
const price = subscription.price;
|
|
1460
|
-
const amount = _optionalChain([price, 'optionalAccess', _42 => _42.unitAmount]) ?
|
|
1461
|
-
const discountedAmount = price ?
|
|
1462
|
-
const period = `${
|
|
1463
|
+
const amount = _optionalChain([price, 'optionalAccess', _42 => _42.unitAmount]) ? _chunk5TH2DSAHjs.formatCurrency.call(void 0, price.unitAmount, price.currency, fmt) : "0";
|
|
1464
|
+
const discountedAmount = price ? _chunk2WK35GO2js.applyDiscount.call(void 0, price.unitAmount, _chunk2WK35GO2js.subscriptionDiscount.call(void 0, subscription)) : null;
|
|
1465
|
+
const period = `${_chunk2WK35GO2js.formatDate.call(void 0, subscription.currentPeriodStart, fmt)} - ${_chunk2WK35GO2js.formatDate.call(void 0, subscription.currentPeriodEnd, fmt)}`;
|
|
1463
1466
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1464
|
-
|
|
1467
|
+
_chunk2WK35GO2js.TableRow,
|
|
1465
1468
|
{
|
|
1466
1469
|
onClick: () => handleRowClick(subscription),
|
|
1467
1470
|
className: "cursor-pointer hover:bg-muted/50",
|
|
1468
1471
|
children: [
|
|
1469
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1472
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableCell, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1470
1473
|
SubscriptionStatusBadge,
|
|
1471
1474
|
{
|
|
1472
1475
|
status: subscription.status,
|
|
1473
1476
|
cancelAtPeriodEnd: subscription.cancelAtPeriodEnd
|
|
1474
1477
|
}
|
|
1475
1478
|
) }),
|
|
1476
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1477
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1478
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1479
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableCell, { className: "font-medium", children: formatPlanName3(price, t) }),
|
|
1480
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableCell, { className: "text-muted-foreground text-sm", children: period }),
|
|
1481
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableCell, { className: "text-end font-medium", children: discountedAmount !== null && price ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1479
1482
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "line-through text-muted-foreground me-2", children: amount }),
|
|
1480
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-success", children:
|
|
1483
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-success", children: _chunk5TH2DSAHjs.formatCurrency.call(void 0, discountedAmount, price.currency, fmt) })
|
|
1481
1484
|
] }) : amount }),
|
|
1482
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1483
|
-
|
|
1485
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableCell, { className: "text-end", children: (subscription.status === "active" /* ACTIVE */ || subscription.status === "trialing" /* TRIALING */) && onChangePlan && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1486
|
+
_chunk2WK35GO2js.Button,
|
|
1484
1487
|
{
|
|
1485
1488
|
size: "sm",
|
|
1486
1489
|
variant: "outline",
|
|
@@ -1538,7 +1541,7 @@ function SubscriptionsContainer({
|
|
|
1538
1541
|
}
|
|
1539
1542
|
setLoading(true);
|
|
1540
1543
|
try {
|
|
1541
|
-
const fetchedSubscriptions = await
|
|
1544
|
+
const fetchedSubscriptions = await _chunk5TH2DSAHjs.StripeSubscriptionService.listSubscriptions();
|
|
1542
1545
|
setSubscriptions(fetchedSubscriptions);
|
|
1543
1546
|
} catch (error) {
|
|
1544
1547
|
console.error("[SubscriptionsContainer] Failed to load subscriptions:", error);
|
|
@@ -1561,7 +1564,7 @@ function SubscriptionsContainer({
|
|
|
1561
1564
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-8 w-8" }),
|
|
1562
1565
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h1", { className: "text-primary text-3xl font-semibold", children: t("billing.ui.subscriptions.title") })
|
|
1563
1566
|
] }),
|
|
1564
|
-
subscriptions.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1567
|
+
subscriptions.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Button, { onClick: () => _optionalChain([onOpenWizard, 'optionalCall', _44 => _44()]), children: hasActiveRecurringSubscription ? t("billing.ui.subscriptions.purchase_addons") : t("billing.ui.subscriptions.subscribe") })
|
|
1565
1568
|
] }),
|
|
1566
1569
|
criticalSubscriptions.map((subscription) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BillingAlertBanner, { subscription }, subscription.id)),
|
|
1567
1570
|
subscriptions.length === 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col items-center justify-center py-12 space-y-4", children: [
|
|
@@ -1569,7 +1572,7 @@ function SubscriptionsContainer({
|
|
|
1569
1572
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "text-center", children: [
|
|
1570
1573
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-sm font-medium mb-2", children: t("billing.ui.subscriptions.empty_title") }),
|
|
1571
1574
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-muted-foreground mb-6", children: t("billing.ui.subscriptions.empty_description") }),
|
|
1572
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1575
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Button, { onClick: () => _optionalChain([onOpenWizard, 'optionalCall', _45 => _45()]), children: t("billing.ui.subscriptions.subscribe") })
|
|
1573
1576
|
] })
|
|
1574
1577
|
] }),
|
|
1575
1578
|
subscriptions.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -1592,9 +1595,9 @@ function IntervalToggle({ value, onChange, hasMonthly, hasYearly }) {
|
|
|
1592
1595
|
if (!hasMonthly || !hasYearly) {
|
|
1593
1596
|
return null;
|
|
1594
1597
|
}
|
|
1595
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1596
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1597
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1598
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Tabs, { value, onValueChange: (v) => onChange(v), children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.TabsList, { children: [
|
|
1599
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TabsTrigger, { value: "month", children: t("billing.admin.prices.interval.month") }),
|
|
1600
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TabsTrigger, { value: "year", children: t("billing.admin.prices.interval.year") })
|
|
1598
1601
|
] }) });
|
|
1599
1602
|
}
|
|
1600
1603
|
_chunk7QVYU63Ejs.__name.call(void 0, IntervalToggle, "IntervalToggle");
|
|
@@ -1612,11 +1615,11 @@ function PricingCard({
|
|
|
1612
1615
|
onSelect
|
|
1613
1616
|
}) {
|
|
1614
1617
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
1615
|
-
const fmt =
|
|
1618
|
+
const fmt = _chunk2WK35GO2js.useBillingFormatOptions.call(void 0, );
|
|
1616
1619
|
const description = price.description || price.nickname || t("billing.ui.pricing.standard");
|
|
1617
1620
|
const features = price.features || [];
|
|
1618
|
-
const formattedPrice =
|
|
1619
|
-
const interval =
|
|
1621
|
+
const formattedPrice = _chunk5TH2DSAHjs.formatCurrency.call(void 0, price.unitAmount, price.currency, fmt);
|
|
1622
|
+
const interval = _chunk5TH2DSAHjs.formatInterval.call(void 0, price, fmt);
|
|
1620
1623
|
const handleKeyDown = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (e) => {
|
|
1621
1624
|
if ((e.key === "Enter" || e.key === " ") && !isDisabled && !isCurrentPlan) {
|
|
1622
1625
|
e.preventDefault();
|
|
@@ -1629,7 +1632,7 @@ function PricingCard({
|
|
|
1629
1632
|
}
|
|
1630
1633
|
}, "handleClick");
|
|
1631
1634
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1632
|
-
|
|
1635
|
+
_chunk2WK35GO2js.Card,
|
|
1633
1636
|
{
|
|
1634
1637
|
role: "radio",
|
|
1635
1638
|
"aria-checked": isSelected,
|
|
@@ -1637,7 +1640,7 @@ function PricingCard({
|
|
|
1637
1640
|
tabIndex: isDisabled ? -1 : 0,
|
|
1638
1641
|
onKeyDown: handleKeyDown,
|
|
1639
1642
|
onClick: handleClick,
|
|
1640
|
-
className:
|
|
1643
|
+
className: _chunk5TH2DSAHjs.cn.call(void 0,
|
|
1641
1644
|
"relative cursor-pointer transition-all duration-200 flex flex-col h-full",
|
|
1642
1645
|
"focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
1643
1646
|
isCurrentPlan && "bg-muted/30",
|
|
@@ -1647,9 +1650,9 @@ function PricingCard({
|
|
|
1647
1650
|
isLoading && "pointer-events-none"
|
|
1648
1651
|
),
|
|
1649
1652
|
children: [
|
|
1650
|
-
isCurrentPlan && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1651
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1652
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1653
|
+
isCurrentPlan && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Badge, { variant: "secondary", className: "absolute top-2 end-2", children: t("billing.ui.pricing.current") }),
|
|
1654
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardHeader, { className: "pb-2", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-sm font-medium", children: description }) }),
|
|
1655
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.CardContent, { className: "pb-4 grow", children: [
|
|
1653
1656
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mb-4", children: [
|
|
1654
1657
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-3xl font-bold", children: formattedPrice }),
|
|
1655
1658
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground ms-1", children: interval })
|
|
@@ -1659,8 +1662,8 @@ function PricingCard({
|
|
|
1659
1662
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm text-muted-foreground", children: feature })
|
|
1660
1663
|
] }, index)) })
|
|
1661
1664
|
] }),
|
|
1662
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1663
|
-
|
|
1665
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardFooter, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1666
|
+
_chunk2WK35GO2js.Button,
|
|
1664
1667
|
{
|
|
1665
1668
|
variant: isCurrentPlan ? "secondary" : isSelected ? "default" : "outline",
|
|
1666
1669
|
className: "w-full",
|
|
@@ -1693,7 +1696,7 @@ function ProductPricingRow({
|
|
|
1693
1696
|
return null;
|
|
1694
1697
|
}
|
|
1695
1698
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-3", children: [
|
|
1696
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1699
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.SectionHeader, { children: product.name }),
|
|
1697
1700
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1698
1701
|
"div",
|
|
1699
1702
|
{
|
|
@@ -1794,15 +1797,15 @@ function ProductPricingList({
|
|
|
1794
1797
|
_chunk7QVYU63Ejs.__name.call(void 0, ProductPricingList, "ProductPricingList");
|
|
1795
1798
|
function ProductPricingListSkeleton() {
|
|
1796
1799
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "space-y-6", children: [1, 2].map((rowIndex) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-3", children: [
|
|
1797
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1800
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Skeleton, { className: "h-6 w-32" }),
|
|
1798
1801
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4", children: [1, 2, 3].map((cardIndex) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "p-4 rounded-lg border animate-pulse space-y-3", children: [
|
|
1799
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1800
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1802
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Skeleton, { className: "h-6 w-24" }),
|
|
1803
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Skeleton, { className: "h-8 w-32" }),
|
|
1801
1804
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
1802
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1803
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1805
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Skeleton, { className: "h-4 w-full" }),
|
|
1806
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Skeleton, { className: "h-4 w-3/4" })
|
|
1804
1807
|
] }),
|
|
1805
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1808
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Skeleton, { className: "h-10 w-full" })
|
|
1806
1809
|
] }, cardIndex)) })
|
|
1807
1810
|
] }, rowIndex)) });
|
|
1808
1811
|
}
|
|
@@ -1813,21 +1816,21 @@ _chunk7QVYU63Ejs.__name.call(void 0, ProductPricingListSkeleton, "ProductPricing
|
|
|
1813
1816
|
|
|
1814
1817
|
function ProrationPreview({ preview }) {
|
|
1815
1818
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
1816
|
-
const fmt =
|
|
1819
|
+
const fmt = _chunk2WK35GO2js.useBillingFormatOptions.call(void 0, );
|
|
1817
1820
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "bg-primary/10 border-primary/30 rounded-lg border p-4", children: [
|
|
1818
1821
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h4", { className: "text-primary mb-3 font-semibold", children: t("billing.ui.proration.title") }),
|
|
1819
1822
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
1820
1823
|
preview.lineItems.map((item, index) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between text-sm", children: [
|
|
1821
1824
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground", children: item.description }),
|
|
1822
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: `font-medium ${item.amount < 0 ? "text-success" : "text-foreground"}`, children:
|
|
1825
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: `font-medium ${item.amount < 0 ? "text-success" : "text-foreground"}`, children: _chunk5TH2DSAHjs.formatCurrency.call(void 0, item.amount, preview.currency, fmt) })
|
|
1823
1826
|
] }, index)),
|
|
1824
1827
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border-primary/30 mt-2 border-t pt-2", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between font-semibold", children: [
|
|
1825
1828
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-foreground", children: t("billing.ui.proration.net_due_today") }),
|
|
1826
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-foreground", children:
|
|
1829
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-foreground", children: _chunk5TH2DSAHjs.formatCurrency.call(void 0, preview.immediateCharge, preview.currency, fmt) })
|
|
1827
1830
|
] }) }),
|
|
1828
1831
|
preview.lineItems.length > 0 && preview.lineItems[0].period && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-muted-foreground mt-2 text-xs", children: t("billing.ui.proration.next_invoice", {
|
|
1829
|
-
date:
|
|
1830
|
-
amount:
|
|
1832
|
+
date: _chunk2WK35GO2js.formatDate.call(void 0, preview.lineItems[0].period.end, fmt),
|
|
1833
|
+
amount: _chunk5TH2DSAHjs.formatCurrency.call(void 0, preview.amountDue, preview.currency, fmt)
|
|
1831
1834
|
}) })
|
|
1832
1835
|
] })
|
|
1833
1836
|
] });
|
|
@@ -1840,7 +1843,7 @@ _chunk7QVYU63Ejs.__name.call(void 0, ProrationPreview, "ProrationPreview");
|
|
|
1840
1843
|
|
|
1841
1844
|
function SubscriptionConfirmation({ price, isLoading, onConfirm, onCancel }) {
|
|
1842
1845
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
1843
|
-
const fmt =
|
|
1846
|
+
const fmt = _chunk2WK35GO2js.useBillingFormatOptions.call(void 0, );
|
|
1844
1847
|
const productName = _optionalChain([price, 'access', _51 => _51.product, 'optionalAccess', _52 => _52.name]) || price.nickname || t("billing.ui.wizard.review.selected_plan");
|
|
1845
1848
|
const productDescription = _optionalChain([price, 'access', _53 => _53.product, 'optionalAccess', _54 => _54.description]) || price.description;
|
|
1846
1849
|
const features = price.features || [];
|
|
@@ -1852,16 +1855,16 @@ function SubscriptionConfirmation({ price, isLoading, onConfirm, onCancel }) {
|
|
|
1852
1855
|
productDescription && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-sm text-muted-foreground", children: productDescription })
|
|
1853
1856
|
] }),
|
|
1854
1857
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "text-lg font-semibold", children: [
|
|
1855
|
-
|
|
1856
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-normal text-muted-foreground", children:
|
|
1858
|
+
_chunk5TH2DSAHjs.formatCurrency.call(void 0, price.unitAmount, price.currency, fmt),
|
|
1859
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-normal text-muted-foreground", children: _chunk5TH2DSAHjs.formatInterval.call(void 0, price, fmt) })
|
|
1857
1860
|
] }),
|
|
1858
1861
|
features.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "space-y-1", children: features.map((feature, index) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2 text-sm ", children: [
|
|
1859
1862
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Check, { className: "h-4 w-4 text-primary" }),
|
|
1860
1863
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: feature })
|
|
1861
1864
|
] }, index)) }),
|
|
1862
1865
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-end gap-3 pt-2 border-t border-accent/30", children: [
|
|
1863
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1864
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1866
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Button, { variant: "outline", onClick: onCancel, disabled: isLoading, children: t("ui.buttons.cancel") }),
|
|
1867
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Button, { onClick: onConfirm, disabled: isLoading, children: isLoading ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1865
1868
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Loader2, { className: "h-4 w-4 animate-spin me-2" }),
|
|
1866
1869
|
t("billing.ui.wizard.review.processing")
|
|
1867
1870
|
] }) : t("billing.ui.confirmation.subscribe") })
|
|
@@ -1890,14 +1893,20 @@ function shouldLookUpAutomatic(code) {
|
|
|
1890
1893
|
return !code || code.automatic === true;
|
|
1891
1894
|
}
|
|
1892
1895
|
_chunk7QVYU63Ejs.__name.call(void 0, shouldLookUpAutomatic, "shouldLookUpAutomatic");
|
|
1896
|
+
function read(value, key) {
|
|
1897
|
+
return typeof value === "object" && value !== null ? Reflect.get(value, key) : void 0;
|
|
1898
|
+
}
|
|
1899
|
+
_chunk7QVYU63Ejs.__name.call(void 0, read, "read");
|
|
1893
1900
|
function errorStatus(error) {
|
|
1894
|
-
|
|
1901
|
+
const status = _nullishCoalesce(read(error, "status"), () => ( read(read(error, "response"), "status")));
|
|
1902
|
+
return typeof status === "number" ? status : void 0;
|
|
1895
1903
|
}
|
|
1896
1904
|
_chunk7QVYU63Ejs.__name.call(void 0, errorStatus, "errorStatus");
|
|
1897
1905
|
function errorCode(error) {
|
|
1898
|
-
const body =
|
|
1899
|
-
const
|
|
1900
|
-
const
|
|
1906
|
+
const body = read(error, "body");
|
|
1907
|
+
const errors = read(body, "errors");
|
|
1908
|
+
const first = Array.isArray(errors) ? errors[0] : void 0;
|
|
1909
|
+
const code = _nullishCoalesce(_nullishCoalesce(read(first, "code"), () => ( read(read(read(first, "meta"), "context"), "code"))), () => ( read(body, "code")));
|
|
1901
1910
|
return typeof code === "string" ? code : void 0;
|
|
1902
1911
|
}
|
|
1903
1912
|
_chunk7QVYU63Ejs.__name.call(void 0, errorCode, "errorCode");
|
|
@@ -1944,10 +1953,10 @@ function useConfirmSubscriptionPayment() {
|
|
|
1944
1953
|
error: stripeError.message || t("billing.ui.payment_confirm.errors.failed")
|
|
1945
1954
|
};
|
|
1946
1955
|
}
|
|
1947
|
-
if (_optionalChain([paymentIntent, 'optionalAccess',
|
|
1956
|
+
if (_optionalChain([paymentIntent, 'optionalAccess', _55 => _55.status]) === "succeeded") {
|
|
1948
1957
|
return { success: true };
|
|
1949
1958
|
}
|
|
1950
|
-
if (_optionalChain([paymentIntent, 'optionalAccess',
|
|
1959
|
+
if (_optionalChain([paymentIntent, 'optionalAccess', _56 => _56.status]) === "requires_action") {
|
|
1951
1960
|
return {
|
|
1952
1961
|
success: false,
|
|
1953
1962
|
error: t("billing.ui.payment_confirm.errors.requires_action")
|
|
@@ -1978,12 +1987,12 @@ _chunk7QVYU63Ejs.__name.call(void 0, useConfirmSubscriptionPayment, "useConfirmS
|
|
|
1978
1987
|
|
|
1979
1988
|
// src/features/billing/stripe-subscription/hooks/wizard-payment.ts
|
|
1980
1989
|
function clientSecretToConfirm(meta) {
|
|
1981
|
-
if (!_optionalChain([meta, 'optionalAccess',
|
|
1990
|
+
if (!_optionalChain([meta, 'optionalAccess', _57 => _57.requiresAction])) return null;
|
|
1982
1991
|
return meta.clientSecret || null;
|
|
1983
1992
|
}
|
|
1984
1993
|
_chunk7QVYU63Ejs.__name.call(void 0, clientSecretToConfirm, "clientSecretToConfirm");
|
|
1985
1994
|
function subscriptionIdToSync(answered, opened) {
|
|
1986
|
-
return _optionalChain([answered, 'optionalAccess',
|
|
1995
|
+
return _optionalChain([answered, 'optionalAccess', _58 => _58.id]) || _optionalChain([opened, 'optionalAccess', _59 => _59.id]) || null;
|
|
1987
1996
|
}
|
|
1988
1997
|
_chunk7QVYU63Ejs.__name.call(void 0, subscriptionIdToSync, "subscriptionIdToSync");
|
|
1989
1998
|
|
|
@@ -2034,11 +2043,11 @@ function wizardReducer(state, action) {
|
|
|
2034
2043
|
_chunk7QVYU63Ejs.__name.call(void 0, wizardReducer, "wizardReducer");
|
|
2035
2044
|
function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
2036
2045
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
2037
|
-
const locale =
|
|
2046
|
+
const locale = _chunk5TH2DSAHjs.useI18nLocale.call(void 0, );
|
|
2038
2047
|
const { confirmPayment } = useConfirmSubscriptionPayment();
|
|
2039
2048
|
const [state, dispatch] = _react.useReducer.call(void 0, wizardReducer, {
|
|
2040
2049
|
...initialState,
|
|
2041
|
-
selectedPrice: _optionalChain([subscription, 'optionalAccess',
|
|
2050
|
+
selectedPrice: _optionalChain([subscription, 'optionalAccess', _60 => _60.price]) || null
|
|
2042
2051
|
});
|
|
2043
2052
|
const onSuccessRef = _react.useRef.call(void 0, onSuccess);
|
|
2044
2053
|
const onCloseRef = _react.useRef.call(void 0, onClose);
|
|
@@ -2046,7 +2055,7 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
2046
2055
|
onCloseRef.current = onClose;
|
|
2047
2056
|
const checkPaymentMethod = _react.useCallback.call(void 0, async () => {
|
|
2048
2057
|
try {
|
|
2049
|
-
const methods = await
|
|
2058
|
+
const methods = await _chunk5TH2DSAHjs.StripeCustomerService.listPaymentMethods();
|
|
2050
2059
|
dispatch({ type: "SET_HAS_PAYMENT_METHOD", hasMethod: methods.length > 0 });
|
|
2051
2060
|
} catch (error) {
|
|
2052
2061
|
console.error("[useSubscriptionWizard] Failed to check payment methods:", error);
|
|
@@ -2064,10 +2073,10 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
2064
2073
|
}, []);
|
|
2065
2074
|
const lookUpAutomaticCode = _react.useCallback.call(void 0, async (priceId) => {
|
|
2066
2075
|
try {
|
|
2067
|
-
const automaticCode = await
|
|
2076
|
+
const automaticCode = await _chunk5TH2DSAHjs.StripeCouponCodeService.findAutomatic({ priceId });
|
|
2068
2077
|
dispatch({
|
|
2069
2078
|
type: "SET_PROMOTION_CODE",
|
|
2070
|
-
code: automaticCode ?
|
|
2079
|
+
code: automaticCode ? _chunk5TH2DSAHjs.toPromotionCodeResult.call(void 0, automaticCode) : null
|
|
2071
2080
|
});
|
|
2072
2081
|
return true;
|
|
2073
2082
|
} catch (error) {
|
|
@@ -2091,10 +2100,10 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
2091
2100
|
dispatch({ type: "SET_PROCESSING", isProcessing: true });
|
|
2092
2101
|
try {
|
|
2093
2102
|
await checkPaymentMethod();
|
|
2094
|
-
const isTrialUpgrade = _optionalChain([subscription, 'optionalAccess',
|
|
2103
|
+
const isTrialUpgrade = _optionalChain([subscription, 'optionalAccess', _61 => _61.status]) === "trialing" /* TRIALING */;
|
|
2095
2104
|
dispatch({ type: "SET_IS_TRIAL_SUBSCRIPTION", isTrial: isTrialUpgrade });
|
|
2096
2105
|
if (isTrialUpgrade && !state.hasPaymentMethod) {
|
|
2097
|
-
const methods = await
|
|
2106
|
+
const methods = await _chunk5TH2DSAHjs.StripeCustomerService.listPaymentMethods();
|
|
2098
2107
|
if (methods.length === 0) {
|
|
2099
2108
|
dispatch({ type: "SET_STEP", step: "payment-method" });
|
|
2100
2109
|
dispatch({
|
|
@@ -2111,8 +2120,8 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
2111
2120
|
return;
|
|
2112
2121
|
}
|
|
2113
2122
|
}
|
|
2114
|
-
if (subscription && state.selectedPrice.id !== _optionalChain([subscription, 'access',
|
|
2115
|
-
const preview = await
|
|
2123
|
+
if (subscription && state.selectedPrice.id !== _optionalChain([subscription, 'access', _62 => _62.price, 'optionalAccess', _63 => _63.id])) {
|
|
2124
|
+
const preview = await _chunk5TH2DSAHjs.StripeSubscriptionService.getProrationPreview({
|
|
2116
2125
|
subscriptionId: subscription.id,
|
|
2117
2126
|
newPriceId: state.selectedPrice.id
|
|
2118
2127
|
});
|
|
@@ -2121,7 +2130,7 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
2121
2130
|
dispatch({ type: "SET_STEP", step: "review" });
|
|
2122
2131
|
} catch (error) {
|
|
2123
2132
|
console.error("[useSubscriptionWizard] Error preparing review:", error);
|
|
2124
|
-
dispatch({ type: "SET_ERROR", error: _optionalChain([error, 'optionalAccess',
|
|
2133
|
+
dispatch({ type: "SET_ERROR", error: _optionalChain([error, 'optionalAccess', _64 => _64.message]) || t("billing.ui.wizard.errors.prepare_review") });
|
|
2125
2134
|
} finally {
|
|
2126
2135
|
dispatch({ type: "SET_PROCESSING", isProcessing: false });
|
|
2127
2136
|
}
|
|
@@ -2146,14 +2155,14 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
2146
2155
|
newPriceId: state.selectedPrice.id,
|
|
2147
2156
|
promotionCode: promotionCodeToSend(state.promotionCode)
|
|
2148
2157
|
};
|
|
2149
|
-
result = await
|
|
2158
|
+
result = await _chunk5TH2DSAHjs.StripeSubscriptionService.changePlanWithMeta(changePlanParams);
|
|
2150
2159
|
} else {
|
|
2151
2160
|
const createParams = {
|
|
2152
2161
|
id: _uuid.v4.call(void 0, ),
|
|
2153
2162
|
priceId: state.selectedPrice.id,
|
|
2154
2163
|
promotionCode: promotionCodeToSend(state.promotionCode)
|
|
2155
2164
|
};
|
|
2156
|
-
result = await
|
|
2165
|
+
result = await _chunk5TH2DSAHjs.StripeSubscriptionService.createSubscription(createParams);
|
|
2157
2166
|
}
|
|
2158
2167
|
const clientSecret = clientSecretToConfirm(result.meta);
|
|
2159
2168
|
if (clientSecret) {
|
|
@@ -2169,7 +2178,7 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
2169
2178
|
const subscriptionId = subscriptionIdToSync(result.subscription, subscription);
|
|
2170
2179
|
if (subscriptionId) {
|
|
2171
2180
|
try {
|
|
2172
|
-
await
|
|
2181
|
+
await _chunk5TH2DSAHjs.StripeSubscriptionService.syncSubscription({ subscriptionId });
|
|
2173
2182
|
} catch (syncError) {
|
|
2174
2183
|
console.error("[useSubscriptionWizard] Subscription sync after payment failed:", syncError);
|
|
2175
2184
|
}
|
|
@@ -2188,19 +2197,19 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
2188
2197
|
await refreshAutomaticCodeOrLeaveReview(state.selectedPrice.id);
|
|
2189
2198
|
return;
|
|
2190
2199
|
}
|
|
2191
|
-
if (_optionalChain([error, 'optionalAccess',
|
|
2200
|
+
if (_optionalChain([error, 'optionalAccess', _65 => _65.status]) === 409 || _optionalChain([error, 'optionalAccess', _66 => _66.response, 'optionalAccess', _67 => _67.status]) === 409) {
|
|
2192
2201
|
dispatch({
|
|
2193
2202
|
type: "SET_ERROR",
|
|
2194
2203
|
error: t("billing.ui.wizard.errors.already_subscribed")
|
|
2195
2204
|
});
|
|
2196
2205
|
return;
|
|
2197
2206
|
}
|
|
2198
|
-
if (_optionalChain([error, 'optionalAccess',
|
|
2207
|
+
if (_optionalChain([error, 'optionalAccess', _68 => _68.status]) === 402 || _optionalChain([error, 'optionalAccess', _69 => _69.response, 'optionalAccess', _70 => _70.status]) === 402) {
|
|
2199
2208
|
dispatch({ type: "SET_HAS_PAYMENT_METHOD", hasMethod: false });
|
|
2200
2209
|
dispatch({ type: "SET_STEP", step: "payment-method" });
|
|
2201
2210
|
return;
|
|
2202
2211
|
}
|
|
2203
|
-
dispatch({ type: "SET_ERROR", error: _optionalChain([error, 'optionalAccess',
|
|
2212
|
+
dispatch({ type: "SET_ERROR", error: _optionalChain([error, 'optionalAccess', _71 => _71.message]) || t("billing.ui.wizard.errors.process_subscription") });
|
|
2204
2213
|
} finally {
|
|
2205
2214
|
dispatch({ type: "SET_PROCESSING", isProcessing: false });
|
|
2206
2215
|
}
|
|
@@ -2217,9 +2226,9 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
2217
2226
|
dispatch({ type: "SET_VALIDATING_PROMO_CODE", isValidating: true });
|
|
2218
2227
|
dispatch({ type: "SET_PROMO_CODE_ERROR", error: null });
|
|
2219
2228
|
try {
|
|
2220
|
-
const result = await
|
|
2229
|
+
const result = await _chunk5TH2DSAHjs.StripePromotionCodeService.validatePromotionCode({
|
|
2221
2230
|
code,
|
|
2222
|
-
stripePriceId: _optionalChain([state, 'access',
|
|
2231
|
+
stripePriceId: _optionalChain([state, 'access', _72 => _72.selectedPrice, 'optionalAccess', _73 => _73.id]),
|
|
2223
2232
|
language: locale
|
|
2224
2233
|
});
|
|
2225
2234
|
if (result.valid) {
|
|
@@ -2234,13 +2243,13 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
2234
2243
|
console.error("[useSubscriptionWizard] Promo code validation error:", error);
|
|
2235
2244
|
dispatch({
|
|
2236
2245
|
type: "SET_PROMO_CODE_ERROR",
|
|
2237
|
-
error: _optionalChain([error, 'optionalAccess',
|
|
2246
|
+
error: _optionalChain([error, 'optionalAccess', _74 => _74.message]) || t("billing.ui.wizard.errors.validate_promo_code")
|
|
2238
2247
|
});
|
|
2239
2248
|
} finally {
|
|
2240
2249
|
dispatch({ type: "SET_VALIDATING_PROMO_CODE", isValidating: false });
|
|
2241
2250
|
}
|
|
2242
2251
|
},
|
|
2243
|
-
[_optionalChain([state, 'access',
|
|
2252
|
+
[_optionalChain([state, 'access', _75 => _75.selectedPrice, 'optionalAccess', _76 => _76.id]), t, locale]
|
|
2244
2253
|
);
|
|
2245
2254
|
const clearPromoCode = _react.useCallback.call(void 0, async () => {
|
|
2246
2255
|
dispatch({ type: "SET_PROMOTION_CODE", code: null });
|
|
@@ -2342,7 +2351,7 @@ function WizardStepPlanSelection({
|
|
|
2342
2351
|
_react.useEffect.call(void 0, () => {
|
|
2343
2352
|
const loadProducts = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2344
2353
|
try {
|
|
2345
|
-
const fetchedProducts = await
|
|
2354
|
+
const fetchedProducts = await _chunk5TH2DSAHjs.StripeProductService.listProducts({ active: true });
|
|
2346
2355
|
setProducts(fetchedProducts);
|
|
2347
2356
|
} catch (error) {
|
|
2348
2357
|
console.error("[WizardStepPlanSelection] Failed to load products:", error);
|
|
@@ -2357,10 +2366,10 @@ function WizardStepPlanSelection({
|
|
|
2357
2366
|
let hasYearly2 = false;
|
|
2358
2367
|
for (const product of products) {
|
|
2359
2368
|
for (const price of product.stripePrices || []) {
|
|
2360
|
-
if (price.priceType === "recurring" && _optionalChain([price, 'access',
|
|
2369
|
+
if (price.priceType === "recurring" && _optionalChain([price, 'access', _77 => _77.recurring, 'optionalAccess', _78 => _78.interval]) === "month") {
|
|
2361
2370
|
hasMonthly2 = true;
|
|
2362
2371
|
}
|
|
2363
|
-
if (price.priceType === "recurring" && _optionalChain([price, 'access',
|
|
2372
|
+
if (price.priceType === "recurring" && _optionalChain([price, 'access', _79 => _79.recurring, 'optionalAccess', _80 => _80.interval]) === "year") {
|
|
2364
2373
|
hasYearly2 = true;
|
|
2365
2374
|
}
|
|
2366
2375
|
}
|
|
@@ -2386,14 +2395,14 @@ function WizardStepPlanSelection({
|
|
|
2386
2395
|
products,
|
|
2387
2396
|
selectedInterval,
|
|
2388
2397
|
currentPriceId,
|
|
2389
|
-
selectedPriceId: _optionalChain([selectedPrice, 'optionalAccess',
|
|
2398
|
+
selectedPriceId: _optionalChain([selectedPrice, 'optionalAccess', _81 => _81.id]),
|
|
2390
2399
|
loading,
|
|
2391
2400
|
hideRecurringPrices,
|
|
2392
2401
|
hideOneTimePrices,
|
|
2393
2402
|
onSelectPrice: handleSelectPrice
|
|
2394
2403
|
}
|
|
2395
2404
|
),
|
|
2396
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex justify-end pt-4 border-t", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2405
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex justify-end pt-4 border-t", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Button, { onClick: onNext, disabled: !selectedPrice || isProcessing, children: isProcessing ? t("common.loading") : t("billing.ui.wizard.next_review") }) })
|
|
2397
2406
|
] });
|
|
2398
2407
|
}
|
|
2399
2408
|
_chunk7QVYU63Ejs.__name.call(void 0, WizardStepPlanSelection, "WizardStepPlanSelection");
|
|
@@ -2417,9 +2426,9 @@ function PromoCodeInput({
|
|
|
2417
2426
|
disabled = false
|
|
2418
2427
|
}) {
|
|
2419
2428
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
2420
|
-
const locale =
|
|
2429
|
+
const locale = _chunk5TH2DSAHjs.useI18nLocale.call(void 0, );
|
|
2421
2430
|
const [code, setCode] = _react.useState.call(void 0, "");
|
|
2422
|
-
const appliedKey = _optionalChain([appliedCode, 'optionalAccess',
|
|
2431
|
+
const appliedKey = _optionalChain([appliedCode, 'optionalAccess', _82 => _82.valid]) ? `${appliedCode.automatic ? "auto" : "typed"}:${_nullishCoalesce(appliedCode.code, () => ( ""))}` : null;
|
|
2423
2432
|
const [previousAppliedKey, setPreviousAppliedKey] = _react.useState.call(void 0, appliedKey);
|
|
2424
2433
|
if (appliedKey !== previousAppliedKey) {
|
|
2425
2434
|
setPreviousAppliedKey(appliedKey);
|
|
@@ -2445,8 +2454,8 @@ function PromoCodeInput({
|
|
|
2445
2454
|
return t("billing.ui.wizard.review.percent_off", { value: String(result.discountValue) });
|
|
2446
2455
|
}
|
|
2447
2456
|
const amount = (result.discountValue || 0) / 100;
|
|
2448
|
-
const currency = _optionalChain([result, 'access',
|
|
2449
|
-
return t("billing.ui.wizard.review.amount_off", { amount: `${currency} ${
|
|
2457
|
+
const currency = _optionalChain([result, 'access', _83 => _83.currency, 'optionalAccess', _84 => _84.toUpperCase, 'call', _85 => _85()]) || "USD";
|
|
2458
|
+
return t("billing.ui.wizard.review.amount_off", { amount: `${currency} ${_chunk5TH2DSAHjs.formatFixed.call(void 0, amount, locale, 2)}` });
|
|
2450
2459
|
}, "formatDiscount");
|
|
2451
2460
|
const formatDuration = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (result) => {
|
|
2452
2461
|
switch (result.duration) {
|
|
@@ -2463,7 +2472,7 @@ function PromoCodeInput({
|
|
|
2463
2472
|
const codeInput = /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
2464
2473
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex gap-2", children: [
|
|
2465
2474
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2466
|
-
|
|
2475
|
+
_chunk2WK35GO2js.Input,
|
|
2467
2476
|
{
|
|
2468
2477
|
placeholder: t("billing.ui.promo_code.placeholder"),
|
|
2469
2478
|
value: code,
|
|
@@ -2473,11 +2482,11 @@ function PromoCodeInput({
|
|
|
2473
2482
|
className: "flex-1"
|
|
2474
2483
|
}
|
|
2475
2484
|
),
|
|
2476
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2485
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Button, { variant: "outline", onClick: handleApply, disabled: disabled || isValidating || !code.trim(), children: isValidating ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Loader2, { className: "h-4 w-4 animate-spin" }) : t("billing.ui.promo_code.apply") })
|
|
2477
2486
|
] }),
|
|
2478
2487
|
error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive text-xs/relaxed", children: error })
|
|
2479
2488
|
] });
|
|
2480
|
-
if (_optionalChain([appliedCode, 'optionalAccess',
|
|
2489
|
+
if (_optionalChain([appliedCode, 'optionalAccess', _86 => _86.valid]) && appliedCode.automatic) {
|
|
2481
2490
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-3", children: [
|
|
2482
2491
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
2483
2492
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "bg-success/15 border-success/30 flex items-center gap-2 rounded-lg border p-3", children: [
|
|
@@ -2488,12 +2497,12 @@ function PromoCodeInput({
|
|
|
2488
2497
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-success text-sm", children: formatDuration(appliedCode) })
|
|
2489
2498
|
] }),
|
|
2490
2499
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
2491
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-muted-foreground text-
|
|
2500
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-muted-foreground text-xs/relaxed", children: t("billing.ui.promo_code.use_different") }),
|
|
2492
2501
|
codeInput
|
|
2493
2502
|
] })
|
|
2494
2503
|
] });
|
|
2495
2504
|
}
|
|
2496
|
-
if (_optionalChain([appliedCode, 'optionalAccess',
|
|
2505
|
+
if (_optionalChain([appliedCode, 'optionalAccess', _87 => _87.valid])) {
|
|
2497
2506
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
2498
2507
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "bg-success/15 border-success/30 flex items-center justify-between rounded-lg border p-3", children: [
|
|
2499
2508
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
|
|
@@ -2502,7 +2511,7 @@ function PromoCodeInput({
|
|
|
2502
2511
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-success text-sm", children: formatDiscount(appliedCode) })
|
|
2503
2512
|
] }),
|
|
2504
2513
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2505
|
-
|
|
2514
|
+
_chunk2WK35GO2js.Button,
|
|
2506
2515
|
{
|
|
2507
2516
|
variant: "ghost",
|
|
2508
2517
|
size: "sm",
|
|
@@ -2524,7 +2533,7 @@ _chunk7QVYU63Ejs.__name.call(void 0, PromoCodeInput, "PromoCodeInput");
|
|
|
2524
2533
|
function reviewCard(methods, defaultPaymentMethodId) {
|
|
2525
2534
|
if (!methods || methods.length === 0) return null;
|
|
2526
2535
|
const method = defaultPaymentMethodId && methods.find((m) => m.id === defaultPaymentMethodId) || methods[0];
|
|
2527
|
-
if (!_optionalChain([method, 'access',
|
|
2536
|
+
if (!_optionalChain([method, 'access', _88 => _88.card, 'optionalAccess', _89 => _89.last4])) return null;
|
|
2528
2537
|
const brand = method.card.brand ? method.card.brand.charAt(0).toUpperCase() + method.card.brand.slice(1) : method.type.charAt(0).toUpperCase() + method.type.slice(1);
|
|
2529
2538
|
return { brand, last4: method.card.last4 };
|
|
2530
2539
|
}
|
|
@@ -2550,7 +2559,7 @@ function WizardStepReview({
|
|
|
2550
2559
|
isTrialUpgrade
|
|
2551
2560
|
}) {
|
|
2552
2561
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
2553
|
-
const fmt =
|
|
2562
|
+
const fmt = _chunk2WK35GO2js.useBillingFormatOptions.call(void 0, );
|
|
2554
2563
|
const [card, setCard] = _react.useState.call(void 0, null);
|
|
2555
2564
|
_react.useEffect.call(void 0, () => {
|
|
2556
2565
|
if (!hasPaymentMethod) {
|
|
@@ -2558,8 +2567,8 @@ function WizardStepReview({
|
|
|
2558
2567
|
return;
|
|
2559
2568
|
}
|
|
2560
2569
|
let cancelled = false;
|
|
2561
|
-
Promise.all([
|
|
2562
|
-
if (!cancelled) setCard(reviewCard(methods, _optionalChain([customer, 'optionalAccess',
|
|
2570
|
+
Promise.all([_chunk5TH2DSAHjs.StripeCustomerService.listPaymentMethods(), _chunk5TH2DSAHjs.StripeCustomerService.getCustomer()]).then(([methods, customer]) => {
|
|
2571
|
+
if (!cancelled) setCard(reviewCard(methods, _optionalChain([customer, 'optionalAccess', _90 => _90.defaultPaymentMethodId])));
|
|
2563
2572
|
}).catch((err) => {
|
|
2564
2573
|
console.error("[WizardStepReview] Failed to load the card on file:", err);
|
|
2565
2574
|
if (!cancelled) setCard(null);
|
|
@@ -2571,42 +2580,42 @@ function WizardStepReview({
|
|
|
2571
2580
|
if (!selectedPrice) {
|
|
2572
2581
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-center py-8 text-muted-foreground", children: t("billing.ui.wizard.review.no_plan") });
|
|
2573
2582
|
}
|
|
2574
|
-
const isChangingPlan = subscription && _optionalChain([subscription, 'access',
|
|
2583
|
+
const isChangingPlan = subscription && _optionalChain([subscription, 'access', _91 => _91.price, 'optionalAccess', _92 => _92.id]) !== selectedPrice.id;
|
|
2575
2584
|
const formatInterval2 = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (price) => {
|
|
2576
2585
|
if (price.priceType === "one_time") return t("billing.ui.wizard.review.interval_one_time");
|
|
2577
|
-
const interval = _optionalChain([price, 'access',
|
|
2586
|
+
const interval = _optionalChain([price, 'access', _93 => _93.recurring, 'optionalAccess', _94 => _94.interval]) || "month";
|
|
2578
2587
|
return interval === "year" ? t("billing.ui.wizard.review.interval_yearly") : t("billing.ui.wizard.review.interval_monthly");
|
|
2579
2588
|
}, "formatInterval");
|
|
2580
|
-
const codeDiscount =
|
|
2581
|
-
const carriedDiscount = isChangingPlan && !codeDiscount ?
|
|
2589
|
+
const codeDiscount = _chunk2WK35GO2js.promotionCodeDiscount.call(void 0, promotionCode);
|
|
2590
|
+
const carriedDiscount = isChangingPlan && !codeDiscount ? _chunk2WK35GO2js.subscriptionDiscount.call(void 0, subscription) : null;
|
|
2582
2591
|
const discount = _nullishCoalesce(codeDiscount, () => ( carriedDiscount));
|
|
2583
|
-
const discountedPrice =
|
|
2584
|
-
const discountedImmediateCharge =
|
|
2592
|
+
const discountedPrice = _chunk2WK35GO2js.applyDiscount.call(void 0, selectedPrice.unitAmount, discount);
|
|
2593
|
+
const discountedImmediateCharge = _chunk2WK35GO2js.applyDiscount.call(void 0, _optionalChain([prorationPreview, 'optionalAccess', _95 => _95.immediateCharge]), discount);
|
|
2585
2594
|
const getDiscountDescription = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => {
|
|
2586
2595
|
if (!discount) return null;
|
|
2587
2596
|
if (discount.discountType === "percent_off") {
|
|
2588
2597
|
return t("billing.ui.wizard.review.percent_off", { value: discount.discountValue });
|
|
2589
2598
|
}
|
|
2590
2599
|
return t("billing.ui.wizard.review.amount_off", {
|
|
2591
|
-
amount:
|
|
2600
|
+
amount: _chunk5TH2DSAHjs.formatCurrency.call(void 0, discount.discountValue, discount.currency || selectedPrice.currency, fmt)
|
|
2592
2601
|
});
|
|
2593
2602
|
}, "getDiscountDescription");
|
|
2594
2603
|
const discountDescription = getDiscountDescription();
|
|
2595
2604
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-6", children: [
|
|
2596
2605
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "bg-muted/50 rounded-lg p-4 space-y-3", children: [
|
|
2597
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2606
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.SectionHeader, { children: t("billing.ui.wizard.review.selected_plan") }),
|
|
2598
2607
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between items-center", children: [
|
|
2599
2608
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
2600
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "font-medium", children: _optionalChain([selectedPrice, 'access',
|
|
2609
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "font-medium", children: _optionalChain([selectedPrice, 'access', _96 => _96.product, 'optionalAccess', _97 => _97.name]) }),
|
|
2601
2610
|
selectedPrice.nickname && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: selectedPrice.nickname })
|
|
2602
2611
|
] }),
|
|
2603
2612
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "text-end", children: [
|
|
2604
2613
|
discountedPrice !== null ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
2605
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground line-through", children:
|
|
2606
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-success text-lg font-semibold", children:
|
|
2607
|
-
discountDescription && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2614
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground line-through", children: _chunk5TH2DSAHjs.formatCurrency.call(void 0, selectedPrice.unitAmount || 0, selectedPrice.currency, fmt) }),
|
|
2615
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-success text-lg font-semibold", children: _chunk5TH2DSAHjs.formatCurrency.call(void 0, discountedPrice, selectedPrice.currency, fmt) }),
|
|
2616
|
+
discountDescription && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Badge, { variant: "softGreen", children: discountDescription }),
|
|
2608
2617
|
carriedDiscount && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: t("billing.ui.wizard.review.discount_carries_over") })
|
|
2609
|
-
] }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "font-semibold text-lg", children:
|
|
2618
|
+
] }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "font-semibold text-lg", children: _chunk5TH2DSAHjs.formatCurrency.call(void 0, selectedPrice.unitAmount || 0, selectedPrice.currency, fmt) }),
|
|
2610
2619
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: formatInterval2(selectedPrice) })
|
|
2611
2620
|
] })
|
|
2612
2621
|
] })
|
|
@@ -2621,9 +2630,9 @@ function WizardStepReview({
|
|
|
2621
2630
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between text-sm", children: [
|
|
2622
2631
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: `${isTrialUpgrade ? "text-warning" : "text-muted-foreground"}`, children: isTrialUpgrade ? t("billing.ui.wizard.review.charge_now") : t("billing.ui.wizard.review.due_now") }),
|
|
2623
2632
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: `font-medium ${isTrialUpgrade ? "text-warning" : "text-foreground"}`, children: discountedImmediateCharge !== null ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
2624
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "line-through text-muted-foreground me-2", children:
|
|
2625
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-success", children:
|
|
2626
|
-
] }) :
|
|
2633
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "line-through text-muted-foreground me-2", children: _chunk5TH2DSAHjs.formatCurrency.call(void 0, prorationPreview.immediateCharge, prorationPreview.currency, fmt) }),
|
|
2634
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-success", children: _chunk5TH2DSAHjs.formatCurrency.call(void 0, discountedImmediateCharge, prorationPreview.currency, fmt) })
|
|
2635
|
+
] }) : _chunk5TH2DSAHjs.formatCurrency.call(void 0, prorationPreview.immediateCharge, prorationPreview.currency, fmt) })
|
|
2627
2636
|
] })
|
|
2628
2637
|
]
|
|
2629
2638
|
}
|
|
@@ -2647,15 +2656,15 @@ function WizardStepReview({
|
|
|
2647
2656
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h4", { className: "font-medium", children: t("billing.ui.payment_method.title") }),
|
|
2648
2657
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: hasPaymentMethod ? card ? t("billing.ui.wizard.review.card_on_file", { brand: card.brand, last4: card.last4 }) : t("billing.ui.wizard.review.payment_on_file") : t("billing.ui.wizard.review.no_payment_on_file") })
|
|
2649
2658
|
] }),
|
|
2650
|
-
hasPaymentMethod ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2659
|
+
hasPaymentMethod ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Button, { variant: "outline", onClick: onAddPaymentMethod, disabled: isProcessing, children: t("billing.ui.wizard.review.use_another_card") }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Button, { variant: "outline", onClick: onAddPaymentMethod, children: t("billing.ui.payment_methods.add") })
|
|
2651
2660
|
] }) }),
|
|
2652
|
-
error && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2661
|
+
error && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Alert, { variant: "destructive", children: [
|
|
2653
2662
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.AlertCircle, { className: "h-4 w-4" }),
|
|
2654
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2663
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.AlertDescription, { children: error })
|
|
2655
2664
|
] }),
|
|
2656
2665
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between pt-4 border-t", children: [
|
|
2657
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2658
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2666
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Button, { variant: "outline", onClick: onBack, disabled: isProcessing, children: t("billing.ui.wizard.back") }),
|
|
2667
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Button, { onClick: hasPaymentMethod ? onConfirm : onAddPaymentMethod, disabled: isProcessing, children: isProcessing ? t("billing.ui.wizard.review.processing") : hasPaymentMethod ? isChangingPlan ? t("billing.ui.wizard.review.confirm_change") : t("billing.ui.wizard.review.subscribe_now") : t("billing.ui.payment_methods.add") })
|
|
2659
2668
|
] })
|
|
2660
2669
|
] });
|
|
2661
2670
|
}
|
|
@@ -2668,7 +2677,7 @@ function WizardStepPaymentMethod({ onBack, onSuccess, isProcessing }) {
|
|
|
2668
2677
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
2669
2678
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-6", children: [
|
|
2670
2679
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "text-center", children: [
|
|
2671
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2680
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.SectionHeader, { children: t("billing.ui.payment_methods.add") }),
|
|
2672
2681
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: t("billing.ui.wizard.payment_description") })
|
|
2673
2682
|
] }),
|
|
2674
2683
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, PaymentMethodForm, { onSuccess, onCancel: onBack, isLoading: isProcessing, alwaysSetDefault: true })
|
|
@@ -2711,10 +2720,10 @@ function SubscriptionWizard({
|
|
|
2711
2720
|
const isChangePlanMode = !!subscription;
|
|
2712
2721
|
const dialogTitle = subscription ? t("billing.ui.wizard.change_title") : isPurchasingAddons ? t("billing.ui.subscriptions.purchase_addons") : t("billing.ui.subscriptions.subscribe");
|
|
2713
2722
|
const dialogDescription = subscription ? t("billing.ui.wizard.change_description") : isPurchasingAddons ? t("billing.ui.wizard.addons_description") : t("billing.ui.wizard.subscribe_description");
|
|
2714
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2715
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2716
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2717
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2723
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.DialogContent, { className: "max-w-2xl max-h-[90vh] overflow-y-auto", children: [
|
|
2724
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.DialogHeader, { children: [
|
|
2725
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.DialogTitle, { children: dialogTitle }),
|
|
2726
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.DialogDescription, { children: dialogDescription })
|
|
2718
2727
|
] }),
|
|
2719
2728
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, WizardProgressIndicator, { currentStep: state.step }),
|
|
2720
2729
|
state.step === "plan-selection" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -2722,7 +2731,7 @@ function SubscriptionWizard({
|
|
|
2722
2731
|
{
|
|
2723
2732
|
selectedPrice: state.selectedPrice,
|
|
2724
2733
|
selectedInterval: state.selectedInterval,
|
|
2725
|
-
currentPriceId: _optionalChain([subscription, 'optionalAccess',
|
|
2734
|
+
currentPriceId: _optionalChain([subscription, 'optionalAccess', _98 => _98.price, 'optionalAccess', _99 => _99.id]),
|
|
2726
2735
|
hideRecurringPrices: isPurchasingAddons,
|
|
2727
2736
|
hideOneTimePrices: isChangePlanMode,
|
|
2728
2737
|
onSelectPrice: actions.selectPrice,
|
|
@@ -2793,23 +2802,23 @@ function formatDate2(date, { locale, t }) {
|
|
|
2793
2802
|
_chunk7QVYU63Ejs.__name.call(void 0, formatDate2, "formatDate");
|
|
2794
2803
|
function UsageSummaryCard({ meter, summary }) {
|
|
2795
2804
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
2796
|
-
const fmt =
|
|
2797
|
-
const currentUsage = _nullishCoalesce(_optionalChain([summary, 'optionalAccess',
|
|
2805
|
+
const fmt = _chunk2WK35GO2js.useBillingFormatOptions.call(void 0, );
|
|
2806
|
+
const currentUsage = _nullishCoalesce(_optionalChain([summary, 'optionalAccess', _100 => _100.aggregatedValue]), () => ( 0));
|
|
2798
2807
|
const limit = meter.limit;
|
|
2799
2808
|
const percentage = limit && limit > 0 ? currentUsage / limit * 100 : null;
|
|
2800
2809
|
const progressColor = getProgressColor(percentage);
|
|
2801
2810
|
const progressWidth = percentage !== null ? Math.min(percentage, 100) : 0;
|
|
2802
2811
|
const displayName = meter.displayName || meter.eventName;
|
|
2803
2812
|
const hasLimit = limit !== null && limit !== void 0;
|
|
2804
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2805
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2813
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Card, { children: [
|
|
2814
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.CardHeader, { className: "flex flex-row items-center gap-x-3 pb-3", children: [
|
|
2806
2815
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex h-10 w-10 items-center justify-center rounded-lg bg-blue-100 text-blue-600", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Activity, { className: "h-5 w-5" }) }),
|
|
2807
2816
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col", children: [
|
|
2808
2817
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-sm font-medium", children: displayName }),
|
|
2809
2818
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-muted-foreground text-xs", children: meter.id })
|
|
2810
2819
|
] })
|
|
2811
2820
|
] }),
|
|
2812
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2821
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.CardContent, { className: "flex flex-col gap-y-4", children: [
|
|
2813
2822
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
2814
2823
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-3xl font-bold", children: currentUsage.toLocaleString(fmt.locale) }),
|
|
2815
2824
|
hasLimit && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-muted-foreground text-sm", children: t("billing.ui.usage.of_limit_used", { limit: limit.toLocaleString(fmt.locale) }) })
|
|
@@ -2817,7 +2826,7 @@ function UsageSummaryCard({ meter, summary }) {
|
|
|
2817
2826
|
hasLimit ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-y-2", children: [
|
|
2818
2827
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "h-2 w-full overflow-hidden rounded-full bg-gray-200", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: `h-full transition-all ${progressColor}`, style: { width: `${progressWidth}%` } }) }),
|
|
2819
2828
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-muted-foreground text-sm", children: t("billing.ui.usage.percent_used", {
|
|
2820
|
-
value: percentage !== null ?
|
|
2829
|
+
value: percentage !== null ? _chunk5TH2DSAHjs.formatFixed.call(void 0, percentage, fmt.locale, 1) : ""
|
|
2821
2830
|
}) })
|
|
2822
2831
|
] }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-muted-foreground text-sm", children: t("billing.ui.usage.no_limit") }),
|
|
2823
2832
|
summary && summary.start && summary.end && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border-t pt-3", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-muted-foreground text-xs", children: t("billing.ui.usage.period", {
|
|
@@ -2850,14 +2859,14 @@ function UsageContainer() {
|
|
|
2850
2859
|
const loadUsageData = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2851
2860
|
setLoading(true);
|
|
2852
2861
|
try {
|
|
2853
|
-
const fetchedSubscriptions = await
|
|
2862
|
+
const fetchedSubscriptions = await _chunk5TH2DSAHjs.StripeSubscriptionService.listSubscriptions();
|
|
2854
2863
|
setSubscriptions(fetchedSubscriptions);
|
|
2855
|
-
const hasMeteredSubscriptions2 = fetchedSubscriptions.some((sub) => _optionalChain([sub, 'access',
|
|
2864
|
+
const hasMeteredSubscriptions2 = fetchedSubscriptions.some((sub) => _optionalChain([sub, 'access', _101 => _101.price, 'optionalAccess', _102 => _102.recurring, 'optionalAccess', _103 => _103.usageType]) === "metered");
|
|
2856
2865
|
if (!hasMeteredSubscriptions2) {
|
|
2857
2866
|
setLoading(false);
|
|
2858
2867
|
return;
|
|
2859
2868
|
}
|
|
2860
|
-
const fetchedMeters = await
|
|
2869
|
+
const fetchedMeters = await _chunk5TH2DSAHjs.StripeUsageService.listMeters();
|
|
2861
2870
|
setMeters(fetchedMeters);
|
|
2862
2871
|
const summariesMap = {};
|
|
2863
2872
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -2865,7 +2874,7 @@ function UsageContainer() {
|
|
|
2865
2874
|
const endOfMonth = new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59, 999);
|
|
2866
2875
|
for (const meter of fetchedMeters) {
|
|
2867
2876
|
try {
|
|
2868
|
-
const meterSummaries = await
|
|
2877
|
+
const meterSummaries = await _chunk5TH2DSAHjs.StripeUsageService.getMeterSummaries({
|
|
2869
2878
|
meterId: meter.id,
|
|
2870
2879
|
startTime: startOfMonth,
|
|
2871
2880
|
endTime: endOfMonth
|
|
@@ -2883,7 +2892,7 @@ function UsageContainer() {
|
|
|
2883
2892
|
setLoading(false);
|
|
2884
2893
|
}
|
|
2885
2894
|
}, "loadUsageData");
|
|
2886
|
-
const hasMeteredSubscriptions = subscriptions.some((sub) => _optionalChain([sub, 'access',
|
|
2895
|
+
const hasMeteredSubscriptions = subscriptions.some((sub) => _optionalChain([sub, 'access', _104 => _104.price, 'optionalAccess', _105 => _105.recurring, 'optionalAccess', _106 => _106.usageType]) === "metered");
|
|
2887
2896
|
if (!loading && !hasMeteredSubscriptions) {
|
|
2888
2897
|
return null;
|
|
2889
2898
|
}
|
|
@@ -2928,27 +2937,27 @@ function formatDateTime(date, { locale, t }) {
|
|
|
2928
2937
|
_chunk7QVYU63Ejs.__name.call(void 0, formatDateTime, "formatDateTime");
|
|
2929
2938
|
function UsageHistoryTable({ usageRecords }) {
|
|
2930
2939
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
2931
|
-
const fmt =
|
|
2940
|
+
const fmt = _chunk2WK35GO2js.useBillingFormatOptions.call(void 0, );
|
|
2932
2941
|
if (usageRecords.length === 0) {
|
|
2933
2942
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rounded-lg border p-8 text-center", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-muted-foreground", children: t("billing.ui.usage.history_empty") }) });
|
|
2934
2943
|
}
|
|
2935
2944
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-y-4", children: [
|
|
2936
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2937
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "overflow-clip rounded-lg border", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2938
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2939
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2940
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2941
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2942
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2945
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.SectionHeader, { level: 2, children: t("billing.ui.usage.history_title") }),
|
|
2946
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "overflow-clip rounded-lg border", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Table, { children: [
|
|
2947
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableHeader, { className: "bg-muted", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.TableRow, { children: [
|
|
2948
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableHead, { children: t("billing.ui.columns.date_time") }),
|
|
2949
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableHead, { children: t("billing.ui.columns.meter_event") }),
|
|
2950
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableHead, { className: "text-end", children: t("billing.ui.columns.quantity") }),
|
|
2951
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableHead, { children: t("billing.ui.columns.event_id") })
|
|
2943
2952
|
] }) }),
|
|
2944
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2953
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableBody, { children: usageRecords.map((record) => {
|
|
2945
2954
|
const dateTime = formatDateTime(record.timestamp, fmt);
|
|
2946
2955
|
const quantity = record.quantity.toLocaleString(fmt.locale);
|
|
2947
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2948
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2949
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2950
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2951
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2956
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.TableRow, { children: [
|
|
2957
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableCell, { className: "font-medium", children: dateTime }),
|
|
2958
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableCell, { className: "text-muted-foreground", children: record.meterEventName }),
|
|
2959
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableCell, { className: "text-end font-medium", children: quantity }),
|
|
2960
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.TableCell, { className: "text-muted-foreground text-sm tabular-nums", children: record.stripeEventId })
|
|
2952
2961
|
] }, record.id);
|
|
2953
2962
|
}) })
|
|
2954
2963
|
] }) })
|
|
@@ -2959,8 +2968,8 @@ _chunk7QVYU63Ejs.__name.call(void 0, UsageHistoryTable, "UsageHistoryTable");
|
|
|
2959
2968
|
// src/features/billing/components/modals/BillingDetailModal.tsx
|
|
2960
2969
|
|
|
2961
2970
|
function BillingDetailModal({ open, onOpenChange, title, children, className }) {
|
|
2962
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2963
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2971
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.DialogContent, { className: _nullishCoalesce(className, () => ( "max-w-4xl max-h-[90vh] overflow-y-auto")), children: [
|
|
2972
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.DialogHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.DialogTitle, { children: title }) }),
|
|
2964
2973
|
children
|
|
2965
2974
|
] }) });
|
|
2966
2975
|
}
|
|
@@ -2988,7 +2997,7 @@ function BillingAlertBanner({ subscription, onUpdatePayment, onAddPayment }) {
|
|
|
2988
2997
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-destructive text-sm font-medium", children: t("billing.ui.alert.payment_failed_title") }),
|
|
2989
2998
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive mt-1 text-sm", children: t("billing.ui.alert.payment_failed_description") })
|
|
2990
2999
|
] }),
|
|
2991
|
-
onUpdatePayment && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3000
|
+
onUpdatePayment && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Button, { variant: "outline", size: "sm", onClick: onUpdatePayment, className: "text-destructive border-red-300", children: t("billing.ui.alert.update_payment_method") })
|
|
2992
3001
|
] });
|
|
2993
3002
|
}
|
|
2994
3003
|
if (subscription.status === "trialing" /* TRIALING */ && subscription.trialEnd) {
|
|
@@ -3002,7 +3011,7 @@ function BillingAlertBanner({ subscription, onUpdatePayment, onAddPayment }) {
|
|
|
3002
3011
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-warning text-sm font-medium", children: t("billing.ui.alert.trial_ending_title") }),
|
|
3003
3012
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-warning mt-1 text-sm", children: t("billing.ui.alert.trial_ending_description", { count: daysRemaining }) })
|
|
3004
3013
|
] }),
|
|
3005
|
-
onAddPayment && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3014
|
+
onAddPayment && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Button, { variant: "outline", size: "sm", onClick: onAddPayment, className: "text-warning border-yellow-300", children: t("billing.ui.payment_methods.add") })
|
|
3006
3015
|
] });
|
|
3007
3016
|
}
|
|
3008
3017
|
}
|
|
@@ -3043,24 +3052,24 @@ function BillingDashboardContainer() {
|
|
|
3043
3052
|
const [showWizard, setShowWizard] = _react.useState.call(void 0, false);
|
|
3044
3053
|
const [editingSubscription, setEditingSubscription] = _react.useState.call(void 0, null);
|
|
3045
3054
|
const hasMeteredSubscriptions = _react.useCallback.call(void 0, () => {
|
|
3046
|
-
return data.subscriptions.some((sub) => _optionalChain([sub, 'access',
|
|
3055
|
+
return data.subscriptions.some((sub) => _optionalChain([sub, 'access', _107 => _107.price, 'optionalAccess', _108 => _108.recurring, 'optionalAccess', _109 => _109.usageType]) === "metered");
|
|
3047
3056
|
}, [data.subscriptions]);
|
|
3048
3057
|
const hasActiveRecurringSubscription = _react.useMemo.call(void 0, () => {
|
|
3049
3058
|
return data.subscriptions.some(
|
|
3050
|
-
(sub) => (sub.status === "active" /* ACTIVE */ || sub.status === "trialing" /* TRIALING */) && _optionalChain([sub, 'access',
|
|
3059
|
+
(sub) => (sub.status === "active" /* ACTIVE */ || sub.status === "trialing" /* TRIALING */) && _optionalChain([sub, 'access', _110 => _110.price, 'optionalAccess', _111 => _111.priceType]) === "recurring"
|
|
3051
3060
|
);
|
|
3052
3061
|
}, [data.subscriptions]);
|
|
3053
3062
|
const fetchAllData = _react.useCallback.call(void 0, async () => {
|
|
3054
3063
|
setNoCustomerExists(false);
|
|
3055
3064
|
let customer = null;
|
|
3056
3065
|
try {
|
|
3057
|
-
customer = await
|
|
3066
|
+
customer = await _chunk5TH2DSAHjs.StripeCustomerService.getCustomer();
|
|
3058
3067
|
setData((prev) => ({ ...prev, customer }));
|
|
3059
3068
|
setErrors((prev) => ({ ...prev, customer: null }));
|
|
3060
3069
|
setNoCustomerExists(false);
|
|
3061
3070
|
} catch (error) {
|
|
3062
3071
|
console.error("[BillingDashboard] Failed to load customer:", error);
|
|
3063
|
-
if (_optionalChain([error, 'optionalAccess',
|
|
3072
|
+
if (_optionalChain([error, 'optionalAccess', _112 => _112.status]) === 404) {
|
|
3064
3073
|
setNoCustomerExists(true);
|
|
3065
3074
|
} else {
|
|
3066
3075
|
setErrors((prev) => ({ ...prev, customer: "billing.ui.dashboard.errors.load_customer" }));
|
|
@@ -3080,7 +3089,7 @@ function BillingDashboardContainer() {
|
|
|
3080
3089
|
}
|
|
3081
3090
|
const fetchSubscriptions = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
3082
3091
|
try {
|
|
3083
|
-
const subscriptions2 = await
|
|
3092
|
+
const subscriptions2 = await _chunk5TH2DSAHjs.StripeSubscriptionService.listSubscriptions();
|
|
3084
3093
|
setData((prev) => ({ ...prev, subscriptions: subscriptions2 }));
|
|
3085
3094
|
setErrors((prev) => ({ ...prev, subscriptions: null }));
|
|
3086
3095
|
return subscriptions2;
|
|
@@ -3094,7 +3103,7 @@ function BillingDashboardContainer() {
|
|
|
3094
3103
|
}, "fetchSubscriptions");
|
|
3095
3104
|
const fetchPaymentMethods = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
3096
3105
|
try {
|
|
3097
|
-
const paymentMethods = await
|
|
3106
|
+
const paymentMethods = await _chunk5TH2DSAHjs.StripeCustomerService.listPaymentMethods();
|
|
3098
3107
|
setData((prev) => ({ ...prev, paymentMethods }));
|
|
3099
3108
|
setErrors((prev) => ({ ...prev, paymentMethods: null }));
|
|
3100
3109
|
} catch (error) {
|
|
@@ -3106,7 +3115,7 @@ function BillingDashboardContainer() {
|
|
|
3106
3115
|
}, "fetchPaymentMethods");
|
|
3107
3116
|
const fetchInvoices = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
3108
3117
|
try {
|
|
3109
|
-
const invoices = await
|
|
3118
|
+
const invoices = await _chunk5TH2DSAHjs.StripeInvoiceService.listInvoices();
|
|
3110
3119
|
setData((prev) => ({ ...prev, invoices }));
|
|
3111
3120
|
setErrors((prev) => ({ ...prev, invoices: null }));
|
|
3112
3121
|
} catch (error) {
|
|
@@ -3118,7 +3127,7 @@ function BillingDashboardContainer() {
|
|
|
3118
3127
|
}, "fetchInvoices");
|
|
3119
3128
|
const [subscriptions] = await Promise.all([fetchSubscriptions(), fetchPaymentMethods(), fetchInvoices()]);
|
|
3120
3129
|
const hasMetered = subscriptions.some(
|
|
3121
|
-
(sub) => _optionalChain([sub, 'access',
|
|
3130
|
+
(sub) => _optionalChain([sub, 'access', _113 => _113.price, 'optionalAccess', _114 => _114.recurring, 'optionalAccess', _115 => _115.usageType]) === "metered"
|
|
3122
3131
|
);
|
|
3123
3132
|
if (hasMetered) {
|
|
3124
3133
|
await fetchUsageData();
|
|
@@ -3129,7 +3138,7 @@ function BillingDashboardContainer() {
|
|
|
3129
3138
|
const handleCreateCustomer = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
3130
3139
|
setCreatingCustomer(true);
|
|
3131
3140
|
try {
|
|
3132
|
-
await
|
|
3141
|
+
await _chunk5TH2DSAHjs.StripeCustomerService.createCustomer();
|
|
3133
3142
|
setNoCustomerExists(false);
|
|
3134
3143
|
await fetchAllData();
|
|
3135
3144
|
} catch (error) {
|
|
@@ -3141,7 +3150,7 @@ function BillingDashboardContainer() {
|
|
|
3141
3150
|
}, "handleCreateCustomer");
|
|
3142
3151
|
const fetchUsageData = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
3143
3152
|
try {
|
|
3144
|
-
const meters = await
|
|
3153
|
+
const meters = await _chunk5TH2DSAHjs.StripeUsageService.listMeters();
|
|
3145
3154
|
setData((prev) => ({ ...prev, meters }));
|
|
3146
3155
|
const summariesMap = {};
|
|
3147
3156
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -3149,7 +3158,7 @@ function BillingDashboardContainer() {
|
|
|
3149
3158
|
const endOfMonth = new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59, 999);
|
|
3150
3159
|
for (const meter of meters) {
|
|
3151
3160
|
try {
|
|
3152
|
-
const meterSummaries = await
|
|
3161
|
+
const meterSummaries = await _chunk5TH2DSAHjs.StripeUsageService.getMeterSummaries({
|
|
3153
3162
|
meterId: meter.id,
|
|
3154
3163
|
startTime: startOfMonth,
|
|
3155
3164
|
endTime: endOfMonth
|
|
@@ -3236,18 +3245,18 @@ function BillingDashboardContainer() {
|
|
|
3236
3245
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Wallet, { className: "h-8 w-8" }),
|
|
3237
3246
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h1", { className: "text-primary text-3xl font-semibold", children: t("billing.title") })
|
|
3238
3247
|
] }),
|
|
3239
|
-
isInitialLoading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3240
|
-
noCustomerExists && !isInitialLoading && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3241
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3248
|
+
isInitialLoading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Card, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardContent, { className: "flex items-center justify-center py-12", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Loader2, { className: "h-8 w-8 animate-spin text-muted-foreground" }) }) }),
|
|
3249
|
+
noCustomerExists && !isInitialLoading && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Card, { children: [
|
|
3250
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.CardHeader, { className: "text-center", children: [
|
|
3242
3251
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-primary/10", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-8 w-8 text-primary" }) }),
|
|
3243
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3244
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3252
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardTitle, { children: t("billing.ui.dashboard.setup_title") }),
|
|
3253
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardDescription, { children: t("billing.ui.dashboard.setup_description") })
|
|
3245
3254
|
] }),
|
|
3246
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3255
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardContent, { className: "flex justify-center pb-8", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Button, { onClick: handleCreateCustomer, disabled: creatingCustomer, size: "lg", children: creatingCustomer ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
3247
3256
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Loader2, { className: "me-2 h-4 w-4 animate-spin" }),
|
|
3248
3257
|
t("billing.ui.dashboard.setting_up")
|
|
3249
3258
|
] }) : t("billing.ui.dashboard.setup_button") }) }),
|
|
3250
|
-
errors.customer && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3259
|
+
errors.customer && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CardContent, { className: "pt-0", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-center text-destructive text-xs/relaxed", children: t(errors.customer) }) })
|
|
3251
3260
|
] }),
|
|
3252
3261
|
!noCustomerExists && !isInitialLoading && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
3253
3262
|
criticalSubscriptions.map((subscription) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -3279,7 +3288,7 @@ function BillingDashboardContainer() {
|
|
|
3279
3288
|
PaymentMethodSummaryCard,
|
|
3280
3289
|
{
|
|
3281
3290
|
paymentMethods: data.paymentMethods,
|
|
3282
|
-
defaultPaymentMethodId: _optionalChain([data, 'access',
|
|
3291
|
+
defaultPaymentMethodId: _optionalChain([data, 'access', _116 => _116.customer, 'optionalAccess', _117 => _117.defaultPaymentMethodId]),
|
|
3283
3292
|
loading: loading.paymentMethods,
|
|
3284
3293
|
error: errors.paymentMethods ? t(errors.paymentMethods) : void 0,
|
|
3285
3294
|
onManageClick: () => setActiveModal("payment-methods")
|
|
@@ -3382,7 +3391,7 @@ function getStripePromise(publishableKey) {
|
|
|
3382
3391
|
if (!publishableKey) {
|
|
3383
3392
|
return Promise.resolve(null);
|
|
3384
3393
|
}
|
|
3385
|
-
if (_optionalChain([stripePromiseCache, 'optionalAccess',
|
|
3394
|
+
if (_optionalChain([stripePromiseCache, 'optionalAccess', _118 => _118.key]) === publishableKey) {
|
|
3386
3395
|
return stripePromiseCache.promise;
|
|
3387
3396
|
}
|
|
3388
3397
|
const promise = _stripejs.loadStripe.call(void 0, publishableKey);
|
|
@@ -3391,7 +3400,7 @@ function getStripePromise(publishableKey) {
|
|
|
3391
3400
|
}
|
|
3392
3401
|
_chunk7QVYU63Ejs.__name.call(void 0, getStripePromise, "getStripePromise");
|
|
3393
3402
|
function StripeProvider({ children }) {
|
|
3394
|
-
const publishableKey =
|
|
3403
|
+
const publishableKey = _chunkXOSC3FFPjs.getStripePublishableKey.call(void 0, );
|
|
3395
3404
|
const stripePromise = _react.useMemo.call(void 0, () => getStripePromise(publishableKey), [publishableKey]);
|
|
3396
3405
|
const options = _react.useMemo.call(void 0, () => ({}), []);
|
|
3397
3406
|
if (!publishableKey) {
|
|
@@ -3401,7 +3410,7 @@ function StripeProvider({ children }) {
|
|
|
3401
3410
|
}
|
|
3402
3411
|
_chunk7QVYU63Ejs.__name.call(void 0, StripeProvider, "StripeProvider");
|
|
3403
3412
|
function isStripeConfigured() {
|
|
3404
|
-
return !!
|
|
3413
|
+
return !!_chunkXOSC3FFPjs.getStripePublishableKey.call(void 0, );
|
|
3405
3414
|
}
|
|
3406
3415
|
_chunk7QVYU63Ejs.__name.call(void 0, isStripeConfigured, "isStripeConfigured");
|
|
3407
3416
|
|
|
@@ -3416,18 +3425,18 @@ _chunk7QVYU63Ejs.__name.call(void 0, isStripeConfigured, "isStripeConfigured");
|
|
|
3416
3425
|
|
|
3417
3426
|
function PriceArchiver({ price }) {
|
|
3418
3427
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
3419
|
-
const fmt =
|
|
3428
|
+
const fmt = _chunk2WK35GO2js.useBillingFormatOptions.call(void 0, );
|
|
3420
3429
|
const { archivePrice, restorePrice } = usePriceContext();
|
|
3421
3430
|
const [open, setOpen] = _react.useState.call(void 0, false);
|
|
3422
3431
|
const isArchived = !price.active;
|
|
3423
3432
|
const scope = isArchived ? "restore" : "archive";
|
|
3424
3433
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
3425
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3434
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Button, { variant: "outline", size: "sm", onClick: () => setOpen(true), children: [
|
|
3426
3435
|
isArchived ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.RotateCcwIcon, {}) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ArchiveIcon, {}),
|
|
3427
3436
|
t(`billing.admin.prices.${scope}.confirm`)
|
|
3428
3437
|
] }),
|
|
3429
3438
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3430
|
-
|
|
3439
|
+
_chunk2WK35GO2js.ConfirmDialog,
|
|
3431
3440
|
{
|
|
3432
3441
|
open,
|
|
3433
3442
|
onOpenChange: setOpen,
|
|
@@ -3441,7 +3450,7 @@ function PriceArchiver({ price }) {
|
|
|
3441
3450
|
if (isArchived) await restorePrice(price.id);
|
|
3442
3451
|
else await archivePrice(price.id);
|
|
3443
3452
|
} catch (error) {
|
|
3444
|
-
|
|
3453
|
+
_chunk2WK35GO2js.errorToast.call(void 0, { title: t(`billing.admin.prices.${scope}.title`), error });
|
|
3445
3454
|
throw error;
|
|
3446
3455
|
}
|
|
3447
3456
|
}
|
|
@@ -3473,15 +3482,15 @@ function PriceEditorInternal({
|
|
|
3473
3482
|
onDialogOpenChange
|
|
3474
3483
|
}) {
|
|
3475
3484
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
3476
|
-
const fmt =
|
|
3477
|
-
const router =
|
|
3485
|
+
const fmt = _chunk2WK35GO2js.useBillingFormatOptions.call(void 0, );
|
|
3486
|
+
const router = _chunk5TH2DSAHjs.useI18nRouter.call(void 0, );
|
|
3478
3487
|
const { createPrice, updatePrice, productId: contextProductId } = usePriceContext();
|
|
3479
3488
|
const [allFeatures, setAllFeatures] = _react.useState.call(void 0, []);
|
|
3480
3489
|
const isEdit = !!price;
|
|
3481
|
-
const targetProductId = _nullishCoalesce(_nullishCoalesce(productId, () => ( _optionalChain([price, 'optionalAccess',
|
|
3490
|
+
const targetProductId = _nullishCoalesce(_nullishCoalesce(productId, () => ( _optionalChain([price, 'optionalAccess', _119 => _119.product, 'optionalAccess', _120 => _120.id]))), () => ( contextProductId));
|
|
3482
3491
|
_react.useEffect.call(void 0, () => {
|
|
3483
3492
|
const fetchFeatures = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
3484
|
-
setAllFeatures(await
|
|
3493
|
+
setAllFeatures(await _chunk5TH2DSAHjs.FeatureService.findMany({}));
|
|
3485
3494
|
}, "fetchFeatures");
|
|
3486
3495
|
void fetchFeatures();
|
|
3487
3496
|
}, []);
|
|
@@ -3557,22 +3566,22 @@ function PriceEditorInternal({
|
|
|
3557
3566
|
// `.toString()`, for the same reason the schema keeps the token
|
|
3558
3567
|
// pipeline string-based: a seeded `0` must survive as "0" and not be
|
|
3559
3568
|
// dropped as falsy.
|
|
3560
|
-
token: _nullishCoalesce(_optionalChain([seed, 'access',
|
|
3569
|
+
token: _nullishCoalesce(_optionalChain([seed, 'access', _121 => _121.token, 'optionalAccess', _122 => _122.toString, 'call', _123 => _123()]), () => ( "")),
|
|
3561
3570
|
featureIds: [.../* @__PURE__ */ new Set([...resolvePlatformFeatures(seed.platformFeatures).ids, ...coreFeatureIds])]
|
|
3562
3571
|
};
|
|
3563
3572
|
}
|
|
3564
3573
|
return {
|
|
3565
|
-
unitAmount: _optionalChain([price, 'optionalAccess',
|
|
3566
|
-
currency: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3567
|
-
interval: _optionalChain([price, 'optionalAccess',
|
|
3568
|
-
intervalCount: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3569
|
-
usageType: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3570
|
-
nickname: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3571
|
-
isTrial: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3572
|
-
description: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3573
|
-
features: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3574
|
-
token: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3575
|
-
featureIds: [.../* @__PURE__ */ new Set([..._nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3574
|
+
unitAmount: _optionalChain([price, 'optionalAccess', _124 => _124.unitAmount]) ? price.unitAmount / 100 : 0,
|
|
3575
|
+
currency: _nullishCoalesce(_optionalChain([price, 'optionalAccess', _125 => _125.currency]), () => ( "usd")),
|
|
3576
|
+
interval: _optionalChain([price, 'optionalAccess', _126 => _126.priceType]) === "one_time" ? "one_time" : _nullishCoalesce(_optionalChain([price, 'optionalAccess', _127 => _127.recurring, 'optionalAccess', _128 => _128.interval]), () => ( "month")),
|
|
3577
|
+
intervalCount: _nullishCoalesce(_optionalChain([price, 'optionalAccess', _129 => _129.recurring, 'optionalAccess', _130 => _130.intervalCount]), () => ( 1)),
|
|
3578
|
+
usageType: _nullishCoalesce(_optionalChain([price, 'optionalAccess', _131 => _131.recurring, 'optionalAccess', _132 => _132.usageType]), () => ( "licensed")),
|
|
3579
|
+
nickname: _nullishCoalesce(_optionalChain([price, 'optionalAccess', _133 => _133.nickname]), () => ( "")),
|
|
3580
|
+
isTrial: _nullishCoalesce(_optionalChain([price, 'optionalAccess', _134 => _134.isTrial]), () => ( false)),
|
|
3581
|
+
description: _nullishCoalesce(_optionalChain([price, 'optionalAccess', _135 => _135.description]), () => ( "")),
|
|
3582
|
+
features: _nullishCoalesce(_optionalChain([price, 'optionalAccess', _136 => _136.features]), () => ( [])),
|
|
3583
|
+
token: _nullishCoalesce(_optionalChain([price, 'optionalAccess', _137 => _137.token, 'optionalAccess', _138 => _138.toString, 'call', _139 => _139()]), () => ( "")),
|
|
3584
|
+
featureIds: [.../* @__PURE__ */ new Set([..._nullishCoalesce(_optionalChain([price, 'optionalAccess', _140 => _140.priceFeatures, 'optionalAccess', _141 => _141.map, 'call', _142 => _142((f) => f.id)]), () => ( [])), ...coreFeatureIds])]
|
|
3576
3585
|
};
|
|
3577
3586
|
}, [price, seed, allFeatures, resolvePlatformFeatures]);
|
|
3578
3587
|
const form = _reacthookform.useForm.call(void 0, {
|
|
@@ -3594,7 +3603,7 @@ function PriceEditorInternal({
|
|
|
3594
3603
|
warnedUnknownFor.current = fingerprint;
|
|
3595
3604
|
const { unknown } = resolvePlatformFeatures(seed.platformFeatures);
|
|
3596
3605
|
if (unknown.length > 0)
|
|
3597
|
-
|
|
3606
|
+
_chunk5TH2DSAHjs.showToast.call(void 0, t("billing.admin.prices.import.warnings.unknownFeatures", { features: unknown.join(", ") }));
|
|
3598
3607
|
}, [seed, isEdit, allFeatures, resolvePlatformFeatures, t]);
|
|
3599
3608
|
const watchInterval = form.watch("interval");
|
|
3600
3609
|
const isRecurring = watchInterval !== "one_time";
|
|
@@ -3615,13 +3624,13 @@ function PriceEditorInternal({
|
|
|
3615
3624
|
{ id: "metered", text: t("billing.admin.prices.usage.metered") }
|
|
3616
3625
|
];
|
|
3617
3626
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3618
|
-
|
|
3627
|
+
_chunk2WK35GO2js.EditorSheet,
|
|
3619
3628
|
{
|
|
3620
3629
|
form,
|
|
3621
3630
|
entityType: t("billing.admin.prices.entity"),
|
|
3622
3631
|
entityName: price ? priceLabel(price, fmt) : void 0,
|
|
3623
3632
|
isEdit,
|
|
3624
|
-
module:
|
|
3633
|
+
module: _chunk5TH2DSAHjs.Modules.StripePrice,
|
|
3625
3634
|
size: "lg",
|
|
3626
3635
|
propagateChanges,
|
|
3627
3636
|
onSuccess,
|
|
@@ -3670,13 +3679,13 @@ function PriceEditorInternal({
|
|
|
3670
3679
|
dialogOpen,
|
|
3671
3680
|
onDialogOpenChange,
|
|
3672
3681
|
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-y-4", children: [
|
|
3673
|
-
isEdit && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3674
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3675
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3682
|
+
isEdit && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Alert, { children: [
|
|
3683
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.AlertTitle, { children: t("billing.admin.prices.immutability.title") }),
|
|
3684
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.AlertDescription, { children: t("billing.admin.prices.immutability.description") })
|
|
3676
3685
|
] }),
|
|
3677
3686
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid grid-cols-2 gap-x-4", children: [
|
|
3678
3687
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3679
|
-
|
|
3688
|
+
_chunk2WK35GO2js.FormInput,
|
|
3680
3689
|
{
|
|
3681
3690
|
form,
|
|
3682
3691
|
id: "unitAmount",
|
|
@@ -3688,7 +3697,7 @@ function PriceEditorInternal({
|
|
|
3688
3697
|
}
|
|
3689
3698
|
),
|
|
3690
3699
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3691
|
-
|
|
3700
|
+
_chunk2WK35GO2js.FormSelect,
|
|
3692
3701
|
{
|
|
3693
3702
|
form,
|
|
3694
3703
|
id: "currency",
|
|
@@ -3699,7 +3708,7 @@ function PriceEditorInternal({
|
|
|
3699
3708
|
)
|
|
3700
3709
|
] }),
|
|
3701
3710
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3702
|
-
|
|
3711
|
+
_chunk2WK35GO2js.FormSelect,
|
|
3703
3712
|
{
|
|
3704
3713
|
form,
|
|
3705
3714
|
id: "interval",
|
|
@@ -3710,7 +3719,7 @@ function PriceEditorInternal({
|
|
|
3710
3719
|
),
|
|
3711
3720
|
isRecurring && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid grid-cols-2 gap-x-4", children: [
|
|
3712
3721
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3713
|
-
|
|
3722
|
+
_chunk2WK35GO2js.FormInput,
|
|
3714
3723
|
{
|
|
3715
3724
|
form,
|
|
3716
3725
|
id: "intervalCount",
|
|
@@ -3721,7 +3730,7 @@ function PriceEditorInternal({
|
|
|
3721
3730
|
}
|
|
3722
3731
|
),
|
|
3723
3732
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3724
|
-
|
|
3733
|
+
_chunk2WK35GO2js.FormSelect,
|
|
3725
3734
|
{
|
|
3726
3735
|
form,
|
|
3727
3736
|
id: "usageType",
|
|
@@ -3732,7 +3741,7 @@ function PriceEditorInternal({
|
|
|
3732
3741
|
)
|
|
3733
3742
|
] }),
|
|
3734
3743
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3735
|
-
|
|
3744
|
+
_chunk2WK35GO2js.FormInput,
|
|
3736
3745
|
{
|
|
3737
3746
|
form,
|
|
3738
3747
|
id: "nickname",
|
|
@@ -3741,7 +3750,7 @@ function PriceEditorInternal({
|
|
|
3741
3750
|
}
|
|
3742
3751
|
),
|
|
3743
3752
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3744
|
-
|
|
3753
|
+
_chunk2WK35GO2js.FormTextarea,
|
|
3745
3754
|
{
|
|
3746
3755
|
form,
|
|
3747
3756
|
id: "description",
|
|
@@ -3751,7 +3760,7 @@ function PriceEditorInternal({
|
|
|
3751
3760
|
}
|
|
3752
3761
|
),
|
|
3753
3762
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3754
|
-
|
|
3763
|
+
_chunk2WK35GO2js.FormInput,
|
|
3755
3764
|
{
|
|
3756
3765
|
form,
|
|
3757
3766
|
id: "token",
|
|
@@ -3761,10 +3770,10 @@ function PriceEditorInternal({
|
|
|
3761
3770
|
}
|
|
3762
3771
|
),
|
|
3763
3772
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-y-2", children: [
|
|
3764
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3773
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.FieldLabel, { children: t("billing.admin.prices.fields.features") }),
|
|
3765
3774
|
form.watch("features").map((_, index) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex gap-2", children: [
|
|
3766
3775
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3767
|
-
|
|
3776
|
+
_chunk2WK35GO2js.Input,
|
|
3768
3777
|
{
|
|
3769
3778
|
...form.register(`features.${index}`),
|
|
3770
3779
|
placeholder: t("billing.admin.prices.placeholders.feature", { index: index + 1 }),
|
|
@@ -3772,7 +3781,7 @@ function PriceEditorInternal({
|
|
|
3772
3781
|
}
|
|
3773
3782
|
),
|
|
3774
3783
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3775
|
-
|
|
3784
|
+
_chunk2WK35GO2js.Button,
|
|
3776
3785
|
{
|
|
3777
3786
|
type: "button",
|
|
3778
3787
|
variant: "outline",
|
|
@@ -3787,7 +3796,7 @@ function PriceEditorInternal({
|
|
|
3787
3796
|
)
|
|
3788
3797
|
] }, index)),
|
|
3789
3798
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3790
|
-
|
|
3799
|
+
_chunk2WK35GO2js.Button,
|
|
3791
3800
|
{
|
|
3792
3801
|
type: "button",
|
|
3793
3802
|
variant: "outline",
|
|
@@ -3802,12 +3811,12 @@ function PriceEditorInternal({
|
|
|
3802
3811
|
)
|
|
3803
3812
|
] }),
|
|
3804
3813
|
isRecurring && allFeatures.length > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-y-2", children: [
|
|
3805
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3814
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.FieldLabel, { children: t("billing.admin.prices.fields.platformFeatures") }),
|
|
3806
3815
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex max-h-48 flex-col gap-y-2 overflow-y-auto rounded-md border p-4", children: allFeatures.map((feature) => {
|
|
3807
3816
|
const isChecked = form.watch("featureIds").includes(feature.id);
|
|
3808
3817
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-2", children: [
|
|
3809
3818
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3810
|
-
|
|
3819
|
+
_chunk2WK35GO2js.Checkbox,
|
|
3811
3820
|
{
|
|
3812
3821
|
id: `feature-${feature.id}`,
|
|
3813
3822
|
checked: isChecked,
|
|
@@ -3823,13 +3832,13 @@ function PriceEditorInternal({
|
|
|
3823
3832
|
}
|
|
3824
3833
|
}
|
|
3825
3834
|
),
|
|
3826
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3835
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.FieldLabel, { htmlFor: `feature-${feature.id}`, children: feature.name }),
|
|
3827
3836
|
feature.isCore && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("billing.admin.prices.help.core") })
|
|
3828
3837
|
] }, feature.id);
|
|
3829
3838
|
}) })
|
|
3830
3839
|
] }),
|
|
3831
3840
|
isRecurring && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3832
|
-
|
|
3841
|
+
_chunk2WK35GO2js.FormCheckbox,
|
|
3833
3842
|
{
|
|
3834
3843
|
form,
|
|
3835
3844
|
id: "isTrial",
|
|
@@ -3872,7 +3881,7 @@ var defaultContextValue = {
|
|
|
3872
3881
|
productId: void 0
|
|
3873
3882
|
};
|
|
3874
3883
|
function priceLabel(price, fmt = {}) {
|
|
3875
|
-
return _nullishCoalesce(price.nickname, () => ( `${
|
|
3884
|
+
return _nullishCoalesce(price.nickname, () => ( `${_chunk5TH2DSAHjs.formatCurrency.call(void 0, price.unitAmount, price.currency, fmt)} ${_chunk5TH2DSAHjs.formatInterval.call(void 0, price, fmt)}`.trim()));
|
|
3876
3885
|
}
|
|
3877
3886
|
_chunk7QVYU63Ejs.__name.call(void 0, priceLabel, "priceLabel");
|
|
3878
3887
|
var PriceProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({
|
|
@@ -3882,22 +3891,22 @@ var PriceProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({
|
|
|
3882
3891
|
productId: productIdProp
|
|
3883
3892
|
}) => {
|
|
3884
3893
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
3885
|
-
const fmt =
|
|
3886
|
-
const generateUrl =
|
|
3887
|
-
const { hasRole } =
|
|
3894
|
+
const fmt = _chunk2WK35GO2js.useBillingFormatOptions.call(void 0, );
|
|
3895
|
+
const generateUrl = _chunk2WK35GO2js.usePageUrlGenerator.call(void 0, );
|
|
3896
|
+
const { hasRole } = _chunk2WK35GO2js.useCurrentUserContext.call(void 0, );
|
|
3888
3897
|
const [price, setPrice] = _react.useState.call(void 0,
|
|
3889
|
-
dehydratedPrice ?
|
|
3898
|
+
dehydratedPrice ? _chunk5TH2DSAHjs.rehydrate.call(void 0, _chunk5TH2DSAHjs.Modules.StripePrice, dehydratedPrice) : void 0
|
|
3890
3899
|
);
|
|
3891
3900
|
const [priceVersion, setPriceVersion] = _react.useState.call(void 0, 0);
|
|
3892
3901
|
const refreshPrices = _react.useCallback.call(void 0, () => setPriceVersion((value2) => value2 + 1), []);
|
|
3893
|
-
const productId = _nullishCoalesce(productIdProp, () => ( _optionalChain([price, 'optionalAccess',
|
|
3902
|
+
const productId = _nullishCoalesce(productIdProp, () => ( _optionalChain([price, 'optionalAccess', _143 => _143.product, 'optionalAccess', _144 => _144.id])));
|
|
3894
3903
|
const reloadPrice = _react.useCallback.call(void 0, async () => {
|
|
3895
|
-
if (!_optionalChain([price, 'optionalAccess',
|
|
3896
|
-
setPrice(await
|
|
3897
|
-
}, [_optionalChain([price, 'optionalAccess',
|
|
3904
|
+
if (!_optionalChain([price, 'optionalAccess', _145 => _145.id])) return;
|
|
3905
|
+
setPrice(await _chunk5TH2DSAHjs.StripePriceService.getPrice({ id: price.id }));
|
|
3906
|
+
}, [_optionalChain([price, 'optionalAccess', _146 => _146.id])]);
|
|
3898
3907
|
const createPrice = _react.useCallback.call(void 0,
|
|
3899
3908
|
async (input) => {
|
|
3900
|
-
const saved = await
|
|
3909
|
+
const saved = await _chunk5TH2DSAHjs.StripePriceService.createPrice(input);
|
|
3901
3910
|
refreshPrices();
|
|
3902
3911
|
return saved;
|
|
3903
3912
|
},
|
|
@@ -3905,7 +3914,7 @@ var PriceProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({
|
|
|
3905
3914
|
);
|
|
3906
3915
|
const updatePrice = _react.useCallback.call(void 0,
|
|
3907
3916
|
async (input) => {
|
|
3908
|
-
const saved = await
|
|
3917
|
+
const saved = await _chunk5TH2DSAHjs.StripePriceService.updatePrice(input);
|
|
3909
3918
|
setPrice(saved);
|
|
3910
3919
|
refreshPrices();
|
|
3911
3920
|
return saved;
|
|
@@ -3914,23 +3923,23 @@ var PriceProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({
|
|
|
3914
3923
|
);
|
|
3915
3924
|
const archivePrice = _react.useCallback.call(void 0,
|
|
3916
3925
|
async (id) => {
|
|
3917
|
-
const target = _nullishCoalesce(id, () => ( _optionalChain([price, 'optionalAccess',
|
|
3926
|
+
const target = _nullishCoalesce(id, () => ( _optionalChain([price, 'optionalAccess', _147 => _147.id])));
|
|
3918
3927
|
if (!target) return;
|
|
3919
|
-
await
|
|
3928
|
+
await _chunk5TH2DSAHjs.StripePriceService.archivePrice({ id: target });
|
|
3920
3929
|
await reloadPrice();
|
|
3921
3930
|
refreshPrices();
|
|
3922
3931
|
},
|
|
3923
|
-
[_optionalChain([price, 'optionalAccess',
|
|
3932
|
+
[_optionalChain([price, 'optionalAccess', _148 => _148.id]), reloadPrice, refreshPrices]
|
|
3924
3933
|
);
|
|
3925
3934
|
const restorePrice = _react.useCallback.call(void 0,
|
|
3926
3935
|
async (id) => {
|
|
3927
|
-
const target = _nullishCoalesce(id, () => ( _optionalChain([price, 'optionalAccess',
|
|
3936
|
+
const target = _nullishCoalesce(id, () => ( _optionalChain([price, 'optionalAccess', _149 => _149.id])));
|
|
3928
3937
|
if (!target) return;
|
|
3929
|
-
await
|
|
3938
|
+
await _chunk5TH2DSAHjs.StripePriceService.reactivatePrice({ id: target });
|
|
3930
3939
|
await reloadPrice();
|
|
3931
3940
|
refreshPrices();
|
|
3932
3941
|
},
|
|
3933
|
-
[_optionalChain([price, 'optionalAccess',
|
|
3942
|
+
[_optionalChain([price, 'optionalAccess', _150 => _150.id]), reloadPrice, refreshPrices]
|
|
3934
3943
|
);
|
|
3935
3944
|
const value = _react.useMemo.call(void 0,
|
|
3936
3945
|
() => ({
|
|
@@ -3950,12 +3959,12 @@ var PriceProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({
|
|
|
3950
3959
|
if (!publishChrome) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PriceContext.Provider, { value, children });
|
|
3951
3960
|
const breadcrumb = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => {
|
|
3952
3961
|
const items = [
|
|
3953
|
-
{ name: t("billing.admin.products.title"), href: generateUrl({ page:
|
|
3962
|
+
{ name: t("billing.admin.products.title"), href: generateUrl({ page: _chunk5TH2DSAHjs.Modules.StripeProduct }) }
|
|
3954
3963
|
];
|
|
3955
|
-
if (_optionalChain([price, 'optionalAccess',
|
|
3964
|
+
if (_optionalChain([price, 'optionalAccess', _151 => _151.product]))
|
|
3956
3965
|
items.push({
|
|
3957
3966
|
name: price.product.name,
|
|
3958
|
-
href: generateUrl({ page:
|
|
3967
|
+
href: generateUrl({ page: _chunk5TH2DSAHjs.Modules.StripeProduct, id: price.product.id })
|
|
3959
3968
|
});
|
|
3960
3969
|
if (price) items.push({ name: priceLabel(price, fmt) });
|
|
3961
3970
|
return items;
|
|
@@ -3972,7 +3981,7 @@ var PriceProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({
|
|
|
3972
3981
|
}
|
|
3973
3982
|
return response;
|
|
3974
3983
|
}, "title");
|
|
3975
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3984
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.SharedProvider, { value: { breadcrumbs: breadcrumb(), title: title() }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PriceContext.Provider, { value, children }) });
|
|
3976
3985
|
}, "PriceProvider");
|
|
3977
3986
|
var usePriceContext = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => _nullishCoalesce(_react.useContext.call(void 0, PriceContext), () => ( defaultContextValue)), "usePriceContext");
|
|
3978
3987
|
|
|
@@ -3992,12 +4001,12 @@ function ProductArchiver({ product }) {
|
|
|
3992
4001
|
const isArchived = !product.active;
|
|
3993
4002
|
const scope = isArchived ? "restore" : "archive";
|
|
3994
4003
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
3995
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
4004
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Button, { variant: "outline", size: "sm", onClick: () => setOpen(true), children: [
|
|
3996
4005
|
isArchived ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.RotateCcwIcon, {}) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ArchiveIcon, {}),
|
|
3997
4006
|
t(`billing.admin.products.${scope}.confirm`)
|
|
3998
4007
|
] }),
|
|
3999
4008
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4000
|
-
|
|
4009
|
+
_chunk2WK35GO2js.ConfirmDialog,
|
|
4001
4010
|
{
|
|
4002
4011
|
open,
|
|
4003
4012
|
onOpenChange: setOpen,
|
|
@@ -4011,7 +4020,7 @@ function ProductArchiver({ product }) {
|
|
|
4011
4020
|
if (isArchived) await restoreProduct(product.id);
|
|
4012
4021
|
else await archiveProduct(product.id);
|
|
4013
4022
|
} catch (error) {
|
|
4014
|
-
|
|
4023
|
+
_chunk2WK35GO2js.errorToast.call(void 0, { title: t(`billing.admin.products.${scope}.title`), error });
|
|
4015
4024
|
throw error;
|
|
4016
4025
|
}
|
|
4017
4026
|
}
|
|
@@ -4040,7 +4049,7 @@ function ProductEditorInternal({
|
|
|
4040
4049
|
onDialogOpenChange
|
|
4041
4050
|
}) {
|
|
4042
4051
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
4043
|
-
const router =
|
|
4052
|
+
const router = _chunk5TH2DSAHjs.useI18nRouter.call(void 0, );
|
|
4044
4053
|
const { createProduct, updateProduct } = useProductContext();
|
|
4045
4054
|
const isEdit = !!product;
|
|
4046
4055
|
const formSchema2 = _react.useMemo.call(void 0,
|
|
@@ -4053,9 +4062,9 @@ function ProductEditorInternal({
|
|
|
4053
4062
|
);
|
|
4054
4063
|
const getDefaultValues = _react.useCallback.call(void 0,
|
|
4055
4064
|
() => ({
|
|
4056
|
-
id: _nullishCoalesce(_optionalChain([product, 'optionalAccess',
|
|
4057
|
-
name: _nullishCoalesce(_optionalChain([product, 'optionalAccess',
|
|
4058
|
-
description: _nullishCoalesce(_optionalChain([product, 'optionalAccess',
|
|
4065
|
+
id: _nullishCoalesce(_optionalChain([product, 'optionalAccess', _152 => _152.id]), () => ( _uuid.v4.call(void 0, ))),
|
|
4066
|
+
name: _nullishCoalesce(_optionalChain([product, 'optionalAccess', _153 => _153.name]), () => ( "")),
|
|
4067
|
+
description: _nullishCoalesce(_optionalChain([product, 'optionalAccess', _154 => _154.description]), () => ( ""))
|
|
4059
4068
|
}),
|
|
4060
4069
|
[product]
|
|
4061
4070
|
);
|
|
@@ -4064,13 +4073,13 @@ function ProductEditorInternal({
|
|
|
4064
4073
|
defaultValues: getDefaultValues()
|
|
4065
4074
|
});
|
|
4066
4075
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4067
|
-
|
|
4076
|
+
_chunk2WK35GO2js.EditorSheet,
|
|
4068
4077
|
{
|
|
4069
4078
|
form,
|
|
4070
4079
|
entityType: t("billing.admin.products.entity"),
|
|
4071
|
-
entityName: _optionalChain([product, 'optionalAccess',
|
|
4080
|
+
entityName: _optionalChain([product, 'optionalAccess', _155 => _155.name]),
|
|
4072
4081
|
isEdit,
|
|
4073
|
-
module:
|
|
4082
|
+
module: _chunk5TH2DSAHjs.Modules.StripeProduct,
|
|
4074
4083
|
size: "md",
|
|
4075
4084
|
propagateChanges,
|
|
4076
4085
|
onSuccess,
|
|
@@ -4087,7 +4096,7 @@ function ProductEditorInternal({
|
|
|
4087
4096
|
onDialogOpenChange,
|
|
4088
4097
|
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-y-4", children: [
|
|
4089
4098
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4090
|
-
|
|
4099
|
+
_chunk2WK35GO2js.FormInput,
|
|
4091
4100
|
{
|
|
4092
4101
|
form,
|
|
4093
4102
|
id: "name",
|
|
@@ -4097,7 +4106,7 @@ function ProductEditorInternal({
|
|
|
4097
4106
|
}
|
|
4098
4107
|
),
|
|
4099
4108
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4100
|
-
|
|
4109
|
+
_chunk2WK35GO2js.FormTextarea,
|
|
4101
4110
|
{
|
|
4102
4111
|
form,
|
|
4103
4112
|
id: "description",
|
|
@@ -4141,20 +4150,20 @@ var defaultContextValue2 = {
|
|
|
4141
4150
|
};
|
|
4142
4151
|
var ProductProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({ children, dehydratedProduct, publishChrome = true }) => {
|
|
4143
4152
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
4144
|
-
const generateUrl =
|
|
4145
|
-
const { hasRole } =
|
|
4153
|
+
const generateUrl = _chunk2WK35GO2js.usePageUrlGenerator.call(void 0, );
|
|
4154
|
+
const { hasRole } = _chunk2WK35GO2js.useCurrentUserContext.call(void 0, );
|
|
4146
4155
|
const [product, setProduct] = _react.useState.call(void 0,
|
|
4147
|
-
dehydratedProduct ?
|
|
4156
|
+
dehydratedProduct ? _chunk5TH2DSAHjs.rehydrate.call(void 0, _chunk5TH2DSAHjs.Modules.StripeProduct, dehydratedProduct) : void 0
|
|
4148
4157
|
);
|
|
4149
4158
|
const [catalogueVersion, setCatalogueVersion] = _react.useState.call(void 0, 0);
|
|
4150
4159
|
const refreshCatalogue = _react.useCallback.call(void 0, () => setCatalogueVersion((value2) => value2 + 1), []);
|
|
4151
4160
|
const reloadProduct = _react.useCallback.call(void 0, async () => {
|
|
4152
|
-
if (!_optionalChain([product, 'optionalAccess',
|
|
4153
|
-
setProduct(await
|
|
4154
|
-
}, [_optionalChain([product, 'optionalAccess',
|
|
4161
|
+
if (!_optionalChain([product, 'optionalAccess', _156 => _156.id])) return;
|
|
4162
|
+
setProduct(await _chunk5TH2DSAHjs.StripeProductService.getProduct({ id: product.id }));
|
|
4163
|
+
}, [_optionalChain([product, 'optionalAccess', _157 => _157.id])]);
|
|
4155
4164
|
const createProduct = _react.useCallback.call(void 0,
|
|
4156
4165
|
async (input) => {
|
|
4157
|
-
const saved = await
|
|
4166
|
+
const saved = await _chunk5TH2DSAHjs.StripeProductService.createProduct(input);
|
|
4158
4167
|
refreshCatalogue();
|
|
4159
4168
|
return saved;
|
|
4160
4169
|
},
|
|
@@ -4162,7 +4171,7 @@ var ProductProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({ ch
|
|
|
4162
4171
|
);
|
|
4163
4172
|
const updateProduct = _react.useCallback.call(void 0,
|
|
4164
4173
|
async (input) => {
|
|
4165
|
-
const saved = await
|
|
4174
|
+
const saved = await _chunk5TH2DSAHjs.StripeProductService.updateProduct(input);
|
|
4166
4175
|
setProduct(saved);
|
|
4167
4176
|
refreshCatalogue();
|
|
4168
4177
|
return saved;
|
|
@@ -4171,23 +4180,23 @@ var ProductProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({ ch
|
|
|
4171
4180
|
);
|
|
4172
4181
|
const archiveProduct = _react.useCallback.call(void 0,
|
|
4173
4182
|
async (id) => {
|
|
4174
|
-
const target = _nullishCoalesce(id, () => ( _optionalChain([product, 'optionalAccess',
|
|
4183
|
+
const target = _nullishCoalesce(id, () => ( _optionalChain([product, 'optionalAccess', _158 => _158.id])));
|
|
4175
4184
|
if (!target) return;
|
|
4176
|
-
await
|
|
4185
|
+
await _chunk5TH2DSAHjs.StripeProductService.archiveProduct({ id: target });
|
|
4177
4186
|
await reloadProduct();
|
|
4178
4187
|
refreshCatalogue();
|
|
4179
4188
|
},
|
|
4180
|
-
[_optionalChain([product, 'optionalAccess',
|
|
4189
|
+
[_optionalChain([product, 'optionalAccess', _159 => _159.id]), reloadProduct, refreshCatalogue]
|
|
4181
4190
|
);
|
|
4182
4191
|
const restoreProduct = _react.useCallback.call(void 0,
|
|
4183
4192
|
async (id) => {
|
|
4184
|
-
const target = _nullishCoalesce(id, () => ( _optionalChain([product, 'optionalAccess',
|
|
4193
|
+
const target = _nullishCoalesce(id, () => ( _optionalChain([product, 'optionalAccess', _160 => _160.id])));
|
|
4185
4194
|
if (!target) return;
|
|
4186
|
-
await
|
|
4195
|
+
await _chunk5TH2DSAHjs.StripeProductService.reactivateProduct({ id: target });
|
|
4187
4196
|
await reloadProduct();
|
|
4188
4197
|
refreshCatalogue();
|
|
4189
4198
|
},
|
|
4190
|
-
[_optionalChain([product, 'optionalAccess',
|
|
4199
|
+
[_optionalChain([product, 'optionalAccess', _161 => _161.id]), reloadProduct, refreshCatalogue]
|
|
4191
4200
|
);
|
|
4192
4201
|
const value = _react.useMemo.call(void 0,
|
|
4193
4202
|
() => ({
|
|
@@ -4218,7 +4227,7 @@ var ProductProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({ ch
|
|
|
4218
4227
|
{
|
|
4219
4228
|
name: t("billing.admin.products.title"),
|
|
4220
4229
|
// Linked only when it is NOT the current page.
|
|
4221
|
-
...product ? { href: generateUrl({ page:
|
|
4230
|
+
...product ? { href: generateUrl({ page: _chunk5TH2DSAHjs.Modules.StripeProduct }) } : {}
|
|
4222
4231
|
}
|
|
4223
4232
|
];
|
|
4224
4233
|
if (product) items.push({ name: product.name });
|
|
@@ -4236,7 +4245,7 @@ var ProductProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({ ch
|
|
|
4236
4245
|
}
|
|
4237
4246
|
return response;
|
|
4238
4247
|
}, "title");
|
|
4239
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4248
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.SharedProvider, { value: { breadcrumbs: breadcrumb(), title: title() }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ProductContext.Provider, { value, children }) });
|
|
4240
4249
|
}, "ProductProvider");
|
|
4241
4250
|
var useProductContext = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => _nullishCoalesce(_react.useContext.call(void 0, ProductContext), () => ( defaultContextValue2)), "useProductContext");
|
|
4242
4251
|
|
|
@@ -4245,83 +4254,83 @@ var useProductContext = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ()
|
|
|
4245
4254
|
|
|
4246
4255
|
function PriceDetails() {
|
|
4247
4256
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
4248
|
-
const fmt =
|
|
4249
|
-
const generateUrl =
|
|
4257
|
+
const fmt = _chunk2WK35GO2js.useBillingFormatOptions.call(void 0, );
|
|
4258
|
+
const generateUrl = _chunk2WK35GO2js.usePageUrlGenerator.call(void 0, );
|
|
4250
4259
|
const { price } = usePriceContext();
|
|
4251
4260
|
if (!price) return null;
|
|
4252
4261
|
const isRecurring = price.priceType === "recurring";
|
|
4253
4262
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-y-8", children: [
|
|
4254
4263
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-y-4", children: [
|
|
4255
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4264
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.SectionHeader, { children: t("billing.admin.prices.title") }),
|
|
4256
4265
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [
|
|
4257
4266
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4258
|
-
|
|
4267
|
+
_chunk2WK35GO2js.DetailField,
|
|
4259
4268
|
{
|
|
4260
4269
|
label: t("billing.admin.prices.fields.product"),
|
|
4261
|
-
value: price.product ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4270
|
+
value: price.product ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Link, { href: generateUrl({ page: _chunk5TH2DSAHjs.Modules.StripeProduct, id: price.product.id }), children: price.product.name }) : "\u2014"
|
|
4262
4271
|
}
|
|
4263
4272
|
),
|
|
4264
4273
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4265
|
-
|
|
4274
|
+
_chunk2WK35GO2js.DetailField,
|
|
4266
4275
|
{
|
|
4267
4276
|
label: t("billing.admin.prices.fields.status"),
|
|
4268
4277
|
value: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "flex flex-wrap items-center gap-1", children: [
|
|
4269
|
-
price.active ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4270
|
-
price.isTrial && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4278
|
+
price.active ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Badge, { variant: "softGreen", children: t("billing.admin.prices.status.active") }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Badge, { variant: "softGray", children: t("billing.admin.prices.status.archived") }),
|
|
4279
|
+
price.isTrial && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Badge, { variant: "softBlue", children: t("billing.admin.prices.badge.trial") })
|
|
4271
4280
|
] })
|
|
4272
4281
|
}
|
|
4273
4282
|
),
|
|
4274
4283
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4275
|
-
|
|
4284
|
+
_chunk2WK35GO2js.DetailField,
|
|
4276
4285
|
{
|
|
4277
4286
|
label: t("billing.admin.prices.fields.amount"),
|
|
4278
|
-
value: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tabular-nums", children:
|
|
4287
|
+
value: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tabular-nums", children: _chunk5TH2DSAHjs.formatCurrency.call(void 0, price.unitAmount, price.currency, fmt) })
|
|
4279
4288
|
}
|
|
4280
4289
|
),
|
|
4281
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4290
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.DetailField, { label: t("billing.admin.prices.fields.currency"), value: price.currency.toUpperCase() }),
|
|
4282
4291
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4283
|
-
|
|
4292
|
+
_chunk2WK35GO2js.DetailField,
|
|
4284
4293
|
{
|
|
4285
4294
|
label: t("billing.admin.prices.fields.type"),
|
|
4286
4295
|
value: isRecurring ? t("billing.admin.prices.type.recurring") : t("billing.admin.prices.type.oneTime")
|
|
4287
4296
|
}
|
|
4288
4297
|
),
|
|
4289
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4298
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.DetailField, { label: t("billing.admin.prices.fields.billing"), value: _chunk5TH2DSAHjs.formatInterval.call(void 0, price, fmt) }),
|
|
4290
4299
|
isRecurring && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4291
|
-
|
|
4300
|
+
_chunk2WK35GO2js.DetailField,
|
|
4292
4301
|
{
|
|
4293
4302
|
label: t("billing.admin.prices.fields.intervalCount"),
|
|
4294
|
-
value: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tabular-nums", children: _nullishCoalesce(_optionalChain([price, 'access',
|
|
4303
|
+
value: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tabular-nums", children: _nullishCoalesce(_optionalChain([price, 'access', _162 => _162.recurring, 'optionalAccess', _163 => _163.intervalCount]), () => ( 1)) })
|
|
4295
4304
|
}
|
|
4296
4305
|
),
|
|
4297
4306
|
isRecurring && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4298
|
-
|
|
4307
|
+
_chunk2WK35GO2js.DetailField,
|
|
4299
4308
|
{
|
|
4300
4309
|
label: t("billing.admin.prices.fields.usageType"),
|
|
4301
|
-
value: _optionalChain([price, 'access',
|
|
4310
|
+
value: _optionalChain([price, 'access', _164 => _164.recurring, 'optionalAccess', _165 => _165.usageType]) === "metered" ? t("billing.admin.prices.usage.metered") : t("billing.admin.prices.usage.licensed")
|
|
4302
4311
|
}
|
|
4303
4312
|
)
|
|
4304
4313
|
] })
|
|
4305
4314
|
] }),
|
|
4306
4315
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-y-4", children: [
|
|
4307
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4316
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.SectionHeader, { children: t("billing.admin.prices.fields.platformFeatures") }),
|
|
4308
4317
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [
|
|
4309
4318
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4310
|
-
|
|
4319
|
+
_chunk2WK35GO2js.DetailField,
|
|
4311
4320
|
{
|
|
4312
4321
|
label: t("billing.admin.prices.fields.token"),
|
|
4313
4322
|
value: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tabular-nums", children: _nullishCoalesce(price.token, () => ( "\u2014")) })
|
|
4314
4323
|
}
|
|
4315
4324
|
),
|
|
4316
4325
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4317
|
-
|
|
4326
|
+
_chunk2WK35GO2js.DetailField,
|
|
4318
4327
|
{
|
|
4319
4328
|
label: t("billing.admin.prices.fields.stripeId"),
|
|
4320
4329
|
value: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tabular-nums", children: price.stripePriceId })
|
|
4321
4330
|
}
|
|
4322
4331
|
),
|
|
4323
4332
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4324
|
-
|
|
4333
|
+
_chunk2WK35GO2js.DetailField,
|
|
4325
4334
|
{
|
|
4326
4335
|
label: t("billing.admin.prices.fields.description"),
|
|
4327
4336
|
value: _nullishCoalesce(price.description, () => ( "\u2014")),
|
|
@@ -4329,7 +4338,7 @@ function PriceDetails() {
|
|
|
4329
4338
|
}
|
|
4330
4339
|
),
|
|
4331
4340
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4332
|
-
|
|
4341
|
+
_chunk2WK35GO2js.DetailField,
|
|
4333
4342
|
{
|
|
4334
4343
|
label: t("billing.admin.prices.fields.features"),
|
|
4335
4344
|
className: "md:col-span-2",
|
|
@@ -4337,11 +4346,11 @@ function PriceDetails() {
|
|
|
4337
4346
|
}
|
|
4338
4347
|
),
|
|
4339
4348
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4340
|
-
|
|
4349
|
+
_chunk2WK35GO2js.DetailField,
|
|
4341
4350
|
{
|
|
4342
4351
|
label: t("billing.admin.prices.fields.platformFeatures"),
|
|
4343
4352
|
className: "md:col-span-2",
|
|
4344
|
-
value: price.priceFeatures.length > 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "flex flex-wrap items-center gap-1", children: price.priceFeatures.map((feature) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4353
|
+
value: price.priceFeatures.length > 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "flex flex-wrap items-center gap-1", children: price.priceFeatures.map((feature) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Badge, { variant: "softGray", children: feature.name }, feature.id)) }) : "\u2014"
|
|
4345
4354
|
}
|
|
4346
4355
|
)
|
|
4347
4356
|
] })
|
|
@@ -4355,7 +4364,7 @@ _chunk7QVYU63Ejs.__name.call(void 0, PriceDetails, "PriceDetails");
|
|
|
4355
4364
|
function PriceContainer() {
|
|
4356
4365
|
const { price } = usePriceContext();
|
|
4357
4366
|
if (!price) return null;
|
|
4358
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4367
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.RoundPageContainer, { module: _chunk5TH2DSAHjs.Modules.StripePrice, id: price.id, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PriceDetails, {}) });
|
|
4359
4368
|
}
|
|
4360
4369
|
_chunk7QVYU63Ejs.__name.call(void 0, PriceContainer, "PriceContainer");
|
|
4361
4370
|
|
|
@@ -4382,9 +4391,9 @@ var seedSchema = _zod3.z.object({
|
|
|
4382
4391
|
isTrial: _zod3.z.boolean().optional(),
|
|
4383
4392
|
platformFeatures: _zod3.z.array(_zod3.z.string()).optional()
|
|
4384
4393
|
});
|
|
4385
|
-
function readOptional(
|
|
4394
|
+
function readOptional(read2) {
|
|
4386
4395
|
try {
|
|
4387
|
-
return
|
|
4396
|
+
return read2();
|
|
4388
4397
|
} catch (e2) {
|
|
4389
4398
|
return void 0;
|
|
4390
4399
|
}
|
|
@@ -4399,25 +4408,25 @@ function priceToSeed(price) {
|
|
|
4399
4408
|
const priceType = readOptional(() => price.priceType);
|
|
4400
4409
|
const currency = readOptional(() => price.currency);
|
|
4401
4410
|
const recurring = price.recurring;
|
|
4402
|
-
const interval = priceType === "one_time" ? "one_time" : _nullishCoalesce(_optionalChain([recurring, 'optionalAccess',
|
|
4411
|
+
const interval = priceType === "one_time" ? "one_time" : _nullishCoalesce(_optionalChain([recurring, 'optionalAccess', _166 => _166.interval]), () => ( "month"));
|
|
4403
4412
|
const seed = {
|
|
4404
4413
|
unitAmount: _nullishCoalesce(price.unitAmount, () => ( 0)),
|
|
4405
4414
|
currency: _nullishCoalesce(currency, () => ( "usd")),
|
|
4406
4415
|
interval
|
|
4407
4416
|
};
|
|
4408
4417
|
if (interval !== "one_time") {
|
|
4409
|
-
if (typeof _optionalChain([recurring, 'optionalAccess',
|
|
4410
|
-
if (_optionalChain([recurring, 'optionalAccess',
|
|
4418
|
+
if (typeof _optionalChain([recurring, 'optionalAccess', _167 => _167.intervalCount]) === "number") seed.intervalCount = recurring.intervalCount;
|
|
4419
|
+
if (_optionalChain([recurring, 'optionalAccess', _168 => _168.usageType])) seed.usageType = recurring.usageType;
|
|
4411
4420
|
}
|
|
4412
|
-
const nickname = _optionalChain([price, 'access',
|
|
4421
|
+
const nickname = _optionalChain([price, 'access', _169 => _169.nickname, 'optionalAccess', _170 => _170.trim, 'call', _171 => _171()]);
|
|
4413
4422
|
if (nickname) seed.nickname = nickname;
|
|
4414
|
-
const description = _optionalChain([price, 'access',
|
|
4423
|
+
const description = _optionalChain([price, 'access', _172 => _172.description, 'optionalAccess', _173 => _173.trim, 'call', _174 => _174()]);
|
|
4415
4424
|
if (description) seed.description = description;
|
|
4416
4425
|
const features = nonEmptyStrings(price.features);
|
|
4417
4426
|
if (features.length > 0) seed.features = features;
|
|
4418
4427
|
if (typeof price.token === "number" && !Number.isNaN(price.token)) seed.token = price.token;
|
|
4419
4428
|
if (typeof price.isTrial === "boolean") seed.isTrial = price.isTrial;
|
|
4420
|
-
const platformFeatures = nonEmptyStrings(_optionalChain([price, 'access',
|
|
4429
|
+
const platformFeatures = nonEmptyStrings(_optionalChain([price, 'access', _175 => _175.priceFeatures, 'optionalAccess', _176 => _176.map, 'call', _177 => _177((feature) => feature.name)]));
|
|
4421
4430
|
if (platformFeatures.length > 0) seed.platformFeatures = platformFeatures;
|
|
4422
4431
|
return seed;
|
|
4423
4432
|
}
|
|
@@ -4480,10 +4489,10 @@ function PricesList({ productId, fullWidth }) {
|
|
|
4480
4489
|
const importInputRef = _react.useRef.call(void 0, null);
|
|
4481
4490
|
const [seed, setSeed] = _react.useState.call(void 0, void 0);
|
|
4482
4491
|
const [seedNonce, setSeedNonce] = _react.useState.call(void 0, 0);
|
|
4483
|
-
const data =
|
|
4484
|
-
retriever: /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (params) =>
|
|
4492
|
+
const data = _chunk2WK35GO2js.useDataListRetriever.call(void 0, {
|
|
4493
|
+
retriever: /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (params) => _chunk5TH2DSAHjs.StripePriceService.listPrices({ ...params, productId }), "retriever"),
|
|
4485
4494
|
retrieverParams: {},
|
|
4486
|
-
module:
|
|
4495
|
+
module: _chunk5TH2DSAHjs.Modules.StripePrice
|
|
4487
4496
|
});
|
|
4488
4497
|
_react.useEffect.call(void 0, () => {
|
|
4489
4498
|
if (priceVersion > 0) void data.refresh();
|
|
@@ -4510,7 +4519,7 @@ function PricesList({ productId, fullWidth }) {
|
|
|
4510
4519
|
const onImportFileChange = _react.useCallback.call(void 0,
|
|
4511
4520
|
async (event) => {
|
|
4512
4521
|
const input = event.target;
|
|
4513
|
-
const file = _optionalChain([input, 'access',
|
|
4522
|
+
const file = _optionalChain([input, 'access', _178 => _178.files, 'optionalAccess', _179 => _179[0]]);
|
|
4514
4523
|
input.value = "";
|
|
4515
4524
|
if (!file) return;
|
|
4516
4525
|
try {
|
|
@@ -4518,7 +4527,7 @@ function PricesList({ productId, fullWidth }) {
|
|
|
4518
4527
|
openSeededEditor(transfer.price);
|
|
4519
4528
|
} catch (error) {
|
|
4520
4529
|
console.error("[PricesList] price import failed", error);
|
|
4521
|
-
|
|
4530
|
+
_chunk2WK35GO2js.errorToast.call(void 0, {
|
|
4522
4531
|
title: t("billing.admin.prices.import.errors.title"),
|
|
4523
4532
|
error: t("billing.admin.prices.import.errors.invalid")
|
|
4524
4533
|
});
|
|
@@ -4537,7 +4546,7 @@ function PricesList({ productId, fullWidth }) {
|
|
|
4537
4546
|
"create-price"
|
|
4538
4547
|
),
|
|
4539
4548
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.Fragment, { children: [
|
|
4540
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
4549
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk2WK35GO2js.Button, { variant: "outline", size: "sm", type: "button", onClick: () => _optionalChain([importInputRef, 'access', _180 => _180.current, 'optionalAccess', _181 => _181.click, 'call', _182 => _182()]), children: [
|
|
4541
4550
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.UploadIcon, {}),
|
|
4542
4551
|
t("billing.admin.prices.actions.import")
|
|
4543
4552
|
] }),
|
|
@@ -4555,7 +4564,7 @@ function PricesList({ productId, fullWidth }) {
|
|
|
4555
4564
|
];
|
|
4556
4565
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
4557
4566
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4558
|
-
|
|
4567
|
+
_chunk2WK35GO2js.ContentListTable,
|
|
4559
4568
|
{
|
|
4560
4569
|
data,
|
|
4561
4570
|
fields: [
|
|
@@ -4566,13 +4575,13 @@ function PricesList({ productId, fullWidth }) {
|
|
|
4566
4575
|
"status" /* status */,
|
|
4567
4576
|
"actions" /* actions */
|
|
4568
4577
|
],
|
|
4569
|
-
tableGeneratorType:
|
|
4578
|
+
tableGeneratorType: _chunk5TH2DSAHjs.Modules.StripePrice,
|
|
4570
4579
|
functions,
|
|
4571
4580
|
context: tableContext,
|
|
4572
4581
|
fullWidth,
|
|
4573
4582
|
title: t("billing.admin.prices.title"),
|
|
4574
4583
|
emptyState: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4575
|
-
|
|
4584
|
+
_chunk2WK35GO2js.EmptyState,
|
|
4576
4585
|
{
|
|
4577
4586
|
icon: _lucidereact.DollarSignIcon,
|
|
4578
4587
|
title: t("billing.admin.prices.empty.title"),
|
|
@@ -4612,18 +4621,18 @@ function ProductDetails() {
|
|
|
4612
4621
|
const { product } = useProductContext();
|
|
4613
4622
|
if (!product) return null;
|
|
4614
4623
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-y-4", children: [
|
|
4615
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4624
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.SectionHeader, { children: t("billing.admin.products.tabs.details") }),
|
|
4616
4625
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [
|
|
4617
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4626
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.DetailField, { label: t("billing.admin.products.fields.name"), value: product.name }),
|
|
4618
4627
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4619
|
-
|
|
4628
|
+
_chunk2WK35GO2js.DetailField,
|
|
4620
4629
|
{
|
|
4621
4630
|
label: t("billing.admin.products.fields.status"),
|
|
4622
|
-
value: product.active ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4631
|
+
value: product.active ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Badge, { variant: "softGreen", children: t("billing.admin.products.status.active") }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Badge, { variant: "softGray", children: t("billing.admin.products.status.archived") })
|
|
4623
4632
|
}
|
|
4624
4633
|
),
|
|
4625
4634
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4626
|
-
|
|
4635
|
+
_chunk2WK35GO2js.DetailField,
|
|
4627
4636
|
{
|
|
4628
4637
|
label: t("billing.admin.products.fields.description"),
|
|
4629
4638
|
value: _nullishCoalesce(product.description, () => ( "\u2014")),
|
|
@@ -4631,14 +4640,14 @@ function ProductDetails() {
|
|
|
4631
4640
|
}
|
|
4632
4641
|
),
|
|
4633
4642
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4634
|
-
|
|
4643
|
+
_chunk2WK35GO2js.DetailField,
|
|
4635
4644
|
{
|
|
4636
4645
|
label: t("billing.admin.products.fields.prices"),
|
|
4637
4646
|
value: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tabular-nums", children: product.stripePrices.length })
|
|
4638
4647
|
}
|
|
4639
4648
|
),
|
|
4640
4649
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4641
|
-
|
|
4650
|
+
_chunk2WK35GO2js.DetailField,
|
|
4642
4651
|
{
|
|
4643
4652
|
label: t("billing.admin.products.fields.stripeId"),
|
|
4644
4653
|
value: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tabular-nums", children: product.stripeProductId })
|
|
@@ -4656,9 +4665,9 @@ function ProductContainer() {
|
|
|
4656
4665
|
const { product } = useProductContext();
|
|
4657
4666
|
if (!product) return null;
|
|
4658
4667
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4659
|
-
|
|
4668
|
+
_chunk2WK35GO2js.RoundPageContainer,
|
|
4660
4669
|
{
|
|
4661
|
-
module:
|
|
4670
|
+
module: _chunk5TH2DSAHjs.Modules.StripeProduct,
|
|
4662
4671
|
id: product.id,
|
|
4663
4672
|
tabs: [
|
|
4664
4673
|
{
|
|
@@ -4667,7 +4676,7 @@ function ProductContainer() {
|
|
|
4667
4676
|
content: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ProductDetails, {})
|
|
4668
4677
|
},
|
|
4669
4678
|
{
|
|
4670
|
-
key:
|
|
4679
|
+
key: _chunk5TH2DSAHjs.Modules.StripePrice,
|
|
4671
4680
|
label: t("billing.admin.prices.title"),
|
|
4672
4681
|
// publishChrome={false}: SharedProvider REPLACES its value for the
|
|
4673
4682
|
// subtree (SharedContext.tsx:35-37), so a nested provider publishing
|
|
@@ -4693,18 +4702,18 @@ _chunk7QVYU63Ejs.__name.call(void 0, ProductContainer, "ProductContainer");
|
|
|
4693
4702
|
|
|
4694
4703
|
function CouponsList({ fullWidth } = {}) {
|
|
4695
4704
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
4696
|
-
const { catalogueVersion } =
|
|
4697
|
-
const data =
|
|
4698
|
-
retriever: /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (params) =>
|
|
4705
|
+
const { catalogueVersion } = _chunk2WK35GO2js.useCouponContext.call(void 0, );
|
|
4706
|
+
const data = _chunk2WK35GO2js.useDataListRetriever.call(void 0, {
|
|
4707
|
+
retriever: /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (params) => _chunk5TH2DSAHjs.StripeCouponService.listCoupons(params), "retriever"),
|
|
4699
4708
|
retrieverParams: {},
|
|
4700
|
-
module:
|
|
4709
|
+
module: _chunk5TH2DSAHjs.Modules.StripeCoupon
|
|
4701
4710
|
});
|
|
4702
4711
|
_react.useEffect.call(void 0, () => {
|
|
4703
4712
|
if (catalogueVersion > 0) void data.refresh();
|
|
4704
4713
|
}, [catalogueVersion]);
|
|
4705
|
-
const functions = [/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4714
|
+
const functions = [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CouponEditor, {}, "create-coupon")];
|
|
4706
4715
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4707
|
-
|
|
4716
|
+
_chunk2WK35GO2js.ContentListTable,
|
|
4708
4717
|
{
|
|
4709
4718
|
data,
|
|
4710
4719
|
fields: [
|
|
@@ -4714,12 +4723,12 @@ function CouponsList({ fullWidth } = {}) {
|
|
|
4714
4723
|
"codes" /* codes */,
|
|
4715
4724
|
"status" /* status */
|
|
4716
4725
|
],
|
|
4717
|
-
tableGeneratorType:
|
|
4726
|
+
tableGeneratorType: _chunk5TH2DSAHjs.Modules.StripeCoupon,
|
|
4718
4727
|
functions,
|
|
4719
4728
|
fullWidth,
|
|
4720
4729
|
title: t("billing.admin.coupons.title"),
|
|
4721
4730
|
emptyState: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4722
|
-
|
|
4731
|
+
_chunk2WK35GO2js.EmptyState,
|
|
4723
4732
|
{
|
|
4724
4733
|
icon: _lucidereact.TicketPercentIcon,
|
|
4725
4734
|
title: t("billing.admin.coupons.empty.title"),
|
|
@@ -4739,26 +4748,26 @@ _chunk7QVYU63Ejs.__name.call(void 0, CouponsList, "CouponsList");
|
|
|
4739
4748
|
function ProductsList({ fullWidth } = {}) {
|
|
4740
4749
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
4741
4750
|
const { catalogueVersion } = useProductContext();
|
|
4742
|
-
const data =
|
|
4743
|
-
retriever: /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (params) =>
|
|
4751
|
+
const data = _chunk2WK35GO2js.useDataListRetriever.call(void 0, {
|
|
4752
|
+
retriever: /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (params) => _chunk5TH2DSAHjs.StripeProductService.listProducts(params), "retriever"),
|
|
4744
4753
|
retrieverParams: {},
|
|
4745
|
-
module:
|
|
4754
|
+
module: _chunk5TH2DSAHjs.Modules.StripeProduct
|
|
4746
4755
|
});
|
|
4747
4756
|
_react.useEffect.call(void 0, () => {
|
|
4748
4757
|
if (catalogueVersion > 0) void data.refresh();
|
|
4749
4758
|
}, [catalogueVersion]);
|
|
4750
4759
|
const functions = [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ProductEditor, {}, "create-product")];
|
|
4751
4760
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4752
|
-
|
|
4761
|
+
_chunk2WK35GO2js.ContentListTable,
|
|
4753
4762
|
{
|
|
4754
4763
|
data,
|
|
4755
4764
|
fields: ["name" /* name */, "status" /* status */, "prices" /* prices */],
|
|
4756
|
-
tableGeneratorType:
|
|
4765
|
+
tableGeneratorType: _chunk5TH2DSAHjs.Modules.StripeProduct,
|
|
4757
4766
|
functions,
|
|
4758
4767
|
fullWidth,
|
|
4759
4768
|
title: t("billing.admin.products.title"),
|
|
4760
4769
|
emptyState: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4761
|
-
|
|
4770
|
+
_chunk2WK35GO2js.EmptyState,
|
|
4762
4771
|
{
|
|
4763
4772
|
icon: _lucidereact.PackageIcon,
|
|
4764
4773
|
title: t("billing.admin.products.empty.title"),
|
|
@@ -4774,10 +4783,10 @@ _chunk7QVYU63Ejs.__name.call(void 0, ProductsList, "ProductsList");
|
|
|
4774
4783
|
|
|
4775
4784
|
function ProductsListContainer() {
|
|
4776
4785
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
4777
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ProductProvider, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4778
|
-
|
|
4786
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ProductProvider, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CouponProvider, { publishChrome: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4787
|
+
_chunk2WK35GO2js.RoundPageContainer,
|
|
4779
4788
|
{
|
|
4780
|
-
module:
|
|
4789
|
+
module: _chunk5TH2DSAHjs.Modules.StripeProduct,
|
|
4781
4790
|
tabs: [
|
|
4782
4791
|
{ sectionKey: "products", label: t("billing.admin.products.tabs.products"), content: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ProductsList, {}) },
|
|
4783
4792
|
{ sectionKey: "codes", label: t("billing.admin.products.tabs.codes"), content: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CouponsList, {}) }
|
|
@@ -4795,24 +4804,30 @@ _chunk7QVYU63Ejs.__name.call(void 0, ProductsListContainer, "ProductsListContain
|
|
|
4795
4804
|
|
|
4796
4805
|
function CouponDetails() {
|
|
4797
4806
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
4798
|
-
const fmt =
|
|
4799
|
-
const { coupon } =
|
|
4807
|
+
const fmt = _chunk2WK35GO2js.useBillingFormatOptions.call(void 0, );
|
|
4808
|
+
const { coupon } = _chunk2WK35GO2js.useCouponContext.call(void 0, );
|
|
4800
4809
|
if (!coupon) return null;
|
|
4801
4810
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-y-4", children: [
|
|
4802
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4811
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.SectionHeader, { children: t("billing.admin.products.tabs.details") }),
|
|
4803
4812
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-muted-foreground text-xs/relaxed", children: t("billing.admin.coupons.fixed_notice") }),
|
|
4804
4813
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [
|
|
4805
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4814
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.DetailField, { label: t("billing.admin.coupons.fields.name"), value: coupon.name }),
|
|
4806
4815
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4807
|
-
|
|
4816
|
+
_chunk2WK35GO2js.DetailField,
|
|
4808
4817
|
{
|
|
4809
4818
|
label: t("billing.admin.coupons.fields.status"),
|
|
4810
|
-
value: coupon.valid ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4819
|
+
value: coupon.valid ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Badge, { variant: "softGreen", children: t("billing.admin.coupons.status.active") }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.Badge, { variant: "softGray", children: t("billing.admin.coupons.status.ended") })
|
|
4820
|
+
}
|
|
4821
|
+
),
|
|
4822
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4823
|
+
_chunk2WK35GO2js.DetailField,
|
|
4824
|
+
{
|
|
4825
|
+
label: t("billing.admin.coupons.fields.discount"),
|
|
4826
|
+
value: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tabular-nums", children: _chunk5TH2DSAHjs.formatCouponDiscount.call(void 0, coupon, t, fmt) })
|
|
4811
4827
|
}
|
|
4812
4828
|
),
|
|
4813
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLQ4DK4JFjs.DetailField, { label: t("billing.admin.coupons.fields.discount"), value: _chunkHKZAESS6js.formatCouponDiscount.call(void 0, coupon, t, fmt) }),
|
|
4814
4829
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4815
|
-
|
|
4830
|
+
_chunk2WK35GO2js.DetailField,
|
|
4816
4831
|
{
|
|
4817
4832
|
label: t("billing.admin.coupons.fields.places"),
|
|
4818
4833
|
value: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tabular-nums", children: coupon.maxRedemptions !== void 0 ? t("billing.admin.coupons.places.limited", {
|
|
@@ -4822,21 +4837,21 @@ function CouponDetails() {
|
|
|
4822
4837
|
}
|
|
4823
4838
|
),
|
|
4824
4839
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4825
|
-
|
|
4840
|
+
_chunk2WK35GO2js.DetailField,
|
|
4826
4841
|
{
|
|
4827
4842
|
label: t("billing.admin.coupons.fields.products"),
|
|
4828
4843
|
value: coupon.stripeProductIds.length > 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tabular-nums", children: coupon.stripeProductIds.join(", ") }) : t("billing.admin.coupons.all_products")
|
|
4829
4844
|
}
|
|
4830
4845
|
),
|
|
4831
4846
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4832
|
-
|
|
4847
|
+
_chunk2WK35GO2js.DetailField,
|
|
4833
4848
|
{
|
|
4834
4849
|
label: t("billing.admin.coupons.fields.redeemBy"),
|
|
4835
|
-
value: coupon.redeemBy ?
|
|
4850
|
+
value: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tabular-nums", children: coupon.redeemBy ? _chunk2WK35GO2js.formatDate.call(void 0, coupon.redeemBy, fmt) : "\u2014" })
|
|
4836
4851
|
}
|
|
4837
4852
|
),
|
|
4838
4853
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4839
|
-
|
|
4854
|
+
_chunk2WK35GO2js.DetailField,
|
|
4840
4855
|
{
|
|
4841
4856
|
label: t("billing.admin.coupons.fields.stripeId"),
|
|
4842
4857
|
value: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tabular-nums", children: coupon.stripeCouponId })
|
|
@@ -4870,33 +4885,33 @@ function CouponCodeEditorInternal({
|
|
|
4870
4885
|
onDialogOpenChange
|
|
4871
4886
|
}) {
|
|
4872
4887
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
4873
|
-
const router =
|
|
4874
|
-
const { createCode } =
|
|
4875
|
-
const formSchema2 = _react.useMemo.call(void 0, () => _zod3.z.object({ id: _zod3.z.uuidv4() }).and(
|
|
4876
|
-
const getDefaultValues = _react.useCallback.call(void 0, () => ({ id: _uuid.v4.call(void 0, ), ...
|
|
4888
|
+
const router = _chunk5TH2DSAHjs.useI18nRouter.call(void 0, );
|
|
4889
|
+
const { createCode } = _chunk2WK35GO2js.useCouponContext.call(void 0, );
|
|
4890
|
+
const formSchema2 = _react.useMemo.call(void 0, () => _zod3.z.object({ id: _zod3.z.uuidv4() }).and(_chunk2WK35GO2js.couponCodeSchema.call(void 0, t)), [t]);
|
|
4891
|
+
const getDefaultValues = _react.useCallback.call(void 0, () => ({ id: _uuid.v4.call(void 0, ), ..._chunk2WK35GO2js.couponCodeDefaults.call(void 0, ) }), []);
|
|
4877
4892
|
const form = _reacthookform.useForm.call(void 0, {
|
|
4878
4893
|
resolver: _zod.zodResolver.call(void 0, formSchema2),
|
|
4879
4894
|
defaultValues: getDefaultValues()
|
|
4880
4895
|
});
|
|
4881
4896
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4882
|
-
|
|
4897
|
+
_chunk2WK35GO2js.EditorSheet,
|
|
4883
4898
|
{
|
|
4884
4899
|
form,
|
|
4885
4900
|
entityType: t("billing.admin.coupons.codes.entity"),
|
|
4886
4901
|
isEdit: false,
|
|
4887
|
-
module:
|
|
4902
|
+
module: _chunk5TH2DSAHjs.Modules.StripeCouponCode,
|
|
4888
4903
|
size: "md",
|
|
4889
4904
|
onSuccess: _nullishCoalesce(onSuccess, () => ( (() => {
|
|
4890
4905
|
}))),
|
|
4891
4906
|
onNavigate: (url) => router.push(url),
|
|
4892
|
-
onSubmit: async (values) => await createCode({ id: values.id, couponId, ...
|
|
4907
|
+
onSubmit: async (values) => await createCode({ id: values.id, couponId, ..._chunk2WK35GO2js.toCouponCodeInput.call(void 0, values) }),
|
|
4893
4908
|
onReset: getDefaultValues,
|
|
4894
4909
|
trigger,
|
|
4895
4910
|
forceShow,
|
|
4896
4911
|
onClose,
|
|
4897
4912
|
dialogOpen,
|
|
4898
4913
|
onDialogOpenChange,
|
|
4899
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4914
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2WK35GO2js.CouponCodeFields, { form })
|
|
4900
4915
|
}
|
|
4901
4916
|
);
|
|
4902
4917
|
}
|
|
@@ -4910,18 +4925,18 @@ _chunk7QVYU63Ejs.__name.call(void 0, CouponCodeEditor, "CouponCodeEditor");
|
|
|
4910
4925
|
|
|
4911
4926
|
function CouponCodesList({ couponId }) {
|
|
4912
4927
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
4913
|
-
const { catalogueVersion } =
|
|
4914
|
-
const data =
|
|
4915
|
-
retriever: /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (params) =>
|
|
4928
|
+
const { catalogueVersion } = _chunk2WK35GO2js.useCouponContext.call(void 0, );
|
|
4929
|
+
const data = _chunk2WK35GO2js.useDataListRetriever.call(void 0, {
|
|
4930
|
+
retriever: /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (params) => _chunk5TH2DSAHjs.StripeCouponCodeService.listByCoupon({ ...params, couponId }), "retriever"),
|
|
4916
4931
|
retrieverParams: {},
|
|
4917
|
-
module:
|
|
4932
|
+
module: _chunk5TH2DSAHjs.Modules.StripeCouponCode
|
|
4918
4933
|
});
|
|
4919
4934
|
_react.useEffect.call(void 0, () => {
|
|
4920
4935
|
if (catalogueVersion > 0) void data.refresh();
|
|
4921
4936
|
}, [catalogueVersion]);
|
|
4922
4937
|
const functions = [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CouponCodeEditor, { couponId }, "create-code")];
|
|
4923
4938
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4924
|
-
|
|
4939
|
+
_chunk2WK35GO2js.ContentListTable,
|
|
4925
4940
|
{
|
|
4926
4941
|
data,
|
|
4927
4942
|
fields: [
|
|
@@ -4932,11 +4947,11 @@ function CouponCodesList({ couponId }) {
|
|
|
4932
4947
|
"status" /* status */,
|
|
4933
4948
|
"actions" /* actions */
|
|
4934
4949
|
],
|
|
4935
|
-
tableGeneratorType:
|
|
4950
|
+
tableGeneratorType: _chunk5TH2DSAHjs.Modules.StripeCouponCode,
|
|
4936
4951
|
functions,
|
|
4937
4952
|
title: t("billing.admin.coupons.codes.title"),
|
|
4938
4953
|
emptyState: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4939
|
-
|
|
4954
|
+
_chunk2WK35GO2js.EmptyState,
|
|
4940
4955
|
{
|
|
4941
4956
|
icon: _lucidereact.TicketIcon,
|
|
4942
4957
|
title: t("billing.admin.coupons.codes.empty.title"),
|
|
@@ -4952,12 +4967,12 @@ _chunk7QVYU63Ejs.__name.call(void 0, CouponCodesList, "CouponCodesList");
|
|
|
4952
4967
|
|
|
4953
4968
|
function CouponContainer() {
|
|
4954
4969
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
4955
|
-
const { coupon } =
|
|
4970
|
+
const { coupon } = _chunk2WK35GO2js.useCouponContext.call(void 0, );
|
|
4956
4971
|
if (!coupon) return null;
|
|
4957
4972
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4958
|
-
|
|
4973
|
+
_chunk2WK35GO2js.RoundPageContainer,
|
|
4959
4974
|
{
|
|
4960
|
-
module:
|
|
4975
|
+
module: _chunk2WK35GO2js.couponPageModule.call(void 0, ),
|
|
4961
4976
|
id: coupon.id,
|
|
4962
4977
|
tabs: [
|
|
4963
4978
|
{
|
|
@@ -5062,5 +5077,7 @@ _chunk7QVYU63Ejs.__name.call(void 0, CouponContainer, "CouponContainer");
|
|
|
5062
5077
|
|
|
5063
5078
|
|
|
5064
5079
|
|
|
5065
|
-
|
|
5080
|
+
|
|
5081
|
+
|
|
5082
|
+
exports.BillingAlertBanner = BillingAlertBanner; exports.BillingDashboardContainer = BillingDashboardContainer; exports.BillingDetailModal = BillingDetailModal; exports.BillingUsageSummaryCard = BillingUsageSummaryCard; exports.CancelSubscriptionDialog = CancelSubscriptionDialog; exports.CouponCodeActions = _chunk2WK35GO2js.CouponCodeActions; exports.CouponCodeEditor = CouponCodeEditor; exports.CouponCodeFields = _chunk2WK35GO2js.CouponCodeFields; exports.CouponCodesList = CouponCodesList; exports.CouponContainer = CouponContainer; exports.CouponDetails = CouponDetails; exports.CouponEditor = _chunk2WK35GO2js.CouponEditor; exports.CouponProvider = _chunk2WK35GO2js.CouponProvider; exports.CouponRefresher = _chunk2WK35GO2js.CouponRefresher; exports.CouponsList = CouponsList; exports.CustomerInfoCard = CustomerInfoCard; exports.IntervalToggle = IntervalToggle; exports.InvoiceDetails = InvoiceDetails; exports.InvoiceStatusBadge = InvoiceStatusBadge; exports.InvoicesContainer = InvoicesContainer; exports.InvoicesList = InvoicesList; exports.InvoicesSummaryCard = InvoicesSummaryCard; exports.PaymentMethodCard = PaymentMethodCard; exports.PaymentMethodEditor = PaymentMethodEditor; exports.PaymentMethodForm = PaymentMethodForm; exports.PaymentMethodSummaryCard = PaymentMethodSummaryCard; exports.PaymentMethodsContainer = PaymentMethodsContainer; exports.PaymentMethodsList = PaymentMethodsList; exports.PriceArchiver = PriceArchiver; exports.PriceContainer = PriceContainer; exports.PriceDetails = PriceDetails; exports.PriceEditor = PriceEditor; exports.PriceProvider = PriceProvider; exports.PricesList = PricesList; exports.PricingCard = PricingCard; exports.ProductArchiver = ProductArchiver; exports.ProductContainer = ProductContainer; exports.ProductDetails = ProductDetails; exports.ProductEditor = ProductEditor; exports.ProductPricingList = ProductPricingList; exports.ProductPricingRow = ProductPricingRow; exports.ProductProvider = ProductProvider; exports.ProductsList = ProductsList; exports.ProductsListContainer = ProductsListContainer; exports.PromoCodeInput = PromoCodeInput; exports.ProrationPreview = ProrationPreview; exports.StripeProvider = StripeProvider; exports.SubscriptionConfirmation = SubscriptionConfirmation; exports.SubscriptionDetails = SubscriptionDetails; exports.SubscriptionStatusBadge = SubscriptionStatusBadge; exports.SubscriptionSummaryCard = SubscriptionSummaryCard; exports.SubscriptionWizard = SubscriptionWizard; exports.SubscriptionsContainer = SubscriptionsContainer; exports.SubscriptionsList = SubscriptionsList; exports.UsageContainer = UsageContainer; exports.UsageHistoryTable = UsageHistoryTable; exports.UsageSummaryCard = UsageSummaryCard; exports.UsageSummaryCards = UsageSummaryCards; exports.WizardProgressIndicator = WizardProgressIndicator; exports.WizardStepPaymentMethod = WizardStepPaymentMethod; exports.WizardStepPlanSelection = WizardStepPlanSelection; exports.WizardStepReview = WizardStepReview; exports.applyDiscount = _chunk2WK35GO2js.applyDiscount; exports.couponCodeDefaults = _chunk2WK35GO2js.couponCodeDefaults; exports.couponCodeSchema = _chunk2WK35GO2js.couponCodeSchema; exports.couponCurrencyOptions = _chunk2WK35GO2js.couponCurrencyOptions; exports.formatCurrency = _chunk5TH2DSAHjs.formatCurrency; exports.formatDate = _chunk2WK35GO2js.formatDate; exports.formatFixed = _chunk5TH2DSAHjs.formatFixed; exports.formatInterval = _chunk5TH2DSAHjs.formatInterval; exports.isStripeConfigured = isStripeConfigured; exports.optionalDate = _chunk2WK35GO2js.optionalDate; exports.optionalDecimal = _chunk2WK35GO2js.optionalDecimal; exports.optionalPositiveInt = _chunk2WK35GO2js.optionalPositiveInt; exports.parseOptionalDecimal = _chunk2WK35GO2js.parseOptionalDecimal; exports.parseOptionalPositiveInt = _chunk2WK35GO2js.parseOptionalPositiveInt; exports.priceLabel = priceLabel; exports.promotionCodeDiscount = _chunk2WK35GO2js.promotionCodeDiscount; exports.subscriptionDiscount = _chunk2WK35GO2js.subscriptionDiscount; exports.toCouponCodeInput = _chunk2WK35GO2js.toCouponCodeInput; exports.useBillingFormatOptions = _chunk2WK35GO2js.useBillingFormatOptions; exports.useCouponContext = _chunk2WK35GO2js.useCouponContext; exports.usePriceContext = usePriceContext; exports.useProductContext = useProductContext;
|
|
5066
5083
|
//# sourceMappingURL=index.js.map
|