@carlonicora/nextjs-jsonapi 5.5.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-GVQCKRMU.mjs → BlockNoteEditor-R3WXUFHX.mjs} +4 -4
- package/dist/{BlockNoteEditor-THBJH2UR.js → BlockNoteEditor-ZHXXFWUJ.js} +19 -19
- package/dist/{BlockNoteEditor-THBJH2UR.js.map → BlockNoteEditor-ZHXXFWUJ.js.map} +1 -1
- package/dist/{BlockNoteViewer-U6E3DS4F.mjs → BlockNoteViewer-BVVN6D3T.mjs} +2 -2
- package/dist/{BlockNoteViewer-VZOVKTFO.js → BlockNoteViewer-SD3ZFIXD.js} +3 -3
- package/dist/{BlockNoteViewer-VZOVKTFO.js.map → BlockNoteViewer-SD3ZFIXD.js.map} +1 -1
- package/dist/billing/index.d.mts +197 -46
- package/dist/billing/index.d.ts +197 -46
- package/dist/billing/index.js +1166 -589
- package/dist/billing/index.js.map +1 -1
- package/dist/billing/index.mjs +803 -226
- package/dist/billing/index.mjs.map +1 -1
- package/dist/{chunk-WPYT4UKJ.js → chunk-2TXE57LE.js} +3 -3
- package/dist/{chunk-WPYT4UKJ.js.map → chunk-2TXE57LE.js.map} +1 -1
- package/dist/{chunk-G6UE6MEP.js → chunk-5TH2DSAH.js} +901 -204
- package/dist/chunk-5TH2DSAH.js.map +1 -0
- package/dist/{chunk-X5WIUUNG.mjs → chunk-CFB6FHIY.mjs} +3342 -2377
- package/dist/chunk-CFB6FHIY.mjs.map +1 -0
- package/dist/{chunk-VC5A3AUZ.mjs → chunk-FK26NX3S.mjs} +701 -4
- package/dist/chunk-FK26NX3S.mjs.map +1 -0
- package/dist/{chunk-YDYVJM4I.js → chunk-IJME5SAM.js} +4 -4
- package/dist/{chunk-YDYVJM4I.js.map → chunk-IJME5SAM.js.map} +1 -1
- package/dist/{chunk-W7F5BDSV.mjs → chunk-OKCV4GPJ.mjs} +2 -2
- package/dist/{chunk-3CGROPF3.mjs → chunk-RGQYFSJF.mjs} +2 -2
- package/dist/{chunk-6SQYXUVP.mjs → chunk-WCHLCOZG.mjs} +2 -2
- package/dist/{chunk-S4YJ5WCW.js → chunk-XOSC3FFP.js} +8 -8
- package/dist/{chunk-S4YJ5WCW.js.map → chunk-XOSC3FFP.js.map} +1 -1
- package/dist/{chunk-TY5FYP3G.js → chunk-ZCOPOO7T.js} +2024 -1059
- 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 +248 -3
- package/dist/core/index.d.ts +248 -3
- package/dist/core/index.js +42 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +41 -1
- package/dist/{stripe-promotion-code.interface-ClZ7DxS9.d.mts → currency-DT_dveBx.d.mts} +137 -1
- package/dist/{stripe-promotion-code.interface-C3qqh3mi.d.ts → currency-pK9eRYRC.d.ts} +137 -1
- 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 +43 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -2
- package/dist/server/index.js +3 -3
- package/dist/server/index.mjs +2 -2
- package/messages/en.json +125 -3
- package/messages/it.json +125 -3
- package/package.json +1 -1
- package/scripts/validate-messages.mjs +1 -0
- package/src/billing/index.ts +1 -0
- package/src/client/index.ts +4 -0
- package/src/core/index.ts +4 -0
- package/src/core/registry/ModuleRegistry.ts +3 -0
- package/src/features/billing/components/cards/InvoicesSummaryCard.tsx +3 -2
- package/src/features/billing/components/cards/SubscriptionSummaryCard.tsx +4 -3
- package/src/features/billing/components/containers/BillingDashboardContainer.tsx +22 -5
- package/src/features/billing/components/utils/__tests__/discount.spec.ts +59 -0
- package/src/features/billing/components/utils/__tests__/url.spec.ts +32 -0
- package/src/features/billing/components/utils/discount.ts +38 -0
- package/src/features/billing/components/utils/index.ts +2 -0
- package/src/features/billing/components/utils/url.ts +12 -0
- package/src/features/billing/contexts/CouponContext.tsx +209 -0
- package/src/features/billing/contexts/index.ts +1 -0
- package/src/features/billing/i18n-keys.ts +79 -0
- package/src/features/billing/stripe-coupon/components/containers/CouponContainer.tsx +38 -0
- package/src/features/billing/stripe-coupon/components/containers/index.ts +1 -0
- package/src/features/billing/stripe-coupon/components/details/CouponDetails.tsx +72 -0
- package/src/features/billing/stripe-coupon/components/details/index.ts +1 -0
- package/src/features/billing/stripe-coupon/components/forms/CouponCodeEditor.tsx +80 -0
- package/src/features/billing/stripe-coupon/components/forms/CouponCodeFields.tsx +214 -0
- package/src/features/billing/stripe-coupon/components/forms/CouponEditor.tsx +425 -0
- package/src/features/billing/stripe-coupon/components/forms/CouponRefresher.tsx +45 -0
- package/src/features/billing/stripe-coupon/components/forms/index.ts +6 -0
- package/src/features/billing/stripe-coupon/components/index.ts +5 -0
- package/src/features/billing/stripe-coupon/components/lists/CouponCodesList.tsx +61 -0
- package/src/features/billing/stripe-coupon/components/lists/CouponsList.tsx +67 -0
- package/src/features/billing/stripe-coupon/components/lists/index.ts +2 -0
- package/src/features/billing/stripe-coupon/components/widgets/CouponCodeActions.tsx +81 -0
- package/src/features/billing/stripe-coupon/components/widgets/index.ts +1 -0
- package/src/features/billing/stripe-coupon/data/__tests__/stripe-coupon-models.spec.ts +114 -0
- package/src/features/billing/stripe-coupon/data/index.ts +10 -0
- package/src/features/billing/stripe-coupon/data/stripe-coupon-code.fields.ts +8 -0
- package/src/features/billing/stripe-coupon/data/stripe-coupon-code.interface.ts +44 -0
- package/src/features/billing/stripe-coupon/data/stripe-coupon-code.service.ts +92 -0
- package/src/features/billing/stripe-coupon/data/stripe-coupon-code.ts +132 -0
- package/src/features/billing/stripe-coupon/data/stripe-coupon-offer.interface.ts +17 -0
- package/src/features/billing/stripe-coupon/data/stripe-coupon-offer.ts +70 -0
- package/src/features/billing/stripe-coupon/data/stripe-coupon.fields.ts +7 -0
- package/src/features/billing/stripe-coupon/data/stripe-coupon.interface.ts +55 -0
- package/src/features/billing/stripe-coupon/data/stripe-coupon.service.ts +93 -0
- package/src/features/billing/stripe-coupon/data/stripe-coupon.ts +167 -0
- package/src/features/billing/stripe-coupon/hooks/useStripeCouponCodeTableStructure.tsx +161 -0
- package/src/features/billing/stripe-coupon/hooks/useStripeCouponTableStructure.tsx +113 -0
- package/src/features/billing/stripe-coupon/index.ts +5 -0
- package/src/features/billing/stripe-coupon/stripe-coupon-code.module.ts +15 -0
- package/src/features/billing/stripe-coupon/stripe-coupon-offer.module.ts +10 -0
- package/src/features/billing/stripe-coupon/stripe-coupon.module.ts +25 -0
- package/src/features/billing/stripe-coupon/utils/__tests__/coupon-places.spec.ts +19 -0
- package/src/features/billing/stripe-coupon/utils/__tests__/to-promotion-code-result.spec.ts +41 -0
- package/src/features/billing/stripe-coupon/utils/coupon-places.ts +23 -0
- package/src/features/billing/stripe-coupon/utils/format-coupon-discount.ts +36 -0
- package/src/features/billing/stripe-coupon/utils/index.ts +3 -0
- package/src/features/billing/stripe-coupon/utils/to-promotion-code-result.ts +23 -0
- package/src/features/billing/stripe-customer/components/forms/PaymentMethodForm.tsx +24 -8
- package/src/features/billing/stripe-product/components/containers/ProductsListContainer.tsx +21 -6
- package/src/features/billing/stripe-promotion-code/components/PromoCodeInput.tsx +60 -19
- package/src/features/billing/stripe-promotion-code/data/stripe-promotion-code.interface.ts +2 -0
- package/src/features/billing/stripe-subscription/components/containers/SubscriptionsContainer.tsx +24 -5
- package/src/features/billing/stripe-subscription/components/lists/SubscriptionsList.tsx +21 -2
- package/src/features/billing/stripe-subscription/components/wizards/SubscriptionWizard.tsx +1 -1
- package/src/features/billing/stripe-subscription/components/wizards/WizardStepPaymentMethod.tsx +1 -1
- package/src/features/billing/stripe-subscription/components/wizards/WizardStepReview.tsx +60 -49
- package/src/features/billing/stripe-subscription/components/wizards/__tests__/review-card.spec.ts +34 -0
- package/src/features/billing/stripe-subscription/components/wizards/review-card.ts +24 -0
- package/src/features/billing/stripe-subscription/data/__tests__/stripe-subscription.discount.spec.ts +67 -0
- package/src/features/billing/stripe-subscription/data/stripe-subscription.interface.ts +14 -0
- package/src/features/billing/stripe-subscription/data/stripe-subscription.service.ts +39 -0
- package/src/features/billing/stripe-subscription/data/stripe-subscription.ts +21 -0
- package/src/features/billing/stripe-subscription/hooks/__tests__/wizard-payment.spec.ts +48 -0
- package/src/features/billing/stripe-subscription/hooks/__tests__/wizard-promotion.spec.ts +132 -0
- package/src/features/billing/stripe-subscription/hooks/useSubscriptionWizard.ts +138 -12
- package/src/features/billing/stripe-subscription/hooks/wizard-payment.ts +30 -0
- package/src/features/billing/stripe-subscription/hooks/wizard-promotion.ts +61 -0
- package/src/features/user/contexts/CurrentUserContext.tsx +25 -0
- package/src/features/user/contexts/__tests__/CurrentUserContext.spec.tsx +121 -2
- package/dist/chunk-G6UE6MEP.js.map +0 -1
- package/dist/chunk-TY5FYP3G.js.map +0 -1
- package/dist/chunk-VC5A3AUZ.mjs.map +0 -1
- package/dist/chunk-X5WIUUNG.mjs.map +0 -1
- /package/dist/{BlockNoteEditor-GVQCKRMU.mjs.map → BlockNoteEditor-R3WXUFHX.mjs.map} +0 -0
- /package/dist/{BlockNoteViewer-U6E3DS4F.mjs.map → BlockNoteViewer-BVVN6D3T.mjs.map} +0 -0
- /package/dist/{chunk-W7F5BDSV.mjs.map → chunk-OKCV4GPJ.mjs.map} +0 -0
- /package/dist/{chunk-3CGROPF3.mjs.map → chunk-RGQYFSJF.mjs.map} +0 -0
- /package/dist/{chunk-6SQYXUVP.mjs.map → chunk-WCHLCOZG.mjs.map} +0 -0
package/dist/billing/index.js
CHANGED
|
@@ -65,10 +65,25 @@
|
|
|
65
65
|
|
|
66
66
|
|
|
67
67
|
|
|
68
|
-
var _chunkTY5FYP3Gjs = require('../chunk-TY5FYP3G.js');
|
|
69
68
|
|
|
70
69
|
|
|
71
|
-
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
var _chunkZCOPOO7Tjs = require('../chunk-ZCOPOO7T.js');
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
var _chunkXOSC3FFPjs = require('../chunk-XOSC3FFP.js');
|
|
72
87
|
|
|
73
88
|
|
|
74
89
|
var _chunkG4JR3SFVjs = require('../chunk-G4JR3SFV.js');
|
|
@@ -89,7 +104,14 @@ var _chunkG4JR3SFVjs = require('../chunk-G4JR3SFV.js');
|
|
|
89
104
|
|
|
90
105
|
|
|
91
106
|
|
|
92
|
-
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
var _chunk5TH2DSAHjs = require('../chunk-5TH2DSAH.js');
|
|
93
115
|
require('../chunk-GHE4VT2R.js');
|
|
94
116
|
require('../chunk-LXKSUWAV.js');
|
|
95
117
|
require('../chunk-JTPRJNT2.js');
|
|
@@ -102,7 +124,7 @@ var _chunk7QVYU63Ejs = require('../chunk-7QVYU63E.js');
|
|
|
102
124
|
var _nextintl = require('next-intl');
|
|
103
125
|
var _lucidereact = require('lucide-react');
|
|
104
126
|
var _jsxruntime = require('react/jsx-runtime');
|
|
105
|
-
var SUBSCRIPTION_STATUSES = Object.values(
|
|
127
|
+
var SUBSCRIPTION_STATUSES = Object.values(_chunk5TH2DSAHjs.SubscriptionStatus);
|
|
106
128
|
function getStatusBadgeVariant(status) {
|
|
107
129
|
switch (status) {
|
|
108
130
|
case "active" /* ACTIVE */:
|
|
@@ -134,43 +156,43 @@ function SubscriptionSummaryCard({
|
|
|
134
156
|
onManageClick
|
|
135
157
|
}) {
|
|
136
158
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
137
|
-
const fmt =
|
|
159
|
+
const fmt = _chunkZCOPOO7Tjs.useBillingFormatOptions.call(void 0, );
|
|
138
160
|
if (loading) {
|
|
139
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
140
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
141
|
-
/* @__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") }),
|
|
142
164
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-4 w-4 text-muted-foreground" })
|
|
143
165
|
] }),
|
|
144
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
145
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
146
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
147
|
-
/* @__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" })
|
|
148
170
|
] })
|
|
149
171
|
] });
|
|
150
172
|
}
|
|
151
173
|
if (error) {
|
|
152
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
153
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
154
|
-
/* @__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") }),
|
|
155
177
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-4 w-4 text-muted-foreground" })
|
|
156
178
|
] }),
|
|
157
|
-
/* @__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 }) })
|
|
158
180
|
] });
|
|
159
181
|
}
|
|
160
182
|
const activeSubscriptions = subscriptions.filter(
|
|
161
183
|
(sub) => sub.status === "active" /* ACTIVE */ || sub.status === "trialing" /* TRIALING */
|
|
162
184
|
);
|
|
163
185
|
const primarySubscription = activeSubscriptions[0];
|
|
164
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
165
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
166
|
-
/* @__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") }),
|
|
167
189
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-4 w-4 text-muted-foreground" })
|
|
168
190
|
] }),
|
|
169
|
-
/* @__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: [
|
|
170
192
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold text-muted-foreground", children: t("billing.ui.cards.subscriptions.empty_title") }),
|
|
171
193
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: t("billing.ui.cards.subscriptions.empty_description") }),
|
|
172
194
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
173
|
-
|
|
195
|
+
_chunkZCOPOO7Tjs.Button,
|
|
174
196
|
{
|
|
175
197
|
variant: "outline",
|
|
176
198
|
size: "sm",
|
|
@@ -185,11 +207,11 @@ function SubscriptionSummaryCard({
|
|
|
185
207
|
]
|
|
186
208
|
}
|
|
187
209
|
)
|
|
188
|
-
] }) :
|
|
210
|
+
] }) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
189
211
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
|
|
190
212
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold", children: formatPlanName(primarySubscription, t("billing.ui.cards.subscriptions.fallback_name")) }),
|
|
191
213
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
192
|
-
|
|
214
|
+
_chunkZCOPOO7Tjs.Badge,
|
|
193
215
|
{
|
|
194
216
|
variant: primarySubscription.cancelAtPeriodEnd ? "secondary" : getStatusBadgeVariant(primarySubscription.status),
|
|
195
217
|
children: primarySubscription.cancelAtPeriodEnd ? t("billing.ui.cards.subscriptions.canceling") : SUBSCRIPTION_STATUSES.includes(primarySubscription.status) ? t(`billing.ui.subscription_status.${primarySubscription.status}`) : primarySubscription.status
|
|
@@ -197,14 +219,14 @@ function SubscriptionSummaryCard({
|
|
|
197
219
|
)
|
|
198
220
|
] }),
|
|
199
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", {
|
|
200
|
-
date:
|
|
222
|
+
date: _chunkZCOPOO7Tjs.formatDate.call(void 0, primarySubscription.currentPeriodEnd, fmt)
|
|
201
223
|
}) : primarySubscription.cancelAtPeriodEnd ? t("billing.ui.cards.subscriptions.cancels_on", {
|
|
202
|
-
date:
|
|
224
|
+
date: _chunkZCOPOO7Tjs.formatDate.call(void 0, primarySubscription.currentPeriodEnd, fmt)
|
|
203
225
|
}) : t("billing.ui.cards.subscriptions.renews_on", {
|
|
204
|
-
date:
|
|
226
|
+
date: _chunkZCOPOO7Tjs.formatDate.call(void 0, primarySubscription.currentPeriodEnd, fmt)
|
|
205
227
|
}) }),
|
|
206
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 }) })
|
|
207
|
-
] })
|
|
229
|
+
] }) })
|
|
208
230
|
] });
|
|
209
231
|
}
|
|
210
232
|
_chunk7QVYU63Ejs.__name.call(void 0, SubscriptionSummaryCard, "SubscriptionSummaryCard");
|
|
@@ -235,37 +257,37 @@ function PaymentMethodSummaryCard({
|
|
|
235
257
|
}) {
|
|
236
258
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
237
259
|
if (loading) {
|
|
238
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
239
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
240
|
-
/* @__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") }),
|
|
241
263
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Wallet, { className: "h-4 w-4 text-muted-foreground" })
|
|
242
264
|
] }),
|
|
243
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
244
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
245
|
-
/* @__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" })
|
|
246
268
|
] })
|
|
247
269
|
] });
|
|
248
270
|
}
|
|
249
271
|
if (error) {
|
|
250
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
251
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
252
|
-
/* @__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") }),
|
|
253
275
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Wallet, { className: "h-4 w-4 text-muted-foreground" })
|
|
254
276
|
] }),
|
|
255
|
-
/* @__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 }) })
|
|
256
278
|
] });
|
|
257
279
|
}
|
|
258
280
|
const defaultMethod = paymentMethods.find((pm) => pm.id === defaultPaymentMethodId) || paymentMethods[0];
|
|
259
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
260
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
261
|
-
/* @__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") }),
|
|
262
284
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Wallet, { className: "h-4 w-4 text-muted-foreground" })
|
|
263
285
|
] }),
|
|
264
|
-
/* @__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: [
|
|
265
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") }),
|
|
266
288
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: t("billing.ui.cards.payment_method.empty_description") }),
|
|
267
289
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
268
|
-
|
|
290
|
+
_chunkZCOPOO7Tjs.Button,
|
|
269
291
|
{
|
|
270
292
|
variant: "outline",
|
|
271
293
|
size: "sm",
|
|
@@ -314,13 +336,13 @@ function formatBalance(balance, currency, locale) {
|
|
|
314
336
|
_chunk7QVYU63Ejs.__name.call(void 0, formatBalance, "formatBalance");
|
|
315
337
|
function CustomerInfoCard({ customer, loading, error }) {
|
|
316
338
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
317
|
-
const locale =
|
|
339
|
+
const locale = _chunk5TH2DSAHjs.useI18nLocale.call(void 0, );
|
|
318
340
|
const [portalLoading, setPortalLoading] = _react.useState.call(void 0, false);
|
|
319
341
|
const handlePortalClick = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async (e) => {
|
|
320
342
|
e.stopPropagation();
|
|
321
343
|
setPortalLoading(true);
|
|
322
344
|
try {
|
|
323
|
-
const { url } = await
|
|
345
|
+
const { url } = await _chunk5TH2DSAHjs.StripeCustomerService.createPortalSession();
|
|
324
346
|
window.open(url, "_blank");
|
|
325
347
|
} catch (err) {
|
|
326
348
|
console.error("[CustomerInfoCard] Failed to create portal session:", err);
|
|
@@ -329,45 +351,45 @@ function CustomerInfoCard({ customer, loading, error }) {
|
|
|
329
351
|
}
|
|
330
352
|
}, "handlePortalClick");
|
|
331
353
|
if (loading) {
|
|
332
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
333
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
334
|
-
/* @__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") }),
|
|
335
357
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.User, { className: "h-4 w-4 text-muted-foreground" })
|
|
336
358
|
] }),
|
|
337
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
338
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
339
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
340
|
-
/* @__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" })
|
|
341
363
|
] })
|
|
342
364
|
] });
|
|
343
365
|
}
|
|
344
366
|
if (error) {
|
|
345
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
346
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
347
|
-
/* @__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") }),
|
|
348
370
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.User, { className: "h-4 w-4 text-muted-foreground" })
|
|
349
371
|
] }),
|
|
350
|
-
/* @__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 }) })
|
|
351
373
|
] });
|
|
352
374
|
}
|
|
353
375
|
if (!customer) {
|
|
354
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
355
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
356
|
-
/* @__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") }),
|
|
357
379
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.User, { className: "h-4 w-4 text-muted-foreground" })
|
|
358
380
|
] }),
|
|
359
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
381
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkZCOPOO7Tjs.CardContent, { children: [
|
|
360
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") }),
|
|
361
383
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: t("billing.ui.cards.customer.not_set_up_description") })
|
|
362
384
|
] })
|
|
363
385
|
] });
|
|
364
386
|
}
|
|
365
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
366
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
367
|
-
/* @__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") }),
|
|
368
390
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.User, { className: "h-4 w-4 text-muted-foreground" })
|
|
369
391
|
] }),
|
|
370
|
-
/* @__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: [
|
|
371
393
|
customer.name && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold", children: customer.name }),
|
|
372
394
|
customer.email && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: customer.email }),
|
|
373
395
|
customer.balance !== void 0 && customer.balance !== 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-sm", children: [
|
|
@@ -377,7 +399,7 @@ function CustomerInfoCard({ customer, loading, error }) {
|
|
|
377
399
|
] }),
|
|
378
400
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: customer.balance < 0 ? "text-success" : "text-destructive", children: formatBalance(customer.balance, customer.currency, locale) })
|
|
379
401
|
] }),
|
|
380
|
-
/* @__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: [
|
|
381
403
|
portalLoading ? t("common.loading") : t("billing.ui.cards.customer.manage_portal"),
|
|
382
404
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ExternalLink, { className: "h-4 w-4 ms-1" })
|
|
383
405
|
] })
|
|
@@ -390,7 +412,7 @@ _chunk7QVYU63Ejs.__name.call(void 0, CustomerInfoCard, "CustomerInfoCard");
|
|
|
390
412
|
|
|
391
413
|
|
|
392
414
|
|
|
393
|
-
var INVOICE_STATUSES = Object.values(
|
|
415
|
+
var INVOICE_STATUSES = Object.values(_chunk5TH2DSAHjs.InvoiceStatus);
|
|
394
416
|
function getStatusBadgeVariant2(status) {
|
|
395
417
|
switch (status) {
|
|
396
418
|
case "paid" /* PAID */:
|
|
@@ -415,46 +437,46 @@ function formatAmount(amount, currency, locale) {
|
|
|
415
437
|
_chunk7QVYU63Ejs.__name.call(void 0, formatAmount, "formatAmount");
|
|
416
438
|
function InvoicesSummaryCard({ invoices, loading, error, onViewAllClick }) {
|
|
417
439
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
418
|
-
const fmt =
|
|
440
|
+
const fmt = _chunkZCOPOO7Tjs.useBillingFormatOptions.call(void 0, );
|
|
419
441
|
if (loading) {
|
|
420
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
421
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
422
|
-
/* @__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") }),
|
|
423
445
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ReceiptIcon, { className: "h-4 w-4 text-muted-foreground" })
|
|
424
446
|
] }),
|
|
425
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
426
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
427
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
428
|
-
/* @__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" })
|
|
429
451
|
] })
|
|
430
452
|
] });
|
|
431
453
|
}
|
|
432
454
|
if (error) {
|
|
433
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
434
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
435
|
-
/* @__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") }),
|
|
436
458
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ReceiptIcon, { className: "h-4 w-4 text-muted-foreground" })
|
|
437
459
|
] }),
|
|
438
|
-
/* @__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 }) })
|
|
439
461
|
] });
|
|
440
462
|
}
|
|
441
|
-
const latestInvoice = invoices[0];
|
|
463
|
+
const latestInvoice = _nullishCoalesce(invoices.find((inv) => inv.status !== "void" /* VOID */), () => ( invoices[0]));
|
|
442
464
|
const paidInvoices = invoices.filter((inv) => inv.status === "paid" /* PAID */);
|
|
443
465
|
const openInvoices = invoices.filter((inv) => inv.status === "open" /* OPEN */);
|
|
444
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
445
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
446
|
-
/* @__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") }),
|
|
447
469
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ReceiptIcon, { className: "h-4 w-4 text-muted-foreground" })
|
|
448
470
|
] }),
|
|
449
|
-
/* @__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: [
|
|
450
472
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold text-muted-foreground", children: t("billing.ui.invoices.empty_title") }),
|
|
451
473
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: t("billing.ui.cards.invoices.empty_description") })
|
|
452
474
|
] }) : latestInvoice ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
453
475
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
|
|
454
476
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold", children: formatAmount(latestInvoice.total, latestInvoice.currency, fmt.locale) }),
|
|
455
|
-
/* @__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 })
|
|
456
478
|
] }),
|
|
457
|
-
/* @__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) }) }),
|
|
458
480
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-4 text-xs text-muted-foreground", children: [
|
|
459
481
|
paidInvoices.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: t("billing.ui.cards.invoices.paid_count", { count: paidInvoices.length }) }),
|
|
460
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 }) }),
|
|
@@ -487,26 +509,26 @@ function BillingUsageSummaryCard({
|
|
|
487
509
|
onViewDetailsClick
|
|
488
510
|
}) {
|
|
489
511
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
490
|
-
const locale =
|
|
512
|
+
const locale = _chunk5TH2DSAHjs.useI18nLocale.call(void 0, );
|
|
491
513
|
if (loading) {
|
|
492
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
493
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
494
|
-
/* @__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") }),
|
|
495
517
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Activity, { className: "h-4 w-4 text-muted-foreground" })
|
|
496
518
|
] }),
|
|
497
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
498
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
499
|
-
/* @__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" })
|
|
500
522
|
] })
|
|
501
523
|
] });
|
|
502
524
|
}
|
|
503
525
|
if (error) {
|
|
504
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
505
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
506
|
-
/* @__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") }),
|
|
507
529
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Activity, { className: "h-4 w-4 text-muted-foreground" })
|
|
508
530
|
] }),
|
|
509
|
-
/* @__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 }) })
|
|
510
532
|
] });
|
|
511
533
|
}
|
|
512
534
|
const totalUsage = Object.values(summaries).reduce((acc, summary) => {
|
|
@@ -514,12 +536,12 @@ function BillingUsageSummaryCard({
|
|
|
514
536
|
}, 0);
|
|
515
537
|
const primaryMeter = meters.find((m) => _optionalChain([summaries, 'access', _17 => _17[m.id], 'optionalAccess', _18 => _18.aggregatedValue]));
|
|
516
538
|
const primarySummary = primaryMeter ? summaries[primaryMeter.id] : null;
|
|
517
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
518
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
519
|
-
/* @__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") }),
|
|
520
542
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Activity, { className: "h-4 w-4 text-muted-foreground" })
|
|
521
543
|
] }),
|
|
522
|
-
/* @__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: [
|
|
523
545
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold text-muted-foreground", children: t("billing.ui.cards.usage.no_meters") }),
|
|
524
546
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: t("billing.ui.cards.usage.no_meters_description") })
|
|
525
547
|
] }) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
@@ -558,7 +580,12 @@ var _navigation = require('next/navigation');
|
|
|
558
580
|
var _reactstripejs = require('@stripe/react-stripe-js');
|
|
559
581
|
|
|
560
582
|
|
|
561
|
-
function PaymentMethodForm({
|
|
583
|
+
function PaymentMethodForm({
|
|
584
|
+
onSuccess,
|
|
585
|
+
onCancel,
|
|
586
|
+
isLoading = false,
|
|
587
|
+
alwaysSetDefault = false
|
|
588
|
+
}) {
|
|
562
589
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
563
590
|
const stripe = _reactstripejs.useStripe.call(void 0, );
|
|
564
591
|
const elements = _reactstripejs.useElements.call(void 0, );
|
|
@@ -571,7 +598,7 @@ function PaymentMethodForm({ onSuccess, onCancel, isLoading = false }) {
|
|
|
571
598
|
const fetchSetupIntent = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
572
599
|
setLoading(true);
|
|
573
600
|
try {
|
|
574
|
-
const intent = await
|
|
601
|
+
const intent = await _chunk5TH2DSAHjs.StripeCustomerService.createSetupIntent();
|
|
575
602
|
setSetupIntent(intent);
|
|
576
603
|
} catch (err) {
|
|
577
604
|
console.error("[PaymentMethodForm] Failed to create setup intent:", err);
|
|
@@ -608,8 +635,8 @@ function PaymentMethodForm({ onSuccess, onCancel, isLoading = false }) {
|
|
|
608
635
|
setIsSubmitting(false);
|
|
609
636
|
return;
|
|
610
637
|
}
|
|
611
|
-
if (setAsDefault && _optionalChain([confirmedSetupIntent, 'optionalAccess', _19 => _19.payment_method])) {
|
|
612
|
-
await
|
|
638
|
+
if ((alwaysSetDefault || setAsDefault) && _optionalChain([confirmedSetupIntent, 'optionalAccess', _19 => _19.payment_method])) {
|
|
639
|
+
await _chunk5TH2DSAHjs.StripeCustomerService.setDefaultPaymentMethod({
|
|
613
640
|
paymentMethodId: typeof confirmedSetupIntent.payment_method === "string" ? confirmedSetupIntent.payment_method : confirmedSetupIntent.payment_method.id
|
|
614
641
|
});
|
|
615
642
|
}
|
|
@@ -625,7 +652,7 @@ function PaymentMethodForm({ onSuccess, onCancel, isLoading = false }) {
|
|
|
625
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") }) });
|
|
626
653
|
}
|
|
627
654
|
if (!setupIntent && error) {
|
|
628
|
-
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 }) });
|
|
629
656
|
}
|
|
630
657
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { onSubmit: handleSubmit, className: "flex flex-col gap-y-4", children: [
|
|
631
658
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rounded-md border border-gray-300 p-3", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -647,14 +674,21 @@ function PaymentMethodForm({ onSuccess, onCancel, isLoading = false }) {
|
|
|
647
674
|
}
|
|
648
675
|
}
|
|
649
676
|
) }),
|
|
650
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-2", children: [
|
|
651
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
652
|
-
|
|
677
|
+
!alwaysSetDefault && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-2", children: [
|
|
678
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
679
|
+
_chunkZCOPOO7Tjs.Checkbox,
|
|
680
|
+
{
|
|
681
|
+
id: "setAsDefault",
|
|
682
|
+
checked: setAsDefault,
|
|
683
|
+
onCheckedChange: (checked) => setSetAsDefault(!!checked)
|
|
684
|
+
}
|
|
685
|
+
),
|
|
686
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkZCOPOO7Tjs.Label, { htmlFor: "setAsDefault", className: "cursor-pointer font-normal", children: t("billing.ui.payment_form.set_default") })
|
|
653
687
|
] }),
|
|
654
|
-
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 }) }),
|
|
655
689
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-end gap-x-2", children: [
|
|
656
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
657
|
-
/* @__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") })
|
|
658
692
|
] })
|
|
659
693
|
] });
|
|
660
694
|
}
|
|
@@ -671,10 +705,10 @@ function PaymentMethodEditor({ open, onOpenChange, onSuccess }) {
|
|
|
671
705
|
const handleCancel = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => {
|
|
672
706
|
onOpenChange(false);
|
|
673
707
|
}, "handleCancel");
|
|
674
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
675
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
676
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
677
|
-
/* @__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") })
|
|
678
712
|
] }),
|
|
679
713
|
open && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PaymentMethodForm, { onSuccess: handleSuccess, onCancel: handleCancel })
|
|
680
714
|
] }) });
|
|
@@ -700,7 +734,7 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
700
734
|
_react.useEffect.call(void 0, () => {
|
|
701
735
|
const loadCustomer = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
702
736
|
try {
|
|
703
|
-
const fetchedCustomer = await
|
|
737
|
+
const fetchedCustomer = await _chunk5TH2DSAHjs.StripeCustomerService.getCustomer();
|
|
704
738
|
setCustomer(fetchedCustomer);
|
|
705
739
|
} catch (error) {
|
|
706
740
|
console.error("[PaymentMethodCard] Failed to load customer:", error);
|
|
@@ -717,7 +751,7 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
717
751
|
const handleSetDefault = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
718
752
|
setLoading(true);
|
|
719
753
|
try {
|
|
720
|
-
await
|
|
754
|
+
await _chunk5TH2DSAHjs.StripeCustomerService.setDefaultPaymentMethod({ paymentMethodId: paymentMethod.id });
|
|
721
755
|
onUpdate();
|
|
722
756
|
} catch (error) {
|
|
723
757
|
console.error("[PaymentMethodCard] Failed to set as default:", error);
|
|
@@ -728,7 +762,7 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
728
762
|
const handleRemove = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
729
763
|
setLoading(true);
|
|
730
764
|
try {
|
|
731
|
-
await
|
|
765
|
+
await _chunk5TH2DSAHjs.StripeCustomerService.removePaymentMethod({ paymentMethodId: paymentMethod.id });
|
|
732
766
|
setShowRemoveDialog(false);
|
|
733
767
|
onUpdate();
|
|
734
768
|
} catch (error) {
|
|
@@ -737,16 +771,16 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
737
771
|
}
|
|
738
772
|
}, "handleRemove");
|
|
739
773
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
740
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
741
|
-
isDefault && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
742
|
-
/* @__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: [
|
|
743
777
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-2", children: [
|
|
744
778
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-2xl", children: brandIcon }),
|
|
745
779
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-medium capitalize", children: brand })
|
|
746
780
|
] }),
|
|
747
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
748
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
749
|
-
|
|
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,
|
|
750
784
|
{
|
|
751
785
|
render: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {}),
|
|
752
786
|
nativeButton: false,
|
|
@@ -757,10 +791,10 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
757
791
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.MoreVertical, { className: "h-4 w-4" })
|
|
758
792
|
}
|
|
759
793
|
) }),
|
|
760
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
761
|
-
!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") }),
|
|
762
796
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
763
|
-
|
|
797
|
+
_chunkZCOPOO7Tjs.DropdownMenuItem,
|
|
764
798
|
{
|
|
765
799
|
onClick: () => setShowRemoveDialog(true),
|
|
766
800
|
disabled: loading,
|
|
@@ -771,7 +805,7 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
771
805
|
] })
|
|
772
806
|
] })
|
|
773
807
|
] }),
|
|
774
|
-
/* @__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: [
|
|
775
809
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-lg font-semibold", children: [
|
|
776
810
|
"\u2022\u2022\u2022\u2022 ",
|
|
777
811
|
last4
|
|
@@ -779,17 +813,17 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
779
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}` }) })
|
|
780
814
|
] }) })
|
|
781
815
|
] }),
|
|
782
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
783
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
784
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
785
|
-
/* @__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: [
|
|
786
820
|
t("billing.ui.payment_methods.remove_description"),
|
|
787
821
|
isDefault && ` ${t("billing.ui.payment_methods.remove_default_warning")}`
|
|
788
822
|
] })
|
|
789
823
|
] }),
|
|
790
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
791
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
792
|
-
/* @__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") })
|
|
793
827
|
] })
|
|
794
828
|
] }) })
|
|
795
829
|
] });
|
|
@@ -813,7 +847,7 @@ function PaymentMethodsContainer() {
|
|
|
813
847
|
const loadPaymentMethods = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
814
848
|
setLoading(true);
|
|
815
849
|
try {
|
|
816
|
-
const fetchedPaymentMethods = await
|
|
850
|
+
const fetchedPaymentMethods = await _chunk5TH2DSAHjs.StripeCustomerService.listPaymentMethods();
|
|
817
851
|
setPaymentMethods(fetchedPaymentMethods);
|
|
818
852
|
} catch (error) {
|
|
819
853
|
console.error("[PaymentMethodsContainer] Failed to load payment methods:", error);
|
|
@@ -833,14 +867,14 @@ function PaymentMethodsContainer() {
|
|
|
833
867
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-8 w-8" }),
|
|
834
868
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h1", { className: "text-primary text-3xl font-semibold", children: t("billing.ui.payment_methods.title") })
|
|
835
869
|
] }),
|
|
836
|
-
/* @__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") })
|
|
837
871
|
] }),
|
|
838
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: [
|
|
839
873
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-16 w-16 text-muted-foreground" }),
|
|
840
874
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "text-center", children: [
|
|
841
875
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "mb-2 text-sm font-medium", children: t("billing.ui.payment_methods.empty_title") }),
|
|
842
876
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "mb-4 text-muted-foreground", children: t("billing.ui.payment_methods.empty_description") }),
|
|
843
|
-
/* @__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") })
|
|
844
878
|
] })
|
|
845
879
|
] }),
|
|
846
880
|
paymentMethods.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PaymentMethodsList, { paymentMethods, onUpdate: loadPaymentMethods }),
|
|
@@ -896,7 +930,7 @@ var statusConfig = {
|
|
|
896
930
|
function InvoiceStatusBadge({ status }) {
|
|
897
931
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
898
932
|
const config = statusConfig[status] || statusConfig["draft" /* DRAFT */];
|
|
899
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
933
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkZCOPOO7Tjs.Badge, { variant: config.variant, children: t(config.label) });
|
|
900
934
|
}
|
|
901
935
|
_chunk7QVYU63Ejs.__name.call(void 0, InvoiceStatusBadge, "InvoiceStatusBadge");
|
|
902
936
|
|
|
@@ -909,7 +943,7 @@ function InvoiceDetails({
|
|
|
909
943
|
onInvoiceChange: _onInvoiceChange
|
|
910
944
|
}) {
|
|
911
945
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
912
|
-
const fmt =
|
|
946
|
+
const fmt = _chunkZCOPOO7Tjs.useBillingFormatOptions.call(void 0, );
|
|
913
947
|
const handleDownloadPDF = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => {
|
|
914
948
|
if (invoice.stripePdfUrl) {
|
|
915
949
|
window.open(invoice.stripePdfUrl, "_blank");
|
|
@@ -929,10 +963,10 @@ function InvoiceDetails({
|
|
|
929
963
|
return invoice.stripeInvoiceId.slice(-8);
|
|
930
964
|
}, "getInvoiceNumber");
|
|
931
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");
|
|
932
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
933
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
934
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
935
|
-
/* @__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) })
|
|
936
970
|
] }),
|
|
937
971
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-6", children: [
|
|
938
972
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-3", children: [
|
|
@@ -943,18 +977,18 @@ function InvoiceDetails({
|
|
|
943
977
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
944
978
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("billing.ui.invoice.billing_period") }),
|
|
945
979
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-sm", children: [
|
|
946
|
-
|
|
980
|
+
_chunkZCOPOO7Tjs.formatDate.call(void 0, invoice.periodStart, fmt),
|
|
947
981
|
" - ",
|
|
948
|
-
|
|
982
|
+
_chunkZCOPOO7Tjs.formatDate.call(void 0, invoice.periodEnd, fmt)
|
|
949
983
|
] })
|
|
950
984
|
] }),
|
|
951
985
|
invoice.dueDate && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
952
986
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("billing.ui.invoice.due_date") }),
|
|
953
|
-
/* @__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) })
|
|
954
988
|
] }),
|
|
955
989
|
invoice.paidAt && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
956
990
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("billing.ui.invoice.paid_date") }),
|
|
957
|
-
/* @__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) })
|
|
958
992
|
] }),
|
|
959
993
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
960
994
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("billing.ui.invoice.attempt_count") }),
|
|
@@ -970,42 +1004,42 @@ function InvoiceDetails({
|
|
|
970
1004
|
] }) }),
|
|
971
1005
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "tbody", { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "tr", { className: "border-t", children: [
|
|
972
1006
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "td", { className: "p-3", children: productName }),
|
|
973
|
-
/* @__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) })
|
|
974
1008
|
] }) })
|
|
975
1009
|
] }) })
|
|
976
1010
|
] }),
|
|
977
1011
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2 border-t pt-4", children: [
|
|
978
1012
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between", children: [
|
|
979
1013
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("billing.ui.invoice.subtotal") }),
|
|
980
|
-
/* @__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) })
|
|
981
1015
|
] }),
|
|
982
1016
|
invoice.tax !== void 0 && invoice.tax > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between", children: [
|
|
983
1017
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("billing.ui.invoice.tax") }),
|
|
984
|
-
/* @__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) })
|
|
985
1019
|
] }),
|
|
986
1020
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between text-lg font-semibold border-t pt-2", children: [
|
|
987
1021
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: t("billing.ui.invoice.total") }),
|
|
988
|
-
/* @__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) })
|
|
989
1023
|
] }),
|
|
990
1024
|
invoice.amountPaid > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between", children: [
|
|
991
1025
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("billing.ui.invoice.amount_paid") }),
|
|
992
|
-
/* @__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) })
|
|
993
1027
|
] }),
|
|
994
1028
|
invoice.amountRemaining > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between", children: [
|
|
995
1029
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("billing.ui.invoice.amount_due") }),
|
|
996
|
-
/* @__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) })
|
|
997
1031
|
] })
|
|
998
1032
|
] }),
|
|
999
1033
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-wrap gap-2 pt-4 border-t", children: [
|
|
1000
|
-
invoice.stripePdfUrl && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1034
|
+
invoice.stripePdfUrl && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkZCOPOO7Tjs.Button, { variant: "outline", onClick: handleDownloadPDF, children: [
|
|
1001
1035
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Download, { className: "me-2 h-4 w-4" }),
|
|
1002
1036
|
t("billing.ui.invoice.download_pdf")
|
|
1003
1037
|
] }),
|
|
1004
|
-
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: [
|
|
1005
1039
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.RefreshCw, { className: "me-2 h-4 w-4" }),
|
|
1006
1040
|
t("billing.ui.invoice.retry_payment")
|
|
1007
1041
|
] }),
|
|
1008
|
-
invoice.stripeHostedInvoiceUrl && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1042
|
+
invoice.stripeHostedInvoiceUrl && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkZCOPOO7Tjs.Button, { variant: "outline", onClick: handleViewInStripe, children: [
|
|
1009
1043
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ExternalLink, { className: "me-2 h-4 w-4" }),
|
|
1010
1044
|
t("billing.ui.invoice.view_in_stripe")
|
|
1011
1045
|
] })
|
|
@@ -1019,7 +1053,7 @@ _chunk7QVYU63Ejs.__name.call(void 0, InvoiceDetails, "InvoiceDetails");
|
|
|
1019
1053
|
|
|
1020
1054
|
function InvoicesList({ invoices, onInvoicesChange }) {
|
|
1021
1055
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
1022
|
-
const fmt =
|
|
1056
|
+
const fmt = _chunkZCOPOO7Tjs.useBillingFormatOptions.call(void 0, );
|
|
1023
1057
|
const [selectedInvoice, setSelectedInvoice] = _react.useState.call(void 0, null);
|
|
1024
1058
|
const handleRowClick = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (invoice) => {
|
|
1025
1059
|
setSelectedInvoice(invoice);
|
|
@@ -1031,30 +1065,30 @@ function InvoicesList({ invoices, onInvoicesChange }) {
|
|
|
1031
1065
|
return invoice.stripeInvoiceId.slice(-8);
|
|
1032
1066
|
}, "getInvoiceNumber");
|
|
1033
1067
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1034
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border rounded-lg overflow-clip", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1035
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1036
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1037
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1038
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1039
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1040
|
-
/* @__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") })
|
|
1041
1075
|
] }) }),
|
|
1042
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1076
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkZCOPOO7Tjs.TableBody, { children: invoices.map((invoice) => {
|
|
1043
1077
|
const invoiceNumber = getInvoiceNumber(invoice);
|
|
1044
|
-
const date =
|
|
1045
|
-
const amount =
|
|
1046
|
-
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)}`;
|
|
1047
1081
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1048
|
-
|
|
1082
|
+
_chunkZCOPOO7Tjs.TableRow,
|
|
1049
1083
|
{
|
|
1050
1084
|
onClick: () => handleRowClick(invoice),
|
|
1051
1085
|
className: "cursor-pointer hover:bg-muted/50",
|
|
1052
1086
|
children: [
|
|
1053
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1054
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1055
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1056
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1057
|
-
/* @__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 })
|
|
1058
1092
|
]
|
|
1059
1093
|
},
|
|
1060
1094
|
invoice.id
|
|
@@ -1088,7 +1122,7 @@ function InvoicesContainer() {
|
|
|
1088
1122
|
setLoading(true);
|
|
1089
1123
|
try {
|
|
1090
1124
|
const params = statusFilter !== "all" ? { status: statusFilter } : void 0;
|
|
1091
|
-
const data = await
|
|
1125
|
+
const data = await _chunk5TH2DSAHjs.StripeInvoiceService.listInvoices(params);
|
|
1092
1126
|
setInvoices(data);
|
|
1093
1127
|
} catch (error) {
|
|
1094
1128
|
console.error("[InvoicesContainer] Failed to load invoices:", error);
|
|
@@ -1104,12 +1138,12 @@ function InvoicesContainer() {
|
|
|
1104
1138
|
setStatusFilter(value);
|
|
1105
1139
|
}, "handleFilterChange");
|
|
1106
1140
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-4", children: [
|
|
1107
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1108
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1109
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1110
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1111
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1112
|
-
/* @__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") })
|
|
1113
1147
|
] }) }),
|
|
1114
1148
|
loading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-center py-8 text-muted-foreground", children: t("billing.ui.invoices.loading") }),
|
|
1115
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: [
|
|
@@ -1151,7 +1185,7 @@ function CancelSubscriptionDialog({
|
|
|
1151
1185
|
onSuccess
|
|
1152
1186
|
}) {
|
|
1153
1187
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
1154
|
-
const fmt =
|
|
1188
|
+
const fmt = _chunkZCOPOO7Tjs.useBillingFormatOptions.call(void 0, );
|
|
1155
1189
|
const [isSubmitting, setIsSubmitting] = _react.useState.call(void 0, false);
|
|
1156
1190
|
const form = _reacthookform.useForm.call(void 0, {
|
|
1157
1191
|
resolver: _zod.zodResolver.call(void 0, formSchema),
|
|
@@ -1162,7 +1196,7 @@ function CancelSubscriptionDialog({
|
|
|
1162
1196
|
const onSubmit = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async (_values) => {
|
|
1163
1197
|
setIsSubmitting(true);
|
|
1164
1198
|
try {
|
|
1165
|
-
await
|
|
1199
|
+
await _chunk5TH2DSAHjs.StripeSubscriptionService.cancelSubscription({
|
|
1166
1200
|
id: subscription.id,
|
|
1167
1201
|
cancelImmediately: false
|
|
1168
1202
|
});
|
|
@@ -1174,16 +1208,16 @@ function CancelSubscriptionDialog({
|
|
|
1174
1208
|
setIsSubmitting(false);
|
|
1175
1209
|
}
|
|
1176
1210
|
}, "onSubmit");
|
|
1177
|
-
const periodEndDate =
|
|
1178
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1179
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1180
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1181
|
-
/* @__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") })
|
|
1182
1216
|
] }),
|
|
1183
|
-
/* @__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: [
|
|
1184
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 }) }),
|
|
1185
1219
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1186
|
-
|
|
1220
|
+
_chunkZCOPOO7Tjs.FormTextarea,
|
|
1187
1221
|
{
|
|
1188
1222
|
form,
|
|
1189
1223
|
id: "reason",
|
|
@@ -1193,8 +1227,8 @@ function CancelSubscriptionDialog({
|
|
|
1193
1227
|
}
|
|
1194
1228
|
),
|
|
1195
1229
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex gap-x-2 justify-end pt-2", children: [
|
|
1196
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1197
|
-
/* @__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") })
|
|
1198
1232
|
] })
|
|
1199
1233
|
] }) })
|
|
1200
1234
|
] }) });
|
|
@@ -1245,7 +1279,7 @@ var cancelingConfig = {
|
|
|
1245
1279
|
function SubscriptionStatusBadge({ status, cancelAtPeriodEnd }) {
|
|
1246
1280
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
1247
1281
|
const config = cancelAtPeriodEnd ? cancelingConfig : statusConfig2[status] || statusConfig2["canceled" /* CANCELED */];
|
|
1248
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1282
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkZCOPOO7Tjs.Badge, { variant: config.variant, children: t(config.label) });
|
|
1249
1283
|
}
|
|
1250
1284
|
_chunk7QVYU63Ejs.__name.call(void 0, SubscriptionStatusBadge, "SubscriptionStatusBadge");
|
|
1251
1285
|
|
|
@@ -1272,7 +1306,7 @@ function formatPlanName2(price, t) {
|
|
|
1272
1306
|
_chunk7QVYU63Ejs.__name.call(void 0, formatPlanName2, "formatPlanName");
|
|
1273
1307
|
function formatBillingAmount(price, notAvailable, fmt) {
|
|
1274
1308
|
if (!_optionalChain([price, 'optionalAccess', _37 => _37.unitAmount])) return notAvailable;
|
|
1275
|
-
return
|
|
1309
|
+
return _chunk5TH2DSAHjs.formatCurrency.call(void 0, price.unitAmount, price.currency, fmt);
|
|
1276
1310
|
}
|
|
1277
1311
|
_chunk7QVYU63Ejs.__name.call(void 0, formatBillingAmount, "formatBillingAmount");
|
|
1278
1312
|
function SubscriptionDetails({
|
|
@@ -1283,13 +1317,13 @@ function SubscriptionDetails({
|
|
|
1283
1317
|
onChangePlan
|
|
1284
1318
|
}) {
|
|
1285
1319
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
1286
|
-
const fmt =
|
|
1320
|
+
const fmt = _chunkZCOPOO7Tjs.useBillingFormatOptions.call(void 0, );
|
|
1287
1321
|
const [showCancel, setShowCancel] = _react.useState.call(void 0, false);
|
|
1288
1322
|
const [isProcessing, setIsProcessing] = _react.useState.call(void 0, false);
|
|
1289
1323
|
const handlePause = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
1290
1324
|
setIsProcessing(true);
|
|
1291
1325
|
try {
|
|
1292
|
-
await
|
|
1326
|
+
await _chunk5TH2DSAHjs.StripeSubscriptionService.pauseSubscription({ subscriptionId: subscription.id });
|
|
1293
1327
|
onSubscriptionChange();
|
|
1294
1328
|
} catch (error) {
|
|
1295
1329
|
console.error("[SubscriptionDetails] Failed to pause subscription:", error);
|
|
@@ -1300,7 +1334,7 @@ function SubscriptionDetails({
|
|
|
1300
1334
|
const handleResume = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
1301
1335
|
setIsProcessing(true);
|
|
1302
1336
|
try {
|
|
1303
|
-
await
|
|
1337
|
+
await _chunk5TH2DSAHjs.StripeSubscriptionService.resumeSubscription({ subscriptionId: subscription.id });
|
|
1304
1338
|
onSubscriptionChange();
|
|
1305
1339
|
} catch (error) {
|
|
1306
1340
|
console.error("[SubscriptionDetails] Failed to resume subscription:", error);
|
|
@@ -1310,7 +1344,7 @@ function SubscriptionDetails({
|
|
|
1310
1344
|
}, "handleResume");
|
|
1311
1345
|
const handleManageViaPortal = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
1312
1346
|
try {
|
|
1313
|
-
const { url } = await
|
|
1347
|
+
const { url } = await _chunk5TH2DSAHjs.StripeCustomerService.createPortalSession();
|
|
1314
1348
|
window.open(url, "_blank");
|
|
1315
1349
|
} catch (error) {
|
|
1316
1350
|
console.error("[SubscriptionDetails] Failed to create portal session:", error);
|
|
@@ -1320,10 +1354,10 @@ function SubscriptionDetails({
|
|
|
1320
1354
|
const canResume = subscription.status === "paused" /* PAUSED */;
|
|
1321
1355
|
const canCancel = subscription.status === "active" /* ACTIVE */ || subscription.status === "trialing" /* TRIALING */ || subscription.status === "paused" /* PAUSED */;
|
|
1322
1356
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1323
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1324
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1325
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1326
|
-
/* @__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") })
|
|
1327
1361
|
] }),
|
|
1328
1362
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-6", children: [
|
|
1329
1363
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-3", children: [
|
|
@@ -1349,24 +1383,24 @@ function SubscriptionDetails({
|
|
|
1349
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: [
|
|
1350
1384
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("billing.ui.subscription.current_period") }),
|
|
1351
1385
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "text-sm", children: [
|
|
1352
|
-
|
|
1386
|
+
_chunkZCOPOO7Tjs.formatDate.call(void 0, subscription.currentPeriodStart, fmt),
|
|
1353
1387
|
" - ",
|
|
1354
|
-
|
|
1388
|
+
_chunkZCOPOO7Tjs.formatDate.call(void 0, subscription.currentPeriodEnd, fmt)
|
|
1355
1389
|
] })
|
|
1356
1390
|
] }) }),
|
|
1357
1391
|
subscription.trialEnd && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between", children: [
|
|
1358
1392
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("billing.ui.subscription.trial_ends") }),
|
|
1359
|
-
/* @__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) })
|
|
1360
1394
|
] }),
|
|
1361
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", {
|
|
1362
|
-
date:
|
|
1396
|
+
date: _chunkZCOPOO7Tjs.formatDate.call(void 0, subscription.currentPeriodEnd, fmt)
|
|
1363
1397
|
}) }) }),
|
|
1364
1398
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-wrap gap-2 pt-4 border-t", children: [
|
|
1365
|
-
onChangePlan && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1366
|
-
canPause && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1367
|
-
canResume && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1368
|
-
canCancel && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1369
|
-
/* @__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") })
|
|
1370
1404
|
] })
|
|
1371
1405
|
] })
|
|
1372
1406
|
] }) }),
|
|
@@ -1409,42 +1443,46 @@ function formatPlanName3(price, t) {
|
|
|
1409
1443
|
_chunk7QVYU63Ejs.__name.call(void 0, formatPlanName3, "formatPlanName");
|
|
1410
1444
|
function SubscriptionsList({ subscriptions, onSubscriptionsChange, onChangePlan }) {
|
|
1411
1445
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
1412
|
-
const fmt =
|
|
1446
|
+
const fmt = _chunkZCOPOO7Tjs.useBillingFormatOptions.call(void 0, );
|
|
1413
1447
|
const [selectedSub, setSelectedSub] = _react.useState.call(void 0, null);
|
|
1414
1448
|
const handleRowClick = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (subscription) => {
|
|
1415
1449
|
setSelectedSub(subscription);
|
|
1416
1450
|
}, "handleRowClick");
|
|
1417
1451
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1418
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border rounded-lg overflow-clip", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1419
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1420
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1421
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1422
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1423
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1424
|
-
/* @__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") })
|
|
1425
1459
|
] }) }),
|
|
1426
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1460
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkZCOPOO7Tjs.TableBody, { children: subscriptions.map((subscription) => {
|
|
1427
1461
|
const price = subscription.price;
|
|
1428
|
-
const amount = _optionalChain([price, 'optionalAccess', _42 => _42.unitAmount]) ?
|
|
1429
|
-
const
|
|
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)}`;
|
|
1430
1465
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1431
|
-
|
|
1466
|
+
_chunkZCOPOO7Tjs.TableRow,
|
|
1432
1467
|
{
|
|
1433
1468
|
onClick: () => handleRowClick(subscription),
|
|
1434
1469
|
className: "cursor-pointer hover:bg-muted/50",
|
|
1435
1470
|
children: [
|
|
1436
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1471
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkZCOPOO7Tjs.TableCell, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1437
1472
|
SubscriptionStatusBadge,
|
|
1438
1473
|
{
|
|
1439
1474
|
status: subscription.status,
|
|
1440
1475
|
cancelAtPeriodEnd: subscription.cancelAtPeriodEnd
|
|
1441
1476
|
}
|
|
1442
1477
|
) }),
|
|
1443
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1444
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1445
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1446
|
-
|
|
1447
|
-
|
|
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: [
|
|
1481
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "line-through text-muted-foreground me-2", children: amount }),
|
|
1482
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-success", children: _chunk5TH2DSAHjs.formatCurrency.call(void 0, discountedAmount, price.currency, fmt) })
|
|
1483
|
+
] }) : amount }),
|
|
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,
|
|
1448
1486
|
{
|
|
1449
1487
|
size: "sm",
|
|
1450
1488
|
variant: "outline",
|
|
@@ -1483,23 +1521,35 @@ _chunk7QVYU63Ejs.__name.call(void 0, SubscriptionsList, "SubscriptionsList");
|
|
|
1483
1521
|
|
|
1484
1522
|
// src/features/billing/stripe-subscription/components/containers/SubscriptionsContainer.tsx
|
|
1485
1523
|
|
|
1486
|
-
function SubscriptionsContainer({
|
|
1524
|
+
function SubscriptionsContainer({
|
|
1525
|
+
onOpenWizard,
|
|
1526
|
+
hasActiveRecurringSubscription,
|
|
1527
|
+
subscriptions: parentSubscriptions,
|
|
1528
|
+
onSubscriptionsChange
|
|
1529
|
+
}) {
|
|
1487
1530
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
1488
|
-
const
|
|
1489
|
-
const [
|
|
1531
|
+
const isControlled = parentSubscriptions !== void 0;
|
|
1532
|
+
const [ownSubscriptions, setSubscriptions] = _react.useState.call(void 0, []);
|
|
1533
|
+
const [ownLoading, setLoading] = _react.useState.call(void 0, !isControlled);
|
|
1534
|
+
const subscriptions = _nullishCoalesce(parentSubscriptions, () => ( ownSubscriptions));
|
|
1535
|
+
const loading = isControlled ? false : ownLoading;
|
|
1490
1536
|
const loadSubscriptions = _react.useCallback.call(void 0, async () => {
|
|
1537
|
+
if (isControlled) {
|
|
1538
|
+
_optionalChain([onSubscriptionsChange, 'optionalCall', _43 => _43()]);
|
|
1539
|
+
return;
|
|
1540
|
+
}
|
|
1491
1541
|
setLoading(true);
|
|
1492
1542
|
try {
|
|
1493
|
-
const fetchedSubscriptions = await
|
|
1543
|
+
const fetchedSubscriptions = await _chunk5TH2DSAHjs.StripeSubscriptionService.listSubscriptions();
|
|
1494
1544
|
setSubscriptions(fetchedSubscriptions);
|
|
1495
1545
|
} catch (error) {
|
|
1496
1546
|
console.error("[SubscriptionsContainer] Failed to load subscriptions:", error);
|
|
1497
1547
|
} finally {
|
|
1498
1548
|
setLoading(false);
|
|
1499
1549
|
}
|
|
1500
|
-
}, []);
|
|
1550
|
+
}, [isControlled, onSubscriptionsChange]);
|
|
1501
1551
|
_react.useEffect.call(void 0, () => {
|
|
1502
|
-
loadSubscriptions();
|
|
1552
|
+
if (!isControlled) loadSubscriptions();
|
|
1503
1553
|
}, []);
|
|
1504
1554
|
const criticalSubscriptions = subscriptions.filter(
|
|
1505
1555
|
(sub) => sub.status === "past_due" /* PAST_DUE */ || sub.status === "trialing" /* TRIALING */ && sub.trialEnd && new Date(sub.trialEnd).getTime() - (/* @__PURE__ */ new Date()).getTime() <= 7 * 24 * 60 * 60 * 1e3
|
|
@@ -1513,7 +1563,7 @@ function SubscriptionsContainer({ onOpenWizard, hasActiveRecurringSubscription }
|
|
|
1513
1563
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-8 w-8" }),
|
|
1514
1564
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h1", { className: "text-primary text-3xl font-semibold", children: t("billing.ui.subscriptions.title") })
|
|
1515
1565
|
] }),
|
|
1516
|
-
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") })
|
|
1517
1567
|
] }),
|
|
1518
1568
|
criticalSubscriptions.map((subscription) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BillingAlertBanner, { subscription }, subscription.id)),
|
|
1519
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: [
|
|
@@ -1521,7 +1571,7 @@ function SubscriptionsContainer({ onOpenWizard, hasActiveRecurringSubscription }
|
|
|
1521
1571
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "text-center", children: [
|
|
1522
1572
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-sm font-medium mb-2", children: t("billing.ui.subscriptions.empty_title") }),
|
|
1523
1573
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-muted-foreground mb-6", children: t("billing.ui.subscriptions.empty_description") }),
|
|
1524
|
-
/* @__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") })
|
|
1525
1575
|
] })
|
|
1526
1576
|
] }),
|
|
1527
1577
|
subscriptions.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -1529,7 +1579,7 @@ function SubscriptionsContainer({ onOpenWizard, hasActiveRecurringSubscription }
|
|
|
1529
1579
|
{
|
|
1530
1580
|
subscriptions,
|
|
1531
1581
|
onSubscriptionsChange: loadSubscriptions,
|
|
1532
|
-
onChangePlan: (sub) => _optionalChain([onOpenWizard, 'optionalCall',
|
|
1582
|
+
onChangePlan: (sub) => _optionalChain([onOpenWizard, 'optionalCall', _46 => _46(sub)])
|
|
1533
1583
|
}
|
|
1534
1584
|
)
|
|
1535
1585
|
] });
|
|
@@ -1544,9 +1594,9 @@ function IntervalToggle({ value, onChange, hasMonthly, hasYearly }) {
|
|
|
1544
1594
|
if (!hasMonthly || !hasYearly) {
|
|
1545
1595
|
return null;
|
|
1546
1596
|
}
|
|
1547
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1548
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1549
|
-
/* @__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") })
|
|
1550
1600
|
] }) });
|
|
1551
1601
|
}
|
|
1552
1602
|
_chunk7QVYU63Ejs.__name.call(void 0, IntervalToggle, "IntervalToggle");
|
|
@@ -1564,11 +1614,11 @@ function PricingCard({
|
|
|
1564
1614
|
onSelect
|
|
1565
1615
|
}) {
|
|
1566
1616
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
1567
|
-
const fmt =
|
|
1617
|
+
const fmt = _chunkZCOPOO7Tjs.useBillingFormatOptions.call(void 0, );
|
|
1568
1618
|
const description = price.description || price.nickname || t("billing.ui.pricing.standard");
|
|
1569
1619
|
const features = price.features || [];
|
|
1570
|
-
const formattedPrice =
|
|
1571
|
-
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);
|
|
1572
1622
|
const handleKeyDown = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (e) => {
|
|
1573
1623
|
if ((e.key === "Enter" || e.key === " ") && !isDisabled && !isCurrentPlan) {
|
|
1574
1624
|
e.preventDefault();
|
|
@@ -1581,7 +1631,7 @@ function PricingCard({
|
|
|
1581
1631
|
}
|
|
1582
1632
|
}, "handleClick");
|
|
1583
1633
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1584
|
-
|
|
1634
|
+
_chunkZCOPOO7Tjs.Card,
|
|
1585
1635
|
{
|
|
1586
1636
|
role: "radio",
|
|
1587
1637
|
"aria-checked": isSelected,
|
|
@@ -1589,7 +1639,7 @@ function PricingCard({
|
|
|
1589
1639
|
tabIndex: isDisabled ? -1 : 0,
|
|
1590
1640
|
onKeyDown: handleKeyDown,
|
|
1591
1641
|
onClick: handleClick,
|
|
1592
|
-
className:
|
|
1642
|
+
className: _chunk5TH2DSAHjs.cn.call(void 0,
|
|
1593
1643
|
"relative cursor-pointer transition-all duration-200 flex flex-col h-full",
|
|
1594
1644
|
"focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
1595
1645
|
isCurrentPlan && "bg-muted/30",
|
|
@@ -1599,9 +1649,9 @@ function PricingCard({
|
|
|
1599
1649
|
isLoading && "pointer-events-none"
|
|
1600
1650
|
),
|
|
1601
1651
|
children: [
|
|
1602
|
-
isCurrentPlan && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1603
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1604
|
-
/* @__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: [
|
|
1605
1655
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mb-4", children: [
|
|
1606
1656
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-3xl font-bold", children: formattedPrice }),
|
|
1607
1657
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground ms-1", children: interval })
|
|
@@ -1611,8 +1661,8 @@ function PricingCard({
|
|
|
1611
1661
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm text-muted-foreground", children: feature })
|
|
1612
1662
|
] }, index)) })
|
|
1613
1663
|
] }),
|
|
1614
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1615
|
-
|
|
1664
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkZCOPOO7Tjs.CardFooter, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1665
|
+
_chunkZCOPOO7Tjs.Button,
|
|
1616
1666
|
{
|
|
1617
1667
|
variant: isCurrentPlan ? "secondary" : isSelected ? "default" : "outline",
|
|
1618
1668
|
className: "w-full",
|
|
@@ -1645,7 +1695,7 @@ function ProductPricingRow({
|
|
|
1645
1695
|
return null;
|
|
1646
1696
|
}
|
|
1647
1697
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-3", children: [
|
|
1648
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1698
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkZCOPOO7Tjs.SectionHeader, { children: product.name }),
|
|
1649
1699
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1650
1700
|
"div",
|
|
1651
1701
|
{
|
|
@@ -1681,11 +1731,11 @@ function getFilteredPrices(prices, selectedInterval) {
|
|
|
1681
1731
|
return prices.filter((p) => p.priceType === "one_time");
|
|
1682
1732
|
}
|
|
1683
1733
|
const intervalPrices = prices.filter(
|
|
1684
|
-
(p) => p.priceType === "recurring" && _optionalChain([p, 'access',
|
|
1734
|
+
(p) => p.priceType === "recurring" && _optionalChain([p, 'access', _47 => _47.recurring, 'optionalAccess', _48 => _48.interval]) === selectedInterval
|
|
1685
1735
|
);
|
|
1686
1736
|
if (intervalPrices.length === 0) {
|
|
1687
1737
|
const fallbackInterval = selectedInterval === "month" ? "year" : "month";
|
|
1688
|
-
return prices.filter((p) => p.priceType === "recurring" && _optionalChain([p, 'access',
|
|
1738
|
+
return prices.filter((p) => p.priceType === "recurring" && _optionalChain([p, 'access', _49 => _49.recurring, 'optionalAccess', _50 => _50.interval]) === fallbackInterval);
|
|
1689
1739
|
}
|
|
1690
1740
|
return intervalPrices;
|
|
1691
1741
|
}
|
|
@@ -1746,15 +1796,15 @@ function ProductPricingList({
|
|
|
1746
1796
|
_chunk7QVYU63Ejs.__name.call(void 0, ProductPricingList, "ProductPricingList");
|
|
1747
1797
|
function ProductPricingListSkeleton() {
|
|
1748
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: [
|
|
1749
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1799
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkZCOPOO7Tjs.Skeleton, { className: "h-6 w-32" }),
|
|
1750
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: [
|
|
1751
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1752
|
-
/* @__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" }),
|
|
1753
1803
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
1754
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1755
|
-
/* @__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" })
|
|
1756
1806
|
] }),
|
|
1757
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1807
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkZCOPOO7Tjs.Skeleton, { className: "h-10 w-full" })
|
|
1758
1808
|
] }, cardIndex)) })
|
|
1759
1809
|
] }, rowIndex)) });
|
|
1760
1810
|
}
|
|
@@ -1765,21 +1815,21 @@ _chunk7QVYU63Ejs.__name.call(void 0, ProductPricingListSkeleton, "ProductPricing
|
|
|
1765
1815
|
|
|
1766
1816
|
function ProrationPreview({ preview }) {
|
|
1767
1817
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
1768
|
-
const fmt =
|
|
1818
|
+
const fmt = _chunkZCOPOO7Tjs.useBillingFormatOptions.call(void 0, );
|
|
1769
1819
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "bg-primary/10 border-primary/30 rounded-lg border p-4", children: [
|
|
1770
1820
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h4", { className: "text-primary mb-3 font-semibold", children: t("billing.ui.proration.title") }),
|
|
1771
1821
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
1772
1822
|
preview.lineItems.map((item, index) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between text-sm", children: [
|
|
1773
1823
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground", children: item.description }),
|
|
1774
|
-
/* @__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) })
|
|
1775
1825
|
] }, index)),
|
|
1776
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: [
|
|
1777
1827
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-foreground", children: t("billing.ui.proration.net_due_today") }),
|
|
1778
|
-
/* @__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) })
|
|
1779
1829
|
] }) }),
|
|
1780
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", {
|
|
1781
|
-
date:
|
|
1782
|
-
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)
|
|
1783
1833
|
}) })
|
|
1784
1834
|
] })
|
|
1785
1835
|
] });
|
|
@@ -1792,9 +1842,9 @@ _chunk7QVYU63Ejs.__name.call(void 0, ProrationPreview, "ProrationPreview");
|
|
|
1792
1842
|
|
|
1793
1843
|
function SubscriptionConfirmation({ price, isLoading, onConfirm, onCancel }) {
|
|
1794
1844
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
1795
|
-
const fmt =
|
|
1796
|
-
const productName = _optionalChain([price, 'access',
|
|
1797
|
-
const productDescription = _optionalChain([price, 'access',
|
|
1845
|
+
const fmt = _chunkZCOPOO7Tjs.useBillingFormatOptions.call(void 0, );
|
|
1846
|
+
const productName = _optionalChain([price, 'access', _51 => _51.product, 'optionalAccess', _52 => _52.name]) || price.nickname || t("billing.ui.wizard.review.selected_plan");
|
|
1847
|
+
const productDescription = _optionalChain([price, 'access', _53 => _53.product, 'optionalAccess', _54 => _54.description]) || price.description;
|
|
1798
1848
|
const features = price.features || [];
|
|
1799
1849
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "bg-accent/10 border border-accent/30 rounded-lg p-4", children: [
|
|
1800
1850
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h4", { className: "font-semibold mb-3", children: t("billing.ui.confirmation.title") }),
|
|
@@ -1804,16 +1854,16 @@ function SubscriptionConfirmation({ price, isLoading, onConfirm, onCancel }) {
|
|
|
1804
1854
|
productDescription && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-sm text-muted-foreground", children: productDescription })
|
|
1805
1855
|
] }),
|
|
1806
1856
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "text-lg font-semibold", children: [
|
|
1807
|
-
|
|
1808
|
-
/* @__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) })
|
|
1809
1859
|
] }),
|
|
1810
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: [
|
|
1811
1861
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Check, { className: "h-4 w-4 text-primary" }),
|
|
1812
1862
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: feature })
|
|
1813
1863
|
] }, index)) }),
|
|
1814
1864
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-end gap-3 pt-2 border-t border-accent/30", children: [
|
|
1815
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1816
|
-
/* @__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: [
|
|
1817
1867
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Loader2, { className: "h-4 w-4 animate-spin me-2" }),
|
|
1818
1868
|
t("billing.ui.wizard.review.processing")
|
|
1819
1869
|
] }) : t("billing.ui.confirmation.subscribe") })
|
|
@@ -1831,6 +1881,121 @@ _chunk7QVYU63Ejs.__name.call(void 0, SubscriptionConfirmation, "SubscriptionConf
|
|
|
1831
1881
|
|
|
1832
1882
|
|
|
1833
1883
|
var _uuid = require('uuid');
|
|
1884
|
+
|
|
1885
|
+
// src/features/billing/stripe-subscription/hooks/wizard-promotion.ts
|
|
1886
|
+
function promotionCodeToSend(code) {
|
|
1887
|
+
if (!code) return void 0;
|
|
1888
|
+
return code.promotionCodeId;
|
|
1889
|
+
}
|
|
1890
|
+
_chunk7QVYU63Ejs.__name.call(void 0, promotionCodeToSend, "promotionCodeToSend");
|
|
1891
|
+
function shouldLookUpAutomatic(code) {
|
|
1892
|
+
return !code || code.automatic === true;
|
|
1893
|
+
}
|
|
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");
|
|
1899
|
+
function errorStatus(error) {
|
|
1900
|
+
const status = _nullishCoalesce(read(error, "status"), () => ( read(read(error, "response"), "status")));
|
|
1901
|
+
return typeof status === "number" ? status : void 0;
|
|
1902
|
+
}
|
|
1903
|
+
_chunk7QVYU63Ejs.__name.call(void 0, errorStatus, "errorStatus");
|
|
1904
|
+
function errorCode(error) {
|
|
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")));
|
|
1909
|
+
return typeof code === "string" ? code : void 0;
|
|
1910
|
+
}
|
|
1911
|
+
_chunk7QVYU63Ejs.__name.call(void 0, errorCode, "errorCode");
|
|
1912
|
+
function isDiscountSoldOut(error) {
|
|
1913
|
+
return errorStatus(error) === 410 && errorCode(error) === "discount_sold_out";
|
|
1914
|
+
}
|
|
1915
|
+
_chunk7QVYU63Ejs.__name.call(void 0, isDiscountSoldOut, "isDiscountSoldOut");
|
|
1916
|
+
function isDiscountUnavailable(error) {
|
|
1917
|
+
return errorStatus(error) === 422 && errorCode(error) === "discount_unavailable";
|
|
1918
|
+
}
|
|
1919
|
+
_chunk7QVYU63Ejs.__name.call(void 0, isDiscountUnavailable, "isDiscountUnavailable");
|
|
1920
|
+
|
|
1921
|
+
// src/features/billing/stripe-subscription/hooks/useConfirmSubscriptionPayment.ts
|
|
1922
|
+
|
|
1923
|
+
|
|
1924
|
+
|
|
1925
|
+
function useConfirmSubscriptionPayment() {
|
|
1926
|
+
const stripe = _reactstripejs.useStripe.call(void 0, );
|
|
1927
|
+
const t = _nextintl.useTranslations.call(void 0, );
|
|
1928
|
+
const [isConfirming, setIsConfirming] = _react.useState.call(void 0, false);
|
|
1929
|
+
const confirmPayment = _react.useCallback.call(void 0,
|
|
1930
|
+
async (clientSecret) => {
|
|
1931
|
+
if (!stripe) {
|
|
1932
|
+
console.error("[useConfirmSubscriptionPayment] Stripe not initialized");
|
|
1933
|
+
return {
|
|
1934
|
+
success: false,
|
|
1935
|
+
error: t("billing.ui.payment_confirm.errors.not_initialized")
|
|
1936
|
+
};
|
|
1937
|
+
}
|
|
1938
|
+
if (!clientSecret) {
|
|
1939
|
+
console.error("[useConfirmSubscriptionPayment] No client secret provided");
|
|
1940
|
+
return {
|
|
1941
|
+
success: false,
|
|
1942
|
+
error: t("billing.ui.payment_confirm.errors.missing_details")
|
|
1943
|
+
};
|
|
1944
|
+
}
|
|
1945
|
+
setIsConfirming(true);
|
|
1946
|
+
try {
|
|
1947
|
+
const { error: stripeError, paymentIntent } = await stripe.confirmCardPayment(clientSecret);
|
|
1948
|
+
if (stripeError) {
|
|
1949
|
+
console.error("[useConfirmSubscriptionPayment] Stripe error:", stripeError);
|
|
1950
|
+
return {
|
|
1951
|
+
success: false,
|
|
1952
|
+
error: stripeError.message || t("billing.ui.payment_confirm.errors.failed")
|
|
1953
|
+
};
|
|
1954
|
+
}
|
|
1955
|
+
if (_optionalChain([paymentIntent, 'optionalAccess', _55 => _55.status]) === "succeeded") {
|
|
1956
|
+
return { success: true };
|
|
1957
|
+
}
|
|
1958
|
+
if (_optionalChain([paymentIntent, 'optionalAccess', _56 => _56.status]) === "requires_action") {
|
|
1959
|
+
return {
|
|
1960
|
+
success: false,
|
|
1961
|
+
error: t("billing.ui.payment_confirm.errors.requires_action")
|
|
1962
|
+
};
|
|
1963
|
+
}
|
|
1964
|
+
return {
|
|
1965
|
+
success: false,
|
|
1966
|
+
error: t("billing.ui.payment_confirm.errors.not_completed")
|
|
1967
|
+
};
|
|
1968
|
+
} catch (err) {
|
|
1969
|
+
console.error("[useConfirmSubscriptionPayment] Unexpected error:", err);
|
|
1970
|
+
return {
|
|
1971
|
+
success: false,
|
|
1972
|
+
error: err.message || t("billing.ui.payment_confirm.errors.unexpected")
|
|
1973
|
+
};
|
|
1974
|
+
} finally {
|
|
1975
|
+
setIsConfirming(false);
|
|
1976
|
+
}
|
|
1977
|
+
},
|
|
1978
|
+
[stripe, t]
|
|
1979
|
+
);
|
|
1980
|
+
return {
|
|
1981
|
+
confirmPayment,
|
|
1982
|
+
isConfirming
|
|
1983
|
+
};
|
|
1984
|
+
}
|
|
1985
|
+
_chunk7QVYU63Ejs.__name.call(void 0, useConfirmSubscriptionPayment, "useConfirmSubscriptionPayment");
|
|
1986
|
+
|
|
1987
|
+
// src/features/billing/stripe-subscription/hooks/wizard-payment.ts
|
|
1988
|
+
function clientSecretToConfirm(meta) {
|
|
1989
|
+
if (!_optionalChain([meta, 'optionalAccess', _57 => _57.requiresAction])) return null;
|
|
1990
|
+
return meta.clientSecret || null;
|
|
1991
|
+
}
|
|
1992
|
+
_chunk7QVYU63Ejs.__name.call(void 0, clientSecretToConfirm, "clientSecretToConfirm");
|
|
1993
|
+
function subscriptionIdToSync(answered, opened) {
|
|
1994
|
+
return _optionalChain([answered, 'optionalAccess', _58 => _58.id]) || _optionalChain([opened, 'optionalAccess', _59 => _59.id]) || null;
|
|
1995
|
+
}
|
|
1996
|
+
_chunk7QVYU63Ejs.__name.call(void 0, subscriptionIdToSync, "subscriptionIdToSync");
|
|
1997
|
+
|
|
1998
|
+
// src/features/billing/stripe-subscription/hooks/useSubscriptionWizard.ts
|
|
1834
1999
|
var initialState = {
|
|
1835
2000
|
step: "plan-selection",
|
|
1836
2001
|
selectedPrice: null,
|
|
@@ -1877,10 +2042,11 @@ function wizardReducer(state, action) {
|
|
|
1877
2042
|
_chunk7QVYU63Ejs.__name.call(void 0, wizardReducer, "wizardReducer");
|
|
1878
2043
|
function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
1879
2044
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
1880
|
-
const locale =
|
|
2045
|
+
const locale = _chunk5TH2DSAHjs.useI18nLocale.call(void 0, );
|
|
2046
|
+
const { confirmPayment } = useConfirmSubscriptionPayment();
|
|
1881
2047
|
const [state, dispatch] = _react.useReducer.call(void 0, wizardReducer, {
|
|
1882
2048
|
...initialState,
|
|
1883
|
-
selectedPrice: _optionalChain([subscription, 'optionalAccess',
|
|
2049
|
+
selectedPrice: _optionalChain([subscription, 'optionalAccess', _60 => _60.price]) || null
|
|
1884
2050
|
});
|
|
1885
2051
|
const onSuccessRef = _react.useRef.call(void 0, onSuccess);
|
|
1886
2052
|
const onCloseRef = _react.useRef.call(void 0, onClose);
|
|
@@ -1888,7 +2054,7 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
1888
2054
|
onCloseRef.current = onClose;
|
|
1889
2055
|
const checkPaymentMethod = _react.useCallback.call(void 0, async () => {
|
|
1890
2056
|
try {
|
|
1891
|
-
const methods = await
|
|
2057
|
+
const methods = await _chunk5TH2DSAHjs.StripeCustomerService.listPaymentMethods();
|
|
1892
2058
|
dispatch({ type: "SET_HAS_PAYMENT_METHOD", hasMethod: methods.length > 0 });
|
|
1893
2059
|
} catch (error) {
|
|
1894
2060
|
console.error("[useSubscriptionWizard] Failed to check payment methods:", error);
|
|
@@ -1904,15 +2070,39 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
1904
2070
|
const goToStep = _react.useCallback.call(void 0, (step) => {
|
|
1905
2071
|
dispatch({ type: "SET_STEP", step });
|
|
1906
2072
|
}, []);
|
|
2073
|
+
const lookUpAutomaticCode = _react.useCallback.call(void 0, async (priceId) => {
|
|
2074
|
+
try {
|
|
2075
|
+
const automaticCode = await _chunk5TH2DSAHjs.StripeCouponCodeService.findAutomatic({ priceId });
|
|
2076
|
+
dispatch({
|
|
2077
|
+
type: "SET_PROMOTION_CODE",
|
|
2078
|
+
code: automaticCode ? _chunk5TH2DSAHjs.toPromotionCodeResult.call(void 0, automaticCode) : null
|
|
2079
|
+
});
|
|
2080
|
+
return true;
|
|
2081
|
+
} catch (error) {
|
|
2082
|
+
console.error("[useSubscriptionWizard] Failed to look up the automatic promotion code:", error);
|
|
2083
|
+
dispatch({ type: "SET_PROMOTION_CODE", code: null });
|
|
2084
|
+
return false;
|
|
2085
|
+
}
|
|
2086
|
+
}, []);
|
|
2087
|
+
const refreshAutomaticCodeOrLeaveReview = _react.useCallback.call(void 0,
|
|
2088
|
+
async (priceId) => {
|
|
2089
|
+
const found = await lookUpAutomaticCode(priceId);
|
|
2090
|
+
if (!found) {
|
|
2091
|
+
dispatch({ type: "SET_STEP", step: "plan-selection" });
|
|
2092
|
+
dispatch({ type: "SET_ERROR", error: t("billing.ui.wizard.errors.prepare_review") });
|
|
2093
|
+
}
|
|
2094
|
+
},
|
|
2095
|
+
[lookUpAutomaticCode, t]
|
|
2096
|
+
);
|
|
1907
2097
|
const goToReview = _react.useCallback.call(void 0, async () => {
|
|
1908
2098
|
if (!state.selectedPrice) return;
|
|
1909
2099
|
dispatch({ type: "SET_PROCESSING", isProcessing: true });
|
|
1910
2100
|
try {
|
|
1911
2101
|
await checkPaymentMethod();
|
|
1912
|
-
const isTrialUpgrade = _optionalChain([subscription, 'optionalAccess',
|
|
2102
|
+
const isTrialUpgrade = _optionalChain([subscription, 'optionalAccess', _61 => _61.status]) === "trialing" /* TRIALING */;
|
|
1913
2103
|
dispatch({ type: "SET_IS_TRIAL_SUBSCRIPTION", isTrial: isTrialUpgrade });
|
|
1914
2104
|
if (isTrialUpgrade && !state.hasPaymentMethod) {
|
|
1915
|
-
const methods = await
|
|
2105
|
+
const methods = await _chunk5TH2DSAHjs.StripeCustomerService.listPaymentMethods();
|
|
1916
2106
|
if (methods.length === 0) {
|
|
1917
2107
|
dispatch({ type: "SET_STEP", step: "payment-method" });
|
|
1918
2108
|
dispatch({
|
|
@@ -1922,8 +2112,15 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
1922
2112
|
return;
|
|
1923
2113
|
}
|
|
1924
2114
|
}
|
|
1925
|
-
if (
|
|
1926
|
-
const
|
|
2115
|
+
if (shouldLookUpAutomatic(state.promotionCode)) {
|
|
2116
|
+
const found = await lookUpAutomaticCode(state.selectedPrice.id);
|
|
2117
|
+
if (!found) {
|
|
2118
|
+
dispatch({ type: "SET_ERROR", error: t("billing.ui.wizard.errors.prepare_review") });
|
|
2119
|
+
return;
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
if (subscription && state.selectedPrice.id !== _optionalChain([subscription, 'access', _62 => _62.price, 'optionalAccess', _63 => _63.id])) {
|
|
2123
|
+
const preview = await _chunk5TH2DSAHjs.StripeSubscriptionService.getProrationPreview({
|
|
1927
2124
|
subscriptionId: subscription.id,
|
|
1928
2125
|
newPriceId: state.selectedPrice.id
|
|
1929
2126
|
});
|
|
@@ -1932,55 +2129,94 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
1932
2129
|
dispatch({ type: "SET_STEP", step: "review" });
|
|
1933
2130
|
} catch (error) {
|
|
1934
2131
|
console.error("[useSubscriptionWizard] Error preparing review:", error);
|
|
1935
|
-
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") });
|
|
1936
2133
|
} finally {
|
|
1937
2134
|
dispatch({ type: "SET_PROCESSING", isProcessing: false });
|
|
1938
2135
|
}
|
|
1939
|
-
}, [
|
|
2136
|
+
}, [
|
|
2137
|
+
state.selectedPrice,
|
|
2138
|
+
state.hasPaymentMethod,
|
|
2139
|
+
state.promotionCode,
|
|
2140
|
+
subscription,
|
|
2141
|
+
checkPaymentMethod,
|
|
2142
|
+
lookUpAutomaticCode,
|
|
2143
|
+
t
|
|
2144
|
+
]);
|
|
1940
2145
|
const confirmSubscription = _react.useCallback.call(void 0, async () => {
|
|
1941
2146
|
if (!state.selectedPrice) return;
|
|
1942
2147
|
dispatch({ type: "SET_PROCESSING", isProcessing: true });
|
|
1943
2148
|
dispatch({ type: "SET_ERROR", error: null });
|
|
1944
2149
|
try {
|
|
2150
|
+
let result;
|
|
1945
2151
|
if (subscription) {
|
|
1946
2152
|
const changePlanParams = {
|
|
1947
2153
|
id: subscription.id,
|
|
1948
2154
|
newPriceId: state.selectedPrice.id,
|
|
1949
|
-
promotionCode:
|
|
2155
|
+
promotionCode: promotionCodeToSend(state.promotionCode)
|
|
1950
2156
|
};
|
|
1951
|
-
await
|
|
2157
|
+
result = await _chunk5TH2DSAHjs.StripeSubscriptionService.changePlanWithMeta(changePlanParams);
|
|
1952
2158
|
} else {
|
|
1953
2159
|
const createParams = {
|
|
1954
2160
|
id: _uuid.v4.call(void 0, ),
|
|
1955
2161
|
priceId: state.selectedPrice.id,
|
|
1956
|
-
promotionCode:
|
|
2162
|
+
promotionCode: promotionCodeToSend(state.promotionCode)
|
|
1957
2163
|
};
|
|
1958
|
-
await
|
|
2164
|
+
result = await _chunk5TH2DSAHjs.StripeSubscriptionService.createSubscription(createParams);
|
|
2165
|
+
}
|
|
2166
|
+
const clientSecret = clientSecretToConfirm(result.meta);
|
|
2167
|
+
if (clientSecret) {
|
|
2168
|
+
const confirmation = await confirmPayment(clientSecret);
|
|
2169
|
+
if (!confirmation.success) {
|
|
2170
|
+
console.error("[useSubscriptionWizard] Payment not confirmed:", confirmation.error);
|
|
2171
|
+
dispatch({
|
|
2172
|
+
type: "SET_ERROR",
|
|
2173
|
+
error: t("billing.ui.wizard.errors.payment_not_confirmed", { reason: _nullishCoalesce(confirmation.error, () => ( "")) })
|
|
2174
|
+
});
|
|
2175
|
+
return;
|
|
2176
|
+
}
|
|
2177
|
+
const subscriptionId = subscriptionIdToSync(result.subscription, subscription);
|
|
2178
|
+
if (subscriptionId) {
|
|
2179
|
+
try {
|
|
2180
|
+
await _chunk5TH2DSAHjs.StripeSubscriptionService.syncSubscription({ subscriptionId });
|
|
2181
|
+
} catch (syncError) {
|
|
2182
|
+
console.error("[useSubscriptionWizard] Subscription sync after payment failed:", syncError);
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
1959
2185
|
}
|
|
1960
2186
|
onSuccessRef.current();
|
|
1961
2187
|
onCloseRef.current();
|
|
1962
2188
|
} catch (error) {
|
|
1963
|
-
|
|
2189
|
+
const soldOut = isDiscountSoldOut(error);
|
|
2190
|
+
if (soldOut || isDiscountUnavailable(error)) {
|
|
2191
|
+
dispatch({
|
|
2192
|
+
type: "SET_ERROR",
|
|
2193
|
+
error: soldOut ? t("billing.ui.wizard.errors.discount_sold_out") : t("billing.ui.wizard.errors.discount_unavailable")
|
|
2194
|
+
});
|
|
2195
|
+
dispatch({ type: "SET_PROMOTION_CODE", code: null });
|
|
2196
|
+
await refreshAutomaticCodeOrLeaveReview(state.selectedPrice.id);
|
|
2197
|
+
return;
|
|
2198
|
+
}
|
|
2199
|
+
if (_optionalChain([error, 'optionalAccess', _65 => _65.status]) === 409 || _optionalChain([error, 'optionalAccess', _66 => _66.response, 'optionalAccess', _67 => _67.status]) === 409) {
|
|
1964
2200
|
dispatch({
|
|
1965
2201
|
type: "SET_ERROR",
|
|
1966
2202
|
error: t("billing.ui.wizard.errors.already_subscribed")
|
|
1967
2203
|
});
|
|
1968
2204
|
return;
|
|
1969
2205
|
}
|
|
1970
|
-
if (_optionalChain([error, 'optionalAccess',
|
|
2206
|
+
if (_optionalChain([error, 'optionalAccess', _68 => _68.status]) === 402 || _optionalChain([error, 'optionalAccess', _69 => _69.response, 'optionalAccess', _70 => _70.status]) === 402) {
|
|
1971
2207
|
dispatch({ type: "SET_HAS_PAYMENT_METHOD", hasMethod: false });
|
|
1972
2208
|
dispatch({ type: "SET_STEP", step: "payment-method" });
|
|
1973
2209
|
return;
|
|
1974
2210
|
}
|
|
1975
|
-
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") });
|
|
1976
2212
|
} finally {
|
|
1977
2213
|
dispatch({ type: "SET_PROCESSING", isProcessing: false });
|
|
1978
2214
|
}
|
|
1979
|
-
}, [state.selectedPrice, state.promotionCode, subscription, t]);
|
|
2215
|
+
}, [state.selectedPrice, state.promotionCode, subscription, refreshAutomaticCodeOrLeaveReview, confirmPayment, t]);
|
|
1980
2216
|
const handlePaymentMethodSuccess = _react.useCallback.call(void 0, async () => {
|
|
1981
2217
|
dispatch({ type: "SET_HAS_PAYMENT_METHOD", hasMethod: true });
|
|
1982
|
-
|
|
1983
|
-
}, []);
|
|
2218
|
+
await goToReview();
|
|
2219
|
+
}, [goToReview]);
|
|
1984
2220
|
const reset = _react.useCallback.call(void 0, () => {
|
|
1985
2221
|
dispatch({ type: "RESET" });
|
|
1986
2222
|
}, []);
|
|
@@ -1989,9 +2225,9 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
1989
2225
|
dispatch({ type: "SET_VALIDATING_PROMO_CODE", isValidating: true });
|
|
1990
2226
|
dispatch({ type: "SET_PROMO_CODE_ERROR", error: null });
|
|
1991
2227
|
try {
|
|
1992
|
-
const result = await
|
|
2228
|
+
const result = await _chunk5TH2DSAHjs.StripePromotionCodeService.validatePromotionCode({
|
|
1993
2229
|
code,
|
|
1994
|
-
stripePriceId: _optionalChain([state, 'access',
|
|
2230
|
+
stripePriceId: _optionalChain([state, 'access', _72 => _72.selectedPrice, 'optionalAccess', _73 => _73.id]),
|
|
1995
2231
|
language: locale
|
|
1996
2232
|
});
|
|
1997
2233
|
if (result.valid) {
|
|
@@ -2006,19 +2242,26 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
2006
2242
|
console.error("[useSubscriptionWizard] Promo code validation error:", error);
|
|
2007
2243
|
dispatch({
|
|
2008
2244
|
type: "SET_PROMO_CODE_ERROR",
|
|
2009
|
-
error: _optionalChain([error, 'optionalAccess',
|
|
2245
|
+
error: _optionalChain([error, 'optionalAccess', _74 => _74.message]) || t("billing.ui.wizard.errors.validate_promo_code")
|
|
2010
2246
|
});
|
|
2011
2247
|
} finally {
|
|
2012
2248
|
dispatch({ type: "SET_VALIDATING_PROMO_CODE", isValidating: false });
|
|
2013
2249
|
}
|
|
2014
2250
|
},
|
|
2015
|
-
[_optionalChain([state, 'access',
|
|
2251
|
+
[_optionalChain([state, 'access', _75 => _75.selectedPrice, 'optionalAccess', _76 => _76.id]), t, locale]
|
|
2016
2252
|
);
|
|
2017
|
-
const clearPromoCode = _react.useCallback.call(void 0, () => {
|
|
2253
|
+
const clearPromoCode = _react.useCallback.call(void 0, async () => {
|
|
2018
2254
|
dispatch({ type: "SET_PROMOTION_CODE", code: null });
|
|
2019
2255
|
dispatch({ type: "SET_PROMO_CODE_ERROR", error: null });
|
|
2020
2256
|
dispatch({ type: "SET_ERROR", error: null });
|
|
2021
|
-
|
|
2257
|
+
if (!state.selectedPrice) return;
|
|
2258
|
+
dispatch({ type: "SET_PROCESSING", isProcessing: true });
|
|
2259
|
+
try {
|
|
2260
|
+
await refreshAutomaticCodeOrLeaveReview(state.selectedPrice.id);
|
|
2261
|
+
} finally {
|
|
2262
|
+
dispatch({ type: "SET_PROCESSING", isProcessing: false });
|
|
2263
|
+
}
|
|
2264
|
+
}, [state.selectedPrice, refreshAutomaticCodeOrLeaveReview]);
|
|
2022
2265
|
const actions = _react.useMemo.call(void 0,
|
|
2023
2266
|
() => ({
|
|
2024
2267
|
selectPrice,
|
|
@@ -2107,7 +2350,7 @@ function WizardStepPlanSelection({
|
|
|
2107
2350
|
_react.useEffect.call(void 0, () => {
|
|
2108
2351
|
const loadProducts = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2109
2352
|
try {
|
|
2110
|
-
const fetchedProducts = await
|
|
2353
|
+
const fetchedProducts = await _chunk5TH2DSAHjs.StripeProductService.listProducts({ active: true });
|
|
2111
2354
|
setProducts(fetchedProducts);
|
|
2112
2355
|
} catch (error) {
|
|
2113
2356
|
console.error("[WizardStepPlanSelection] Failed to load products:", error);
|
|
@@ -2122,10 +2365,10 @@ function WizardStepPlanSelection({
|
|
|
2122
2365
|
let hasYearly2 = false;
|
|
2123
2366
|
for (const product of products) {
|
|
2124
2367
|
for (const price of product.stripePrices || []) {
|
|
2125
|
-
if (price.priceType === "recurring" && _optionalChain([price, 'access',
|
|
2368
|
+
if (price.priceType === "recurring" && _optionalChain([price, 'access', _77 => _77.recurring, 'optionalAccess', _78 => _78.interval]) === "month") {
|
|
2126
2369
|
hasMonthly2 = true;
|
|
2127
2370
|
}
|
|
2128
|
-
if (price.priceType === "recurring" && _optionalChain([price, 'access',
|
|
2371
|
+
if (price.priceType === "recurring" && _optionalChain([price, 'access', _79 => _79.recurring, 'optionalAccess', _80 => _80.interval]) === "year") {
|
|
2129
2372
|
hasYearly2 = true;
|
|
2130
2373
|
}
|
|
2131
2374
|
}
|
|
@@ -2151,14 +2394,14 @@ function WizardStepPlanSelection({
|
|
|
2151
2394
|
products,
|
|
2152
2395
|
selectedInterval,
|
|
2153
2396
|
currentPriceId,
|
|
2154
|
-
selectedPriceId: _optionalChain([selectedPrice, 'optionalAccess',
|
|
2397
|
+
selectedPriceId: _optionalChain([selectedPrice, 'optionalAccess', _81 => _81.id]),
|
|
2155
2398
|
loading,
|
|
2156
2399
|
hideRecurringPrices,
|
|
2157
2400
|
hideOneTimePrices,
|
|
2158
2401
|
onSelectPrice: handleSelectPrice
|
|
2159
2402
|
}
|
|
2160
2403
|
),
|
|
2161
|
-
/* @__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") }) })
|
|
2162
2405
|
] });
|
|
2163
2406
|
}
|
|
2164
2407
|
_chunk7QVYU63Ejs.__name.call(void 0, WizardStepPlanSelection, "WizardStepPlanSelection");
|
|
@@ -2167,6 +2410,7 @@ _chunk7QVYU63Ejs.__name.call(void 0, WizardStepPlanSelection, "WizardStepPlanSel
|
|
|
2167
2410
|
|
|
2168
2411
|
|
|
2169
2412
|
|
|
2413
|
+
|
|
2170
2414
|
// src/features/billing/stripe-promotion-code/components/PromoCodeInput.tsx
|
|
2171
2415
|
|
|
2172
2416
|
|
|
@@ -2181,8 +2425,18 @@ function PromoCodeInput({
|
|
|
2181
2425
|
disabled = false
|
|
2182
2426
|
}) {
|
|
2183
2427
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
2184
|
-
const locale =
|
|
2428
|
+
const locale = _chunk5TH2DSAHjs.useI18nLocale.call(void 0, );
|
|
2185
2429
|
const [code, setCode] = _react.useState.call(void 0, "");
|
|
2430
|
+
const appliedKey = _optionalChain([appliedCode, 'optionalAccess', _82 => _82.valid]) ? `${appliedCode.automatic ? "auto" : "typed"}:${_nullishCoalesce(appliedCode.code, () => ( ""))}` : null;
|
|
2431
|
+
const [previousAppliedKey, setPreviousAppliedKey] = _react.useState.call(void 0, appliedKey);
|
|
2432
|
+
if (appliedKey !== previousAppliedKey) {
|
|
2433
|
+
setPreviousAppliedKey(appliedKey);
|
|
2434
|
+
if (appliedKey !== null) setCode("");
|
|
2435
|
+
}
|
|
2436
|
+
const handleRemove = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => {
|
|
2437
|
+
setCode("");
|
|
2438
|
+
onRemove();
|
|
2439
|
+
}, "handleRemove");
|
|
2186
2440
|
const handleApply = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => {
|
|
2187
2441
|
if (code.trim()) {
|
|
2188
2442
|
onApply(code.trim().toUpperCase());
|
|
@@ -2199,8 +2453,8 @@ function PromoCodeInput({
|
|
|
2199
2453
|
return t("billing.ui.wizard.review.percent_off", { value: String(result.discountValue) });
|
|
2200
2454
|
}
|
|
2201
2455
|
const amount = (result.discountValue || 0) / 100;
|
|
2202
|
-
const currency = _optionalChain([result, 'access',
|
|
2203
|
-
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)}` });
|
|
2204
2458
|
}, "formatDiscount");
|
|
2205
2459
|
const formatDuration = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (result) => {
|
|
2206
2460
|
switch (result.duration) {
|
|
@@ -2214,7 +2468,40 @@ function PromoCodeInput({
|
|
|
2214
2468
|
return "";
|
|
2215
2469
|
}
|
|
2216
2470
|
}, "formatDuration");
|
|
2217
|
-
|
|
2471
|
+
const codeInput = /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
2472
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex gap-2", children: [
|
|
2473
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2474
|
+
_chunkZCOPOO7Tjs.Input,
|
|
2475
|
+
{
|
|
2476
|
+
placeholder: t("billing.ui.promo_code.placeholder"),
|
|
2477
|
+
value: code,
|
|
2478
|
+
onChange: (e) => setCode(e.target.value.toUpperCase()),
|
|
2479
|
+
onKeyDown: handleKeyDown,
|
|
2480
|
+
disabled: disabled || isValidating,
|
|
2481
|
+
className: "flex-1"
|
|
2482
|
+
}
|
|
2483
|
+
),
|
|
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") })
|
|
2485
|
+
] }),
|
|
2486
|
+
error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive text-xs/relaxed", children: error })
|
|
2487
|
+
] });
|
|
2488
|
+
if (_optionalChain([appliedCode, 'optionalAccess', _86 => _86.valid]) && appliedCode.automatic) {
|
|
2489
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-3", children: [
|
|
2490
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
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: [
|
|
2492
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Check, { className: "text-success h-4 w-4" }),
|
|
2493
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-success font-medium", children: t("billing.ui.promo_code.automatic_label") }),
|
|
2494
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-success text-sm", children: formatDiscount(appliedCode) })
|
|
2495
|
+
] }),
|
|
2496
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-success text-sm", children: formatDuration(appliedCode) })
|
|
2497
|
+
] }),
|
|
2498
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
2499
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-muted-foreground text-xs/relaxed", children: t("billing.ui.promo_code.use_different") }),
|
|
2500
|
+
codeInput
|
|
2501
|
+
] })
|
|
2502
|
+
] });
|
|
2503
|
+
}
|
|
2504
|
+
if (_optionalChain([appliedCode, 'optionalAccess', _87 => _87.valid])) {
|
|
2218
2505
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
2219
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: [
|
|
2220
2507
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
|
|
@@ -2223,11 +2510,11 @@ function PromoCodeInput({
|
|
|
2223
2510
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-success text-sm", children: formatDiscount(appliedCode) })
|
|
2224
2511
|
] }),
|
|
2225
2512
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2226
|
-
|
|
2513
|
+
_chunkZCOPOO7Tjs.Button,
|
|
2227
2514
|
{
|
|
2228
2515
|
variant: "ghost",
|
|
2229
2516
|
size: "sm",
|
|
2230
|
-
onClick:
|
|
2517
|
+
onClick: handleRemove,
|
|
2231
2518
|
disabled,
|
|
2232
2519
|
className: "text-success hover:bg-success/25 hover:text-success",
|
|
2233
2520
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.X, { className: "h-4 w-4" })
|
|
@@ -2237,26 +2524,20 @@ function PromoCodeInput({
|
|
|
2237
2524
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-success text-sm", children: formatDuration(appliedCode) })
|
|
2238
2525
|
] });
|
|
2239
2526
|
}
|
|
2240
|
-
return
|
|
2241
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex gap-2", children: [
|
|
2242
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2243
|
-
_chunkTY5FYP3Gjs.Input,
|
|
2244
|
-
{
|
|
2245
|
-
placeholder: t("billing.ui.promo_code.placeholder"),
|
|
2246
|
-
value: code,
|
|
2247
|
-
onChange: (e) => setCode(e.target.value.toUpperCase()),
|
|
2248
|
-
onKeyDown: handleKeyDown,
|
|
2249
|
-
disabled: disabled || isValidating,
|
|
2250
|
-
className: "flex-1"
|
|
2251
|
-
}
|
|
2252
|
-
),
|
|
2253
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkTY5FYP3Gjs.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") })
|
|
2254
|
-
] }),
|
|
2255
|
-
error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive text-xs/relaxed", children: error })
|
|
2256
|
-
] });
|
|
2527
|
+
return codeInput;
|
|
2257
2528
|
}
|
|
2258
2529
|
_chunk7QVYU63Ejs.__name.call(void 0, PromoCodeInput, "PromoCodeInput");
|
|
2259
2530
|
|
|
2531
|
+
// src/features/billing/stripe-subscription/components/wizards/review-card.ts
|
|
2532
|
+
function reviewCard(methods, defaultPaymentMethodId) {
|
|
2533
|
+
if (!methods || methods.length === 0) return null;
|
|
2534
|
+
const method = defaultPaymentMethodId && methods.find((m) => m.id === defaultPaymentMethodId) || methods[0];
|
|
2535
|
+
if (!_optionalChain([method, 'access', _88 => _88.card, 'optionalAccess', _89 => _89.last4])) return null;
|
|
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);
|
|
2537
|
+
return { brand, last4: method.card.last4 };
|
|
2538
|
+
}
|
|
2539
|
+
_chunk7QVYU63Ejs.__name.call(void 0, reviewCard, "reviewCard");
|
|
2540
|
+
|
|
2260
2541
|
// src/features/billing/stripe-subscription/components/wizards/WizardStepReview.tsx
|
|
2261
2542
|
|
|
2262
2543
|
function WizardStepReview({
|
|
@@ -2277,67 +2558,63 @@ function WizardStepReview({
|
|
|
2277
2558
|
isTrialUpgrade
|
|
2278
2559
|
}) {
|
|
2279
2560
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
2280
|
-
const fmt =
|
|
2561
|
+
const fmt = _chunkZCOPOO7Tjs.useBillingFormatOptions.call(void 0, );
|
|
2562
|
+
const [card, setCard] = _react.useState.call(void 0, null);
|
|
2563
|
+
_react.useEffect.call(void 0, () => {
|
|
2564
|
+
if (!hasPaymentMethod) {
|
|
2565
|
+
setCard(null);
|
|
2566
|
+
return;
|
|
2567
|
+
}
|
|
2568
|
+
let cancelled = false;
|
|
2569
|
+
Promise.all([_chunk5TH2DSAHjs.StripeCustomerService.listPaymentMethods(), _chunk5TH2DSAHjs.StripeCustomerService.getCustomer()]).then(([methods, customer]) => {
|
|
2570
|
+
if (!cancelled) setCard(reviewCard(methods, _optionalChain([customer, 'optionalAccess', _90 => _90.defaultPaymentMethodId])));
|
|
2571
|
+
}).catch((err) => {
|
|
2572
|
+
console.error("[WizardStepReview] Failed to load the card on file:", err);
|
|
2573
|
+
if (!cancelled) setCard(null);
|
|
2574
|
+
});
|
|
2575
|
+
return () => {
|
|
2576
|
+
cancelled = true;
|
|
2577
|
+
};
|
|
2578
|
+
}, [hasPaymentMethod]);
|
|
2281
2579
|
if (!selectedPrice) {
|
|
2282
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") });
|
|
2283
2581
|
}
|
|
2284
|
-
const isChangingPlan = subscription && _optionalChain([subscription, 'access',
|
|
2582
|
+
const isChangingPlan = subscription && _optionalChain([subscription, 'access', _91 => _91.price, 'optionalAccess', _92 => _92.id]) !== selectedPrice.id;
|
|
2285
2583
|
const formatInterval2 = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (price) => {
|
|
2286
2584
|
if (price.priceType === "one_time") return t("billing.ui.wizard.review.interval_one_time");
|
|
2287
|
-
const interval = _optionalChain([price, 'access',
|
|
2585
|
+
const interval = _optionalChain([price, 'access', _93 => _93.recurring, 'optionalAccess', _94 => _94.interval]) || "month";
|
|
2288
2586
|
return interval === "year" ? t("billing.ui.wizard.review.interval_yearly") : t("billing.ui.wizard.review.interval_monthly");
|
|
2289
2587
|
}, "formatInterval");
|
|
2290
|
-
const
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
}
|
|
2296
|
-
if (promotionCode.discountType === "amount_off" && promotionCode.discountValue) {
|
|
2297
|
-
return Math.max(0, originalPrice - promotionCode.discountValue);
|
|
2298
|
-
}
|
|
2299
|
-
return null;
|
|
2300
|
-
}, "calculateDiscountedPrice");
|
|
2301
|
-
const discountedPrice = calculateDiscountedPrice();
|
|
2302
|
-
const calculateDiscountedImmediateCharge = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => {
|
|
2303
|
-
if (!_optionalChain([promotionCode, 'optionalAccess', _89 => _89.valid]) || !_optionalChain([prorationPreview, 'optionalAccess', _90 => _90.immediateCharge])) return null;
|
|
2304
|
-
const originalCharge = prorationPreview.immediateCharge;
|
|
2305
|
-
if (promotionCode.discountType === "percent_off" && promotionCode.discountValue) {
|
|
2306
|
-
return originalCharge * (1 - promotionCode.discountValue / 100);
|
|
2307
|
-
}
|
|
2308
|
-
if (promotionCode.discountType === "amount_off" && promotionCode.discountValue) {
|
|
2309
|
-
return Math.max(0, originalCharge - promotionCode.discountValue);
|
|
2310
|
-
}
|
|
2311
|
-
return null;
|
|
2312
|
-
}, "calculateDiscountedImmediateCharge");
|
|
2313
|
-
const discountedImmediateCharge = calculateDiscountedImmediateCharge();
|
|
2588
|
+
const codeDiscount = _chunkZCOPOO7Tjs.promotionCodeDiscount.call(void 0, promotionCode);
|
|
2589
|
+
const carriedDiscount = isChangingPlan && !codeDiscount ? _chunkZCOPOO7Tjs.subscriptionDiscount.call(void 0, subscription) : null;
|
|
2590
|
+
const discount = _nullishCoalesce(codeDiscount, () => ( carriedDiscount));
|
|
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);
|
|
2314
2593
|
const getDiscountDescription = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => {
|
|
2315
|
-
if (!
|
|
2316
|
-
if (
|
|
2317
|
-
return t("billing.ui.wizard.review.percent_off", { value:
|
|
2318
|
-
}
|
|
2319
|
-
if (promotionCode.discountType === "amount_off" && promotionCode.discountValue) {
|
|
2320
|
-
return t("billing.ui.wizard.review.amount_off", {
|
|
2321
|
-
amount: _chunkTY5FYP3Gjs.formatCurrency.call(void 0, promotionCode.discountValue, promotionCode.currency || selectedPrice.currency, fmt)
|
|
2322
|
-
});
|
|
2594
|
+
if (!discount) return null;
|
|
2595
|
+
if (discount.discountType === "percent_off") {
|
|
2596
|
+
return t("billing.ui.wizard.review.percent_off", { value: discount.discountValue });
|
|
2323
2597
|
}
|
|
2324
|
-
return
|
|
2598
|
+
return t("billing.ui.wizard.review.amount_off", {
|
|
2599
|
+
amount: _chunk5TH2DSAHjs.formatCurrency.call(void 0, discount.discountValue, discount.currency || selectedPrice.currency, fmt)
|
|
2600
|
+
});
|
|
2325
2601
|
}, "getDiscountDescription");
|
|
2326
2602
|
const discountDescription = getDiscountDescription();
|
|
2327
2603
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-6", children: [
|
|
2328
2604
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "bg-muted/50 rounded-lg p-4 space-y-3", children: [
|
|
2329
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2605
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkZCOPOO7Tjs.SectionHeader, { children: t("billing.ui.wizard.review.selected_plan") }),
|
|
2330
2606
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between items-center", children: [
|
|
2331
2607
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
2332
|
-
/* @__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]) }),
|
|
2333
2609
|
selectedPrice.nickname && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: selectedPrice.nickname })
|
|
2334
2610
|
] }),
|
|
2335
2611
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "text-end", children: [
|
|
2336
2612
|
discountedPrice !== null ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
2337
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground line-through", children:
|
|
2338
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-success text-lg font-semibold", children:
|
|
2339
|
-
discountDescription && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2340
|
-
|
|
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 }),
|
|
2616
|
+
carriedDiscount && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: t("billing.ui.wizard.review.discount_carries_over") })
|
|
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) }),
|
|
2341
2618
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: formatInterval2(selectedPrice) })
|
|
2342
2619
|
] })
|
|
2343
2620
|
] })
|
|
@@ -2348,13 +2625,13 @@ function WizardStepReview({
|
|
|
2348
2625
|
className: `${isTrialUpgrade ? "bg-warning/15 border-warning/30" : "bg-primary/10 border-primary/30"} space-y-2 rounded-lg border p-4`,
|
|
2349
2626
|
children: [
|
|
2350
2627
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h4", { className: `font-medium ${isTrialUpgrade ? "text-warning" : "text-primary"}`, children: isTrialUpgrade ? t("billing.ui.wizard.review.trial_upgrade") : t("billing.ui.wizard.review.proration_summary") }),
|
|
2351
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: `text-sm ${isTrialUpgrade ? "text-warning" : "text-foreground"}`, children: isTrialUpgrade ? t("billing.ui.wizard.review.trial_upgrade_description") : t("billing.ui.wizard.review.proration_description") }),
|
|
2628
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: `text-sm ${isTrialUpgrade ? "text-warning" : "text-foreground"}`, children: isTrialUpgrade ? discountedImmediateCharge !== null ? t("billing.ui.wizard.review.trial_upgrade_description_discounted") : t("billing.ui.wizard.review.trial_upgrade_description") : t("billing.ui.wizard.review.proration_description") }),
|
|
2352
2629
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between text-sm", children: [
|
|
2353
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") }),
|
|
2354
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: [
|
|
2355
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "line-through text-muted-foreground me-2", children:
|
|
2356
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-success", children:
|
|
2357
|
-
] }) :
|
|
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) })
|
|
2358
2635
|
] })
|
|
2359
2636
|
]
|
|
2360
2637
|
}
|
|
@@ -2376,17 +2653,17 @@ function WizardStepReview({
|
|
|
2376
2653
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border rounded-lg p-4", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between items-center", children: [
|
|
2377
2654
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
2378
2655
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h4", { className: "font-medium", children: t("billing.ui.payment_method.title") }),
|
|
2379
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: hasPaymentMethod ? t("billing.ui.wizard.review.payment_on_file") : t("billing.ui.wizard.review.no_payment_on_file") })
|
|
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") })
|
|
2380
2657
|
] }),
|
|
2381
|
-
|
|
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") })
|
|
2382
2659
|
] }) }),
|
|
2383
|
-
error && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2660
|
+
error && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkZCOPOO7Tjs.Alert, { variant: "destructive", children: [
|
|
2384
2661
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.AlertCircle, { className: "h-4 w-4" }),
|
|
2385
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2662
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkZCOPOO7Tjs.AlertDescription, { children: error })
|
|
2386
2663
|
] }),
|
|
2387
2664
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between pt-4 border-t", children: [
|
|
2388
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2389
|
-
/* @__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") })
|
|
2390
2667
|
] })
|
|
2391
2668
|
] });
|
|
2392
2669
|
}
|
|
@@ -2399,10 +2676,10 @@ function WizardStepPaymentMethod({ onBack, onSuccess, isProcessing }) {
|
|
|
2399
2676
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
2400
2677
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-6", children: [
|
|
2401
2678
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "text-center", children: [
|
|
2402
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2679
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkZCOPOO7Tjs.SectionHeader, { children: t("billing.ui.payment_methods.add") }),
|
|
2403
2680
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: t("billing.ui.wizard.payment_description") })
|
|
2404
2681
|
] }),
|
|
2405
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, PaymentMethodForm, { onSuccess, onCancel: onBack, isLoading: isProcessing })
|
|
2682
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, PaymentMethodForm, { onSuccess, onCancel: onBack, isLoading: isProcessing, alwaysSetDefault: true })
|
|
2406
2683
|
] });
|
|
2407
2684
|
}
|
|
2408
2685
|
_chunk7QVYU63Ejs.__name.call(void 0, WizardStepPaymentMethod, "WizardStepPaymentMethod");
|
|
@@ -2442,10 +2719,10 @@ function SubscriptionWizard({
|
|
|
2442
2719
|
const isChangePlanMode = !!subscription;
|
|
2443
2720
|
const dialogTitle = subscription ? t("billing.ui.wizard.change_title") : isPurchasingAddons ? t("billing.ui.subscriptions.purchase_addons") : t("billing.ui.subscriptions.subscribe");
|
|
2444
2721
|
const dialogDescription = subscription ? t("billing.ui.wizard.change_description") : isPurchasingAddons ? t("billing.ui.wizard.addons_description") : t("billing.ui.wizard.subscribe_description");
|
|
2445
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2446
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2447
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2448
|
-
/* @__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 })
|
|
2449
2726
|
] }),
|
|
2450
2727
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, WizardProgressIndicator, { currentStep: state.step }),
|
|
2451
2728
|
state.step === "plan-selection" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -2453,7 +2730,7 @@ function SubscriptionWizard({
|
|
|
2453
2730
|
{
|
|
2454
2731
|
selectedPrice: state.selectedPrice,
|
|
2455
2732
|
selectedInterval: state.selectedInterval,
|
|
2456
|
-
currentPriceId: _optionalChain([subscription, 'optionalAccess',
|
|
2733
|
+
currentPriceId: _optionalChain([subscription, 'optionalAccess', _98 => _98.price, 'optionalAccess', _99 => _99.id]),
|
|
2457
2734
|
hideRecurringPrices: isPurchasingAddons,
|
|
2458
2735
|
hideOneTimePrices: isChangePlanMode,
|
|
2459
2736
|
onSelectPrice: actions.selectPrice,
|
|
@@ -2524,23 +2801,23 @@ function formatDate2(date, { locale, t }) {
|
|
|
2524
2801
|
_chunk7QVYU63Ejs.__name.call(void 0, formatDate2, "formatDate");
|
|
2525
2802
|
function UsageSummaryCard({ meter, summary }) {
|
|
2526
2803
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
2527
|
-
const fmt =
|
|
2528
|
-
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));
|
|
2529
2806
|
const limit = meter.limit;
|
|
2530
2807
|
const percentage = limit && limit > 0 ? currentUsage / limit * 100 : null;
|
|
2531
2808
|
const progressColor = getProgressColor(percentage);
|
|
2532
2809
|
const progressWidth = percentage !== null ? Math.min(percentage, 100) : 0;
|
|
2533
2810
|
const displayName = meter.displayName || meter.eventName;
|
|
2534
2811
|
const hasLimit = limit !== null && limit !== void 0;
|
|
2535
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2536
|
-
/* @__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: [
|
|
2537
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" }) }),
|
|
2538
2815
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col", children: [
|
|
2539
2816
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-sm font-medium", children: displayName }),
|
|
2540
2817
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-muted-foreground text-xs", children: meter.id })
|
|
2541
2818
|
] })
|
|
2542
2819
|
] }),
|
|
2543
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2820
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkZCOPOO7Tjs.CardContent, { className: "flex flex-col gap-y-4", children: [
|
|
2544
2821
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
2545
2822
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-3xl font-bold", children: currentUsage.toLocaleString(fmt.locale) }),
|
|
2546
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) }) })
|
|
@@ -2548,7 +2825,7 @@ function UsageSummaryCard({ meter, summary }) {
|
|
|
2548
2825
|
hasLimit ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-y-2", children: [
|
|
2549
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}%` } }) }),
|
|
2550
2827
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-muted-foreground text-sm", children: t("billing.ui.usage.percent_used", {
|
|
2551
|
-
value: percentage !== null ?
|
|
2828
|
+
value: percentage !== null ? _chunk5TH2DSAHjs.formatFixed.call(void 0, percentage, fmt.locale, 1) : ""
|
|
2552
2829
|
}) })
|
|
2553
2830
|
] }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-muted-foreground text-sm", children: t("billing.ui.usage.no_limit") }),
|
|
2554
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", {
|
|
@@ -2581,14 +2858,14 @@ function UsageContainer() {
|
|
|
2581
2858
|
const loadUsageData = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2582
2859
|
setLoading(true);
|
|
2583
2860
|
try {
|
|
2584
|
-
const fetchedSubscriptions = await
|
|
2861
|
+
const fetchedSubscriptions = await _chunk5TH2DSAHjs.StripeSubscriptionService.listSubscriptions();
|
|
2585
2862
|
setSubscriptions(fetchedSubscriptions);
|
|
2586
|
-
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");
|
|
2587
2864
|
if (!hasMeteredSubscriptions2) {
|
|
2588
2865
|
setLoading(false);
|
|
2589
2866
|
return;
|
|
2590
2867
|
}
|
|
2591
|
-
const fetchedMeters = await
|
|
2868
|
+
const fetchedMeters = await _chunk5TH2DSAHjs.StripeUsageService.listMeters();
|
|
2592
2869
|
setMeters(fetchedMeters);
|
|
2593
2870
|
const summariesMap = {};
|
|
2594
2871
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -2596,7 +2873,7 @@ function UsageContainer() {
|
|
|
2596
2873
|
const endOfMonth = new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59, 999);
|
|
2597
2874
|
for (const meter of fetchedMeters) {
|
|
2598
2875
|
try {
|
|
2599
|
-
const meterSummaries = await
|
|
2876
|
+
const meterSummaries = await _chunk5TH2DSAHjs.StripeUsageService.getMeterSummaries({
|
|
2600
2877
|
meterId: meter.id,
|
|
2601
2878
|
startTime: startOfMonth,
|
|
2602
2879
|
endTime: endOfMonth
|
|
@@ -2614,7 +2891,7 @@ function UsageContainer() {
|
|
|
2614
2891
|
setLoading(false);
|
|
2615
2892
|
}
|
|
2616
2893
|
}, "loadUsageData");
|
|
2617
|
-
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");
|
|
2618
2895
|
if (!loading && !hasMeteredSubscriptions) {
|
|
2619
2896
|
return null;
|
|
2620
2897
|
}
|
|
@@ -2659,27 +2936,27 @@ function formatDateTime(date, { locale, t }) {
|
|
|
2659
2936
|
_chunk7QVYU63Ejs.__name.call(void 0, formatDateTime, "formatDateTime");
|
|
2660
2937
|
function UsageHistoryTable({ usageRecords }) {
|
|
2661
2938
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
2662
|
-
const fmt =
|
|
2939
|
+
const fmt = _chunkZCOPOO7Tjs.useBillingFormatOptions.call(void 0, );
|
|
2663
2940
|
if (usageRecords.length === 0) {
|
|
2664
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") }) });
|
|
2665
2942
|
}
|
|
2666
2943
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-y-4", children: [
|
|
2667
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2668
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "overflow-clip rounded-lg border", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2669
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2670
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2671
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2672
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2673
|
-
/* @__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") })
|
|
2674
2951
|
] }) }),
|
|
2675
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2952
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkZCOPOO7Tjs.TableBody, { children: usageRecords.map((record) => {
|
|
2676
2953
|
const dateTime = formatDateTime(record.timestamp, fmt);
|
|
2677
2954
|
const quantity = record.quantity.toLocaleString(fmt.locale);
|
|
2678
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2679
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2680
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2681
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2682
|
-
/* @__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 })
|
|
2683
2960
|
] }, record.id);
|
|
2684
2961
|
}) })
|
|
2685
2962
|
] }) })
|
|
@@ -2690,13 +2967,22 @@ _chunk7QVYU63Ejs.__name.call(void 0, UsageHistoryTable, "UsageHistoryTable");
|
|
|
2690
2967
|
// src/features/billing/components/modals/BillingDetailModal.tsx
|
|
2691
2968
|
|
|
2692
2969
|
function BillingDetailModal({ open, onOpenChange, title, children, className }) {
|
|
2693
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2694
|
-
/* @__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 }) }),
|
|
2695
2972
|
children
|
|
2696
2973
|
] }) });
|
|
2697
2974
|
}
|
|
2698
2975
|
_chunk7QVYU63Ejs.__name.call(void 0, BillingDetailModal, "BillingDetailModal");
|
|
2699
2976
|
|
|
2977
|
+
// src/features/billing/components/utils/url.ts
|
|
2978
|
+
function urlWithoutParam(params) {
|
|
2979
|
+
const query = new URLSearchParams(params.search);
|
|
2980
|
+
query.delete(params.param);
|
|
2981
|
+
const remaining = query.toString();
|
|
2982
|
+
return `${params.pathname}${remaining ? `?${remaining}` : ""}${_nullishCoalesce(params.hash, () => ( ""))}`;
|
|
2983
|
+
}
|
|
2984
|
+
_chunk7QVYU63Ejs.__name.call(void 0, urlWithoutParam, "urlWithoutParam");
|
|
2985
|
+
|
|
2700
2986
|
// src/features/billing/components/widgets/BillingAlertBanner.tsx
|
|
2701
2987
|
|
|
2702
2988
|
|
|
@@ -2710,7 +2996,7 @@ function BillingAlertBanner({ subscription, onUpdatePayment, onAddPayment }) {
|
|
|
2710
2996
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-destructive text-sm font-medium", children: t("billing.ui.alert.payment_failed_title") }),
|
|
2711
2997
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive mt-1 text-sm", children: t("billing.ui.alert.payment_failed_description") })
|
|
2712
2998
|
] }),
|
|
2713
|
-
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") })
|
|
2714
3000
|
] });
|
|
2715
3001
|
}
|
|
2716
3002
|
if (subscription.status === "trialing" /* TRIALING */ && subscription.trialEnd) {
|
|
@@ -2724,7 +3010,7 @@ function BillingAlertBanner({ subscription, onUpdatePayment, onAddPayment }) {
|
|
|
2724
3010
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-warning text-sm font-medium", children: t("billing.ui.alert.trial_ending_title") }),
|
|
2725
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 }) })
|
|
2726
3012
|
] }),
|
|
2727
|
-
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") })
|
|
2728
3014
|
] });
|
|
2729
3015
|
}
|
|
2730
3016
|
}
|
|
@@ -2765,24 +3051,24 @@ function BillingDashboardContainer() {
|
|
|
2765
3051
|
const [showWizard, setShowWizard] = _react.useState.call(void 0, false);
|
|
2766
3052
|
const [editingSubscription, setEditingSubscription] = _react.useState.call(void 0, null);
|
|
2767
3053
|
const hasMeteredSubscriptions = _react.useCallback.call(void 0, () => {
|
|
2768
|
-
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");
|
|
2769
3055
|
}, [data.subscriptions]);
|
|
2770
3056
|
const hasActiveRecurringSubscription = _react.useMemo.call(void 0, () => {
|
|
2771
3057
|
return data.subscriptions.some(
|
|
2772
|
-
(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"
|
|
2773
3059
|
);
|
|
2774
3060
|
}, [data.subscriptions]);
|
|
2775
3061
|
const fetchAllData = _react.useCallback.call(void 0, async () => {
|
|
2776
3062
|
setNoCustomerExists(false);
|
|
2777
3063
|
let customer = null;
|
|
2778
3064
|
try {
|
|
2779
|
-
customer = await
|
|
3065
|
+
customer = await _chunk5TH2DSAHjs.StripeCustomerService.getCustomer();
|
|
2780
3066
|
setData((prev) => ({ ...prev, customer }));
|
|
2781
3067
|
setErrors((prev) => ({ ...prev, customer: null }));
|
|
2782
3068
|
setNoCustomerExists(false);
|
|
2783
3069
|
} catch (error) {
|
|
2784
3070
|
console.error("[BillingDashboard] Failed to load customer:", error);
|
|
2785
|
-
if (_optionalChain([error, 'optionalAccess',
|
|
3071
|
+
if (_optionalChain([error, 'optionalAccess', _112 => _112.status]) === 404) {
|
|
2786
3072
|
setNoCustomerExists(true);
|
|
2787
3073
|
} else {
|
|
2788
3074
|
setErrors((prev) => ({ ...prev, customer: "billing.ui.dashboard.errors.load_customer" }));
|
|
@@ -2802,7 +3088,7 @@ function BillingDashboardContainer() {
|
|
|
2802
3088
|
}
|
|
2803
3089
|
const fetchSubscriptions = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2804
3090
|
try {
|
|
2805
|
-
const subscriptions2 = await
|
|
3091
|
+
const subscriptions2 = await _chunk5TH2DSAHjs.StripeSubscriptionService.listSubscriptions();
|
|
2806
3092
|
setData((prev) => ({ ...prev, subscriptions: subscriptions2 }));
|
|
2807
3093
|
setErrors((prev) => ({ ...prev, subscriptions: null }));
|
|
2808
3094
|
return subscriptions2;
|
|
@@ -2816,7 +3102,7 @@ function BillingDashboardContainer() {
|
|
|
2816
3102
|
}, "fetchSubscriptions");
|
|
2817
3103
|
const fetchPaymentMethods = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2818
3104
|
try {
|
|
2819
|
-
const paymentMethods = await
|
|
3105
|
+
const paymentMethods = await _chunk5TH2DSAHjs.StripeCustomerService.listPaymentMethods();
|
|
2820
3106
|
setData((prev) => ({ ...prev, paymentMethods }));
|
|
2821
3107
|
setErrors((prev) => ({ ...prev, paymentMethods: null }));
|
|
2822
3108
|
} catch (error) {
|
|
@@ -2828,7 +3114,7 @@ function BillingDashboardContainer() {
|
|
|
2828
3114
|
}, "fetchPaymentMethods");
|
|
2829
3115
|
const fetchInvoices = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2830
3116
|
try {
|
|
2831
|
-
const invoices = await
|
|
3117
|
+
const invoices = await _chunk5TH2DSAHjs.StripeInvoiceService.listInvoices();
|
|
2832
3118
|
setData((prev) => ({ ...prev, invoices }));
|
|
2833
3119
|
setErrors((prev) => ({ ...prev, invoices: null }));
|
|
2834
3120
|
} catch (error) {
|
|
@@ -2840,7 +3126,7 @@ function BillingDashboardContainer() {
|
|
|
2840
3126
|
}, "fetchInvoices");
|
|
2841
3127
|
const [subscriptions] = await Promise.all([fetchSubscriptions(), fetchPaymentMethods(), fetchInvoices()]);
|
|
2842
3128
|
const hasMetered = subscriptions.some(
|
|
2843
|
-
(sub) => _optionalChain([sub, 'access',
|
|
3129
|
+
(sub) => _optionalChain([sub, 'access', _113 => _113.price, 'optionalAccess', _114 => _114.recurring, 'optionalAccess', _115 => _115.usageType]) === "metered"
|
|
2844
3130
|
);
|
|
2845
3131
|
if (hasMetered) {
|
|
2846
3132
|
await fetchUsageData();
|
|
@@ -2851,7 +3137,7 @@ function BillingDashboardContainer() {
|
|
|
2851
3137
|
const handleCreateCustomer = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2852
3138
|
setCreatingCustomer(true);
|
|
2853
3139
|
try {
|
|
2854
|
-
await
|
|
3140
|
+
await _chunk5TH2DSAHjs.StripeCustomerService.createCustomer();
|
|
2855
3141
|
setNoCustomerExists(false);
|
|
2856
3142
|
await fetchAllData();
|
|
2857
3143
|
} catch (error) {
|
|
@@ -2863,7 +3149,7 @@ function BillingDashboardContainer() {
|
|
|
2863
3149
|
}, "handleCreateCustomer");
|
|
2864
3150
|
const fetchUsageData = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2865
3151
|
try {
|
|
2866
|
-
const meters = await
|
|
3152
|
+
const meters = await _chunk5TH2DSAHjs.StripeUsageService.listMeters();
|
|
2867
3153
|
setData((prev) => ({ ...prev, meters }));
|
|
2868
3154
|
const summariesMap = {};
|
|
2869
3155
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -2871,7 +3157,7 @@ function BillingDashboardContainer() {
|
|
|
2871
3157
|
const endOfMonth = new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59, 999);
|
|
2872
3158
|
for (const meter of meters) {
|
|
2873
3159
|
try {
|
|
2874
|
-
const meterSummaries = await
|
|
3160
|
+
const meterSummaries = await _chunk5TH2DSAHjs.StripeUsageService.getMeterSummaries({
|
|
2875
3161
|
meterId: meter.id,
|
|
2876
3162
|
startTime: startOfMonth,
|
|
2877
3163
|
endTime: endOfMonth
|
|
@@ -2917,7 +3203,16 @@ function BillingDashboardContainer() {
|
|
|
2917
3203
|
const action = searchParams.get("action");
|
|
2918
3204
|
if (action === "subscribe") {
|
|
2919
3205
|
setShowWizard(true);
|
|
2920
|
-
window.history.replaceState(
|
|
3206
|
+
window.history.replaceState(
|
|
3207
|
+
window.history.state,
|
|
3208
|
+
"",
|
|
3209
|
+
urlWithoutParam({
|
|
3210
|
+
pathname: window.location.pathname,
|
|
3211
|
+
search: window.location.search,
|
|
3212
|
+
hash: window.location.hash,
|
|
3213
|
+
param: "action"
|
|
3214
|
+
})
|
|
3215
|
+
);
|
|
2921
3216
|
}
|
|
2922
3217
|
}, [searchParams]);
|
|
2923
3218
|
const criticalSubscriptions = data.subscriptions.filter(
|
|
@@ -2949,18 +3244,18 @@ function BillingDashboardContainer() {
|
|
|
2949
3244
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Wallet, { className: "h-8 w-8" }),
|
|
2950
3245
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h1", { className: "text-primary text-3xl font-semibold", children: t("billing.title") })
|
|
2951
3246
|
] }),
|
|
2952
|
-
isInitialLoading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2953
|
-
noCustomerExists && !isInitialLoading && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2954
|
-
/* @__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: [
|
|
2955
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" }) }),
|
|
2956
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2957
|
-
/* @__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") })
|
|
2958
3253
|
] }),
|
|
2959
|
-
/* @__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: [
|
|
2960
3255
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Loader2, { className: "me-2 h-4 w-4 animate-spin" }),
|
|
2961
3256
|
t("billing.ui.dashboard.setting_up")
|
|
2962
3257
|
] }) : t("billing.ui.dashboard.setup_button") }) }),
|
|
2963
|
-
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) }) })
|
|
2964
3259
|
] }),
|
|
2965
3260
|
!noCustomerExists && !isInitialLoading && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
2966
3261
|
criticalSubscriptions.map((subscription) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -2992,7 +3287,7 @@ function BillingDashboardContainer() {
|
|
|
2992
3287
|
PaymentMethodSummaryCard,
|
|
2993
3288
|
{
|
|
2994
3289
|
paymentMethods: data.paymentMethods,
|
|
2995
|
-
defaultPaymentMethodId: _optionalChain([data, 'access',
|
|
3290
|
+
defaultPaymentMethodId: _optionalChain([data, 'access', _116 => _116.customer, 'optionalAccess', _117 => _117.defaultPaymentMethodId]),
|
|
2996
3291
|
loading: loading.paymentMethods,
|
|
2997
3292
|
error: errors.paymentMethods ? t(errors.paymentMethods) : void 0,
|
|
2998
3293
|
onManageClick: () => setActiveModal("payment-methods")
|
|
@@ -3036,7 +3331,9 @@ function BillingDashboardContainer() {
|
|
|
3036
3331
|
SubscriptionsContainer,
|
|
3037
3332
|
{
|
|
3038
3333
|
onOpenWizard: handleOpenWizard,
|
|
3039
|
-
hasActiveRecurringSubscription
|
|
3334
|
+
hasActiveRecurringSubscription,
|
|
3335
|
+
subscriptions: data.subscriptions,
|
|
3336
|
+
onSubscriptionsChange: refreshData
|
|
3040
3337
|
}
|
|
3041
3338
|
)
|
|
3042
3339
|
}
|
|
@@ -3071,7 +3368,7 @@ function BillingDashboardContainer() {
|
|
|
3071
3368
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3072
3369
|
SubscriptionWizard,
|
|
3073
3370
|
{
|
|
3074
|
-
open: showWizard,
|
|
3371
|
+
open: showWizard && !!data.customer,
|
|
3075
3372
|
onOpenChange: (open) => !open && handleWizardClose(),
|
|
3076
3373
|
onSuccess: refreshData,
|
|
3077
3374
|
hasActiveRecurringSubscription,
|
|
@@ -3093,7 +3390,7 @@ function getStripePromise(publishableKey) {
|
|
|
3093
3390
|
if (!publishableKey) {
|
|
3094
3391
|
return Promise.resolve(null);
|
|
3095
3392
|
}
|
|
3096
|
-
if (_optionalChain([stripePromiseCache, 'optionalAccess',
|
|
3393
|
+
if (_optionalChain([stripePromiseCache, 'optionalAccess', _118 => _118.key]) === publishableKey) {
|
|
3097
3394
|
return stripePromiseCache.promise;
|
|
3098
3395
|
}
|
|
3099
3396
|
const promise = _stripejs.loadStripe.call(void 0, publishableKey);
|
|
@@ -3102,7 +3399,7 @@ function getStripePromise(publishableKey) {
|
|
|
3102
3399
|
}
|
|
3103
3400
|
_chunk7QVYU63Ejs.__name.call(void 0, getStripePromise, "getStripePromise");
|
|
3104
3401
|
function StripeProvider({ children }) {
|
|
3105
|
-
const publishableKey =
|
|
3402
|
+
const publishableKey = _chunkXOSC3FFPjs.getStripePublishableKey.call(void 0, );
|
|
3106
3403
|
const stripePromise = _react.useMemo.call(void 0, () => getStripePromise(publishableKey), [publishableKey]);
|
|
3107
3404
|
const options = _react.useMemo.call(void 0, () => ({}), []);
|
|
3108
3405
|
if (!publishableKey) {
|
|
@@ -3112,7 +3409,7 @@ function StripeProvider({ children }) {
|
|
|
3112
3409
|
}
|
|
3113
3410
|
_chunk7QVYU63Ejs.__name.call(void 0, StripeProvider, "StripeProvider");
|
|
3114
3411
|
function isStripeConfigured() {
|
|
3115
|
-
return !!
|
|
3412
|
+
return !!_chunkXOSC3FFPjs.getStripePublishableKey.call(void 0, );
|
|
3116
3413
|
}
|
|
3117
3414
|
_chunk7QVYU63Ejs.__name.call(void 0, isStripeConfigured, "isStripeConfigured");
|
|
3118
3415
|
|
|
@@ -3127,18 +3424,18 @@ _chunk7QVYU63Ejs.__name.call(void 0, isStripeConfigured, "isStripeConfigured");
|
|
|
3127
3424
|
|
|
3128
3425
|
function PriceArchiver({ price }) {
|
|
3129
3426
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
3130
|
-
const fmt =
|
|
3427
|
+
const fmt = _chunkZCOPOO7Tjs.useBillingFormatOptions.call(void 0, );
|
|
3131
3428
|
const { archivePrice, restorePrice } = usePriceContext();
|
|
3132
3429
|
const [open, setOpen] = _react.useState.call(void 0, false);
|
|
3133
3430
|
const isArchived = !price.active;
|
|
3134
3431
|
const scope = isArchived ? "restore" : "archive";
|
|
3135
3432
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
3136
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3433
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkZCOPOO7Tjs.Button, { variant: "outline", size: "sm", onClick: () => setOpen(true), children: [
|
|
3137
3434
|
isArchived ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.RotateCcwIcon, {}) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ArchiveIcon, {}),
|
|
3138
3435
|
t(`billing.admin.prices.${scope}.confirm`)
|
|
3139
3436
|
] }),
|
|
3140
3437
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3141
|
-
|
|
3438
|
+
_chunkZCOPOO7Tjs.ConfirmDialog,
|
|
3142
3439
|
{
|
|
3143
3440
|
open,
|
|
3144
3441
|
onOpenChange: setOpen,
|
|
@@ -3152,7 +3449,7 @@ function PriceArchiver({ price }) {
|
|
|
3152
3449
|
if (isArchived) await restorePrice(price.id);
|
|
3153
3450
|
else await archivePrice(price.id);
|
|
3154
3451
|
} catch (error) {
|
|
3155
|
-
|
|
3452
|
+
_chunkZCOPOO7Tjs.errorToast.call(void 0, { title: t(`billing.admin.prices.${scope}.title`), error });
|
|
3156
3453
|
throw error;
|
|
3157
3454
|
}
|
|
3158
3455
|
}
|
|
@@ -3184,15 +3481,15 @@ function PriceEditorInternal({
|
|
|
3184
3481
|
onDialogOpenChange
|
|
3185
3482
|
}) {
|
|
3186
3483
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
3187
|
-
const fmt =
|
|
3188
|
-
const router =
|
|
3484
|
+
const fmt = _chunkZCOPOO7Tjs.useBillingFormatOptions.call(void 0, );
|
|
3485
|
+
const router = _chunk5TH2DSAHjs.useI18nRouter.call(void 0, );
|
|
3189
3486
|
const { createPrice, updatePrice, productId: contextProductId } = usePriceContext();
|
|
3190
3487
|
const [allFeatures, setAllFeatures] = _react.useState.call(void 0, []);
|
|
3191
3488
|
const isEdit = !!price;
|
|
3192
|
-
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));
|
|
3193
3490
|
_react.useEffect.call(void 0, () => {
|
|
3194
3491
|
const fetchFeatures = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
3195
|
-
setAllFeatures(await
|
|
3492
|
+
setAllFeatures(await _chunk5TH2DSAHjs.FeatureService.findMany({}));
|
|
3196
3493
|
}, "fetchFeatures");
|
|
3197
3494
|
void fetchFeatures();
|
|
3198
3495
|
}, []);
|
|
@@ -3268,22 +3565,22 @@ function PriceEditorInternal({
|
|
|
3268
3565
|
// `.toString()`, for the same reason the schema keeps the token
|
|
3269
3566
|
// pipeline string-based: a seeded `0` must survive as "0" and not be
|
|
3270
3567
|
// dropped as falsy.
|
|
3271
|
-
token: _nullishCoalesce(_optionalChain([seed, 'access',
|
|
3568
|
+
token: _nullishCoalesce(_optionalChain([seed, 'access', _121 => _121.token, 'optionalAccess', _122 => _122.toString, 'call', _123 => _123()]), () => ( "")),
|
|
3272
3569
|
featureIds: [.../* @__PURE__ */ new Set([...resolvePlatformFeatures(seed.platformFeatures).ids, ...coreFeatureIds])]
|
|
3273
3570
|
};
|
|
3274
3571
|
}
|
|
3275
3572
|
return {
|
|
3276
|
-
unitAmount: _optionalChain([price, 'optionalAccess',
|
|
3277
|
-
currency: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3278
|
-
interval: _optionalChain([price, 'optionalAccess',
|
|
3279
|
-
intervalCount: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3280
|
-
usageType: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3281
|
-
nickname: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3282
|
-
isTrial: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3283
|
-
description: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3284
|
-
features: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3285
|
-
token: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3286
|
-
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])]
|
|
3287
3584
|
};
|
|
3288
3585
|
}, [price, seed, allFeatures, resolvePlatformFeatures]);
|
|
3289
3586
|
const form = _reacthookform.useForm.call(void 0, {
|
|
@@ -3305,7 +3602,7 @@ function PriceEditorInternal({
|
|
|
3305
3602
|
warnedUnknownFor.current = fingerprint;
|
|
3306
3603
|
const { unknown } = resolvePlatformFeatures(seed.platformFeatures);
|
|
3307
3604
|
if (unknown.length > 0)
|
|
3308
|
-
|
|
3605
|
+
_chunk5TH2DSAHjs.showToast.call(void 0, t("billing.admin.prices.import.warnings.unknownFeatures", { features: unknown.join(", ") }));
|
|
3309
3606
|
}, [seed, isEdit, allFeatures, resolvePlatformFeatures, t]);
|
|
3310
3607
|
const watchInterval = form.watch("interval");
|
|
3311
3608
|
const isRecurring = watchInterval !== "one_time";
|
|
@@ -3326,13 +3623,13 @@ function PriceEditorInternal({
|
|
|
3326
3623
|
{ id: "metered", text: t("billing.admin.prices.usage.metered") }
|
|
3327
3624
|
];
|
|
3328
3625
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3329
|
-
|
|
3626
|
+
_chunkZCOPOO7Tjs.EditorSheet,
|
|
3330
3627
|
{
|
|
3331
3628
|
form,
|
|
3332
3629
|
entityType: t("billing.admin.prices.entity"),
|
|
3333
3630
|
entityName: price ? priceLabel(price, fmt) : void 0,
|
|
3334
3631
|
isEdit,
|
|
3335
|
-
module:
|
|
3632
|
+
module: _chunk5TH2DSAHjs.Modules.StripePrice,
|
|
3336
3633
|
size: "lg",
|
|
3337
3634
|
propagateChanges,
|
|
3338
3635
|
onSuccess,
|
|
@@ -3381,13 +3678,13 @@ function PriceEditorInternal({
|
|
|
3381
3678
|
dialogOpen,
|
|
3382
3679
|
onDialogOpenChange,
|
|
3383
3680
|
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-y-4", children: [
|
|
3384
|
-
isEdit && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3385
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3386
|
-
/* @__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") })
|
|
3387
3684
|
] }),
|
|
3388
3685
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid grid-cols-2 gap-x-4", children: [
|
|
3389
3686
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3390
|
-
|
|
3687
|
+
_chunkZCOPOO7Tjs.FormInput,
|
|
3391
3688
|
{
|
|
3392
3689
|
form,
|
|
3393
3690
|
id: "unitAmount",
|
|
@@ -3399,7 +3696,7 @@ function PriceEditorInternal({
|
|
|
3399
3696
|
}
|
|
3400
3697
|
),
|
|
3401
3698
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3402
|
-
|
|
3699
|
+
_chunkZCOPOO7Tjs.FormSelect,
|
|
3403
3700
|
{
|
|
3404
3701
|
form,
|
|
3405
3702
|
id: "currency",
|
|
@@ -3410,7 +3707,7 @@ function PriceEditorInternal({
|
|
|
3410
3707
|
)
|
|
3411
3708
|
] }),
|
|
3412
3709
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3413
|
-
|
|
3710
|
+
_chunkZCOPOO7Tjs.FormSelect,
|
|
3414
3711
|
{
|
|
3415
3712
|
form,
|
|
3416
3713
|
id: "interval",
|
|
@@ -3421,7 +3718,7 @@ function PriceEditorInternal({
|
|
|
3421
3718
|
),
|
|
3422
3719
|
isRecurring && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid grid-cols-2 gap-x-4", children: [
|
|
3423
3720
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3424
|
-
|
|
3721
|
+
_chunkZCOPOO7Tjs.FormInput,
|
|
3425
3722
|
{
|
|
3426
3723
|
form,
|
|
3427
3724
|
id: "intervalCount",
|
|
@@ -3432,7 +3729,7 @@ function PriceEditorInternal({
|
|
|
3432
3729
|
}
|
|
3433
3730
|
),
|
|
3434
3731
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3435
|
-
|
|
3732
|
+
_chunkZCOPOO7Tjs.FormSelect,
|
|
3436
3733
|
{
|
|
3437
3734
|
form,
|
|
3438
3735
|
id: "usageType",
|
|
@@ -3443,7 +3740,7 @@ function PriceEditorInternal({
|
|
|
3443
3740
|
)
|
|
3444
3741
|
] }),
|
|
3445
3742
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3446
|
-
|
|
3743
|
+
_chunkZCOPOO7Tjs.FormInput,
|
|
3447
3744
|
{
|
|
3448
3745
|
form,
|
|
3449
3746
|
id: "nickname",
|
|
@@ -3452,7 +3749,7 @@ function PriceEditorInternal({
|
|
|
3452
3749
|
}
|
|
3453
3750
|
),
|
|
3454
3751
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3455
|
-
|
|
3752
|
+
_chunkZCOPOO7Tjs.FormTextarea,
|
|
3456
3753
|
{
|
|
3457
3754
|
form,
|
|
3458
3755
|
id: "description",
|
|
@@ -3462,7 +3759,7 @@ function PriceEditorInternal({
|
|
|
3462
3759
|
}
|
|
3463
3760
|
),
|
|
3464
3761
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3465
|
-
|
|
3762
|
+
_chunkZCOPOO7Tjs.FormInput,
|
|
3466
3763
|
{
|
|
3467
3764
|
form,
|
|
3468
3765
|
id: "token",
|
|
@@ -3472,10 +3769,10 @@ function PriceEditorInternal({
|
|
|
3472
3769
|
}
|
|
3473
3770
|
),
|
|
3474
3771
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-y-2", children: [
|
|
3475
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3772
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkZCOPOO7Tjs.FieldLabel, { children: t("billing.admin.prices.fields.features") }),
|
|
3476
3773
|
form.watch("features").map((_, index) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex gap-2", children: [
|
|
3477
3774
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3478
|
-
|
|
3775
|
+
_chunkZCOPOO7Tjs.Input,
|
|
3479
3776
|
{
|
|
3480
3777
|
...form.register(`features.${index}`),
|
|
3481
3778
|
placeholder: t("billing.admin.prices.placeholders.feature", { index: index + 1 }),
|
|
@@ -3483,7 +3780,7 @@ function PriceEditorInternal({
|
|
|
3483
3780
|
}
|
|
3484
3781
|
),
|
|
3485
3782
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3486
|
-
|
|
3783
|
+
_chunkZCOPOO7Tjs.Button,
|
|
3487
3784
|
{
|
|
3488
3785
|
type: "button",
|
|
3489
3786
|
variant: "outline",
|
|
@@ -3498,7 +3795,7 @@ function PriceEditorInternal({
|
|
|
3498
3795
|
)
|
|
3499
3796
|
] }, index)),
|
|
3500
3797
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3501
|
-
|
|
3798
|
+
_chunkZCOPOO7Tjs.Button,
|
|
3502
3799
|
{
|
|
3503
3800
|
type: "button",
|
|
3504
3801
|
variant: "outline",
|
|
@@ -3513,12 +3810,12 @@ function PriceEditorInternal({
|
|
|
3513
3810
|
)
|
|
3514
3811
|
] }),
|
|
3515
3812
|
isRecurring && allFeatures.length > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-y-2", children: [
|
|
3516
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3813
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkZCOPOO7Tjs.FieldLabel, { children: t("billing.admin.prices.fields.platformFeatures") }),
|
|
3517
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) => {
|
|
3518
3815
|
const isChecked = form.watch("featureIds").includes(feature.id);
|
|
3519
3816
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-2", children: [
|
|
3520
3817
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3521
|
-
|
|
3818
|
+
_chunkZCOPOO7Tjs.Checkbox,
|
|
3522
3819
|
{
|
|
3523
3820
|
id: `feature-${feature.id}`,
|
|
3524
3821
|
checked: isChecked,
|
|
@@ -3534,13 +3831,13 @@ function PriceEditorInternal({
|
|
|
3534
3831
|
}
|
|
3535
3832
|
}
|
|
3536
3833
|
),
|
|
3537
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3834
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkZCOPOO7Tjs.FieldLabel, { htmlFor: `feature-${feature.id}`, children: feature.name }),
|
|
3538
3835
|
feature.isCore && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("billing.admin.prices.help.core") })
|
|
3539
3836
|
] }, feature.id);
|
|
3540
3837
|
}) })
|
|
3541
3838
|
] }),
|
|
3542
3839
|
isRecurring && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3543
|
-
|
|
3840
|
+
_chunkZCOPOO7Tjs.FormCheckbox,
|
|
3544
3841
|
{
|
|
3545
3842
|
form,
|
|
3546
3843
|
id: "isTrial",
|
|
@@ -3583,7 +3880,7 @@ var defaultContextValue = {
|
|
|
3583
3880
|
productId: void 0
|
|
3584
3881
|
};
|
|
3585
3882
|
function priceLabel(price, fmt = {}) {
|
|
3586
|
-
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()));
|
|
3587
3884
|
}
|
|
3588
3885
|
_chunk7QVYU63Ejs.__name.call(void 0, priceLabel, "priceLabel");
|
|
3589
3886
|
var PriceProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({
|
|
@@ -3593,22 +3890,22 @@ var PriceProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({
|
|
|
3593
3890
|
productId: productIdProp
|
|
3594
3891
|
}) => {
|
|
3595
3892
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
3596
|
-
const fmt =
|
|
3597
|
-
const generateUrl =
|
|
3598
|
-
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, );
|
|
3599
3896
|
const [price, setPrice] = _react.useState.call(void 0,
|
|
3600
|
-
dehydratedPrice ?
|
|
3897
|
+
dehydratedPrice ? _chunk5TH2DSAHjs.rehydrate.call(void 0, _chunk5TH2DSAHjs.Modules.StripePrice, dehydratedPrice) : void 0
|
|
3601
3898
|
);
|
|
3602
3899
|
const [priceVersion, setPriceVersion] = _react.useState.call(void 0, 0);
|
|
3603
3900
|
const refreshPrices = _react.useCallback.call(void 0, () => setPriceVersion((value2) => value2 + 1), []);
|
|
3604
|
-
const productId = _nullishCoalesce(productIdProp, () => ( _optionalChain([price, 'optionalAccess',
|
|
3901
|
+
const productId = _nullishCoalesce(productIdProp, () => ( _optionalChain([price, 'optionalAccess', _143 => _143.product, 'optionalAccess', _144 => _144.id])));
|
|
3605
3902
|
const reloadPrice = _react.useCallback.call(void 0, async () => {
|
|
3606
|
-
if (!_optionalChain([price, 'optionalAccess',
|
|
3607
|
-
setPrice(await
|
|
3608
|
-
}, [_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])]);
|
|
3609
3906
|
const createPrice = _react.useCallback.call(void 0,
|
|
3610
3907
|
async (input) => {
|
|
3611
|
-
const saved = await
|
|
3908
|
+
const saved = await _chunk5TH2DSAHjs.StripePriceService.createPrice(input);
|
|
3612
3909
|
refreshPrices();
|
|
3613
3910
|
return saved;
|
|
3614
3911
|
},
|
|
@@ -3616,7 +3913,7 @@ var PriceProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({
|
|
|
3616
3913
|
);
|
|
3617
3914
|
const updatePrice = _react.useCallback.call(void 0,
|
|
3618
3915
|
async (input) => {
|
|
3619
|
-
const saved = await
|
|
3916
|
+
const saved = await _chunk5TH2DSAHjs.StripePriceService.updatePrice(input);
|
|
3620
3917
|
setPrice(saved);
|
|
3621
3918
|
refreshPrices();
|
|
3622
3919
|
return saved;
|
|
@@ -3625,23 +3922,23 @@ var PriceProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({
|
|
|
3625
3922
|
);
|
|
3626
3923
|
const archivePrice = _react.useCallback.call(void 0,
|
|
3627
3924
|
async (id) => {
|
|
3628
|
-
const target = _nullishCoalesce(id, () => ( _optionalChain([price, 'optionalAccess',
|
|
3925
|
+
const target = _nullishCoalesce(id, () => ( _optionalChain([price, 'optionalAccess', _147 => _147.id])));
|
|
3629
3926
|
if (!target) return;
|
|
3630
|
-
await
|
|
3927
|
+
await _chunk5TH2DSAHjs.StripePriceService.archivePrice({ id: target });
|
|
3631
3928
|
await reloadPrice();
|
|
3632
3929
|
refreshPrices();
|
|
3633
3930
|
},
|
|
3634
|
-
[_optionalChain([price, 'optionalAccess',
|
|
3931
|
+
[_optionalChain([price, 'optionalAccess', _148 => _148.id]), reloadPrice, refreshPrices]
|
|
3635
3932
|
);
|
|
3636
3933
|
const restorePrice = _react.useCallback.call(void 0,
|
|
3637
3934
|
async (id) => {
|
|
3638
|
-
const target = _nullishCoalesce(id, () => ( _optionalChain([price, 'optionalAccess',
|
|
3935
|
+
const target = _nullishCoalesce(id, () => ( _optionalChain([price, 'optionalAccess', _149 => _149.id])));
|
|
3639
3936
|
if (!target) return;
|
|
3640
|
-
await
|
|
3937
|
+
await _chunk5TH2DSAHjs.StripePriceService.reactivatePrice({ id: target });
|
|
3641
3938
|
await reloadPrice();
|
|
3642
3939
|
refreshPrices();
|
|
3643
3940
|
},
|
|
3644
|
-
[_optionalChain([price, 'optionalAccess',
|
|
3941
|
+
[_optionalChain([price, 'optionalAccess', _150 => _150.id]), reloadPrice, refreshPrices]
|
|
3645
3942
|
);
|
|
3646
3943
|
const value = _react.useMemo.call(void 0,
|
|
3647
3944
|
() => ({
|
|
@@ -3661,12 +3958,12 @@ var PriceProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({
|
|
|
3661
3958
|
if (!publishChrome) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PriceContext.Provider, { value, children });
|
|
3662
3959
|
const breadcrumb = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => {
|
|
3663
3960
|
const items = [
|
|
3664
|
-
{ name: t("billing.admin.products.title"), href: generateUrl({ page:
|
|
3961
|
+
{ name: t("billing.admin.products.title"), href: generateUrl({ page: _chunk5TH2DSAHjs.Modules.StripeProduct }) }
|
|
3665
3962
|
];
|
|
3666
|
-
if (_optionalChain([price, 'optionalAccess',
|
|
3963
|
+
if (_optionalChain([price, 'optionalAccess', _151 => _151.product]))
|
|
3667
3964
|
items.push({
|
|
3668
3965
|
name: price.product.name,
|
|
3669
|
-
href: generateUrl({ page:
|
|
3966
|
+
href: generateUrl({ page: _chunk5TH2DSAHjs.Modules.StripeProduct, id: price.product.id })
|
|
3670
3967
|
});
|
|
3671
3968
|
if (price) items.push({ name: priceLabel(price, fmt) });
|
|
3672
3969
|
return items;
|
|
@@ -3683,7 +3980,7 @@ var PriceProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({
|
|
|
3683
3980
|
}
|
|
3684
3981
|
return response;
|
|
3685
3982
|
}, "title");
|
|
3686
|
-
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 }) });
|
|
3687
3984
|
}, "PriceProvider");
|
|
3688
3985
|
var usePriceContext = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => _nullishCoalesce(_react.useContext.call(void 0, PriceContext), () => ( defaultContextValue)), "usePriceContext");
|
|
3689
3986
|
|
|
@@ -3703,12 +4000,12 @@ function ProductArchiver({ product }) {
|
|
|
3703
4000
|
const isArchived = !product.active;
|
|
3704
4001
|
const scope = isArchived ? "restore" : "archive";
|
|
3705
4002
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
3706
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
4003
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkZCOPOO7Tjs.Button, { variant: "outline", size: "sm", onClick: () => setOpen(true), children: [
|
|
3707
4004
|
isArchived ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.RotateCcwIcon, {}) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ArchiveIcon, {}),
|
|
3708
4005
|
t(`billing.admin.products.${scope}.confirm`)
|
|
3709
4006
|
] }),
|
|
3710
4007
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3711
|
-
|
|
4008
|
+
_chunkZCOPOO7Tjs.ConfirmDialog,
|
|
3712
4009
|
{
|
|
3713
4010
|
open,
|
|
3714
4011
|
onOpenChange: setOpen,
|
|
@@ -3722,7 +4019,7 @@ function ProductArchiver({ product }) {
|
|
|
3722
4019
|
if (isArchived) await restoreProduct(product.id);
|
|
3723
4020
|
else await archiveProduct(product.id);
|
|
3724
4021
|
} catch (error) {
|
|
3725
|
-
|
|
4022
|
+
_chunkZCOPOO7Tjs.errorToast.call(void 0, { title: t(`billing.admin.products.${scope}.title`), error });
|
|
3726
4023
|
throw error;
|
|
3727
4024
|
}
|
|
3728
4025
|
}
|
|
@@ -3751,7 +4048,7 @@ function ProductEditorInternal({
|
|
|
3751
4048
|
onDialogOpenChange
|
|
3752
4049
|
}) {
|
|
3753
4050
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
3754
|
-
const router =
|
|
4051
|
+
const router = _chunk5TH2DSAHjs.useI18nRouter.call(void 0, );
|
|
3755
4052
|
const { createProduct, updateProduct } = useProductContext();
|
|
3756
4053
|
const isEdit = !!product;
|
|
3757
4054
|
const formSchema2 = _react.useMemo.call(void 0,
|
|
@@ -3764,9 +4061,9 @@ function ProductEditorInternal({
|
|
|
3764
4061
|
);
|
|
3765
4062
|
const getDefaultValues = _react.useCallback.call(void 0,
|
|
3766
4063
|
() => ({
|
|
3767
|
-
id: _nullishCoalesce(_optionalChain([product, 'optionalAccess',
|
|
3768
|
-
name: _nullishCoalesce(_optionalChain([product, 'optionalAccess',
|
|
3769
|
-
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]), () => ( ""))
|
|
3770
4067
|
}),
|
|
3771
4068
|
[product]
|
|
3772
4069
|
);
|
|
@@ -3775,13 +4072,13 @@ function ProductEditorInternal({
|
|
|
3775
4072
|
defaultValues: getDefaultValues()
|
|
3776
4073
|
});
|
|
3777
4074
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3778
|
-
|
|
4075
|
+
_chunkZCOPOO7Tjs.EditorSheet,
|
|
3779
4076
|
{
|
|
3780
4077
|
form,
|
|
3781
4078
|
entityType: t("billing.admin.products.entity"),
|
|
3782
|
-
entityName: _optionalChain([product, 'optionalAccess',
|
|
4079
|
+
entityName: _optionalChain([product, 'optionalAccess', _155 => _155.name]),
|
|
3783
4080
|
isEdit,
|
|
3784
|
-
module:
|
|
4081
|
+
module: _chunk5TH2DSAHjs.Modules.StripeProduct,
|
|
3785
4082
|
size: "md",
|
|
3786
4083
|
propagateChanges,
|
|
3787
4084
|
onSuccess,
|
|
@@ -3798,7 +4095,7 @@ function ProductEditorInternal({
|
|
|
3798
4095
|
onDialogOpenChange,
|
|
3799
4096
|
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-y-4", children: [
|
|
3800
4097
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3801
|
-
|
|
4098
|
+
_chunkZCOPOO7Tjs.FormInput,
|
|
3802
4099
|
{
|
|
3803
4100
|
form,
|
|
3804
4101
|
id: "name",
|
|
@@ -3808,7 +4105,7 @@ function ProductEditorInternal({
|
|
|
3808
4105
|
}
|
|
3809
4106
|
),
|
|
3810
4107
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3811
|
-
|
|
4108
|
+
_chunkZCOPOO7Tjs.FormTextarea,
|
|
3812
4109
|
{
|
|
3813
4110
|
form,
|
|
3814
4111
|
id: "description",
|
|
@@ -3852,20 +4149,20 @@ var defaultContextValue2 = {
|
|
|
3852
4149
|
};
|
|
3853
4150
|
var ProductProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({ children, dehydratedProduct, publishChrome = true }) => {
|
|
3854
4151
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
3855
|
-
const generateUrl =
|
|
3856
|
-
const { hasRole } =
|
|
4152
|
+
const generateUrl = _chunkZCOPOO7Tjs.usePageUrlGenerator.call(void 0, );
|
|
4153
|
+
const { hasRole } = _chunkZCOPOO7Tjs.useCurrentUserContext.call(void 0, );
|
|
3857
4154
|
const [product, setProduct] = _react.useState.call(void 0,
|
|
3858
|
-
dehydratedProduct ?
|
|
4155
|
+
dehydratedProduct ? _chunk5TH2DSAHjs.rehydrate.call(void 0, _chunk5TH2DSAHjs.Modules.StripeProduct, dehydratedProduct) : void 0
|
|
3859
4156
|
);
|
|
3860
4157
|
const [catalogueVersion, setCatalogueVersion] = _react.useState.call(void 0, 0);
|
|
3861
4158
|
const refreshCatalogue = _react.useCallback.call(void 0, () => setCatalogueVersion((value2) => value2 + 1), []);
|
|
3862
4159
|
const reloadProduct = _react.useCallback.call(void 0, async () => {
|
|
3863
|
-
if (!_optionalChain([product, 'optionalAccess',
|
|
3864
|
-
setProduct(await
|
|
3865
|
-
}, [_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])]);
|
|
3866
4163
|
const createProduct = _react.useCallback.call(void 0,
|
|
3867
4164
|
async (input) => {
|
|
3868
|
-
const saved = await
|
|
4165
|
+
const saved = await _chunk5TH2DSAHjs.StripeProductService.createProduct(input);
|
|
3869
4166
|
refreshCatalogue();
|
|
3870
4167
|
return saved;
|
|
3871
4168
|
},
|
|
@@ -3873,7 +4170,7 @@ var ProductProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({ ch
|
|
|
3873
4170
|
);
|
|
3874
4171
|
const updateProduct = _react.useCallback.call(void 0,
|
|
3875
4172
|
async (input) => {
|
|
3876
|
-
const saved = await
|
|
4173
|
+
const saved = await _chunk5TH2DSAHjs.StripeProductService.updateProduct(input);
|
|
3877
4174
|
setProduct(saved);
|
|
3878
4175
|
refreshCatalogue();
|
|
3879
4176
|
return saved;
|
|
@@ -3882,23 +4179,23 @@ var ProductProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({ ch
|
|
|
3882
4179
|
);
|
|
3883
4180
|
const archiveProduct = _react.useCallback.call(void 0,
|
|
3884
4181
|
async (id) => {
|
|
3885
|
-
const target = _nullishCoalesce(id, () => ( _optionalChain([product, 'optionalAccess',
|
|
4182
|
+
const target = _nullishCoalesce(id, () => ( _optionalChain([product, 'optionalAccess', _158 => _158.id])));
|
|
3886
4183
|
if (!target) return;
|
|
3887
|
-
await
|
|
4184
|
+
await _chunk5TH2DSAHjs.StripeProductService.archiveProduct({ id: target });
|
|
3888
4185
|
await reloadProduct();
|
|
3889
4186
|
refreshCatalogue();
|
|
3890
4187
|
},
|
|
3891
|
-
[_optionalChain([product, 'optionalAccess',
|
|
4188
|
+
[_optionalChain([product, 'optionalAccess', _159 => _159.id]), reloadProduct, refreshCatalogue]
|
|
3892
4189
|
);
|
|
3893
4190
|
const restoreProduct = _react.useCallback.call(void 0,
|
|
3894
4191
|
async (id) => {
|
|
3895
|
-
const target = _nullishCoalesce(id, () => ( _optionalChain([product, 'optionalAccess',
|
|
4192
|
+
const target = _nullishCoalesce(id, () => ( _optionalChain([product, 'optionalAccess', _160 => _160.id])));
|
|
3896
4193
|
if (!target) return;
|
|
3897
|
-
await
|
|
4194
|
+
await _chunk5TH2DSAHjs.StripeProductService.reactivateProduct({ id: target });
|
|
3898
4195
|
await reloadProduct();
|
|
3899
4196
|
refreshCatalogue();
|
|
3900
4197
|
},
|
|
3901
|
-
[_optionalChain([product, 'optionalAccess',
|
|
4198
|
+
[_optionalChain([product, 'optionalAccess', _161 => _161.id]), reloadProduct, refreshCatalogue]
|
|
3902
4199
|
);
|
|
3903
4200
|
const value = _react.useMemo.call(void 0,
|
|
3904
4201
|
() => ({
|
|
@@ -3929,7 +4226,7 @@ var ProductProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({ ch
|
|
|
3929
4226
|
{
|
|
3930
4227
|
name: t("billing.admin.products.title"),
|
|
3931
4228
|
// Linked only when it is NOT the current page.
|
|
3932
|
-
...product ? { href: generateUrl({ page:
|
|
4229
|
+
...product ? { href: generateUrl({ page: _chunk5TH2DSAHjs.Modules.StripeProduct }) } : {}
|
|
3933
4230
|
}
|
|
3934
4231
|
];
|
|
3935
4232
|
if (product) items.push({ name: product.name });
|
|
@@ -3947,7 +4244,7 @@ var ProductProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({ ch
|
|
|
3947
4244
|
}
|
|
3948
4245
|
return response;
|
|
3949
4246
|
}, "title");
|
|
3950
|
-
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 }) });
|
|
3951
4248
|
}, "ProductProvider");
|
|
3952
4249
|
var useProductContext = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => _nullishCoalesce(_react.useContext.call(void 0, ProductContext), () => ( defaultContextValue2)), "useProductContext");
|
|
3953
4250
|
|
|
@@ -3956,83 +4253,83 @@ var useProductContext = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ()
|
|
|
3956
4253
|
|
|
3957
4254
|
function PriceDetails() {
|
|
3958
4255
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
3959
|
-
const fmt =
|
|
3960
|
-
const generateUrl =
|
|
4256
|
+
const fmt = _chunkZCOPOO7Tjs.useBillingFormatOptions.call(void 0, );
|
|
4257
|
+
const generateUrl = _chunkZCOPOO7Tjs.usePageUrlGenerator.call(void 0, );
|
|
3961
4258
|
const { price } = usePriceContext();
|
|
3962
4259
|
if (!price) return null;
|
|
3963
4260
|
const isRecurring = price.priceType === "recurring";
|
|
3964
4261
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-y-8", children: [
|
|
3965
4262
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-y-4", children: [
|
|
3966
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4263
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkZCOPOO7Tjs.SectionHeader, { children: t("billing.admin.prices.title") }),
|
|
3967
4264
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [
|
|
3968
4265
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3969
|
-
|
|
4266
|
+
_chunkZCOPOO7Tjs.DetailField,
|
|
3970
4267
|
{
|
|
3971
4268
|
label: t("billing.admin.prices.fields.product"),
|
|
3972
|
-
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"
|
|
3973
4270
|
}
|
|
3974
4271
|
),
|
|
3975
4272
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3976
|
-
|
|
4273
|
+
_chunkZCOPOO7Tjs.DetailField,
|
|
3977
4274
|
{
|
|
3978
4275
|
label: t("billing.admin.prices.fields.status"),
|
|
3979
4276
|
value: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "flex flex-wrap items-center gap-1", children: [
|
|
3980
|
-
price.active ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3981
|
-
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") })
|
|
3982
4279
|
] })
|
|
3983
4280
|
}
|
|
3984
4281
|
),
|
|
3985
4282
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3986
|
-
|
|
4283
|
+
_chunkZCOPOO7Tjs.DetailField,
|
|
3987
4284
|
{
|
|
3988
4285
|
label: t("billing.admin.prices.fields.amount"),
|
|
3989
|
-
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) })
|
|
3990
4287
|
}
|
|
3991
4288
|
),
|
|
3992
|
-
/* @__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() }),
|
|
3993
4290
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3994
|
-
|
|
4291
|
+
_chunkZCOPOO7Tjs.DetailField,
|
|
3995
4292
|
{
|
|
3996
4293
|
label: t("billing.admin.prices.fields.type"),
|
|
3997
4294
|
value: isRecurring ? t("billing.admin.prices.type.recurring") : t("billing.admin.prices.type.oneTime")
|
|
3998
4295
|
}
|
|
3999
4296
|
),
|
|
4000
|
-
/* @__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) }),
|
|
4001
4298
|
isRecurring && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4002
|
-
|
|
4299
|
+
_chunkZCOPOO7Tjs.DetailField,
|
|
4003
4300
|
{
|
|
4004
4301
|
label: t("billing.admin.prices.fields.intervalCount"),
|
|
4005
|
-
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)) })
|
|
4006
4303
|
}
|
|
4007
4304
|
),
|
|
4008
4305
|
isRecurring && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4009
|
-
|
|
4306
|
+
_chunkZCOPOO7Tjs.DetailField,
|
|
4010
4307
|
{
|
|
4011
4308
|
label: t("billing.admin.prices.fields.usageType"),
|
|
4012
|
-
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")
|
|
4013
4310
|
}
|
|
4014
4311
|
)
|
|
4015
4312
|
] })
|
|
4016
4313
|
] }),
|
|
4017
4314
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-y-4", children: [
|
|
4018
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4315
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkZCOPOO7Tjs.SectionHeader, { children: t("billing.admin.prices.fields.platformFeatures") }),
|
|
4019
4316
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [
|
|
4020
4317
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4021
|
-
|
|
4318
|
+
_chunkZCOPOO7Tjs.DetailField,
|
|
4022
4319
|
{
|
|
4023
4320
|
label: t("billing.admin.prices.fields.token"),
|
|
4024
4321
|
value: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tabular-nums", children: _nullishCoalesce(price.token, () => ( "\u2014")) })
|
|
4025
4322
|
}
|
|
4026
4323
|
),
|
|
4027
4324
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4028
|
-
|
|
4325
|
+
_chunkZCOPOO7Tjs.DetailField,
|
|
4029
4326
|
{
|
|
4030
4327
|
label: t("billing.admin.prices.fields.stripeId"),
|
|
4031
4328
|
value: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tabular-nums", children: price.stripePriceId })
|
|
4032
4329
|
}
|
|
4033
4330
|
),
|
|
4034
4331
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4035
|
-
|
|
4332
|
+
_chunkZCOPOO7Tjs.DetailField,
|
|
4036
4333
|
{
|
|
4037
4334
|
label: t("billing.admin.prices.fields.description"),
|
|
4038
4335
|
value: _nullishCoalesce(price.description, () => ( "\u2014")),
|
|
@@ -4040,7 +4337,7 @@ function PriceDetails() {
|
|
|
4040
4337
|
}
|
|
4041
4338
|
),
|
|
4042
4339
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4043
|
-
|
|
4340
|
+
_chunkZCOPOO7Tjs.DetailField,
|
|
4044
4341
|
{
|
|
4045
4342
|
label: t("billing.admin.prices.fields.features"),
|
|
4046
4343
|
className: "md:col-span-2",
|
|
@@ -4048,11 +4345,11 @@ function PriceDetails() {
|
|
|
4048
4345
|
}
|
|
4049
4346
|
),
|
|
4050
4347
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4051
|
-
|
|
4348
|
+
_chunkZCOPOO7Tjs.DetailField,
|
|
4052
4349
|
{
|
|
4053
4350
|
label: t("billing.admin.prices.fields.platformFeatures"),
|
|
4054
4351
|
className: "md:col-span-2",
|
|
4055
|
-
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"
|
|
4056
4353
|
}
|
|
4057
4354
|
)
|
|
4058
4355
|
] })
|
|
@@ -4066,7 +4363,7 @@ _chunk7QVYU63Ejs.__name.call(void 0, PriceDetails, "PriceDetails");
|
|
|
4066
4363
|
function PriceContainer() {
|
|
4067
4364
|
const { price } = usePriceContext();
|
|
4068
4365
|
if (!price) return null;
|
|
4069
|
-
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, {}) });
|
|
4070
4367
|
}
|
|
4071
4368
|
_chunk7QVYU63Ejs.__name.call(void 0, PriceContainer, "PriceContainer");
|
|
4072
4369
|
|
|
@@ -4093,9 +4390,9 @@ var seedSchema = _zod3.z.object({
|
|
|
4093
4390
|
isTrial: _zod3.z.boolean().optional(),
|
|
4094
4391
|
platformFeatures: _zod3.z.array(_zod3.z.string()).optional()
|
|
4095
4392
|
});
|
|
4096
|
-
function readOptional(
|
|
4393
|
+
function readOptional(read2) {
|
|
4097
4394
|
try {
|
|
4098
|
-
return
|
|
4395
|
+
return read2();
|
|
4099
4396
|
} catch (e2) {
|
|
4100
4397
|
return void 0;
|
|
4101
4398
|
}
|
|
@@ -4110,25 +4407,25 @@ function priceToSeed(price) {
|
|
|
4110
4407
|
const priceType = readOptional(() => price.priceType);
|
|
4111
4408
|
const currency = readOptional(() => price.currency);
|
|
4112
4409
|
const recurring = price.recurring;
|
|
4113
|
-
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"));
|
|
4114
4411
|
const seed = {
|
|
4115
4412
|
unitAmount: _nullishCoalesce(price.unitAmount, () => ( 0)),
|
|
4116
4413
|
currency: _nullishCoalesce(currency, () => ( "usd")),
|
|
4117
4414
|
interval
|
|
4118
4415
|
};
|
|
4119
4416
|
if (interval !== "one_time") {
|
|
4120
|
-
if (typeof _optionalChain([recurring, 'optionalAccess',
|
|
4121
|
-
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;
|
|
4122
4419
|
}
|
|
4123
|
-
const nickname = _optionalChain([price, 'access',
|
|
4420
|
+
const nickname = _optionalChain([price, 'access', _169 => _169.nickname, 'optionalAccess', _170 => _170.trim, 'call', _171 => _171()]);
|
|
4124
4421
|
if (nickname) seed.nickname = nickname;
|
|
4125
|
-
const description = _optionalChain([price, 'access',
|
|
4422
|
+
const description = _optionalChain([price, 'access', _172 => _172.description, 'optionalAccess', _173 => _173.trim, 'call', _174 => _174()]);
|
|
4126
4423
|
if (description) seed.description = description;
|
|
4127
4424
|
const features = nonEmptyStrings(price.features);
|
|
4128
4425
|
if (features.length > 0) seed.features = features;
|
|
4129
4426
|
if (typeof price.token === "number" && !Number.isNaN(price.token)) seed.token = price.token;
|
|
4130
4427
|
if (typeof price.isTrial === "boolean") seed.isTrial = price.isTrial;
|
|
4131
|
-
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)]));
|
|
4132
4429
|
if (platformFeatures.length > 0) seed.platformFeatures = platformFeatures;
|
|
4133
4430
|
return seed;
|
|
4134
4431
|
}
|
|
@@ -4191,10 +4488,10 @@ function PricesList({ productId, fullWidth }) {
|
|
|
4191
4488
|
const importInputRef = _react.useRef.call(void 0, null);
|
|
4192
4489
|
const [seed, setSeed] = _react.useState.call(void 0, void 0);
|
|
4193
4490
|
const [seedNonce, setSeedNonce] = _react.useState.call(void 0, 0);
|
|
4194
|
-
const data =
|
|
4195
|
-
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"),
|
|
4196
4493
|
retrieverParams: {},
|
|
4197
|
-
module:
|
|
4494
|
+
module: _chunk5TH2DSAHjs.Modules.StripePrice
|
|
4198
4495
|
});
|
|
4199
4496
|
_react.useEffect.call(void 0, () => {
|
|
4200
4497
|
if (priceVersion > 0) void data.refresh();
|
|
@@ -4221,7 +4518,7 @@ function PricesList({ productId, fullWidth }) {
|
|
|
4221
4518
|
const onImportFileChange = _react.useCallback.call(void 0,
|
|
4222
4519
|
async (event) => {
|
|
4223
4520
|
const input = event.target;
|
|
4224
|
-
const file = _optionalChain([input, 'access',
|
|
4521
|
+
const file = _optionalChain([input, 'access', _178 => _178.files, 'optionalAccess', _179 => _179[0]]);
|
|
4225
4522
|
input.value = "";
|
|
4226
4523
|
if (!file) return;
|
|
4227
4524
|
try {
|
|
@@ -4229,7 +4526,7 @@ function PricesList({ productId, fullWidth }) {
|
|
|
4229
4526
|
openSeededEditor(transfer.price);
|
|
4230
4527
|
} catch (error) {
|
|
4231
4528
|
console.error("[PricesList] price import failed", error);
|
|
4232
|
-
|
|
4529
|
+
_chunkZCOPOO7Tjs.errorToast.call(void 0, {
|
|
4233
4530
|
title: t("billing.admin.prices.import.errors.title"),
|
|
4234
4531
|
error: t("billing.admin.prices.import.errors.invalid")
|
|
4235
4532
|
});
|
|
@@ -4248,7 +4545,7 @@ function PricesList({ productId, fullWidth }) {
|
|
|
4248
4545
|
"create-price"
|
|
4249
4546
|
),
|
|
4250
4547
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.Fragment, { children: [
|
|
4251
|
-
/* @__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: [
|
|
4252
4549
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.UploadIcon, {}),
|
|
4253
4550
|
t("billing.admin.prices.actions.import")
|
|
4254
4551
|
] }),
|
|
@@ -4266,7 +4563,7 @@ function PricesList({ productId, fullWidth }) {
|
|
|
4266
4563
|
];
|
|
4267
4564
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
4268
4565
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4269
|
-
|
|
4566
|
+
_chunkZCOPOO7Tjs.ContentListTable,
|
|
4270
4567
|
{
|
|
4271
4568
|
data,
|
|
4272
4569
|
fields: [
|
|
@@ -4277,13 +4574,13 @@ function PricesList({ productId, fullWidth }) {
|
|
|
4277
4574
|
"status" /* status */,
|
|
4278
4575
|
"actions" /* actions */
|
|
4279
4576
|
],
|
|
4280
|
-
tableGeneratorType:
|
|
4577
|
+
tableGeneratorType: _chunk5TH2DSAHjs.Modules.StripePrice,
|
|
4281
4578
|
functions,
|
|
4282
4579
|
context: tableContext,
|
|
4283
4580
|
fullWidth,
|
|
4284
4581
|
title: t("billing.admin.prices.title"),
|
|
4285
4582
|
emptyState: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4286
|
-
|
|
4583
|
+
_chunkZCOPOO7Tjs.EmptyState,
|
|
4287
4584
|
{
|
|
4288
4585
|
icon: _lucidereact.DollarSignIcon,
|
|
4289
4586
|
title: t("billing.admin.prices.empty.title"),
|
|
@@ -4323,18 +4620,18 @@ function ProductDetails() {
|
|
|
4323
4620
|
const { product } = useProductContext();
|
|
4324
4621
|
if (!product) return null;
|
|
4325
4622
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-y-4", children: [
|
|
4326
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4623
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkZCOPOO7Tjs.SectionHeader, { children: t("billing.admin.products.tabs.details") }),
|
|
4327
4624
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [
|
|
4328
|
-
/* @__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 }),
|
|
4329
4626
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4330
|
-
|
|
4627
|
+
_chunkZCOPOO7Tjs.DetailField,
|
|
4331
4628
|
{
|
|
4332
4629
|
label: t("billing.admin.products.fields.status"),
|
|
4333
|
-
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") })
|
|
4334
4631
|
}
|
|
4335
4632
|
),
|
|
4336
4633
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4337
|
-
|
|
4634
|
+
_chunkZCOPOO7Tjs.DetailField,
|
|
4338
4635
|
{
|
|
4339
4636
|
label: t("billing.admin.products.fields.description"),
|
|
4340
4637
|
value: _nullishCoalesce(product.description, () => ( "\u2014")),
|
|
@@ -4342,14 +4639,14 @@ function ProductDetails() {
|
|
|
4342
4639
|
}
|
|
4343
4640
|
),
|
|
4344
4641
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4345
|
-
|
|
4642
|
+
_chunkZCOPOO7Tjs.DetailField,
|
|
4346
4643
|
{
|
|
4347
4644
|
label: t("billing.admin.products.fields.prices"),
|
|
4348
4645
|
value: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tabular-nums", children: product.stripePrices.length })
|
|
4349
4646
|
}
|
|
4350
4647
|
),
|
|
4351
4648
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4352
|
-
|
|
4649
|
+
_chunkZCOPOO7Tjs.DetailField,
|
|
4353
4650
|
{
|
|
4354
4651
|
label: t("billing.admin.products.fields.stripeId"),
|
|
4355
4652
|
value: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tabular-nums", children: product.stripeProductId })
|
|
@@ -4367,9 +4664,9 @@ function ProductContainer() {
|
|
|
4367
4664
|
const { product } = useProductContext();
|
|
4368
4665
|
if (!product) return null;
|
|
4369
4666
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4370
|
-
|
|
4667
|
+
_chunkZCOPOO7Tjs.RoundPageContainer,
|
|
4371
4668
|
{
|
|
4372
|
-
module:
|
|
4669
|
+
module: _chunk5TH2DSAHjs.Modules.StripeProduct,
|
|
4373
4670
|
id: product.id,
|
|
4374
4671
|
tabs: [
|
|
4375
4672
|
{
|
|
@@ -4378,7 +4675,7 @@ function ProductContainer() {
|
|
|
4378
4675
|
content: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ProductDetails, {})
|
|
4379
4676
|
},
|
|
4380
4677
|
{
|
|
4381
|
-
key:
|
|
4678
|
+
key: _chunk5TH2DSAHjs.Modules.StripePrice,
|
|
4382
4679
|
label: t("billing.admin.prices.title"),
|
|
4383
4680
|
// publishChrome={false}: SharedProvider REPLACES its value for the
|
|
4384
4681
|
// subtree (SharedContext.tsx:35-37), so a nested provider publishing
|
|
@@ -4394,6 +4691,54 @@ function ProductContainer() {
|
|
|
4394
4691
|
}
|
|
4395
4692
|
_chunk7QVYU63Ejs.__name.call(void 0, ProductContainer, "ProductContainer");
|
|
4396
4693
|
|
|
4694
|
+
// src/features/billing/stripe-product/components/containers/ProductsListContainer.tsx
|
|
4695
|
+
|
|
4696
|
+
|
|
4697
|
+
// src/features/billing/stripe-coupon/components/lists/CouponsList.tsx
|
|
4698
|
+
|
|
4699
|
+
|
|
4700
|
+
|
|
4701
|
+
|
|
4702
|
+
function CouponsList({ fullWidth } = {}) {
|
|
4703
|
+
const t = _nextintl.useTranslations.call(void 0, );
|
|
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"),
|
|
4707
|
+
retrieverParams: {},
|
|
4708
|
+
module: _chunk5TH2DSAHjs.Modules.StripeCoupon
|
|
4709
|
+
});
|
|
4710
|
+
_react.useEffect.call(void 0, () => {
|
|
4711
|
+
if (catalogueVersion > 0) void data.refresh();
|
|
4712
|
+
}, [catalogueVersion]);
|
|
4713
|
+
const functions = [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkZCOPOO7Tjs.CouponEditor, {}, "create-coupon")];
|
|
4714
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4715
|
+
_chunkZCOPOO7Tjs.ContentListTable,
|
|
4716
|
+
{
|
|
4717
|
+
data,
|
|
4718
|
+
fields: [
|
|
4719
|
+
"name" /* name */,
|
|
4720
|
+
"discount" /* discount */,
|
|
4721
|
+
"places" /* places */,
|
|
4722
|
+
"codes" /* codes */,
|
|
4723
|
+
"status" /* status */
|
|
4724
|
+
],
|
|
4725
|
+
tableGeneratorType: _chunk5TH2DSAHjs.Modules.StripeCoupon,
|
|
4726
|
+
functions,
|
|
4727
|
+
fullWidth,
|
|
4728
|
+
title: t("billing.admin.coupons.title"),
|
|
4729
|
+
emptyState: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4730
|
+
_chunkZCOPOO7Tjs.EmptyState,
|
|
4731
|
+
{
|
|
4732
|
+
icon: _lucidereact.TicketPercentIcon,
|
|
4733
|
+
title: t("billing.admin.coupons.empty.title"),
|
|
4734
|
+
description: t("billing.admin.coupons.empty.description")
|
|
4735
|
+
}
|
|
4736
|
+
)
|
|
4737
|
+
}
|
|
4738
|
+
);
|
|
4739
|
+
}
|
|
4740
|
+
_chunk7QVYU63Ejs.__name.call(void 0, CouponsList, "CouponsList");
|
|
4741
|
+
|
|
4397
4742
|
// src/features/billing/stripe-product/components/lists/ProductsList.tsx
|
|
4398
4743
|
|
|
4399
4744
|
|
|
@@ -4402,26 +4747,26 @@ _chunk7QVYU63Ejs.__name.call(void 0, ProductContainer, "ProductContainer");
|
|
|
4402
4747
|
function ProductsList({ fullWidth } = {}) {
|
|
4403
4748
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
4404
4749
|
const { catalogueVersion } = useProductContext();
|
|
4405
|
-
const data =
|
|
4406
|
-
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"),
|
|
4407
4752
|
retrieverParams: {},
|
|
4408
|
-
module:
|
|
4753
|
+
module: _chunk5TH2DSAHjs.Modules.StripeProduct
|
|
4409
4754
|
});
|
|
4410
4755
|
_react.useEffect.call(void 0, () => {
|
|
4411
4756
|
if (catalogueVersion > 0) void data.refresh();
|
|
4412
4757
|
}, [catalogueVersion]);
|
|
4413
4758
|
const functions = [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ProductEditor, {}, "create-product")];
|
|
4414
4759
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4415
|
-
|
|
4760
|
+
_chunkZCOPOO7Tjs.ContentListTable,
|
|
4416
4761
|
{
|
|
4417
4762
|
data,
|
|
4418
4763
|
fields: ["name" /* name */, "status" /* status */, "prices" /* prices */],
|
|
4419
|
-
tableGeneratorType:
|
|
4764
|
+
tableGeneratorType: _chunk5TH2DSAHjs.Modules.StripeProduct,
|
|
4420
4765
|
functions,
|
|
4421
4766
|
fullWidth,
|
|
4422
4767
|
title: t("billing.admin.products.title"),
|
|
4423
4768
|
emptyState: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4424
|
-
|
|
4769
|
+
_chunkZCOPOO7Tjs.EmptyState,
|
|
4425
4770
|
{
|
|
4426
4771
|
icon: _lucidereact.PackageIcon,
|
|
4427
4772
|
title: t("billing.admin.products.empty.title"),
|
|
@@ -4436,10 +4781,242 @@ _chunk7QVYU63Ejs.__name.call(void 0, ProductsList, "ProductsList");
|
|
|
4436
4781
|
// src/features/billing/stripe-product/components/containers/ProductsListContainer.tsx
|
|
4437
4782
|
|
|
4438
4783
|
function ProductsListContainer() {
|
|
4439
|
-
|
|
4784
|
+
const t = _nextintl.useTranslations.call(void 0, );
|
|
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,
|
|
4787
|
+
{
|
|
4788
|
+
module: _chunk5TH2DSAHjs.Modules.StripeProduct,
|
|
4789
|
+
tabs: [
|
|
4790
|
+
{ sectionKey: "products", label: t("billing.admin.products.tabs.products"), content: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ProductsList, {}) },
|
|
4791
|
+
{ sectionKey: "codes", label: t("billing.admin.products.tabs.codes"), content: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CouponsList, {}) }
|
|
4792
|
+
]
|
|
4793
|
+
}
|
|
4794
|
+
) }) });
|
|
4440
4795
|
}
|
|
4441
4796
|
_chunk7QVYU63Ejs.__name.call(void 0, ProductsListContainer, "ProductsListContainer");
|
|
4442
4797
|
|
|
4798
|
+
// src/features/billing/stripe-coupon/components/containers/CouponContainer.tsx
|
|
4799
|
+
|
|
4800
|
+
|
|
4801
|
+
// src/features/billing/stripe-coupon/components/details/CouponDetails.tsx
|
|
4802
|
+
|
|
4803
|
+
|
|
4804
|
+
function CouponDetails() {
|
|
4805
|
+
const t = _nextintl.useTranslations.call(void 0, );
|
|
4806
|
+
const fmt = _chunkZCOPOO7Tjs.useBillingFormatOptions.call(void 0, );
|
|
4807
|
+
const { coupon } = _chunkZCOPOO7Tjs.useCouponContext.call(void 0, );
|
|
4808
|
+
if (!coupon) return null;
|
|
4809
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-y-4", children: [
|
|
4810
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkZCOPOO7Tjs.SectionHeader, { children: t("billing.admin.products.tabs.details") }),
|
|
4811
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-muted-foreground text-xs/relaxed", children: t("billing.admin.coupons.fixed_notice") }),
|
|
4812
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [
|
|
4813
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkZCOPOO7Tjs.DetailField, { label: t("billing.admin.coupons.fields.name"), value: coupon.name }),
|
|
4814
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4815
|
+
_chunkZCOPOO7Tjs.DetailField,
|
|
4816
|
+
{
|
|
4817
|
+
label: t("billing.admin.coupons.fields.status"),
|
|
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") })
|
|
4819
|
+
}
|
|
4820
|
+
),
|
|
4821
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
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,
|
|
4830
|
+
{
|
|
4831
|
+
label: t("billing.admin.coupons.fields.places"),
|
|
4832
|
+
value: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tabular-nums", children: coupon.maxRedemptions !== void 0 ? t("billing.admin.coupons.places.limited", {
|
|
4833
|
+
used: String(coupon.timesRedeemed),
|
|
4834
|
+
limit: String(coupon.maxRedemptions)
|
|
4835
|
+
}) : t("billing.admin.coupons.places.unlimited", { used: String(coupon.timesRedeemed) }) })
|
|
4836
|
+
}
|
|
4837
|
+
),
|
|
4838
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4839
|
+
_chunkZCOPOO7Tjs.DetailField,
|
|
4840
|
+
{
|
|
4841
|
+
label: t("billing.admin.coupons.fields.products"),
|
|
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")
|
|
4843
|
+
}
|
|
4844
|
+
),
|
|
4845
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4846
|
+
_chunkZCOPOO7Tjs.DetailField,
|
|
4847
|
+
{
|
|
4848
|
+
label: t("billing.admin.coupons.fields.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" })
|
|
4850
|
+
}
|
|
4851
|
+
),
|
|
4852
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4853
|
+
_chunkZCOPOO7Tjs.DetailField,
|
|
4854
|
+
{
|
|
4855
|
+
label: t("billing.admin.coupons.fields.stripeId"),
|
|
4856
|
+
value: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tabular-nums", children: coupon.stripeCouponId })
|
|
4857
|
+
}
|
|
4858
|
+
)
|
|
4859
|
+
] })
|
|
4860
|
+
] });
|
|
4861
|
+
}
|
|
4862
|
+
_chunk7QVYU63Ejs.__name.call(void 0, CouponDetails, "CouponDetails");
|
|
4863
|
+
|
|
4864
|
+
// src/features/billing/stripe-coupon/components/lists/CouponCodesList.tsx
|
|
4865
|
+
|
|
4866
|
+
|
|
4867
|
+
|
|
4868
|
+
|
|
4869
|
+
// src/features/billing/stripe-coupon/components/forms/CouponCodeEditor.tsx
|
|
4870
|
+
|
|
4871
|
+
|
|
4872
|
+
|
|
4873
|
+
|
|
4874
|
+
|
|
4875
|
+
|
|
4876
|
+
|
|
4877
|
+
function CouponCodeEditorInternal({
|
|
4878
|
+
couponId,
|
|
4879
|
+
onSuccess,
|
|
4880
|
+
trigger,
|
|
4881
|
+
forceShow,
|
|
4882
|
+
onClose,
|
|
4883
|
+
dialogOpen,
|
|
4884
|
+
onDialogOpenChange
|
|
4885
|
+
}) {
|
|
4886
|
+
const t = _nextintl.useTranslations.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, ) }), []);
|
|
4891
|
+
const form = _reacthookform.useForm.call(void 0, {
|
|
4892
|
+
resolver: _zod.zodResolver.call(void 0, formSchema2),
|
|
4893
|
+
defaultValues: getDefaultValues()
|
|
4894
|
+
});
|
|
4895
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4896
|
+
_chunkZCOPOO7Tjs.EditorSheet,
|
|
4897
|
+
{
|
|
4898
|
+
form,
|
|
4899
|
+
entityType: t("billing.admin.coupons.codes.entity"),
|
|
4900
|
+
isEdit: false,
|
|
4901
|
+
module: _chunk5TH2DSAHjs.Modules.StripeCouponCode,
|
|
4902
|
+
size: "md",
|
|
4903
|
+
onSuccess: _nullishCoalesce(onSuccess, () => ( (() => {
|
|
4904
|
+
}))),
|
|
4905
|
+
onNavigate: (url) => router.push(url),
|
|
4906
|
+
onSubmit: async (values) => await createCode({ id: values.id, couponId, ..._chunkZCOPOO7Tjs.toCouponCodeInput.call(void 0, values) }),
|
|
4907
|
+
onReset: getDefaultValues,
|
|
4908
|
+
trigger,
|
|
4909
|
+
forceShow,
|
|
4910
|
+
onClose,
|
|
4911
|
+
dialogOpen,
|
|
4912
|
+
onDialogOpenChange,
|
|
4913
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkZCOPOO7Tjs.CouponCodeFields, { form })
|
|
4914
|
+
}
|
|
4915
|
+
);
|
|
4916
|
+
}
|
|
4917
|
+
_chunk7QVYU63Ejs.__name.call(void 0, CouponCodeEditorInternal, "CouponCodeEditorInternal");
|
|
4918
|
+
function CouponCodeEditor(props) {
|
|
4919
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CouponCodeEditorInternal, { ...props });
|
|
4920
|
+
}
|
|
4921
|
+
_chunk7QVYU63Ejs.__name.call(void 0, CouponCodeEditor, "CouponCodeEditor");
|
|
4922
|
+
|
|
4923
|
+
// src/features/billing/stripe-coupon/components/lists/CouponCodesList.tsx
|
|
4924
|
+
|
|
4925
|
+
function CouponCodesList({ couponId }) {
|
|
4926
|
+
const t = _nextintl.useTranslations.call(void 0, );
|
|
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"),
|
|
4930
|
+
retrieverParams: {},
|
|
4931
|
+
module: _chunk5TH2DSAHjs.Modules.StripeCouponCode
|
|
4932
|
+
});
|
|
4933
|
+
_react.useEffect.call(void 0, () => {
|
|
4934
|
+
if (catalogueVersion > 0) void data.refresh();
|
|
4935
|
+
}, [catalogueVersion]);
|
|
4936
|
+
const functions = [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CouponCodeEditor, { couponId }, "create-code")];
|
|
4937
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4938
|
+
_chunkZCOPOO7Tjs.ContentListTable,
|
|
4939
|
+
{
|
|
4940
|
+
data,
|
|
4941
|
+
fields: [
|
|
4942
|
+
"code" /* code */,
|
|
4943
|
+
"places" /* places */,
|
|
4944
|
+
"expiresAt" /* expiresAt */,
|
|
4945
|
+
"automatic" /* automatic */,
|
|
4946
|
+
"status" /* status */,
|
|
4947
|
+
"actions" /* actions */
|
|
4948
|
+
],
|
|
4949
|
+
tableGeneratorType: _chunk5TH2DSAHjs.Modules.StripeCouponCode,
|
|
4950
|
+
functions,
|
|
4951
|
+
title: t("billing.admin.coupons.codes.title"),
|
|
4952
|
+
emptyState: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4953
|
+
_chunkZCOPOO7Tjs.EmptyState,
|
|
4954
|
+
{
|
|
4955
|
+
icon: _lucidereact.TicketIcon,
|
|
4956
|
+
title: t("billing.admin.coupons.codes.empty.title"),
|
|
4957
|
+
description: t("billing.admin.coupons.codes.empty.description")
|
|
4958
|
+
}
|
|
4959
|
+
)
|
|
4960
|
+
}
|
|
4961
|
+
);
|
|
4962
|
+
}
|
|
4963
|
+
_chunk7QVYU63Ejs.__name.call(void 0, CouponCodesList, "CouponCodesList");
|
|
4964
|
+
|
|
4965
|
+
// src/features/billing/stripe-coupon/components/containers/CouponContainer.tsx
|
|
4966
|
+
|
|
4967
|
+
function CouponContainer() {
|
|
4968
|
+
const t = _nextintl.useTranslations.call(void 0, );
|
|
4969
|
+
const { coupon } = _chunkZCOPOO7Tjs.useCouponContext.call(void 0, );
|
|
4970
|
+
if (!coupon) return null;
|
|
4971
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4972
|
+
_chunkZCOPOO7Tjs.RoundPageContainer,
|
|
4973
|
+
{
|
|
4974
|
+
module: _chunk5TH2DSAHjs.Modules.StripeCoupon,
|
|
4975
|
+
id: coupon.id,
|
|
4976
|
+
tabs: [
|
|
4977
|
+
{
|
|
4978
|
+
sectionKey: "details",
|
|
4979
|
+
label: t("billing.admin.products.tabs.details"),
|
|
4980
|
+
content: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CouponDetails, {})
|
|
4981
|
+
},
|
|
4982
|
+
{
|
|
4983
|
+
sectionKey: "codes",
|
|
4984
|
+
label: t("billing.admin.coupons.codes.title"),
|
|
4985
|
+
// No `fillHeight` and no `fullWidth` on the list: a ContentListTable in
|
|
4986
|
+
// a tab keeps its own bordered card and flows with the panel, exactly
|
|
4987
|
+
// as PricesList does inside ProductContainer. The codes list reads the
|
|
4988
|
+
// page's own CouponProvider, so no nested provider is needed.
|
|
4989
|
+
content: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CouponCodesList, { couponId: coupon.id })
|
|
4990
|
+
}
|
|
4991
|
+
]
|
|
4992
|
+
}
|
|
4993
|
+
);
|
|
4994
|
+
}
|
|
4995
|
+
_chunk7QVYU63Ejs.__name.call(void 0, CouponContainer, "CouponContainer");
|
|
4996
|
+
|
|
4997
|
+
|
|
4998
|
+
|
|
4999
|
+
|
|
5000
|
+
|
|
5001
|
+
|
|
5002
|
+
|
|
5003
|
+
|
|
5004
|
+
|
|
5005
|
+
|
|
5006
|
+
|
|
5007
|
+
|
|
5008
|
+
|
|
5009
|
+
|
|
5010
|
+
|
|
5011
|
+
|
|
5012
|
+
|
|
5013
|
+
|
|
5014
|
+
|
|
5015
|
+
|
|
5016
|
+
|
|
5017
|
+
|
|
5018
|
+
|
|
5019
|
+
|
|
4443
5020
|
|
|
4444
5021
|
|
|
4445
5022
|
|
|
@@ -4501,5 +5078,5 @@ _chunk7QVYU63Ejs.__name.call(void 0, ProductsListContainer, "ProductsListContain
|
|
|
4501
5078
|
|
|
4502
5079
|
|
|
4503
5080
|
|
|
4504
|
-
exports.BillingAlertBanner = BillingAlertBanner; exports.BillingDashboardContainer = BillingDashboardContainer; exports.BillingDetailModal = BillingDetailModal; exports.BillingUsageSummaryCard = BillingUsageSummaryCard; exports.CancelSubscriptionDialog = CancelSubscriptionDialog; 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.formatCurrency =
|
|
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;
|
|
4505
5082
|
//# sourceMappingURL=index.js.map
|