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