@carlonicora/nextjs-jsonapi 1.40.1 → 1.41.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/AuthComponent-BuWc2C4g.d.ts +28 -0
- package/dist/AuthComponent-fLVGdvSr.d.mts +28 -0
- package/dist/{BlockNoteEditor-EKY4AHVK.mjs → BlockNoteEditor-B3RQ4VQ7.mjs} +5 -5
- package/dist/{BlockNoteEditor-4G3L3LSF.js → BlockNoteEditor-VUAWVZF4.js} +15 -15
- package/dist/{BlockNoteEditor-4G3L3LSF.js.map → BlockNoteEditor-VUAWVZF4.js.map} +1 -1
- package/dist/JsonApiRequest-MUPAO7DI.js +24 -0
- package/dist/{JsonApiRequest-GR3L56A5.js.map → JsonApiRequest-MUPAO7DI.js.map} +1 -1
- package/dist/{JsonApiRequest-K5BRU7RE.mjs → JsonApiRequest-XCQHVVYD.mjs} +2 -2
- package/dist/auth.interface-8XglqHir.d.mts +33 -0
- package/dist/auth.interface-BJGKQ0zr.d.ts +33 -0
- package/dist/billing/index.js +409 -415
- package/dist/billing/index.js.map +1 -1
- package/dist/billing/index.mjs +4 -10
- package/dist/billing/index.mjs.map +1 -1
- package/dist/{chunk-BAOP6PTD.mjs → chunk-BJNQZGMN.mjs} +1618 -666
- package/dist/chunk-BJNQZGMN.mjs.map +1 -0
- package/dist/{chunk-U4MTVHOC.mjs → chunk-GCQUTWZ2.mjs} +11 -4
- package/dist/{chunk-U4MTVHOC.mjs.map → chunk-GCQUTWZ2.mjs.map} +1 -1
- package/dist/{chunk-ZNGEVB5M.js → chunk-L5F5ZN5F.js} +960 -140
- package/dist/chunk-L5F5ZN5F.js.map +1 -0
- package/dist/{chunk-RRIYLEY6.mjs → chunk-LBIC4GJK.mjs} +2 -2
- package/dist/{chunk-T5YYOT4Z.js → chunk-OODZEX6P.js} +3 -3
- package/dist/{chunk-T5YYOT4Z.js.map → chunk-OODZEX6P.js.map} +1 -1
- package/dist/{chunk-GVN7XC3U.mjs → chunk-PHNL4QUF.mjs} +835 -15
- package/dist/chunk-PHNL4QUF.mjs.map +1 -0
- package/dist/{chunk-GKY5DAIH.js → chunk-QPWHMXE2.js} +1505 -553
- package/dist/chunk-QPWHMXE2.js.map +1 -0
- package/dist/{chunk-FM6WRAN5.js → chunk-WLS4D6VG.js} +12 -5
- package/dist/chunk-WLS4D6VG.js.map +1 -0
- package/dist/client/index.d.mts +4 -4
- package/dist/client/index.d.ts +4 -4
- package/dist/client/index.js +5 -5
- package/dist/client/index.mjs +4 -4
- package/dist/components/index.d.mts +69 -8
- package/dist/components/index.d.ts +69 -8
- package/dist/components/index.js +27 -5
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +26 -4
- package/dist/{config-BxwhHdCD.d.mts → config-BW5u1e9P.d.mts} +1 -1
- package/dist/{config-BbaBV_yk.d.ts → config-BozK5PY0.d.ts} +1 -1
- package/dist/{content.interface-CgUu4771.d.ts → content.interface-CpCDB1Uk.d.ts} +1 -1
- package/dist/{content.interface-CWV0q4lZ.d.mts → content.interface-b-mzkL_q.d.mts} +1 -1
- package/dist/contexts/index.d.mts +2 -2
- package/dist/contexts/index.d.ts +2 -2
- package/dist/contexts/index.js +5 -5
- package/dist/contexts/index.mjs +4 -4
- package/dist/core/index.d.mts +407 -7
- package/dist/core/index.d.ts +407 -7
- package/dist/core/index.js +61 -3
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +60 -2
- package/dist/index.d.mts +8 -6
- package/dist/index.d.ts +8 -6
- package/dist/index.js +62 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +61 -3
- package/dist/{notification.interface-XARGKJAq.d.ts → notification.interface-CR2PuV6Y.d.ts} +1 -0
- package/dist/{notification.interface-DIln2r7X.d.mts → notification.interface-D241WNUx.d.mts} +1 -0
- package/dist/{s3.service-BoOF5-ln.d.mts → s3.service-D0rbmLFp.d.mts} +10 -31
- package/dist/{s3.service-Mxo-7wQ6.d.ts → s3.service-DOwqcUDT.d.ts} +10 -31
- package/dist/scripts/generate-web-module/generator.js +26 -26
- package/dist/scripts/generate-web-module/generator.js.map +1 -1
- package/dist/scripts/generate-web-module/utils/file-writer.js +9 -9
- package/dist/scripts/generate-web-module/utils/file-writer.js.map +1 -1
- package/dist/server/index.d.mts +4 -3
- package/dist/server/index.d.ts +4 -3
- package/dist/server/index.js +12 -12
- package/dist/server/index.mjs +2 -2
- package/dist/{useSocket-awibcC9B.d.ts → useSocket-CC8SkXdm.d.ts} +1 -1
- package/dist/{useSocket-BILAdmZ0.d.mts → useSocket-CttIHn2P.d.mts} +1 -1
- package/package.json +4 -1
- package/scripts/generate-web-module/generator.ts +26 -26
- package/scripts/generate-web-module/utils/file-writer.ts +9 -9
- package/src/components/pages/PageContentContainer.tsx +22 -9
- package/src/core/abstracts/AbstractService.ts +2 -0
- package/src/core/factories/JsonApiDataFactory.ts +2 -1
- package/src/core/index.ts +14 -0
- package/src/core/registry/DataClassRegistry.ts +7 -1
- package/src/core/registry/ModuleRegistry.ts +15 -0
- package/src/features/auth/backup-code-verify.module.ts +9 -0
- package/src/features/auth/components/containers/SecurityContainer.tsx +11 -0
- package/src/features/auth/components/containers/index.ts +1 -0
- package/src/features/auth/components/forms/Login.tsx +15 -3
- package/src/features/auth/components/forms/Register.tsx +1 -9
- package/src/features/auth/components/forms/TwoFactorChallenge.tsx +202 -0
- package/src/features/auth/components/forms/index.ts +1 -0
- package/src/features/auth/components/index.ts +1 -0
- package/src/features/auth/components/two-factor/BackupCodesDialog.tsx +148 -0
- package/src/features/auth/components/two-factor/DisableTwoFactorDialog.tsx +74 -0
- package/src/features/auth/components/two-factor/PasskeyButton.tsx +59 -0
- package/src/features/auth/components/two-factor/PasskeyList.tsx +172 -0
- package/src/features/auth/components/two-factor/PasskeySetupDialog.tsx +105 -0
- package/src/features/auth/components/two-factor/TotpAuthenticatorList.tsx +104 -0
- package/src/features/auth/components/two-factor/TotpInput.tsx +90 -0
- package/src/features/auth/components/two-factor/TotpSetupDialog.tsx +161 -0
- package/src/features/auth/components/two-factor/TwoFactorSettings.tsx +175 -0
- package/src/features/auth/components/two-factor/index.ts +9 -0
- package/src/features/auth/contexts/AuthContext.tsx +9 -0
- package/src/features/auth/data/auth.service.ts +18 -1
- package/src/features/auth/data/backup-code-verify.ts +20 -0
- package/src/features/auth/data/index.ts +21 -0
- package/src/features/auth/data/passkey-authentication-options.interface.ts +7 -0
- package/src/features/auth/data/passkey-authentication-options.ts +37 -0
- package/src/features/auth/data/passkey-registration-options.ts +46 -0
- package/src/features/auth/data/passkey-registration-verify.ts +62 -0
- package/src/features/auth/data/passkey-rename.ts +20 -0
- package/src/features/auth/data/passkey-verify-login.ts +23 -0
- package/src/features/auth/data/passkey.interface.ts +9 -0
- package/src/features/auth/data/passkey.ts +40 -0
- package/src/features/auth/data/totp-authenticator.interface.ts +7 -0
- package/src/features/auth/data/totp-authenticator.ts +28 -0
- package/src/features/auth/data/totp-setup.interface.ts +5 -0
- package/src/features/auth/data/totp-setup.ts +48 -0
- package/src/features/auth/data/totp-verify-login.ts +20 -0
- package/src/features/auth/data/totp-verify.ts +22 -0
- package/src/features/auth/data/two-factor-challenge.interface.ts +7 -0
- package/src/features/auth/data/two-factor-challenge.ts +45 -0
- package/src/features/auth/data/two-factor-enable.ts +20 -0
- package/src/features/auth/data/two-factor-status.interface.ts +11 -0
- package/src/features/auth/data/two-factor-status.ts +40 -0
- package/src/features/auth/data/two-factor.service.ts +331 -0
- package/src/features/auth/enums/AuthComponent.ts +1 -0
- package/src/features/auth/index.ts +13 -0
- package/src/features/auth/passkey-authentication-options.module.ts +9 -0
- package/src/features/auth/passkey-registration-options.module.ts +9 -0
- package/src/features/auth/passkey-registration-verify.module.ts +9 -0
- package/src/features/auth/passkey-rename.module.ts +9 -0
- package/src/features/auth/passkey-verify-login.module.ts +9 -0
- package/src/features/auth/passkey.module.ts +9 -0
- package/src/features/auth/totp-authenticator.module.ts +9 -0
- package/src/features/auth/totp-setup.module.ts +9 -0
- package/src/features/auth/totp-verify-login.module.ts +9 -0
- package/src/features/auth/totp-verify.module.ts +9 -0
- package/src/features/auth/two-factor-challenge.module.ts +9 -0
- package/src/features/auth/two-factor-enable.module.ts +9 -0
- package/src/features/auth/two-factor-status.module.ts +9 -0
- package/src/features/billing/modules/billing.module.ts +1 -0
- package/src/features/billing/stripe-customer/stripe-customer.module.ts +1 -0
- package/src/features/billing/stripe-customer/stripe-payment-method.module.ts +1 -0
- package/src/features/billing/stripe-invoice/stripe-invoice.module.ts +1 -0
- package/src/features/billing/stripe-price/stripe-price.module.ts +1 -0
- package/src/features/billing/stripe-product/stripe-product.module.ts +1 -0
- package/src/features/billing/stripe-promotion-code/stripe-promotion-code.module.ts +1 -0
- package/src/features/billing/stripe-subscription/data/stripe-subscription.ts +0 -5
- package/src/features/billing/stripe-subscription/hooks/useSubscriptionWizard.ts +0 -8
- package/src/features/billing/stripe-subscription/stripe-subscription.module.ts +1 -0
- package/src/features/billing/stripe-usage/stripe-usage.module.ts +1 -0
- package/src/features/user/data/user.interface.ts +1 -0
- package/src/features/user/data/user.ts +6 -0
- package/src/features/waitlist/data/WaitlistService.ts +1 -8
- package/src/features/waitlist/waitlist-stats.module.ts +1 -0
- package/src/shadcnui/ui/resizable.tsx +33 -11
- package/src/unified/JsonApiRequest.ts +2 -1
- package/dist/AuthComponent-hxOPs9o8.d.mts +0 -11
- package/dist/AuthComponent-hxOPs9o8.d.ts +0 -11
- package/dist/JsonApiRequest-GR3L56A5.js +0 -24
- package/dist/chunk-BAOP6PTD.mjs.map +0 -1
- package/dist/chunk-FM6WRAN5.js.map +0 -1
- package/dist/chunk-GKY5DAIH.js.map +0 -1
- package/dist/chunk-GVN7XC3U.mjs.map +0 -1
- package/dist/chunk-ZNGEVB5M.js.map +0 -1
- /package/dist/{BlockNoteEditor-EKY4AHVK.mjs.map → BlockNoteEditor-B3RQ4VQ7.mjs.map} +0 -0
- /package/dist/{JsonApiRequest-K5BRU7RE.mjs.map → JsonApiRequest-XCQHVVYD.mjs.map} +0 -0
- /package/dist/{chunk-RRIYLEY6.mjs.map → chunk-LBIC4GJK.mjs.map} +0 -0
package/dist/billing/index.js
CHANGED
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
var
|
|
50
|
+
var _chunkQPWHMXE2js = require('../chunk-QPWHMXE2.js');
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
var
|
|
54
|
+
var _chunkOODZEX6Pjs = require('../chunk-OODZEX6P.js');
|
|
55
55
|
|
|
56
56
|
|
|
57
57
|
|
|
@@ -62,10 +62,10 @@ var _chunkT5YYOT4Zjs = require('../chunk-T5YYOT4Z.js');
|
|
|
62
62
|
|
|
63
63
|
|
|
64
64
|
|
|
65
|
-
var
|
|
65
|
+
var _chunkL5F5ZN5Fjs = require('../chunk-L5F5ZN5F.js');
|
|
66
66
|
require('../chunk-LXKSUWAV.js');
|
|
67
67
|
require('../chunk-IBS6NI7D.js');
|
|
68
|
-
require('../chunk-
|
|
68
|
+
require('../chunk-WLS4D6VG.js');
|
|
69
69
|
require('../chunk-3EPNHTMH.js');
|
|
70
70
|
|
|
71
71
|
|
|
@@ -113,41 +113,41 @@ function SubscriptionSummaryCard({
|
|
|
113
113
|
onManageClick
|
|
114
114
|
}) {
|
|
115
115
|
if (loading) {
|
|
116
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
117
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
118
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
116
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.Card, { children: [
|
|
117
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
118
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardTitle, { className: "text-sm font-medium", children: "Subscriptions" }),
|
|
119
119
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-4 w-4 text-muted-foreground" })
|
|
120
120
|
] }),
|
|
121
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
122
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
123
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
124
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
121
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.CardContent, { children: [
|
|
122
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Skeleton, { className: "h-6 w-32 mb-2" }),
|
|
123
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Skeleton, { className: "h-4 w-24 mb-1" }),
|
|
124
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Skeleton, { className: "h-4 w-40" })
|
|
125
125
|
] })
|
|
126
126
|
] });
|
|
127
127
|
}
|
|
128
128
|
if (error) {
|
|
129
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
130
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
131
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
129
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.Card, { children: [
|
|
130
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
131
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardTitle, { className: "text-sm font-medium", children: "Subscriptions" }),
|
|
132
132
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-4 w-4 text-muted-foreground" })
|
|
133
133
|
] }),
|
|
134
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
134
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-destructive", children: error }) })
|
|
135
135
|
] });
|
|
136
136
|
}
|
|
137
137
|
const activeSubscriptions = subscriptions.filter(
|
|
138
138
|
(sub) => sub.status === "active" /* ACTIVE */ || sub.status === "trialing" /* TRIALING */
|
|
139
139
|
);
|
|
140
140
|
const primarySubscription = activeSubscriptions[0];
|
|
141
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
142
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
143
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
141
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.Card, { className: "cursor-pointer hover:bg-accent/50 transition-colors", onClick: onManageClick, children: [
|
|
142
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
143
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardTitle, { className: "text-sm font-medium", children: "Subscriptions" }),
|
|
144
144
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-4 w-4 text-muted-foreground" })
|
|
145
145
|
] }),
|
|
146
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
146
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardContent, { children: subscriptions.length === 0 ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
147
147
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold text-muted-foreground", children: "No active plan" }),
|
|
148
148
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: "Subscribe to get started" }),
|
|
149
149
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
150
|
-
|
|
150
|
+
_chunkQPWHMXE2js.Button,
|
|
151
151
|
{
|
|
152
152
|
variant: "outline",
|
|
153
153
|
size: "sm",
|
|
@@ -166,7 +166,7 @@ function SubscriptionSummaryCard({
|
|
|
166
166
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
|
|
167
167
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold", children: formatPlanName(primarySubscription) }),
|
|
168
168
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
169
|
-
|
|
169
|
+
_chunkQPWHMXE2js.Badge,
|
|
170
170
|
{
|
|
171
171
|
variant: primarySubscription.cancelAtPeriodEnd ? "secondary" : getStatusBadgeVariant(primarySubscription.status),
|
|
172
172
|
children: primarySubscription.cancelAtPeriodEnd ? "Canceling" : primarySubscription.status
|
|
@@ -208,37 +208,37 @@ function PaymentMethodSummaryCard({
|
|
|
208
208
|
onManageClick
|
|
209
209
|
}) {
|
|
210
210
|
if (loading) {
|
|
211
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
212
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
213
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
211
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.Card, { children: [
|
|
212
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
213
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardTitle, { className: "text-sm font-medium", children: "Payment Method" }),
|
|
214
214
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Wallet, { className: "h-4 w-4 text-muted-foreground" })
|
|
215
215
|
] }),
|
|
216
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
217
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
218
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
216
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.CardContent, { children: [
|
|
217
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Skeleton, { className: "h-6 w-32 mb-2" }),
|
|
218
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Skeleton, { className: "h-4 w-24" })
|
|
219
219
|
] })
|
|
220
220
|
] });
|
|
221
221
|
}
|
|
222
222
|
if (error) {
|
|
223
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
224
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
225
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
223
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.Card, { children: [
|
|
224
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
225
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardTitle, { className: "text-sm font-medium", children: "Payment Method" }),
|
|
226
226
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Wallet, { className: "h-4 w-4 text-muted-foreground" })
|
|
227
227
|
] }),
|
|
228
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
228
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-destructive", children: error }) })
|
|
229
229
|
] });
|
|
230
230
|
}
|
|
231
231
|
const defaultMethod = paymentMethods.find((pm) => pm.id === defaultPaymentMethodId) || paymentMethods[0];
|
|
232
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
233
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
234
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
232
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.Card, { className: "cursor-pointer hover:bg-accent/50 transition-colors", onClick: onManageClick, children: [
|
|
233
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
234
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardTitle, { className: "text-sm font-medium", children: "Payment Method" }),
|
|
235
235
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Wallet, { className: "h-4 w-4 text-muted-foreground" })
|
|
236
236
|
] }),
|
|
237
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
237
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardContent, { children: paymentMethods.length === 0 ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
238
238
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold text-muted-foreground", children: "No payment method" }),
|
|
239
239
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: "Add a card to enable subscriptions" }),
|
|
240
240
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
241
|
-
|
|
241
|
+
_chunkQPWHMXE2js.Button,
|
|
242
242
|
{
|
|
243
243
|
variant: "outline",
|
|
244
244
|
size: "sm",
|
|
@@ -302,7 +302,7 @@ function CustomerInfoCard({ customer, loading, error }) {
|
|
|
302
302
|
e.stopPropagation();
|
|
303
303
|
setPortalLoading(true);
|
|
304
304
|
try {
|
|
305
|
-
const { url } = await
|
|
305
|
+
const { url } = await _chunkL5F5ZN5Fjs.StripeCustomerService.createPortalSession();
|
|
306
306
|
window.open(url, "_blank");
|
|
307
307
|
} catch (err) {
|
|
308
308
|
console.error("[CustomerInfoCard] Failed to create portal session:", err);
|
|
@@ -311,52 +311,52 @@ function CustomerInfoCard({ customer, loading, error }) {
|
|
|
311
311
|
}
|
|
312
312
|
}, "handlePortalClick");
|
|
313
313
|
if (loading) {
|
|
314
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
315
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
316
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
314
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.Card, { children: [
|
|
315
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
316
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardTitle, { className: "text-sm font-medium", children: "Billing Account" }),
|
|
317
317
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.User, { className: "h-4 w-4 text-muted-foreground" })
|
|
318
318
|
] }),
|
|
319
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
320
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
321
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
322
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
319
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.CardContent, { children: [
|
|
320
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Skeleton, { className: "h-6 w-32 mb-2" }),
|
|
321
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Skeleton, { className: "h-4 w-48 mb-1" }),
|
|
322
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Skeleton, { className: "h-4 w-24" })
|
|
323
323
|
] })
|
|
324
324
|
] });
|
|
325
325
|
}
|
|
326
326
|
if (error) {
|
|
327
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
328
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
329
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
327
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.Card, { children: [
|
|
328
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
329
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardTitle, { className: "text-sm font-medium", children: "Billing Account" }),
|
|
330
330
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.User, { className: "h-4 w-4 text-muted-foreground" })
|
|
331
331
|
] }),
|
|
332
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
332
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-destructive", children: error }) })
|
|
333
333
|
] });
|
|
334
334
|
}
|
|
335
335
|
if (!customer) {
|
|
336
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
337
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
338
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
336
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.Card, { children: [
|
|
337
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
338
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardTitle, { className: "text-sm font-medium", children: "Billing Account" }),
|
|
339
339
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.User, { className: "h-4 w-4 text-muted-foreground" })
|
|
340
340
|
] }),
|
|
341
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
341
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.CardContent, { children: [
|
|
342
342
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold text-muted-foreground", children: "Not set up" }),
|
|
343
343
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: "Billing account will be created when you subscribe" })
|
|
344
344
|
] })
|
|
345
345
|
] });
|
|
346
346
|
}
|
|
347
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
348
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
349
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
347
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.Card, { children: [
|
|
348
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
349
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardTitle, { className: "text-sm font-medium", children: "Billing Account" }),
|
|
350
350
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.User, { className: "h-4 w-4 text-muted-foreground" })
|
|
351
351
|
] }),
|
|
352
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
352
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
353
353
|
customer.name && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold", children: customer.name }),
|
|
354
354
|
customer.email && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: customer.email }),
|
|
355
355
|
customer.balance !== void 0 && customer.balance !== 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-sm", children: [
|
|
356
356
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground", children: "Credit Balance: " }),
|
|
357
357
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: customer.balance < 0 ? "text-green-600" : "text-destructive", children: formatBalance(customer.balance, customer.currency) })
|
|
358
358
|
] }),
|
|
359
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
359
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.Button, { variant: "outline", size: "sm", className: "mt-2", onClick: handlePortalClick, disabled: portalLoading, children: [
|
|
360
360
|
portalLoading ? "Loading..." : "Manage in Stripe Portal",
|
|
361
361
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ExternalLink, { className: "h-4 w-4 ml-1" })
|
|
362
362
|
] })
|
|
@@ -400,42 +400,42 @@ function formatAmount(amount, currency) {
|
|
|
400
400
|
_chunk7QVYU63Ejs.__name.call(void 0, formatAmount, "formatAmount");
|
|
401
401
|
function InvoicesSummaryCard({ invoices, loading, error, onViewAllClick }) {
|
|
402
402
|
if (loading) {
|
|
403
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
404
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
405
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
403
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.Card, { children: [
|
|
404
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
405
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardTitle, { className: "text-sm font-medium", children: "Recent Invoices" }),
|
|
406
406
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ReceiptIcon, { className: "h-4 w-4 text-muted-foreground" })
|
|
407
407
|
] }),
|
|
408
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
409
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
410
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
411
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
408
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.CardContent, { children: [
|
|
409
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Skeleton, { className: "h-6 w-24 mb-2" }),
|
|
410
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Skeleton, { className: "h-4 w-32 mb-1" }),
|
|
411
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Skeleton, { className: "h-4 w-20" })
|
|
412
412
|
] })
|
|
413
413
|
] });
|
|
414
414
|
}
|
|
415
415
|
if (error) {
|
|
416
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
417
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
418
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
416
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.Card, { children: [
|
|
417
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
418
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardTitle, { className: "text-sm font-medium", children: "Recent Invoices" }),
|
|
419
419
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ReceiptIcon, { className: "h-4 w-4 text-muted-foreground" })
|
|
420
420
|
] }),
|
|
421
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
421
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-destructive", children: error }) })
|
|
422
422
|
] });
|
|
423
423
|
}
|
|
424
424
|
const latestInvoice = invoices[0];
|
|
425
425
|
const paidInvoices = invoices.filter((inv) => inv.status === "paid" /* PAID */);
|
|
426
426
|
const openInvoices = invoices.filter((inv) => inv.status === "open" /* OPEN */);
|
|
427
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
428
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
429
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
427
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.Card, { className: "cursor-pointer hover:bg-accent/50 transition-colors", onClick: onViewAllClick, children: [
|
|
428
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
429
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardTitle, { className: "text-sm font-medium", children: "Recent Invoices" }),
|
|
430
430
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ReceiptIcon, { className: "h-4 w-4 text-muted-foreground" })
|
|
431
431
|
] }),
|
|
432
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
432
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardContent, { children: invoices.length === 0 ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
433
433
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold text-muted-foreground", children: "No invoices yet" }),
|
|
434
434
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: "Invoices will appear after your first billing cycle" })
|
|
435
435
|
] }) : latestInvoice ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
436
436
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
|
|
437
437
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold", children: formatAmount(latestInvoice.total, latestInvoice.currency) }),
|
|
438
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
438
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Badge, { variant: getStatusBadgeVariant2(latestInvoice.status), children: latestInvoice.status })
|
|
439
439
|
] }),
|
|
440
440
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: latestInvoice.stripeInvoiceNumber || `Invoice from ${formatDate2(latestInvoice.periodStart)}` }),
|
|
441
441
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-4 text-xs text-muted-foreground", children: [
|
|
@@ -475,24 +475,24 @@ function BillingUsageSummaryCard({
|
|
|
475
475
|
onViewDetailsClick
|
|
476
476
|
}) {
|
|
477
477
|
if (loading) {
|
|
478
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
479
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
480
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
478
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.Card, { children: [
|
|
479
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
480
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardTitle, { className: "text-sm font-medium", children: "Usage This Month" }),
|
|
481
481
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Activity, { className: "h-4 w-4 text-muted-foreground" })
|
|
482
482
|
] }),
|
|
483
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
484
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
485
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
483
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.CardContent, { children: [
|
|
484
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Skeleton, { className: "h-6 w-24 mb-2" }),
|
|
485
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Skeleton, { className: "h-4 w-32" })
|
|
486
486
|
] })
|
|
487
487
|
] });
|
|
488
488
|
}
|
|
489
489
|
if (error) {
|
|
490
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
491
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
492
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
490
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.Card, { children: [
|
|
491
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
492
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardTitle, { className: "text-sm font-medium", children: "Usage This Month" }),
|
|
493
493
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Activity, { className: "h-4 w-4 text-muted-foreground" })
|
|
494
494
|
] }),
|
|
495
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
495
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-destructive", children: error }) })
|
|
496
496
|
] });
|
|
497
497
|
}
|
|
498
498
|
const totalUsage = Object.values(summaries).reduce((acc, summary) => {
|
|
@@ -500,12 +500,12 @@ function BillingUsageSummaryCard({
|
|
|
500
500
|
}, 0);
|
|
501
501
|
const primaryMeter = meters.find((m) => _optionalChain([summaries, 'access', _17 => _17[m.id], 'optionalAccess', _18 => _18.aggregatedValue]));
|
|
502
502
|
const primarySummary = primaryMeter ? summaries[primaryMeter.id] : null;
|
|
503
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
504
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
505
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
503
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.Card, { className: "cursor-pointer hover:bg-accent/50 transition-colors", onClick: onViewDetailsClick, children: [
|
|
504
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
505
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardTitle, { className: "text-sm font-medium", children: "Usage This Month" }),
|
|
506
506
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Activity, { className: "h-4 w-4 text-muted-foreground" })
|
|
507
507
|
] }),
|
|
508
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
508
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardContent, { children: meters.length === 0 ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
509
509
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold text-muted-foreground", children: "No meters" }),
|
|
510
510
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: "No usage meters are configured" })
|
|
511
511
|
] }) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
@@ -557,7 +557,7 @@ function PaymentMethodForm({ onSuccess, onCancel, isLoading = false }) {
|
|
|
557
557
|
const fetchSetupIntent = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
558
558
|
setLoading(true);
|
|
559
559
|
try {
|
|
560
|
-
const intent = await
|
|
560
|
+
const intent = await _chunkL5F5ZN5Fjs.StripeCustomerService.createSetupIntent();
|
|
561
561
|
setSetupIntent(intent);
|
|
562
562
|
} catch (err) {
|
|
563
563
|
console.error("[PaymentMethodForm] Failed to create setup intent:", err);
|
|
@@ -595,7 +595,7 @@ function PaymentMethodForm({ onSuccess, onCancel, isLoading = false }) {
|
|
|
595
595
|
return;
|
|
596
596
|
}
|
|
597
597
|
if (setAsDefault && _optionalChain([confirmedSetupIntent, 'optionalAccess', _19 => _19.payment_method])) {
|
|
598
|
-
await
|
|
598
|
+
await _chunkL5F5ZN5Fjs.StripeCustomerService.setDefaultPaymentMethod({
|
|
599
599
|
paymentMethodId: typeof confirmedSetupIntent.payment_method === "string" ? confirmedSetupIntent.payment_method : confirmedSetupIntent.payment_method.id
|
|
600
600
|
});
|
|
601
601
|
}
|
|
@@ -611,7 +611,7 @@ function PaymentMethodForm({ onSuccess, onCancel, isLoading = false }) {
|
|
|
611
611
|
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: "Loading payment form..." }) });
|
|
612
612
|
}
|
|
613
613
|
if (!setupIntent && error) {
|
|
614
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
614
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Alert, { variant: "destructive", className: "bg-red-50 border-red-200", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.AlertDescription, { children: error }) });
|
|
615
615
|
}
|
|
616
616
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { onSubmit: handleSubmit, className: "flex flex-col gap-y-4", children: [
|
|
617
617
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rounded-md border border-gray-300 p-3", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -634,13 +634,13 @@ function PaymentMethodForm({ onSuccess, onCancel, isLoading = false }) {
|
|
|
634
634
|
}
|
|
635
635
|
) }),
|
|
636
636
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-2", children: [
|
|
637
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
638
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
637
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Checkbox, { id: "setAsDefault", checked: setAsDefault, onCheckedChange: (checked) => setSetAsDefault(!!checked) }),
|
|
638
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Label, { htmlFor: "setAsDefault", className: "text-sm font-normal", children: "Set as default payment method" })
|
|
639
639
|
] }),
|
|
640
|
-
error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
640
|
+
error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Alert, { variant: "destructive", className: "bg-red-50 border-red-200", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.AlertDescription, { children: error }) }),
|
|
641
641
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-end gap-x-2", children: [
|
|
642
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
643
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
642
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Button, { type: "button", variant: "outline", onClick: onCancel, disabled: isSubmitting || isLoading, children: "Cancel" }),
|
|
643
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Button, { type: "submit", disabled: !stripe || isSubmitting || isLoading, children: isSubmitting ? "Processing..." : "Add Card" })
|
|
644
644
|
] })
|
|
645
645
|
] });
|
|
646
646
|
}
|
|
@@ -656,10 +656,10 @@ function PaymentMethodEditor({ open, onOpenChange, onSuccess }) {
|
|
|
656
656
|
const handleCancel = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => {
|
|
657
657
|
onOpenChange(false);
|
|
658
658
|
}, "handleCancel");
|
|
659
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
660
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
661
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
662
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
659
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.DialogContent, { className: "max-w-md", children: [
|
|
660
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.DialogHeader, { children: [
|
|
661
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.DialogTitle, { children: "Add Payment Method" }),
|
|
662
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.DialogDescription, { children: "Add a new payment method to your account. Your card information is securely processed by Stripe." })
|
|
663
663
|
] }),
|
|
664
664
|
open && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PaymentMethodForm, { onSuccess: handleSuccess, onCancel: handleCancel })
|
|
665
665
|
] }) });
|
|
@@ -683,7 +683,7 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
683
683
|
_react.useEffect.call(void 0, () => {
|
|
684
684
|
const loadCustomer = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
685
685
|
try {
|
|
686
|
-
const fetchedCustomer = await
|
|
686
|
+
const fetchedCustomer = await _chunkL5F5ZN5Fjs.StripeCustomerService.getCustomer();
|
|
687
687
|
setCustomer(fetchedCustomer);
|
|
688
688
|
} catch (error) {
|
|
689
689
|
console.error("[PaymentMethodCard] Failed to load customer:", error);
|
|
@@ -700,7 +700,7 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
700
700
|
const handleSetDefault = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
701
701
|
setLoading(true);
|
|
702
702
|
try {
|
|
703
|
-
await
|
|
703
|
+
await _chunkL5F5ZN5Fjs.StripeCustomerService.setDefaultPaymentMethod({ paymentMethodId: paymentMethod.id });
|
|
704
704
|
onUpdate();
|
|
705
705
|
} catch (error) {
|
|
706
706
|
console.error("[PaymentMethodCard] Failed to set as default:", error);
|
|
@@ -711,7 +711,7 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
711
711
|
const handleRemove = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
712
712
|
setLoading(true);
|
|
713
713
|
try {
|
|
714
|
-
await
|
|
714
|
+
await _chunkL5F5ZN5Fjs.StripeCustomerService.removePaymentMethod({ paymentMethodId: paymentMethod.id });
|
|
715
715
|
setShowRemoveDialog(false);
|
|
716
716
|
onUpdate();
|
|
717
717
|
} catch (error) {
|
|
@@ -720,16 +720,16 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
720
720
|
}
|
|
721
721
|
}, "handleRemove");
|
|
722
722
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
723
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
724
|
-
isDefault && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
725
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
723
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.Card, { className: "relative", children: [
|
|
724
|
+
isDefault && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Badge, { className: "absolute right-2 top-2 bg-green-100 text-green-800 hover:bg-green-100", children: "Default" }),
|
|
725
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.CardHeader, { className: "flex flex-row items-center justify-between pb-2", children: [
|
|
726
726
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-2", children: [
|
|
727
727
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-2xl", children: brandIcon }),
|
|
728
728
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-medium capitalize", children: brand })
|
|
729
729
|
] }),
|
|
730
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
731
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
732
|
-
|
|
730
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.DropdownMenu, { children: [
|
|
731
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.DropdownMenuTrigger, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
732
|
+
_chunkQPWHMXE2js.Button,
|
|
733
733
|
{
|
|
734
734
|
render: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {}),
|
|
735
735
|
nativeButton: false,
|
|
@@ -740,13 +740,13 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
740
740
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.MoreVertical, { className: "h-4 w-4" })
|
|
741
741
|
}
|
|
742
742
|
) }),
|
|
743
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
744
|
-
!isDefault && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
745
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
743
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.DropdownMenuContent, { align: "end", children: [
|
|
744
|
+
!isDefault && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.DropdownMenuItem, { onClick: handleSetDefault, disabled: loading, children: "Set as Default" }),
|
|
745
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.DropdownMenuItem, { onClick: () => setShowRemoveDialog(true), disabled: loading, className: "text-red-600", children: "Remove" })
|
|
746
746
|
] })
|
|
747
747
|
] })
|
|
748
748
|
] }),
|
|
749
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
749
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-y-1", children: [
|
|
750
750
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-lg font-semibold", children: [
|
|
751
751
|
"\u2022\u2022\u2022\u2022 ",
|
|
752
752
|
last4
|
|
@@ -759,17 +759,17 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
759
759
|
] })
|
|
760
760
|
] }) })
|
|
761
761
|
] }),
|
|
762
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
763
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
764
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
765
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
762
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.AlertDialog, { open: showRemoveDialog, onOpenChange: setShowRemoveDialog, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.AlertDialogContent, { children: [
|
|
763
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.AlertDialogHeader, { children: [
|
|
764
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.AlertDialogTitle, { children: "Remove Payment Method" }),
|
|
765
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.AlertDialogDescription, { children: [
|
|
766
766
|
"Are you sure you want to remove this payment method? This action cannot be undone.",
|
|
767
767
|
isDefault && " This is your default payment method."
|
|
768
768
|
] })
|
|
769
769
|
] }),
|
|
770
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
771
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
772
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
770
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.AlertDialogFooter, { children: [
|
|
771
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.AlertDialogCancel, { disabled: loading, children: "Cancel" }),
|
|
772
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.AlertDialogAction, { onClick: handleRemove, disabled: loading, className: "bg-red-600 hover:bg-red-700", children: loading ? "Removing..." : "Remove" })
|
|
773
773
|
] })
|
|
774
774
|
] }) })
|
|
775
775
|
] });
|
|
@@ -792,7 +792,7 @@ function PaymentMethodsContainer() {
|
|
|
792
792
|
const loadPaymentMethods = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
793
793
|
setLoading(true);
|
|
794
794
|
try {
|
|
795
|
-
const fetchedPaymentMethods = await
|
|
795
|
+
const fetchedPaymentMethods = await _chunkL5F5ZN5Fjs.StripeCustomerService.listPaymentMethods();
|
|
796
796
|
setPaymentMethods(fetchedPaymentMethods);
|
|
797
797
|
} catch (error) {
|
|
798
798
|
console.error("[PaymentMethodsContainer] Failed to load payment methods:", error);
|
|
@@ -812,14 +812,14 @@ function PaymentMethodsContainer() {
|
|
|
812
812
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-8 w-8" }),
|
|
813
813
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h1", { className: "text-3xl font-bold", children: "Payment Methods" })
|
|
814
814
|
] }),
|
|
815
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
815
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Button, { onClick: () => setShowAddPaymentMethod(true), children: "Add Payment Method" })
|
|
816
816
|
] }),
|
|
817
817
|
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: [
|
|
818
818
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-16 w-16 text-muted-foreground" }),
|
|
819
819
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "text-center", children: [
|
|
820
820
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "mb-2 text-xl font-semibold", children: "No payment methods" }),
|
|
821
821
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "mb-4 text-muted-foreground", children: "Add a payment method to enable subscriptions and secure checkout." }),
|
|
822
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
822
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Button, { onClick: () => setShowAddPaymentMethod(true), children: "Add Your First Card" })
|
|
823
823
|
] })
|
|
824
824
|
] }),
|
|
825
825
|
paymentMethods.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PaymentMethodsList, { paymentMethods, onUpdate: loadPaymentMethods }),
|
|
@@ -948,13 +948,13 @@ function InvoiceDetails({
|
|
|
948
948
|
return invoice.stripeInvoiceId.slice(-8);
|
|
949
949
|
}, "getInvoiceNumber");
|
|
950
950
|
const productName = _optionalChain([invoice, 'access', _29 => _29.subscription, 'optionalAccess', _30 => _30.price, 'optionalAccess', _31 => _31.product, 'optionalAccess', _32 => _32.name]) || "Subscription";
|
|
951
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
952
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
953
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
951
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.DialogContent, { className: "max-w-2xl", children: [
|
|
952
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.DialogHeader, { children: [
|
|
953
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.DialogTitle, { children: [
|
|
954
954
|
"Invoice ",
|
|
955
955
|
getInvoiceNumber()
|
|
956
956
|
] }),
|
|
957
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
957
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.DialogDescription, { children: formatDate3(invoice.periodStart) })
|
|
958
958
|
] }),
|
|
959
959
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-6", children: [
|
|
960
960
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-3", children: [
|
|
@@ -1019,15 +1019,15 @@ function InvoiceDetails({
|
|
|
1019
1019
|
] })
|
|
1020
1020
|
] }),
|
|
1021
1021
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-wrap gap-2 pt-4 border-t", children: [
|
|
1022
|
-
invoice.stripePdfUrl && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1022
|
+
invoice.stripePdfUrl && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.Button, { variant: "outline", onClick: handleDownloadPDF, children: [
|
|
1023
1023
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Download, { className: "mr-2 h-4 w-4" }),
|
|
1024
1024
|
"Download PDF"
|
|
1025
1025
|
] }),
|
|
1026
|
-
invoice.status === "open" /* OPEN */ && invoice.attempted && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1026
|
+
invoice.status === "open" /* OPEN */ && invoice.attempted && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.Button, { variant: "default", onClick: handleRetryPayment, children: [
|
|
1027
1027
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.RefreshCw, { className: "mr-2 h-4 w-4" }),
|
|
1028
1028
|
"Retry Payment"
|
|
1029
1029
|
] }),
|
|
1030
|
-
invoice.stripeHostedInvoiceUrl && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1030
|
+
invoice.stripeHostedInvoiceUrl && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.Button, { variant: "outline", onClick: handleViewInStripe, children: [
|
|
1031
1031
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ExternalLink, { className: "mr-2 h-4 w-4" }),
|
|
1032
1032
|
"View in Stripe"
|
|
1033
1033
|
] })
|
|
@@ -1051,30 +1051,30 @@ function InvoicesList({ invoices, onInvoicesChange }) {
|
|
|
1051
1051
|
return invoice.stripeInvoiceId.slice(-8);
|
|
1052
1052
|
}, "getInvoiceNumber");
|
|
1053
1053
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1054
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border rounded-lg overflow-clip", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1055
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1056
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1057
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1058
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1059
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1060
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1054
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border rounded-lg overflow-clip", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.Table, { children: [
|
|
1055
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableHeader, { className: "bg-muted", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.TableRow, { children: [
|
|
1056
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableHead, { children: "Invoice #" }),
|
|
1057
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableHead, { children: "Date" }),
|
|
1058
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableHead, { children: "Status" }),
|
|
1059
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableHead, { className: "text-right", children: "Amount" }),
|
|
1060
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableHead, { children: "Period" })
|
|
1061
1061
|
] }) }),
|
|
1062
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1062
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableBody, { children: invoices.map((invoice) => {
|
|
1063
1063
|
const invoiceNumber = getInvoiceNumber(invoice);
|
|
1064
1064
|
const date = formatDate3(invoice.periodStart);
|
|
1065
1065
|
const amount = formatCurrency(invoice.total, invoice.currency);
|
|
1066
1066
|
const period = `${formatDate3(invoice.periodStart)} - ${formatDate3(invoice.periodEnd)}`;
|
|
1067
1067
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1068
|
-
|
|
1068
|
+
_chunkQPWHMXE2js.TableRow,
|
|
1069
1069
|
{
|
|
1070
1070
|
onClick: () => handleRowClick(invoice),
|
|
1071
1071
|
className: "cursor-pointer hover:bg-muted/50",
|
|
1072
1072
|
children: [
|
|
1073
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1074
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1075
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1076
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1077
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1073
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableCell, { className: "font-medium", children: invoiceNumber }),
|
|
1074
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableCell, { className: "text-muted-foreground text-sm", children: date }),
|
|
1075
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableCell, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, InvoiceStatusBadge, { status: invoice.status }) }),
|
|
1076
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableCell, { className: "text-right font-medium", children: amount }),
|
|
1077
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableCell, { className: "text-muted-foreground text-sm", children: period })
|
|
1078
1078
|
]
|
|
1079
1079
|
},
|
|
1080
1080
|
invoice.id
|
|
@@ -1107,7 +1107,7 @@ function InvoicesContainer() {
|
|
|
1107
1107
|
setLoading(true);
|
|
1108
1108
|
try {
|
|
1109
1109
|
const params = statusFilter !== "all" ? { status: statusFilter } : void 0;
|
|
1110
|
-
const data = await
|
|
1110
|
+
const data = await _chunkL5F5ZN5Fjs.StripeInvoiceService.listInvoices(params);
|
|
1111
1111
|
setInvoices(data);
|
|
1112
1112
|
} catch (error) {
|
|
1113
1113
|
console.error("[InvoicesContainer] Failed to load invoices:", error);
|
|
@@ -1123,12 +1123,12 @@ function InvoicesContainer() {
|
|
|
1123
1123
|
setStatusFilter(value);
|
|
1124
1124
|
}, "handleFilterChange");
|
|
1125
1125
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-4", children: [
|
|
1126
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1127
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1128
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1129
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1130
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1131
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1126
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Tabs, { value: statusFilter, onValueChange: handleFilterChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.TabsList, { children: [
|
|
1127
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TabsTrigger, { value: "all", children: "All" }),
|
|
1128
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TabsTrigger, { value: "paid" /* PAID */, children: "Paid" }),
|
|
1129
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TabsTrigger, { value: "open" /* OPEN */, children: "Open" }),
|
|
1130
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TabsTrigger, { value: "void" /* VOID */, children: "Void" }),
|
|
1131
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TabsTrigger, { value: "uncollectible" /* UNCOLLECTIBLE */, children: "Uncollectible" })
|
|
1132
1132
|
] }) }),
|
|
1133
1133
|
loading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-center py-8 text-muted-foreground", children: "Loading invoices..." }),
|
|
1134
1134
|
!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: [
|
|
@@ -1175,7 +1175,7 @@ function CancelSubscriptionDialog({
|
|
|
1175
1175
|
const onSubmit = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async (_values) => {
|
|
1176
1176
|
setIsSubmitting(true);
|
|
1177
1177
|
try {
|
|
1178
|
-
await
|
|
1178
|
+
await _chunkL5F5ZN5Fjs.StripeSubscriptionService.cancelSubscription({
|
|
1179
1179
|
id: subscription.id,
|
|
1180
1180
|
cancelImmediately: false
|
|
1181
1181
|
});
|
|
@@ -1188,19 +1188,19 @@ function CancelSubscriptionDialog({
|
|
|
1188
1188
|
}
|
|
1189
1189
|
}, "onSubmit");
|
|
1190
1190
|
const periodEndDate = formatDate3(subscription.currentPeriodEnd);
|
|
1191
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1192
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1193
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1194
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1191
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.DialogContent, { className: "max-w-md", children: [
|
|
1192
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.DialogHeader, { children: [
|
|
1193
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.DialogTitle, { children: "Cancel Subscription" }),
|
|
1194
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.DialogDescription, { children: "Are you sure you want to cancel this subscription? This action cannot be undone." })
|
|
1195
1195
|
] }),
|
|
1196
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1196
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Form, { ...form, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { onSubmit: form.handleSubmit(onSubmit), className: "flex flex-col gap-y-4", children: [
|
|
1197
1197
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "bg-blue-50 border border-blue-200 rounded-lg p-3 text-sm text-blue-800", children: [
|
|
1198
1198
|
"Your subscription will remain active until ",
|
|
1199
1199
|
periodEndDate,
|
|
1200
1200
|
". You can continue using the service until then."
|
|
1201
1201
|
] }),
|
|
1202
1202
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1203
|
-
|
|
1203
|
+
_chunkQPWHMXE2js.FormTextarea,
|
|
1204
1204
|
{
|
|
1205
1205
|
form,
|
|
1206
1206
|
id: "reason",
|
|
@@ -1210,8 +1210,8 @@ function CancelSubscriptionDialog({
|
|
|
1210
1210
|
}
|
|
1211
1211
|
),
|
|
1212
1212
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex gap-x-2 justify-end pt-2", children: [
|
|
1213
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1214
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1213
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Button, { type: "button", variant: "outline", onClick: () => onOpenChange(false), disabled: isSubmitting, children: "Keep Subscription" }),
|
|
1214
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Button, { type: "submit", variant: "destructive", disabled: isSubmitting, children: isSubmitting ? "Canceling..." : "Confirm Cancellation" })
|
|
1215
1215
|
] })
|
|
1216
1216
|
] }) })
|
|
1217
1217
|
] }) });
|
|
@@ -1302,7 +1302,7 @@ function SubscriptionDetails({
|
|
|
1302
1302
|
const handlePause = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
1303
1303
|
setIsProcessing(true);
|
|
1304
1304
|
try {
|
|
1305
|
-
await
|
|
1305
|
+
await _chunkL5F5ZN5Fjs.StripeSubscriptionService.pauseSubscription({ subscriptionId: subscription.id });
|
|
1306
1306
|
onSubscriptionChange();
|
|
1307
1307
|
} catch (error) {
|
|
1308
1308
|
console.error("[SubscriptionDetails] Failed to pause subscription:", error);
|
|
@@ -1313,7 +1313,7 @@ function SubscriptionDetails({
|
|
|
1313
1313
|
const handleResume = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
1314
1314
|
setIsProcessing(true);
|
|
1315
1315
|
try {
|
|
1316
|
-
await
|
|
1316
|
+
await _chunkL5F5ZN5Fjs.StripeSubscriptionService.resumeSubscription({ subscriptionId: subscription.id });
|
|
1317
1317
|
onSubscriptionChange();
|
|
1318
1318
|
} catch (error) {
|
|
1319
1319
|
console.error("[SubscriptionDetails] Failed to resume subscription:", error);
|
|
@@ -1323,7 +1323,7 @@ function SubscriptionDetails({
|
|
|
1323
1323
|
}, "handleResume");
|
|
1324
1324
|
const handleManageViaPortal = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
1325
1325
|
try {
|
|
1326
|
-
const { url } = await
|
|
1326
|
+
const { url } = await _chunkL5F5ZN5Fjs.StripeCustomerService.createPortalSession();
|
|
1327
1327
|
window.open(url, "_blank");
|
|
1328
1328
|
} catch (error) {
|
|
1329
1329
|
console.error("[SubscriptionDetails] Failed to create portal session:", error);
|
|
@@ -1333,10 +1333,10 @@ function SubscriptionDetails({
|
|
|
1333
1333
|
const canResume = subscription.status === "paused" /* PAUSED */;
|
|
1334
1334
|
const canCancel = subscription.status === "active" /* ACTIVE */ || subscription.status === "trialing" /* TRIALING */ || subscription.status === "paused" /* PAUSED */;
|
|
1335
1335
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1336
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1337
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1338
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1339
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1336
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.DialogContent, { className: "max-w-2xl", children: [
|
|
1337
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.DialogHeader, { children: [
|
|
1338
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.DialogTitle, { children: "Subscription Details" }),
|
|
1339
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.DialogDescription, { children: "View and manage your subscription" })
|
|
1340
1340
|
] }),
|
|
1341
1341
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-6", children: [
|
|
1342
1342
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-3", children: [
|
|
@@ -1378,11 +1378,11 @@ function SubscriptionDetails({
|
|
|
1378
1378
|
"."
|
|
1379
1379
|
] }) }),
|
|
1380
1380
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-wrap gap-2 pt-4 border-t", children: [
|
|
1381
|
-
onChangePlan && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1382
|
-
canPause && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1383
|
-
canResume && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1384
|
-
canCancel && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1385
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1381
|
+
onChangePlan && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Button, { variant: "default", onClick: () => onChangePlan(subscription), children: "Change Plan" }),
|
|
1382
|
+
canPause && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Button, { variant: "outline", onClick: handlePause, disabled: isProcessing, children: isProcessing ? "Pausing..." : "Pause" }),
|
|
1383
|
+
canResume && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Button, { variant: "outline", onClick: handleResume, disabled: isProcessing, children: isProcessing ? "Resuming..." : "Resume" }),
|
|
1384
|
+
canCancel && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Button, { variant: "destructive", onClick: () => setShowCancel(true), children: "Cancel" }),
|
|
1385
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Button, { variant: "outline", onClick: handleManageViaPortal, children: "Manage via Portal" })
|
|
1386
1386
|
] })
|
|
1387
1387
|
] })
|
|
1388
1388
|
] }) }),
|
|
@@ -1429,36 +1429,36 @@ function SubscriptionsList({ subscriptions, onSubscriptionsChange, onChangePlan
|
|
|
1429
1429
|
setSelectedSub(subscription);
|
|
1430
1430
|
}, "handleRowClick");
|
|
1431
1431
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1432
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border rounded-lg overflow-clip", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1433
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1434
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1435
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1436
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1437
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1438
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1432
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border rounded-lg overflow-clip", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.Table, { children: [
|
|
1433
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableHeader, { className: "bg-muted", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.TableRow, { children: [
|
|
1434
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableHead, { children: "Status" }),
|
|
1435
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableHead, { children: "Plan" }),
|
|
1436
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableHead, { children: "Period" }),
|
|
1437
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableHead, { className: "text-right", children: "Amount" }),
|
|
1438
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableHead, { className: "text-right", children: "Actions" })
|
|
1439
1439
|
] }) }),
|
|
1440
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1440
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableBody, { children: subscriptions.map((subscription) => {
|
|
1441
1441
|
const price = subscription.price;
|
|
1442
1442
|
const amount = _optionalChain([price, 'optionalAccess', _42 => _42.unitAmount]) ? formatCurrency(price.unitAmount, price.currency) : "0";
|
|
1443
1443
|
const period = `${formatDate3(subscription.currentPeriodStart)} - ${formatDate3(subscription.currentPeriodEnd)}`;
|
|
1444
1444
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1445
|
-
|
|
1445
|
+
_chunkQPWHMXE2js.TableRow,
|
|
1446
1446
|
{
|
|
1447
1447
|
onClick: () => handleRowClick(subscription),
|
|
1448
1448
|
className: "cursor-pointer hover:bg-muted/50",
|
|
1449
1449
|
children: [
|
|
1450
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1450
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableCell, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1451
1451
|
SubscriptionStatusBadge,
|
|
1452
1452
|
{
|
|
1453
1453
|
status: subscription.status,
|
|
1454
1454
|
cancelAtPeriodEnd: subscription.cancelAtPeriodEnd
|
|
1455
1455
|
}
|
|
1456
1456
|
) }),
|
|
1457
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1458
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1459
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1460
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1461
|
-
|
|
1457
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableCell, { className: "font-medium", children: formatPlanName3(price) }),
|
|
1458
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableCell, { className: "text-muted-foreground text-sm", children: period }),
|
|
1459
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableCell, { className: "text-right font-medium", children: amount }),
|
|
1460
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableCell, { className: "text-right", children: (subscription.status === "active" /* ACTIVE */ || subscription.status === "trialing" /* TRIALING */) && onChangePlan && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1461
|
+
_chunkQPWHMXE2js.Button,
|
|
1462
1462
|
{
|
|
1463
1463
|
size: "sm",
|
|
1464
1464
|
variant: "outline",
|
|
@@ -1503,7 +1503,7 @@ function SubscriptionsContainer({ onOpenWizard, hasActiveRecurringSubscription }
|
|
|
1503
1503
|
const loadSubscriptions = _react.useCallback.call(void 0, async () => {
|
|
1504
1504
|
setLoading(true);
|
|
1505
1505
|
try {
|
|
1506
|
-
const fetchedSubscriptions = await
|
|
1506
|
+
const fetchedSubscriptions = await _chunkL5F5ZN5Fjs.StripeSubscriptionService.listSubscriptions();
|
|
1507
1507
|
setSubscriptions(fetchedSubscriptions);
|
|
1508
1508
|
} catch (error) {
|
|
1509
1509
|
console.error("[SubscriptionsContainer] Failed to load subscriptions:", error);
|
|
@@ -1526,7 +1526,7 @@ function SubscriptionsContainer({ onOpenWizard, hasActiveRecurringSubscription }
|
|
|
1526
1526
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-8 w-8" }),
|
|
1527
1527
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h1", { className: "text-3xl font-bold", children: "Subscriptions" })
|
|
1528
1528
|
] }),
|
|
1529
|
-
subscriptions.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1529
|
+
subscriptions.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Button, { onClick: () => _optionalChain([onOpenWizard, 'optionalCall', _43 => _43()]), children: hasActiveRecurringSubscription ? "Purchase Add-ons" : "Subscribe to a Plan" })
|
|
1530
1530
|
] }),
|
|
1531
1531
|
criticalSubscriptions.map((subscription) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BillingAlertBanner, { subscription }, subscription.id)),
|
|
1532
1532
|
subscriptions.length === 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col items-center justify-center py-12 space-y-4", children: [
|
|
@@ -1534,7 +1534,7 @@ function SubscriptionsContainer({ onOpenWizard, hasActiveRecurringSubscription }
|
|
|
1534
1534
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "text-center", children: [
|
|
1535
1535
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-xl font-semibold mb-2", children: "No Active Subscriptions" }),
|
|
1536
1536
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-muted-foreground mb-6", children: "Choose a subscription plan to get started with our services." }),
|
|
1537
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1537
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Button, { onClick: () => _optionalChain([onOpenWizard, 'optionalCall', _44 => _44()]), children: "Subscribe to a Plan" })
|
|
1538
1538
|
] })
|
|
1539
1539
|
] }),
|
|
1540
1540
|
subscriptions.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -1555,9 +1555,9 @@ function IntervalToggle({ value, onChange, hasMonthly, hasYearly }) {
|
|
|
1555
1555
|
if (!hasMonthly || !hasYearly) {
|
|
1556
1556
|
return null;
|
|
1557
1557
|
}
|
|
1558
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1559
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1560
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1558
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Tabs, { value, onValueChange: (v) => onChange(v), children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.TabsList, { children: [
|
|
1559
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TabsTrigger, { value: "month", children: "Monthly" }),
|
|
1560
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TabsTrigger, { value: "year", children: "Yearly" })
|
|
1561
1561
|
] }) });
|
|
1562
1562
|
}
|
|
1563
1563
|
_chunk7QVYU63Ejs.__name.call(void 0, IntervalToggle, "IntervalToggle");
|
|
@@ -1589,7 +1589,7 @@ function PricingCard({
|
|
|
1589
1589
|
}
|
|
1590
1590
|
}, "handleClick");
|
|
1591
1591
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1592
|
-
|
|
1592
|
+
_chunkQPWHMXE2js.Card,
|
|
1593
1593
|
{
|
|
1594
1594
|
role: "radio",
|
|
1595
1595
|
"aria-checked": isSelected,
|
|
@@ -1597,7 +1597,7 @@ function PricingCard({
|
|
|
1597
1597
|
tabIndex: isDisabled ? -1 : 0,
|
|
1598
1598
|
onKeyDown: handleKeyDown,
|
|
1599
1599
|
onClick: handleClick,
|
|
1600
|
-
className:
|
|
1600
|
+
className: _chunkL5F5ZN5Fjs.cn.call(void 0,
|
|
1601
1601
|
"relative cursor-pointer transition-all duration-200 flex flex-col h-full",
|
|
1602
1602
|
"focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
1603
1603
|
isCurrentPlan && "bg-muted/30",
|
|
@@ -1607,9 +1607,9 @@ function PricingCard({
|
|
|
1607
1607
|
isLoading && "pointer-events-none"
|
|
1608
1608
|
),
|
|
1609
1609
|
children: [
|
|
1610
|
-
isCurrentPlan && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1611
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1612
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1610
|
+
isCurrentPlan && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Badge, { variant: "secondary", className: "absolute top-2 right-2", children: "Current" }),
|
|
1611
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardHeader, { className: "pb-2", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "font-semibold text-lg", children: description }) }),
|
|
1612
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.CardContent, { className: "pb-4 grow", children: [
|
|
1613
1613
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mb-4", children: [
|
|
1614
1614
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-3xl font-bold", children: formattedPrice }),
|
|
1615
1615
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground ml-1", children: interval })
|
|
@@ -1619,8 +1619,8 @@ function PricingCard({
|
|
|
1619
1619
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm text-muted-foreground", children: feature })
|
|
1620
1620
|
] }, index)) })
|
|
1621
1621
|
] }),
|
|
1622
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1623
|
-
|
|
1622
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardFooter, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1623
|
+
_chunkQPWHMXE2js.Button,
|
|
1624
1624
|
{
|
|
1625
1625
|
variant: isCurrentPlan ? "secondary" : isSelected ? "default" : "outline",
|
|
1626
1626
|
className: "w-full",
|
|
@@ -1748,15 +1748,15 @@ function ProductPricingList({
|
|
|
1748
1748
|
_chunk7QVYU63Ejs.__name.call(void 0, ProductPricingList, "ProductPricingList");
|
|
1749
1749
|
function ProductPricingListSkeleton() {
|
|
1750
1750
|
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: [
|
|
1751
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1751
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Skeleton, { className: "h-6 w-32" }),
|
|
1752
1752
|
/* @__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: [
|
|
1753
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1754
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1753
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Skeleton, { className: "h-6 w-24" }),
|
|
1754
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Skeleton, { className: "h-8 w-32" }),
|
|
1755
1755
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
1756
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1757
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1756
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Skeleton, { className: "h-4 w-full" }),
|
|
1757
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Skeleton, { className: "h-4 w-3/4" })
|
|
1758
1758
|
] }),
|
|
1759
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1759
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Skeleton, { className: "h-10 w-full" })
|
|
1760
1760
|
] }, cardIndex)) })
|
|
1761
1761
|
] }, rowIndex)) });
|
|
1762
1762
|
}
|
|
@@ -1811,8 +1811,8 @@ function SubscriptionConfirmation({ price, isLoading, onConfirm, onCancel }) {
|
|
|
1811
1811
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: feature })
|
|
1812
1812
|
] }, index)) }),
|
|
1813
1813
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-end gap-3 pt-2 border-t border-accent/30", children: [
|
|
1814
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1815
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1814
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Button, { variant: "outline", onClick: onCancel, disabled: isLoading, children: "Cancel" }),
|
|
1815
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Button, { onClick: onConfirm, disabled: isLoading, children: isLoading ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1816
1816
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Loader2, { className: "h-4 w-4 animate-spin mr-2" }),
|
|
1817
1817
|
"Processing..."
|
|
1818
1818
|
] }) : "Subscribe" })
|
|
@@ -1883,7 +1883,7 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
1883
1883
|
onCloseRef.current = onClose;
|
|
1884
1884
|
const checkPaymentMethod = _react.useCallback.call(void 0, async () => {
|
|
1885
1885
|
try {
|
|
1886
|
-
const methods = await
|
|
1886
|
+
const methods = await _chunkL5F5ZN5Fjs.StripeCustomerService.listPaymentMethods();
|
|
1887
1887
|
dispatch({ type: "SET_HAS_PAYMENT_METHOD", hasMethod: methods.length > 0 });
|
|
1888
1888
|
} catch (error) {
|
|
1889
1889
|
console.error("[useSubscriptionWizard] Failed to check payment methods:", error);
|
|
@@ -1907,7 +1907,7 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
1907
1907
|
const isTrialUpgrade = _optionalChain([subscription, 'optionalAccess', _55 => _55.status]) === "trialing" /* TRIALING */;
|
|
1908
1908
|
dispatch({ type: "SET_IS_TRIAL_SUBSCRIPTION", isTrial: isTrialUpgrade });
|
|
1909
1909
|
if (isTrialUpgrade && !state.hasPaymentMethod) {
|
|
1910
|
-
const methods = await
|
|
1910
|
+
const methods = await _chunkL5F5ZN5Fjs.StripeCustomerService.listPaymentMethods();
|
|
1911
1911
|
if (methods.length === 0) {
|
|
1912
1912
|
dispatch({ type: "SET_STEP", step: "payment-method" });
|
|
1913
1913
|
dispatch({
|
|
@@ -1918,7 +1918,7 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
1918
1918
|
}
|
|
1919
1919
|
}
|
|
1920
1920
|
if (subscription && state.selectedPrice.id !== _optionalChain([subscription, 'access', _56 => _56.price, 'optionalAccess', _57 => _57.id])) {
|
|
1921
|
-
const preview = await
|
|
1921
|
+
const preview = await _chunkL5F5ZN5Fjs.StripeSubscriptionService.getProrationPreview({
|
|
1922
1922
|
subscriptionId: subscription.id,
|
|
1923
1923
|
newPriceId: state.selectedPrice.id
|
|
1924
1924
|
});
|
|
@@ -1934,9 +1934,6 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
1934
1934
|
}, [state.selectedPrice, state.hasPaymentMethod, subscription, checkPaymentMethod]);
|
|
1935
1935
|
const confirmSubscription = _react.useCallback.call(void 0, async () => {
|
|
1936
1936
|
if (!state.selectedPrice) return;
|
|
1937
|
-
console.log("[useSubscriptionWizard] confirmSubscription called");
|
|
1938
|
-
console.log("[useSubscriptionWizard] state.promotionCode:", JSON.stringify(state.promotionCode, null, 2));
|
|
1939
|
-
console.log("[useSubscriptionWizard] promotionCodeId to send:", _optionalChain([state, 'access', _59 => _59.promotionCode, 'optionalAccess', _60 => _60.promotionCodeId]));
|
|
1940
1937
|
dispatch({ type: "SET_PROCESSING", isProcessing: true });
|
|
1941
1938
|
dispatch({ type: "SET_ERROR", error: null });
|
|
1942
1939
|
try {
|
|
@@ -1944,36 +1941,33 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
1944
1941
|
const changePlanParams = {
|
|
1945
1942
|
id: subscription.id,
|
|
1946
1943
|
newPriceId: state.selectedPrice.id,
|
|
1947
|
-
promotionCode: _optionalChain([state, 'access',
|
|
1944
|
+
promotionCode: _optionalChain([state, 'access', _59 => _59.promotionCode, 'optionalAccess', _60 => _60.promotionCodeId])
|
|
1948
1945
|
};
|
|
1949
|
-
|
|
1950
|
-
await _chunkZNGEVB5Mjs.StripeSubscriptionService.changePlan(changePlanParams);
|
|
1946
|
+
await _chunkL5F5ZN5Fjs.StripeSubscriptionService.changePlan(changePlanParams);
|
|
1951
1947
|
} else {
|
|
1952
1948
|
const createParams = {
|
|
1953
1949
|
id: _uuid.v4.call(void 0, ),
|
|
1954
1950
|
priceId: state.selectedPrice.id,
|
|
1955
|
-
promotionCode: _optionalChain([state, 'access',
|
|
1951
|
+
promotionCode: _optionalChain([state, 'access', _61 => _61.promotionCode, 'optionalAccess', _62 => _62.promotionCodeId])
|
|
1956
1952
|
};
|
|
1957
|
-
|
|
1958
|
-
await _chunkZNGEVB5Mjs.StripeSubscriptionService.createSubscription(createParams);
|
|
1953
|
+
await _chunkL5F5ZN5Fjs.StripeSubscriptionService.createSubscription(createParams);
|
|
1959
1954
|
}
|
|
1960
1955
|
onSuccessRef.current();
|
|
1961
1956
|
onCloseRef.current();
|
|
1962
1957
|
} catch (error) {
|
|
1963
|
-
|
|
1964
|
-
if (_optionalChain([error, 'optionalAccess', _65 => _65.status]) === 409 || _optionalChain([error, 'optionalAccess', _66 => _66.response, 'optionalAccess', _67 => _67.status]) === 409) {
|
|
1958
|
+
if (_optionalChain([error, 'optionalAccess', _63 => _63.status]) === 409 || _optionalChain([error, 'optionalAccess', _64 => _64.response, 'optionalAccess', _65 => _65.status]) === 409) {
|
|
1965
1959
|
dispatch({
|
|
1966
1960
|
type: "SET_ERROR",
|
|
1967
1961
|
error: "You already have an active subscription. Please change your existing plan instead."
|
|
1968
1962
|
});
|
|
1969
1963
|
return;
|
|
1970
1964
|
}
|
|
1971
|
-
if (_optionalChain([error, 'optionalAccess',
|
|
1965
|
+
if (_optionalChain([error, 'optionalAccess', _66 => _66.status]) === 402 || _optionalChain([error, 'optionalAccess', _67 => _67.response, 'optionalAccess', _68 => _68.status]) === 402) {
|
|
1972
1966
|
dispatch({ type: "SET_HAS_PAYMENT_METHOD", hasMethod: false });
|
|
1973
1967
|
dispatch({ type: "SET_STEP", step: "payment-method" });
|
|
1974
1968
|
return;
|
|
1975
1969
|
}
|
|
1976
|
-
dispatch({ type: "SET_ERROR", error: _optionalChain([error, 'optionalAccess',
|
|
1970
|
+
dispatch({ type: "SET_ERROR", error: _optionalChain([error, 'optionalAccess', _69 => _69.message]) || "Failed to process subscription" });
|
|
1977
1971
|
} finally {
|
|
1978
1972
|
dispatch({ type: "SET_PROCESSING", isProcessing: false });
|
|
1979
1973
|
}
|
|
@@ -1990,9 +1984,9 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
1990
1984
|
dispatch({ type: "SET_VALIDATING_PROMO_CODE", isValidating: true });
|
|
1991
1985
|
dispatch({ type: "SET_PROMO_CODE_ERROR", error: null });
|
|
1992
1986
|
try {
|
|
1993
|
-
const result = await
|
|
1987
|
+
const result = await _chunkL5F5ZN5Fjs.StripePromotionCodeService.validatePromotionCode({
|
|
1994
1988
|
code,
|
|
1995
|
-
stripePriceId: _optionalChain([state, 'access',
|
|
1989
|
+
stripePriceId: _optionalChain([state, 'access', _70 => _70.selectedPrice, 'optionalAccess', _71 => _71.id])
|
|
1996
1990
|
});
|
|
1997
1991
|
if (result.valid) {
|
|
1998
1992
|
dispatch({ type: "SET_PROMOTION_CODE", code: result });
|
|
@@ -2001,12 +1995,12 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
2001
1995
|
}
|
|
2002
1996
|
} catch (error) {
|
|
2003
1997
|
console.error("[useSubscriptionWizard] Promo code validation error:", error);
|
|
2004
|
-
dispatch({ type: "SET_PROMO_CODE_ERROR", error: _optionalChain([error, 'optionalAccess',
|
|
1998
|
+
dispatch({ type: "SET_PROMO_CODE_ERROR", error: _optionalChain([error, 'optionalAccess', _72 => _72.message]) || "Failed to validate promotion code" });
|
|
2005
1999
|
} finally {
|
|
2006
2000
|
dispatch({ type: "SET_VALIDATING_PROMO_CODE", isValidating: false });
|
|
2007
2001
|
}
|
|
2008
2002
|
},
|
|
2009
|
-
[_optionalChain([state, 'access',
|
|
2003
|
+
[_optionalChain([state, 'access', _73 => _73.selectedPrice, 'optionalAccess', _74 => _74.id])]
|
|
2010
2004
|
);
|
|
2011
2005
|
const clearPromoCode = _react.useCallback.call(void 0, () => {
|
|
2012
2006
|
dispatch({ type: "SET_PROMOTION_CODE", code: null });
|
|
@@ -2097,7 +2091,7 @@ function WizardStepPlanSelection({
|
|
|
2097
2091
|
_react.useEffect.call(void 0, () => {
|
|
2098
2092
|
const loadProducts = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2099
2093
|
try {
|
|
2100
|
-
const fetchedProducts = await
|
|
2094
|
+
const fetchedProducts = await _chunkL5F5ZN5Fjs.StripeProductService.listProducts({ active: true });
|
|
2101
2095
|
setProducts(fetchedProducts);
|
|
2102
2096
|
} catch (error) {
|
|
2103
2097
|
console.error("[WizardStepPlanSelection] Failed to load products:", error);
|
|
@@ -2112,10 +2106,10 @@ function WizardStepPlanSelection({
|
|
|
2112
2106
|
let hasYearly2 = false;
|
|
2113
2107
|
for (const product of products) {
|
|
2114
2108
|
for (const price of product.stripePrices || []) {
|
|
2115
|
-
if (price.priceType === "recurring" && _optionalChain([price, 'access',
|
|
2109
|
+
if (price.priceType === "recurring" && _optionalChain([price, 'access', _75 => _75.recurring, 'optionalAccess', _76 => _76.interval]) === "month") {
|
|
2116
2110
|
hasMonthly2 = true;
|
|
2117
2111
|
}
|
|
2118
|
-
if (price.priceType === "recurring" && _optionalChain([price, 'access',
|
|
2112
|
+
if (price.priceType === "recurring" && _optionalChain([price, 'access', _77 => _77.recurring, 'optionalAccess', _78 => _78.interval]) === "year") {
|
|
2119
2113
|
hasYearly2 = true;
|
|
2120
2114
|
}
|
|
2121
2115
|
}
|
|
@@ -2141,14 +2135,14 @@ function WizardStepPlanSelection({
|
|
|
2141
2135
|
products,
|
|
2142
2136
|
selectedInterval,
|
|
2143
2137
|
currentPriceId,
|
|
2144
|
-
selectedPriceId: _optionalChain([selectedPrice, 'optionalAccess',
|
|
2138
|
+
selectedPriceId: _optionalChain([selectedPrice, 'optionalAccess', _79 => _79.id]),
|
|
2145
2139
|
loading,
|
|
2146
2140
|
hideRecurringPrices,
|
|
2147
2141
|
hideOneTimePrices,
|
|
2148
2142
|
onSelectPrice: handleSelectPrice
|
|
2149
2143
|
}
|
|
2150
2144
|
),
|
|
2151
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex justify-end pt-4 border-t", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2145
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex justify-end pt-4 border-t", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Button, { onClick: onNext, disabled: !selectedPrice || isProcessing, children: isProcessing ? "Loading..." : "Next: Review" }) })
|
|
2152
2146
|
] });
|
|
2153
2147
|
}
|
|
2154
2148
|
_chunk7QVYU63Ejs.__name.call(void 0, WizardStepPlanSelection, "WizardStepPlanSelection");
|
|
@@ -2185,7 +2179,7 @@ function PromoCodeInput({
|
|
|
2185
2179
|
return `${result.discountValue}% off`;
|
|
2186
2180
|
}
|
|
2187
2181
|
const amount = (result.discountValue || 0) / 100;
|
|
2188
|
-
const currency = _optionalChain([result, 'access',
|
|
2182
|
+
const currency = _optionalChain([result, 'access', _80 => _80.currency, 'optionalAccess', _81 => _81.toUpperCase, 'call', _82 => _82()]) || "USD";
|
|
2189
2183
|
return `${currency} ${amount.toFixed(2)} off`;
|
|
2190
2184
|
}, "formatDiscount");
|
|
2191
2185
|
const formatDuration = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (result) => {
|
|
@@ -2200,7 +2194,7 @@ function PromoCodeInput({
|
|
|
2200
2194
|
return "";
|
|
2201
2195
|
}
|
|
2202
2196
|
}, "formatDuration");
|
|
2203
|
-
if (_optionalChain([appliedCode, 'optionalAccess',
|
|
2197
|
+
if (_optionalChain([appliedCode, 'optionalAccess', _83 => _83.valid])) {
|
|
2204
2198
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
2205
2199
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-between p-3 bg-green-50 border border-green-200 rounded-lg", children: [
|
|
2206
2200
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
|
|
@@ -2209,7 +2203,7 @@ function PromoCodeInput({
|
|
|
2209
2203
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm text-green-600", children: formatDiscount(appliedCode) })
|
|
2210
2204
|
] }),
|
|
2211
2205
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2212
|
-
|
|
2206
|
+
_chunkQPWHMXE2js.Button,
|
|
2213
2207
|
{
|
|
2214
2208
|
variant: "ghost",
|
|
2215
2209
|
size: "sm",
|
|
@@ -2226,7 +2220,7 @@ function PromoCodeInput({
|
|
|
2226
2220
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
2227
2221
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex gap-2", children: [
|
|
2228
2222
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2229
|
-
|
|
2223
|
+
_chunkQPWHMXE2js.Input,
|
|
2230
2224
|
{
|
|
2231
2225
|
placeholder: "Enter promo code",
|
|
2232
2226
|
value: code,
|
|
@@ -2236,7 +2230,7 @@ function PromoCodeInput({
|
|
|
2236
2230
|
className: "flex-1"
|
|
2237
2231
|
}
|
|
2238
2232
|
),
|
|
2239
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2233
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.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" }) : "Apply" })
|
|
2240
2234
|
] }),
|
|
2241
2235
|
error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-red-500", children: error })
|
|
2242
2236
|
] });
|
|
@@ -2265,14 +2259,14 @@ function WizardStepReview({
|
|
|
2265
2259
|
if (!selectedPrice) {
|
|
2266
2260
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-center py-8 text-muted-foreground", children: "No plan selected. Please go back and select a plan." });
|
|
2267
2261
|
}
|
|
2268
|
-
const isChangingPlan = subscription && _optionalChain([subscription, 'access',
|
|
2262
|
+
const isChangingPlan = subscription && _optionalChain([subscription, 'access', _84 => _84.price, 'optionalAccess', _85 => _85.id]) !== selectedPrice.id;
|
|
2269
2263
|
const formatInterval2 = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (price) => {
|
|
2270
2264
|
if (price.priceType === "one_time") return "one-time";
|
|
2271
|
-
const interval = _optionalChain([price, 'access',
|
|
2265
|
+
const interval = _optionalChain([price, 'access', _86 => _86.recurring, 'optionalAccess', _87 => _87.interval]) || "month";
|
|
2272
2266
|
return interval === "year" ? "yearly" : "monthly";
|
|
2273
2267
|
}, "formatInterval");
|
|
2274
2268
|
const calculateDiscountedPrice = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => {
|
|
2275
|
-
if (!_optionalChain([promotionCode, 'optionalAccess',
|
|
2269
|
+
if (!_optionalChain([promotionCode, 'optionalAccess', _88 => _88.valid]) || !selectedPrice.unitAmount) return null;
|
|
2276
2270
|
const originalPrice = selectedPrice.unitAmount;
|
|
2277
2271
|
if (promotionCode.discountType === "percent_off" && promotionCode.discountValue) {
|
|
2278
2272
|
return originalPrice * (1 - promotionCode.discountValue / 100);
|
|
@@ -2284,7 +2278,7 @@ function WizardStepReview({
|
|
|
2284
2278
|
}, "calculateDiscountedPrice");
|
|
2285
2279
|
const discountedPrice = calculateDiscountedPrice();
|
|
2286
2280
|
const calculateDiscountedImmediateCharge = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => {
|
|
2287
|
-
if (!_optionalChain([promotionCode, 'optionalAccess',
|
|
2281
|
+
if (!_optionalChain([promotionCode, 'optionalAccess', _89 => _89.valid]) || !_optionalChain([prorationPreview, 'optionalAccess', _90 => _90.immediateCharge])) return null;
|
|
2288
2282
|
const originalCharge = prorationPreview.immediateCharge;
|
|
2289
2283
|
if (promotionCode.discountType === "percent_off" && promotionCode.discountValue) {
|
|
2290
2284
|
return originalCharge * (1 - promotionCode.discountValue / 100);
|
|
@@ -2296,7 +2290,7 @@ function WizardStepReview({
|
|
|
2296
2290
|
}, "calculateDiscountedImmediateCharge");
|
|
2297
2291
|
const discountedImmediateCharge = calculateDiscountedImmediateCharge();
|
|
2298
2292
|
const getDiscountDescription = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => {
|
|
2299
|
-
if (!_optionalChain([promotionCode, 'optionalAccess',
|
|
2293
|
+
if (!_optionalChain([promotionCode, 'optionalAccess', _91 => _91.valid])) return null;
|
|
2300
2294
|
if (promotionCode.discountType === "percent_off" && promotionCode.discountValue) {
|
|
2301
2295
|
return `${promotionCode.discountValue}% off`;
|
|
2302
2296
|
}
|
|
@@ -2311,7 +2305,7 @@ function WizardStepReview({
|
|
|
2311
2305
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "font-semibold text-lg", children: "Selected Plan" }),
|
|
2312
2306
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between items-center", children: [
|
|
2313
2307
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
2314
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "font-medium", children: _optionalChain([selectedPrice, 'access',
|
|
2308
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "font-medium", children: _optionalChain([selectedPrice, 'access', _92 => _92.product, 'optionalAccess', _93 => _93.name]) }),
|
|
2315
2309
|
selectedPrice.nickname && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: selectedPrice.nickname })
|
|
2316
2310
|
] }),
|
|
2317
2311
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "text-right", children: [
|
|
@@ -2360,15 +2354,15 @@ function WizardStepReview({
|
|
|
2360
2354
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h4", { className: "font-medium", children: "Payment Method" }),
|
|
2361
2355
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: hasPaymentMethod ? "A payment method is on file" : "No payment method on file" })
|
|
2362
2356
|
] }),
|
|
2363
|
-
!hasPaymentMethod && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2357
|
+
!hasPaymentMethod && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Button, { variant: "outline", onClick: onAddPaymentMethod, children: "Add Payment Method" })
|
|
2364
2358
|
] }) }),
|
|
2365
|
-
error && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2359
|
+
error && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.Alert, { variant: "destructive", children: [
|
|
2366
2360
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.AlertCircle, { className: "h-4 w-4" }),
|
|
2367
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2361
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.AlertDescription, { children: error })
|
|
2368
2362
|
] }),
|
|
2369
2363
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between pt-4 border-t", children: [
|
|
2370
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2371
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2364
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Button, { variant: "outline", onClick: onBack, disabled: isProcessing, children: "Back" }),
|
|
2365
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Button, { onClick: hasPaymentMethod ? onConfirm : onAddPaymentMethod, disabled: isProcessing, children: isProcessing ? "Processing..." : hasPaymentMethod ? isChangingPlan ? "Confirm Plan Change" : "Subscribe Now" : "Add Payment Method" })
|
|
2372
2366
|
] })
|
|
2373
2367
|
] });
|
|
2374
2368
|
}
|
|
@@ -2421,10 +2415,10 @@ function SubscriptionWizard({
|
|
|
2421
2415
|
const isChangePlanMode = !!subscription;
|
|
2422
2416
|
const dialogTitle = subscription ? "Change Subscription Plan" : isPurchasingAddons ? "Purchase Add-ons" : "Subscribe to a Plan";
|
|
2423
2417
|
const dialogDescription = subscription ? "Select a new plan for your subscription" : isPurchasingAddons ? "Select one-time products to purchase" : "Choose a subscription plan to get started";
|
|
2424
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2425
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2426
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2427
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2418
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.DialogContent, { className: "max-w-2xl", children: [
|
|
2419
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.DialogHeader, { children: [
|
|
2420
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.DialogTitle, { children: dialogTitle }),
|
|
2421
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.DialogDescription, { children: dialogDescription })
|
|
2428
2422
|
] }),
|
|
2429
2423
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, WizardProgressIndicator, { currentStep: state.step }),
|
|
2430
2424
|
state.step === "plan-selection" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -2432,7 +2426,7 @@ function SubscriptionWizard({
|
|
|
2432
2426
|
{
|
|
2433
2427
|
selectedPrice: state.selectedPrice,
|
|
2434
2428
|
selectedInterval: state.selectedInterval,
|
|
2435
|
-
currentPriceId: _optionalChain([subscription, 'optionalAccess',
|
|
2429
|
+
currentPriceId: _optionalChain([subscription, 'optionalAccess', _94 => _94.price, 'optionalAccess', _95 => _95.id]),
|
|
2436
2430
|
hideRecurringPrices: isPurchasingAddons,
|
|
2437
2431
|
hideOneTimePrices: isChangePlanMode,
|
|
2438
2432
|
onSelectPrice: actions.selectPrice,
|
|
@@ -2500,22 +2494,22 @@ function formatDate4(date) {
|
|
|
2500
2494
|
}
|
|
2501
2495
|
_chunk7QVYU63Ejs.__name.call(void 0, formatDate4, "formatDate");
|
|
2502
2496
|
function UsageSummaryCard({ meter, summary }) {
|
|
2503
|
-
const currentUsage = _nullishCoalesce(_optionalChain([summary, 'optionalAccess',
|
|
2497
|
+
const currentUsage = _nullishCoalesce(_optionalChain([summary, 'optionalAccess', _96 => _96.aggregatedValue]), () => ( 0));
|
|
2504
2498
|
const limit = meter.limit;
|
|
2505
2499
|
const percentage = limit && limit > 0 ? currentUsage / limit * 100 : null;
|
|
2506
2500
|
const progressColor = getProgressColor(percentage);
|
|
2507
2501
|
const progressWidth = percentage !== null ? Math.min(percentage, 100) : 0;
|
|
2508
2502
|
const displayName = meter.displayName || meter.eventName;
|
|
2509
2503
|
const hasLimit = limit !== null && limit !== void 0;
|
|
2510
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2511
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2504
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.Card, { children: [
|
|
2505
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.CardHeader, { className: "flex flex-row items-center gap-x-3 pb-3", children: [
|
|
2512
2506
|
/* @__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" }) }),
|
|
2513
2507
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col", children: [
|
|
2514
2508
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "font-semibold", children: displayName }),
|
|
2515
2509
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-gray-500", children: meter.id })
|
|
2516
2510
|
] })
|
|
2517
2511
|
] }),
|
|
2518
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2512
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.CardContent, { className: "flex flex-col gap-y-4", children: [
|
|
2519
2513
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
2520
2514
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-3xl font-bold", children: currentUsage.toLocaleString() }),
|
|
2521
2515
|
hasLimit && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-sm text-gray-500", children: [
|
|
@@ -2527,7 +2521,7 @@ function UsageSummaryCard({ meter, summary }) {
|
|
|
2527
2521
|
hasLimit ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-y-2", children: [
|
|
2528
2522
|
/* @__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}%` } }) }),
|
|
2529
2523
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-sm text-gray-500", children: [
|
|
2530
|
-
_optionalChain([percentage, 'optionalAccess',
|
|
2524
|
+
_optionalChain([percentage, 'optionalAccess', _97 => _97.toFixed, 'call', _98 => _98(1)]),
|
|
2531
2525
|
"% used"
|
|
2532
2526
|
] })
|
|
2533
2527
|
] }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-gray-500", children: "No limit set" }),
|
|
@@ -2562,14 +2556,14 @@ function UsageContainer() {
|
|
|
2562
2556
|
const loadUsageData = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2563
2557
|
setLoading(true);
|
|
2564
2558
|
try {
|
|
2565
|
-
const fetchedSubscriptions = await
|
|
2559
|
+
const fetchedSubscriptions = await _chunkL5F5ZN5Fjs.StripeSubscriptionService.listSubscriptions();
|
|
2566
2560
|
setSubscriptions(fetchedSubscriptions);
|
|
2567
|
-
const hasMeteredSubscriptions2 = fetchedSubscriptions.some((sub) => _optionalChain([sub, 'access',
|
|
2561
|
+
const hasMeteredSubscriptions2 = fetchedSubscriptions.some((sub) => _optionalChain([sub, 'access', _99 => _99.price, 'optionalAccess', _100 => _100.recurring, 'optionalAccess', _101 => _101.usageType]) === "metered");
|
|
2568
2562
|
if (!hasMeteredSubscriptions2) {
|
|
2569
2563
|
setLoading(false);
|
|
2570
2564
|
return;
|
|
2571
2565
|
}
|
|
2572
|
-
const fetchedMeters = await
|
|
2566
|
+
const fetchedMeters = await _chunkL5F5ZN5Fjs.StripeUsageService.listMeters();
|
|
2573
2567
|
setMeters(fetchedMeters);
|
|
2574
2568
|
const summariesMap = {};
|
|
2575
2569
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -2577,7 +2571,7 @@ function UsageContainer() {
|
|
|
2577
2571
|
const endOfMonth = new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59, 999);
|
|
2578
2572
|
for (const meter of fetchedMeters) {
|
|
2579
2573
|
try {
|
|
2580
|
-
const meterSummaries = await
|
|
2574
|
+
const meterSummaries = await _chunkL5F5ZN5Fjs.StripeUsageService.getMeterSummaries({
|
|
2581
2575
|
meterId: meter.id,
|
|
2582
2576
|
startTime: startOfMonth,
|
|
2583
2577
|
endTime: endOfMonth
|
|
@@ -2595,7 +2589,7 @@ function UsageContainer() {
|
|
|
2595
2589
|
setLoading(false);
|
|
2596
2590
|
}
|
|
2597
2591
|
}, "loadUsageData");
|
|
2598
|
-
const hasMeteredSubscriptions = subscriptions.some((sub) => _optionalChain([sub, 'access',
|
|
2592
|
+
const hasMeteredSubscriptions = subscriptions.some((sub) => _optionalChain([sub, 'access', _102 => _102.price, 'optionalAccess', _103 => _103.recurring, 'optionalAccess', _104 => _104.usageType]) === "metered");
|
|
2599
2593
|
if (!loading && !hasMeteredSubscriptions) {
|
|
2600
2594
|
return null;
|
|
2601
2595
|
}
|
|
@@ -2643,21 +2637,21 @@ function UsageHistoryTable({ usageRecords }) {
|
|
|
2643
2637
|
}
|
|
2644
2638
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-y-4", children: [
|
|
2645
2639
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { className: "text-xl font-semibold", children: "Usage History" }),
|
|
2646
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "overflow-clip rounded-lg border", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2647
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2648
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2649
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2650
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2651
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2640
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "overflow-clip rounded-lg border", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.Table, { children: [
|
|
2641
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableHeader, { className: "bg-muted", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.TableRow, { children: [
|
|
2642
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableHead, { children: "Date & Time" }),
|
|
2643
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableHead, { children: "Meter Event" }),
|
|
2644
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableHead, { className: "text-right", children: "Quantity" }),
|
|
2645
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableHead, { children: "Event ID" })
|
|
2652
2646
|
] }) }),
|
|
2653
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2647
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableBody, { children: usageRecords.map((record) => {
|
|
2654
2648
|
const dateTime = formatDateTime(record.timestamp);
|
|
2655
2649
|
const quantity = record.quantity.toLocaleString();
|
|
2656
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2657
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2658
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2659
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2660
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2650
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.TableRow, { children: [
|
|
2651
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableCell, { className: "font-medium", children: dateTime }),
|
|
2652
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableCell, { className: "text-muted-foreground", children: record.meterEventName }),
|
|
2653
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableCell, { className: "text-right font-medium", children: quantity }),
|
|
2654
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.TableCell, { className: "text-muted-foreground text-sm font-mono", children: record.stripeEventId })
|
|
2661
2655
|
] }, record.id);
|
|
2662
2656
|
}) })
|
|
2663
2657
|
] }) })
|
|
@@ -2668,8 +2662,8 @@ _chunk7QVYU63Ejs.__name.call(void 0, UsageHistoryTable, "UsageHistoryTable");
|
|
|
2668
2662
|
// src/features/billing/components/modals/BillingDetailModal.tsx
|
|
2669
2663
|
|
|
2670
2664
|
function BillingDetailModal({ open, onOpenChange, title, children, className }) {
|
|
2671
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2672
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2665
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.DialogContent, { className: _nullishCoalesce(className, () => ( "max-w-4xl max-h-[90vh] overflow-y-auto")), children: [
|
|
2666
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.DialogHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.DialogTitle, { children: title }) }),
|
|
2673
2667
|
children
|
|
2674
2668
|
] }) });
|
|
2675
2669
|
}
|
|
@@ -2686,7 +2680,7 @@ function BillingAlertBanner({ subscription, onUpdatePayment, onAddPayment }) {
|
|
|
2686
2680
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "font-semibold text-red-900", children: "Payment Failed" }),
|
|
2687
2681
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-red-700 mt-1", children: "Your last payment failed. Please update your payment method to avoid service interruption." })
|
|
2688
2682
|
] }),
|
|
2689
|
-
onUpdatePayment && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2683
|
+
onUpdatePayment && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Button, { variant: "outline", size: "sm", onClick: onUpdatePayment, className: "border-red-300 text-red-700", children: "Update Payment Method" })
|
|
2690
2684
|
] });
|
|
2691
2685
|
}
|
|
2692
2686
|
if (subscription.status === "trialing" /* TRIALING */ && subscription.trialEnd) {
|
|
@@ -2706,7 +2700,7 @@ function BillingAlertBanner({ subscription, onUpdatePayment, onAddPayment }) {
|
|
|
2706
2700
|
". Add a payment method to continue your subscription."
|
|
2707
2701
|
] })
|
|
2708
2702
|
] }),
|
|
2709
|
-
onAddPayment && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2703
|
+
onAddPayment && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Button, { variant: "outline", size: "sm", onClick: onAddPayment, className: "border-yellow-300 text-yellow-700", children: "Add Payment Method" })
|
|
2710
2704
|
] });
|
|
2711
2705
|
}
|
|
2712
2706
|
}
|
|
@@ -2746,18 +2740,18 @@ function BillingDashboardContainer() {
|
|
|
2746
2740
|
const [showWizard, setShowWizard] = _react.useState.call(void 0, false);
|
|
2747
2741
|
const [editingSubscription, setEditingSubscription] = _react.useState.call(void 0, null);
|
|
2748
2742
|
const hasMeteredSubscriptions = _react.useCallback.call(void 0, () => {
|
|
2749
|
-
return data.subscriptions.some((sub) => _optionalChain([sub, 'access',
|
|
2743
|
+
return data.subscriptions.some((sub) => _optionalChain([sub, 'access', _105 => _105.price, 'optionalAccess', _106 => _106.recurring, 'optionalAccess', _107 => _107.usageType]) === "metered");
|
|
2750
2744
|
}, [data.subscriptions]);
|
|
2751
2745
|
const hasActiveRecurringSubscription = _react.useMemo.call(void 0, () => {
|
|
2752
2746
|
return data.subscriptions.some(
|
|
2753
|
-
(sub) => (sub.status === "active" /* ACTIVE */ || sub.status === "trialing" /* TRIALING */) && _optionalChain([sub, 'access',
|
|
2747
|
+
(sub) => (sub.status === "active" /* ACTIVE */ || sub.status === "trialing" /* TRIALING */) && _optionalChain([sub, 'access', _108 => _108.price, 'optionalAccess', _109 => _109.priceType]) === "recurring"
|
|
2754
2748
|
);
|
|
2755
2749
|
}, [data.subscriptions]);
|
|
2756
2750
|
const fetchAllData = _react.useCallback.call(void 0, async () => {
|
|
2757
2751
|
setNoCustomerExists(false);
|
|
2758
2752
|
let customer = null;
|
|
2759
2753
|
try {
|
|
2760
|
-
customer = await
|
|
2754
|
+
customer = await _chunkL5F5ZN5Fjs.StripeCustomerService.getCustomer();
|
|
2761
2755
|
setData((prev) => ({ ...prev, customer }));
|
|
2762
2756
|
setErrors((prev) => ({ ...prev, customer: null }));
|
|
2763
2757
|
setNoCustomerExists(false);
|
|
@@ -2782,7 +2776,7 @@ function BillingDashboardContainer() {
|
|
|
2782
2776
|
if (customer) {
|
|
2783
2777
|
const fetchSubscriptions = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2784
2778
|
try {
|
|
2785
|
-
const subscriptions2 = await
|
|
2779
|
+
const subscriptions2 = await _chunkL5F5ZN5Fjs.StripeSubscriptionService.listSubscriptions();
|
|
2786
2780
|
setData((prev) => ({ ...prev, subscriptions: subscriptions2 }));
|
|
2787
2781
|
setErrors((prev) => ({ ...prev, subscriptions: null }));
|
|
2788
2782
|
return subscriptions2;
|
|
@@ -2796,7 +2790,7 @@ function BillingDashboardContainer() {
|
|
|
2796
2790
|
}, "fetchSubscriptions");
|
|
2797
2791
|
const fetchPaymentMethods = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2798
2792
|
try {
|
|
2799
|
-
const paymentMethods = await
|
|
2793
|
+
const paymentMethods = await _chunkL5F5ZN5Fjs.StripeCustomerService.listPaymentMethods();
|
|
2800
2794
|
setData((prev) => ({ ...prev, paymentMethods }));
|
|
2801
2795
|
setErrors((prev) => ({ ...prev, paymentMethods: null }));
|
|
2802
2796
|
} catch (error) {
|
|
@@ -2808,7 +2802,7 @@ function BillingDashboardContainer() {
|
|
|
2808
2802
|
}, "fetchPaymentMethods");
|
|
2809
2803
|
const fetchInvoices = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2810
2804
|
try {
|
|
2811
|
-
const invoices = await
|
|
2805
|
+
const invoices = await _chunkL5F5ZN5Fjs.StripeInvoiceService.listInvoices();
|
|
2812
2806
|
setData((prev) => ({ ...prev, invoices }));
|
|
2813
2807
|
setErrors((prev) => ({ ...prev, invoices: null }));
|
|
2814
2808
|
} catch (error) {
|
|
@@ -2820,7 +2814,7 @@ function BillingDashboardContainer() {
|
|
|
2820
2814
|
}, "fetchInvoices");
|
|
2821
2815
|
const [subscriptions] = await Promise.all([fetchSubscriptions(), fetchPaymentMethods(), fetchInvoices()]);
|
|
2822
2816
|
const hasMetered = subscriptions.some(
|
|
2823
|
-
(sub) => _optionalChain([sub, 'access',
|
|
2817
|
+
(sub) => _optionalChain([sub, 'access', _110 => _110.price, 'optionalAccess', _111 => _111.recurring, 'optionalAccess', _112 => _112.usageType]) === "metered"
|
|
2824
2818
|
);
|
|
2825
2819
|
if (hasMetered) {
|
|
2826
2820
|
await fetchUsageData();
|
|
@@ -2832,7 +2826,7 @@ function BillingDashboardContainer() {
|
|
|
2832
2826
|
const handleCreateCustomer = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2833
2827
|
setCreatingCustomer(true);
|
|
2834
2828
|
try {
|
|
2835
|
-
await
|
|
2829
|
+
await _chunkL5F5ZN5Fjs.StripeCustomerService.createCustomer();
|
|
2836
2830
|
setNoCustomerExists(false);
|
|
2837
2831
|
await fetchAllData();
|
|
2838
2832
|
} catch (error) {
|
|
@@ -2844,7 +2838,7 @@ function BillingDashboardContainer() {
|
|
|
2844
2838
|
}, "handleCreateCustomer");
|
|
2845
2839
|
const fetchUsageData = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2846
2840
|
try {
|
|
2847
|
-
const meters = await
|
|
2841
|
+
const meters = await _chunkL5F5ZN5Fjs.StripeUsageService.listMeters();
|
|
2848
2842
|
setData((prev) => ({ ...prev, meters }));
|
|
2849
2843
|
const summariesMap = {};
|
|
2850
2844
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -2852,7 +2846,7 @@ function BillingDashboardContainer() {
|
|
|
2852
2846
|
const endOfMonth = new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59, 999);
|
|
2853
2847
|
for (const meter of meters) {
|
|
2854
2848
|
try {
|
|
2855
|
-
const meterSummaries = await
|
|
2849
|
+
const meterSummaries = await _chunkL5F5ZN5Fjs.StripeUsageService.getMeterSummaries({
|
|
2856
2850
|
meterId: meter.id,
|
|
2857
2851
|
startTime: startOfMonth,
|
|
2858
2852
|
endTime: endOfMonth
|
|
@@ -2930,18 +2924,18 @@ function BillingDashboardContainer() {
|
|
|
2930
2924
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Wallet, { className: "h-8 w-8" }),
|
|
2931
2925
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h1", { className: "text-3xl font-bold", children: "Billing" })
|
|
2932
2926
|
] }),
|
|
2933
|
-
isInitialLoading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2934
|
-
noCustomerExists && !isInitialLoading && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2935
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2927
|
+
isInitialLoading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Card, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.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" }) }) }),
|
|
2928
|
+
noCustomerExists && !isInitialLoading && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.Card, { children: [
|
|
2929
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.CardHeader, { className: "text-center", children: [
|
|
2936
2930
|
/* @__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" }) }),
|
|
2937
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2938
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2931
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardTitle, { children: "Set Up Billing" }),
|
|
2932
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardDescription, { children: "Your company doesn't have a billing account yet. Set one up to manage subscriptions, payment methods, and view invoices." })
|
|
2939
2933
|
] }),
|
|
2940
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2934
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardContent, { className: "flex justify-center pb-8", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Button, { onClick: handleCreateCustomer, disabled: creatingCustomer, size: "lg", children: creatingCustomer ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
2941
2935
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Loader2, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
2942
2936
|
"Setting up..."
|
|
2943
2937
|
] }) : "Set Up Billing Account" }) }),
|
|
2944
|
-
errors.customer && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2938
|
+
errors.customer && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CardContent, { className: "pt-0", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-center text-sm text-destructive", children: errors.customer }) })
|
|
2945
2939
|
] }),
|
|
2946
2940
|
!noCustomerExists && !isInitialLoading && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
2947
2941
|
criticalSubscriptions.map((subscription) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -2973,7 +2967,7 @@ function BillingDashboardContainer() {
|
|
|
2973
2967
|
PaymentMethodSummaryCard,
|
|
2974
2968
|
{
|
|
2975
2969
|
paymentMethods: data.paymentMethods,
|
|
2976
|
-
defaultPaymentMethodId: _optionalChain([data, 'access',
|
|
2970
|
+
defaultPaymentMethodId: _optionalChain([data, 'access', _113 => _113.customer, 'optionalAccess', _114 => _114.defaultPaymentMethodId]),
|
|
2977
2971
|
loading: loading.paymentMethods,
|
|
2978
2972
|
error: errors.paymentMethods || void 0,
|
|
2979
2973
|
onManageClick: () => setActiveModal("payment-methods")
|
|
@@ -3074,7 +3068,7 @@ function getStripePromise(publishableKey) {
|
|
|
3074
3068
|
if (!publishableKey) {
|
|
3075
3069
|
return Promise.resolve(null);
|
|
3076
3070
|
}
|
|
3077
|
-
if (_optionalChain([stripePromiseCache, 'optionalAccess',
|
|
3071
|
+
if (_optionalChain([stripePromiseCache, 'optionalAccess', _115 => _115.key]) === publishableKey) {
|
|
3078
3072
|
return stripePromiseCache.promise;
|
|
3079
3073
|
}
|
|
3080
3074
|
const promise = _stripejs.loadStripe.call(void 0, publishableKey);
|
|
@@ -3083,7 +3077,7 @@ function getStripePromise(publishableKey) {
|
|
|
3083
3077
|
}
|
|
3084
3078
|
_chunk7QVYU63Ejs.__name.call(void 0, getStripePromise, "getStripePromise");
|
|
3085
3079
|
function StripeProvider({ children }) {
|
|
3086
|
-
const publishableKey =
|
|
3080
|
+
const publishableKey = _chunkOODZEX6Pjs.getStripePublishableKey.call(void 0, );
|
|
3087
3081
|
const stripePromise = _react.useMemo.call(void 0, () => getStripePromise(publishableKey), [publishableKey]);
|
|
3088
3082
|
const options = _react.useMemo.call(void 0, () => ({}), []);
|
|
3089
3083
|
if (!publishableKey) {
|
|
@@ -3093,7 +3087,7 @@ function StripeProvider({ children }) {
|
|
|
3093
3087
|
}
|
|
3094
3088
|
_chunk7QVYU63Ejs.__name.call(void 0, StripeProvider, "StripeProvider");
|
|
3095
3089
|
function isStripeConfigured() {
|
|
3096
|
-
return !!
|
|
3090
|
+
return !!_chunkOODZEX6Pjs.getStripePublishableKey.call(void 0, );
|
|
3097
3091
|
}
|
|
3098
3092
|
_chunk7QVYU63Ejs.__name.call(void 0, isStripeConfigured, "isStripeConfigured");
|
|
3099
3093
|
|
|
@@ -3111,7 +3105,7 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
3111
3105
|
_react.useEffect.call(void 0, () => {
|
|
3112
3106
|
const fetchFeatures = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
3113
3107
|
try {
|
|
3114
|
-
const features = await
|
|
3108
|
+
const features = await _chunkL5F5ZN5Fjs.FeatureService.findMany({});
|
|
3115
3109
|
setAllFeatures(features);
|
|
3116
3110
|
} catch (error) {
|
|
3117
3111
|
console.error("[PriceEditor] Failed to fetch features:", error);
|
|
@@ -3140,23 +3134,23 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
3140
3134
|
featureIds: _zod3.z.array(_zod3.z.string())
|
|
3141
3135
|
});
|
|
3142
3136
|
const isEditMode = !!price;
|
|
3143
|
-
const defaultUnitAmount = _optionalChain([price, 'optionalAccess',
|
|
3137
|
+
const defaultUnitAmount = _optionalChain([price, 'optionalAccess', _116 => _116.unitAmount]) ? price.unitAmount / 100 : 0;
|
|
3144
3138
|
const coreFeatureIds = allFeatures.filter((f) => f.isCore).map((f) => f.id);
|
|
3145
|
-
const defaultFeatureIds = [.../* @__PURE__ */ new Set([..._nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3139
|
+
const defaultFeatureIds = [.../* @__PURE__ */ new Set([..._nullishCoalesce(_optionalChain([price, 'optionalAccess', _117 => _117.priceFeatures, 'optionalAccess', _118 => _118.map, 'call', _119 => _119((f) => f.id)]), () => ( [])), ...coreFeatureIds])];
|
|
3146
3140
|
const form = _reacthookform.useForm.call(void 0, {
|
|
3147
3141
|
resolver: _zod.zodResolver.call(void 0, formSchema2),
|
|
3148
3142
|
defaultValues: {
|
|
3149
3143
|
unitAmount: defaultUnitAmount,
|
|
3150
|
-
currency: _optionalChain([price, 'optionalAccess',
|
|
3151
|
-
interval: _optionalChain([price, 'optionalAccess',
|
|
3152
|
-
intervalCount: _optionalChain([price, 'optionalAccess',
|
|
3153
|
-
usageType: _optionalChain([price, 'optionalAccess',
|
|
3154
|
-
nickname: _optionalChain([price, 'optionalAccess',
|
|
3155
|
-
active: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3156
|
-
isTrial: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3157
|
-
description: _optionalChain([price, 'optionalAccess',
|
|
3158
|
-
features: _optionalChain([price, 'optionalAccess',
|
|
3159
|
-
token: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3144
|
+
currency: _optionalChain([price, 'optionalAccess', _120 => _120.currency]) || "usd",
|
|
3145
|
+
interval: _optionalChain([price, 'optionalAccess', _121 => _121.priceType]) === "one_time" ? "one_time" : _optionalChain([price, 'optionalAccess', _122 => _122.recurring, 'optionalAccess', _123 => _123.interval]) || "month",
|
|
3146
|
+
intervalCount: _optionalChain([price, 'optionalAccess', _124 => _124.recurring, 'optionalAccess', _125 => _125.intervalCount]) || 1,
|
|
3147
|
+
usageType: _optionalChain([price, 'optionalAccess', _126 => _126.recurring, 'optionalAccess', _127 => _127.usageType]) || "licensed",
|
|
3148
|
+
nickname: _optionalChain([price, 'optionalAccess', _128 => _128.nickname]) || "",
|
|
3149
|
+
active: _nullishCoalesce(_optionalChain([price, 'optionalAccess', _129 => _129.active]), () => ( true)),
|
|
3150
|
+
isTrial: _nullishCoalesce(_optionalChain([price, 'optionalAccess', _130 => _130.isTrial]), () => ( false)),
|
|
3151
|
+
description: _optionalChain([price, 'optionalAccess', _131 => _131.description]) || "",
|
|
3152
|
+
features: _optionalChain([price, 'optionalAccess', _132 => _132.features]) || [],
|
|
3153
|
+
token: _nullishCoalesce(_optionalChain([price, 'optionalAccess', _133 => _133.token, 'optionalAccess', _134 => _134.toString, 'call', _135 => _135()]), () => ( "")),
|
|
3160
3154
|
featureIds: defaultFeatureIds
|
|
3161
3155
|
}
|
|
3162
3156
|
});
|
|
@@ -3164,24 +3158,24 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
3164
3158
|
if (open) {
|
|
3165
3159
|
const currentCoreFeatureIds = allFeatures.filter((f) => f.isCore).map((f) => f.id);
|
|
3166
3160
|
const resetFeatureIds = [
|
|
3167
|
-
.../* @__PURE__ */ new Set([..._nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3161
|
+
.../* @__PURE__ */ new Set([..._nullishCoalesce(_optionalChain([price, 'optionalAccess', _136 => _136.priceFeatures, 'optionalAccess', _137 => _137.map, 'call', _138 => _138((f) => f.id)]), () => ( [])), ...currentCoreFeatureIds])
|
|
3168
3162
|
];
|
|
3169
3163
|
form.reset({
|
|
3170
|
-
unitAmount: _optionalChain([price, 'optionalAccess',
|
|
3171
|
-
currency: _optionalChain([price, 'optionalAccess',
|
|
3172
|
-
interval: _optionalChain([price, 'optionalAccess',
|
|
3173
|
-
intervalCount: _optionalChain([price, 'optionalAccess',
|
|
3174
|
-
usageType: _optionalChain([price, 'optionalAccess',
|
|
3175
|
-
nickname: _optionalChain([price, 'optionalAccess',
|
|
3176
|
-
active: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3177
|
-
isTrial: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3178
|
-
description: _optionalChain([price, 'optionalAccess',
|
|
3179
|
-
features: _optionalChain([price, 'optionalAccess',
|
|
3180
|
-
token: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3164
|
+
unitAmount: _optionalChain([price, 'optionalAccess', _139 => _139.unitAmount]) ? price.unitAmount / 100 : 0,
|
|
3165
|
+
currency: _optionalChain([price, 'optionalAccess', _140 => _140.currency]) || "usd",
|
|
3166
|
+
interval: _optionalChain([price, 'optionalAccess', _141 => _141.priceType]) === "one_time" ? "one_time" : _optionalChain([price, 'optionalAccess', _142 => _142.recurring, 'optionalAccess', _143 => _143.interval]) || "month",
|
|
3167
|
+
intervalCount: _optionalChain([price, 'optionalAccess', _144 => _144.recurring, 'optionalAccess', _145 => _145.intervalCount]) || 1,
|
|
3168
|
+
usageType: _optionalChain([price, 'optionalAccess', _146 => _146.recurring, 'optionalAccess', _147 => _147.usageType]) || "licensed",
|
|
3169
|
+
nickname: _optionalChain([price, 'optionalAccess', _148 => _148.nickname]) || "",
|
|
3170
|
+
active: _nullishCoalesce(_optionalChain([price, 'optionalAccess', _149 => _149.active]), () => ( true)),
|
|
3171
|
+
isTrial: _nullishCoalesce(_optionalChain([price, 'optionalAccess', _150 => _150.isTrial]), () => ( false)),
|
|
3172
|
+
description: _optionalChain([price, 'optionalAccess', _151 => _151.description]) || "",
|
|
3173
|
+
features: _optionalChain([price, 'optionalAccess', _152 => _152.features]) || [],
|
|
3174
|
+
token: _nullishCoalesce(_optionalChain([price, 'optionalAccess', _153 => _153.token, 'optionalAccess', _154 => _154.toString, 'call', _155 => _155()]), () => ( "")),
|
|
3181
3175
|
featureIds: resetFeatureIds
|
|
3182
3176
|
});
|
|
3183
3177
|
}
|
|
3184
|
-
}, [open, _optionalChain([price, 'optionalAccess',
|
|
3178
|
+
}, [open, _optionalChain([price, 'optionalAccess', _156 => _156.id]), allFeatures]);
|
|
3185
3179
|
const watchInterval = form.watch("interval");
|
|
3186
3180
|
const isRecurring = watchInterval !== "one_time";
|
|
3187
3181
|
const onSubmit = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async (values) => {
|
|
@@ -3189,14 +3183,14 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
3189
3183
|
try {
|
|
3190
3184
|
const unitAmountInCents = Math.round(values.unitAmount * 100);
|
|
3191
3185
|
if (isEditMode) {
|
|
3192
|
-
await
|
|
3186
|
+
await _chunkL5F5ZN5Fjs.StripePriceService.updatePrice({
|
|
3193
3187
|
id: price.id,
|
|
3194
3188
|
nickname: values.nickname || void 0,
|
|
3195
3189
|
description: values.description || void 0,
|
|
3196
3190
|
features: values.features.filter((f) => f.trim()) || void 0,
|
|
3197
3191
|
token: values.token ? parseInt(values.token, 10) : void 0,
|
|
3198
3192
|
// Only include isTrial and featureIds for recurring prices
|
|
3199
|
-
..._optionalChain([price, 'optionalAccess',
|
|
3193
|
+
..._optionalChain([price, 'optionalAccess', _157 => _157.priceType]) === "recurring" ? { isTrial: values.isTrial, featureIds: values.featureIds } : {}
|
|
3200
3194
|
});
|
|
3201
3195
|
} else {
|
|
3202
3196
|
const createInput = {
|
|
@@ -3231,7 +3225,7 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
3231
3225
|
createInput.featureIds = values.featureIds;
|
|
3232
3226
|
}
|
|
3233
3227
|
}
|
|
3234
|
-
await
|
|
3228
|
+
await _chunkL5F5ZN5Fjs.StripePriceService.createPrice(createInput);
|
|
3235
3229
|
}
|
|
3236
3230
|
onSuccess();
|
|
3237
3231
|
onOpenChange(false);
|
|
@@ -3257,10 +3251,10 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
3257
3251
|
{ id: "licensed", text: "Licensed (per unit)" },
|
|
3258
3252
|
{ id: "metered", text: "Metered (usage-based)" }
|
|
3259
3253
|
];
|
|
3260
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3261
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3262
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3263
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3254
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.DialogContent, { className: "max-w-2xl", children: [
|
|
3255
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.DialogHeader, { children: [
|
|
3256
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.DialogTitle, { children: isEditMode ? "Edit Price" : "Create Price" }),
|
|
3257
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.DialogDescription, { children: isEditMode ? "Update the price details. Note: Only nickname and active status can be changed." : "Create a new price for this product" })
|
|
3264
3258
|
] }),
|
|
3265
3259
|
isEditMode && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "bg-blue-50 border border-blue-200 rounded-lg p-4 flex gap-x-3", children: [
|
|
3266
3260
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.AlertCircle, { className: "h-5 w-5 text-blue-600 flex-shrink-0 mt-0.5" }),
|
|
@@ -3269,10 +3263,10 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
3269
3263
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { children: "Due to Stripe's architecture, only the nickname and active status can be modified after creation. To change amount, currency, or billing interval, create a new price." })
|
|
3270
3264
|
] })
|
|
3271
3265
|
] }),
|
|
3272
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3266
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Form, { ...form, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { onSubmit: form.handleSubmit(onSubmit), className: "flex flex-col gap-y-4", children: [
|
|
3273
3267
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid grid-cols-2 gap-x-4", children: [
|
|
3274
3268
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3275
|
-
|
|
3269
|
+
_chunkQPWHMXE2js.FormInput,
|
|
3276
3270
|
{
|
|
3277
3271
|
form,
|
|
3278
3272
|
id: "unitAmount",
|
|
@@ -3282,10 +3276,10 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
3282
3276
|
isRequired: true
|
|
3283
3277
|
}
|
|
3284
3278
|
),
|
|
3285
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3279
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.FormSelect, { form, id: "currency", name: "Currency", values: currencyOptions, disabled: isEditMode })
|
|
3286
3280
|
] }),
|
|
3287
3281
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3288
|
-
|
|
3282
|
+
_chunkQPWHMXE2js.FormSelect,
|
|
3289
3283
|
{
|
|
3290
3284
|
form,
|
|
3291
3285
|
id: "interval",
|
|
@@ -3296,7 +3290,7 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
3296
3290
|
),
|
|
3297
3291
|
isRecurring && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid grid-cols-2 gap-x-4", children: [
|
|
3298
3292
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3299
|
-
|
|
3293
|
+
_chunkQPWHMXE2js.FormInput,
|
|
3300
3294
|
{
|
|
3301
3295
|
form,
|
|
3302
3296
|
id: "intervalCount",
|
|
@@ -3307,7 +3301,7 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
3307
3301
|
}
|
|
3308
3302
|
),
|
|
3309
3303
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3310
|
-
|
|
3304
|
+
_chunkQPWHMXE2js.FormSelect,
|
|
3311
3305
|
{
|
|
3312
3306
|
form,
|
|
3313
3307
|
id: "usageType",
|
|
@@ -3318,7 +3312,7 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
3318
3312
|
)
|
|
3319
3313
|
] }),
|
|
3320
3314
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3321
|
-
|
|
3315
|
+
_chunkQPWHMXE2js.FormInput,
|
|
3322
3316
|
{
|
|
3323
3317
|
form,
|
|
3324
3318
|
id: "nickname",
|
|
@@ -3327,7 +3321,7 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
3327
3321
|
}
|
|
3328
3322
|
),
|
|
3329
3323
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3330
|
-
|
|
3324
|
+
_chunkQPWHMXE2js.FormTextarea,
|
|
3331
3325
|
{
|
|
3332
3326
|
form,
|
|
3333
3327
|
id: "description",
|
|
@@ -3336,13 +3330,13 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
3336
3330
|
className: "min-h-24"
|
|
3337
3331
|
}
|
|
3338
3332
|
),
|
|
3339
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3333
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.FormInput, { form, id: "token", name: "Token (optional)", placeholder: "Enter token value" }),
|
|
3340
3334
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
3341
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3335
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Label, { children: "Features (optional)" }),
|
|
3342
3336
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
3343
3337
|
form.watch("features").map((_, index) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex gap-2", children: [
|
|
3344
3338
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3345
|
-
|
|
3339
|
+
_chunkQPWHMXE2js.Input,
|
|
3346
3340
|
{
|
|
3347
3341
|
...form.register(`features.${index}`),
|
|
3348
3342
|
placeholder: `Feature ${index + 1}`,
|
|
@@ -3350,7 +3344,7 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
3350
3344
|
}
|
|
3351
3345
|
),
|
|
3352
3346
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3353
|
-
|
|
3347
|
+
_chunkQPWHMXE2js.Button,
|
|
3354
3348
|
{
|
|
3355
3349
|
type: "button",
|
|
3356
3350
|
variant: "outline",
|
|
@@ -3367,7 +3361,7 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
3367
3361
|
)
|
|
3368
3362
|
] }, index)),
|
|
3369
3363
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3370
|
-
|
|
3364
|
+
_chunkQPWHMXE2js.Button,
|
|
3371
3365
|
{
|
|
3372
3366
|
type: "button",
|
|
3373
3367
|
variant: "outline",
|
|
@@ -3386,7 +3380,7 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
3386
3380
|
] })
|
|
3387
3381
|
] }),
|
|
3388
3382
|
isRecurring && allFeatures.length > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
3389
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3383
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Label, { children: "Platform Features" }),
|
|
3390
3384
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border rounded-md p-4 space-y-2 max-h-48 overflow-y-auto", children: allFeatures.map((feature) => {
|
|
3391
3385
|
const isCore = feature.isCore;
|
|
3392
3386
|
const isChecked = form.watch("featureIds").includes(feature.id);
|
|
@@ -3428,9 +3422,9 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
3428
3422
|
] }, feature.id);
|
|
3429
3423
|
}) })
|
|
3430
3424
|
] }),
|
|
3431
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3425
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.FormCheckbox, { form, id: "active", name: "Active" }),
|
|
3432
3426
|
isRecurring && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3433
|
-
|
|
3427
|
+
_chunkQPWHMXE2js.FormCheckbox,
|
|
3434
3428
|
{
|
|
3435
3429
|
form,
|
|
3436
3430
|
id: "isTrial",
|
|
@@ -3438,7 +3432,7 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
3438
3432
|
description: "Mark this as the trial subscription plan (only one price should be marked as trial)"
|
|
3439
3433
|
}
|
|
3440
3434
|
),
|
|
3441
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3435
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CommonEditorButtons, { isEdit: isEditMode, form, disabled: isSubmitting, setOpen: onOpenChange })
|
|
3442
3436
|
] }) })
|
|
3443
3437
|
] }) });
|
|
3444
3438
|
}
|
|
@@ -3460,7 +3454,7 @@ function PricesList({ productId, onPricesChange }) {
|
|
|
3460
3454
|
const loadPrices = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
3461
3455
|
setLoading(true);
|
|
3462
3456
|
try {
|
|
3463
|
-
const fetchedPrices = await
|
|
3457
|
+
const fetchedPrices = await _chunkL5F5ZN5Fjs.StripePriceService.listPrices({ productId });
|
|
3464
3458
|
setPrices(fetchedPrices);
|
|
3465
3459
|
} catch (error) {
|
|
3466
3460
|
console.error("[PricesList] Failed to load prices:", error);
|
|
@@ -3477,7 +3471,7 @@ function PricesList({ productId, onPricesChange }) {
|
|
|
3477
3471
|
}
|
|
3478
3472
|
setArchivingPriceId(priceToArchive.id);
|
|
3479
3473
|
try {
|
|
3480
|
-
await
|
|
3474
|
+
await _chunkL5F5ZN5Fjs.StripePriceService.archivePrice({ id: priceToArchive.id });
|
|
3481
3475
|
setPriceToArchive(null);
|
|
3482
3476
|
await loadPrices();
|
|
3483
3477
|
onPricesChange();
|
|
@@ -3493,7 +3487,7 @@ function PricesList({ productId, onPricesChange }) {
|
|
|
3493
3487
|
}
|
|
3494
3488
|
setReactivatingPriceId(priceToReactivate.id);
|
|
3495
3489
|
try {
|
|
3496
|
-
await
|
|
3490
|
+
await _chunkL5F5ZN5Fjs.StripePriceService.reactivatePrice({ id: priceToReactivate.id });
|
|
3497
3491
|
setPriceToReactivate(null);
|
|
3498
3492
|
await loadPrices();
|
|
3499
3493
|
onPricesChange();
|
|
@@ -3524,12 +3518,12 @@ function PricesList({ productId, onPricesChange }) {
|
|
|
3524
3518
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-y-4", children: [
|
|
3525
3519
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-between mb-4", children: [
|
|
3526
3520
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h4", { className: "text-lg font-semibold", children: "Prices" }),
|
|
3527
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3521
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Button, { size: "sm", onClick: () => setShowCreatePrice(true), children: "Add Price" })
|
|
3528
3522
|
] }),
|
|
3529
3523
|
prices.length === 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "bg-background flex flex-col items-center justify-center gap-y-3 rounded-lg border border-dashed p-8", children: [
|
|
3530
3524
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.DollarSign, { className: "text-muted-foreground h-12 w-12" }),
|
|
3531
3525
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-muted-foreground text-sm", children: "No prices yet. Add a price to enable subscriptions." }),
|
|
3532
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3526
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Button, { size: "sm", onClick: () => setShowCreatePrice(true), children: "Add Price" })
|
|
3533
3527
|
] }),
|
|
3534
3528
|
prices.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4", children: prices.map((price) => {
|
|
3535
3529
|
const isArchiving = archivingPriceId === price.id;
|
|
@@ -3538,9 +3532,9 @@ function PricesList({ productId, onPricesChange }) {
|
|
|
3538
3532
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-start justify-between mb-3", children: [
|
|
3539
3533
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.DollarSign, { className: "h-5 w-5 text-primary" }),
|
|
3540
3534
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex gap-1", children: [
|
|
3541
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3535
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Button, { variant: "ghost", size: "sm", onClick: () => setEditingPrice(price), className: "h-8 w-8 p-0", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Edit, { className: "h-4 w-4" }) }),
|
|
3542
3536
|
price.active ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3543
|
-
|
|
3537
|
+
_chunkQPWHMXE2js.Button,
|
|
3544
3538
|
{
|
|
3545
3539
|
variant: "ghost",
|
|
3546
3540
|
size: "sm",
|
|
@@ -3550,7 +3544,7 @@ function PricesList({ productId, onPricesChange }) {
|
|
|
3550
3544
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Archive, { className: "h-4 w-4" })
|
|
3551
3545
|
}
|
|
3552
3546
|
) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3553
|
-
|
|
3547
|
+
_chunkQPWHMXE2js.Button,
|
|
3554
3548
|
{
|
|
3555
3549
|
variant: "ghost",
|
|
3556
3550
|
size: "sm",
|
|
@@ -3567,10 +3561,10 @@ function PricesList({ productId, onPricesChange }) {
|
|
|
3567
3561
|
" ",
|
|
3568
3562
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-sm font-normal", children: formatInterval2(price) })
|
|
3569
3563
|
] }) }),
|
|
3570
|
-
_optionalChain([price, 'access',
|
|
3564
|
+
_optionalChain([price, 'access', _158 => _158.metadata, 'optionalAccess', _159 => _159.nickname]) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm font-medium mb-2", children: price.metadata.nickname }),
|
|
3571
3565
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-wrap gap-2", children: [
|
|
3572
3566
|
price.active ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "bg-green-100 text-green-800 text-xs px-2 py-1 rounded-full font-medium", children: "Active" }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "bg-gray-100 text-gray-800 text-xs px-2 py-1 rounded-full font-medium", children: "Inactive" }),
|
|
3573
|
-
_optionalChain([price, 'access',
|
|
3567
|
+
_optionalChain([price, 'access', _160 => _160.recurring, 'optionalAccess', _161 => _161.usageType]) === "metered" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "bg-blue-100 text-blue-800 text-xs px-2 py-1 rounded-full font-medium", children: "Metered" }),
|
|
3574
3568
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "bg-gray-100 text-gray-800 text-xs px-2 py-1 rounded-full font-medium uppercase", children: price.currency })
|
|
3575
3569
|
] })
|
|
3576
3570
|
] }, price.id);
|
|
@@ -3601,20 +3595,20 @@ function PricesList({ productId, onPricesChange }) {
|
|
|
3601
3595
|
}
|
|
3602
3596
|
}
|
|
3603
3597
|
),
|
|
3604
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3605
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3606
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3607
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3598
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.AlertDialog, { open: !!priceToArchive, onOpenChange: (open) => !open && setPriceToArchive(null), children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.AlertDialogContent, { children: [
|
|
3599
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.AlertDialogHeader, { children: [
|
|
3600
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.AlertDialogTitle, { children: "Archive Price" }),
|
|
3601
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.AlertDialogDescription, { children: [
|
|
3608
3602
|
"Are you sure you want to archive the price for",
|
|
3609
3603
|
" ",
|
|
3610
3604
|
priceToArchive && `${formatCurrency(priceToArchive.unitAmount, priceToArchive.currency)} ${formatInterval2(priceToArchive)}`,
|
|
3611
3605
|
"? This will prevent new subscriptions but existing ones will continue."
|
|
3612
3606
|
] })
|
|
3613
3607
|
] }),
|
|
3614
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3615
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3608
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.AlertDialogFooter, { children: [
|
|
3609
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.AlertDialogCancel, { disabled: !!archivingPriceId, children: "Cancel" }),
|
|
3616
3610
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3617
|
-
|
|
3611
|
+
_chunkQPWHMXE2js.AlertDialogAction,
|
|
3618
3612
|
{
|
|
3619
3613
|
onClick: handleArchive,
|
|
3620
3614
|
disabled: !!archivingPriceId,
|
|
@@ -3624,20 +3618,20 @@ function PricesList({ productId, onPricesChange }) {
|
|
|
3624
3618
|
)
|
|
3625
3619
|
] })
|
|
3626
3620
|
] }) }),
|
|
3627
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3628
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3629
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3630
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3621
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.AlertDialog, { open: !!priceToReactivate, onOpenChange: (open) => !open && setPriceToReactivate(null), children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.AlertDialogContent, { children: [
|
|
3622
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.AlertDialogHeader, { children: [
|
|
3623
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.AlertDialogTitle, { children: "Reactivate Price" }),
|
|
3624
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.AlertDialogDescription, { children: [
|
|
3631
3625
|
"Are you sure you want to reactivate the price for",
|
|
3632
3626
|
" ",
|
|
3633
3627
|
priceToReactivate && `${formatCurrency(priceToReactivate.unitAmount, priceToReactivate.currency)} ${formatInterval2(priceToReactivate)}`,
|
|
3634
3628
|
"? This will allow new subscriptions again."
|
|
3635
3629
|
] })
|
|
3636
3630
|
] }),
|
|
3637
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3638
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3631
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.AlertDialogFooter, { children: [
|
|
3632
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.AlertDialogCancel, { disabled: !!reactivatingPriceId, children: "Cancel" }),
|
|
3639
3633
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3640
|
-
|
|
3634
|
+
_chunkQPWHMXE2js.AlertDialogAction,
|
|
3641
3635
|
{
|
|
3642
3636
|
onClick: handleReactivate,
|
|
3643
3637
|
disabled: !!reactivatingPriceId,
|
|
@@ -3672,23 +3666,23 @@ function ProductEditor({ product, open, onOpenChange, onSuccess }) {
|
|
|
3672
3666
|
const form = _reacthookform.useForm.call(void 0, {
|
|
3673
3667
|
resolver: _zod.zodResolver.call(void 0, formSchema2),
|
|
3674
3668
|
defaultValues: {
|
|
3675
|
-
name: _optionalChain([product, 'optionalAccess',
|
|
3676
|
-
description: _optionalChain([product, 'optionalAccess',
|
|
3677
|
-
active: _nullishCoalesce(_optionalChain([product, 'optionalAccess',
|
|
3669
|
+
name: _optionalChain([product, 'optionalAccess', _162 => _162.name]) || "",
|
|
3670
|
+
description: _optionalChain([product, 'optionalAccess', _163 => _163.description]) || "",
|
|
3671
|
+
active: _nullishCoalesce(_optionalChain([product, 'optionalAccess', _164 => _164.active]), () => ( true))
|
|
3678
3672
|
}
|
|
3679
3673
|
});
|
|
3680
3674
|
const onSubmit = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async (values) => {
|
|
3681
3675
|
setIsSubmitting(true);
|
|
3682
3676
|
try {
|
|
3683
3677
|
if (product) {
|
|
3684
|
-
await
|
|
3678
|
+
await _chunkL5F5ZN5Fjs.StripeProductService.updateProduct({
|
|
3685
3679
|
id: product.id,
|
|
3686
3680
|
name: values.name,
|
|
3687
3681
|
description: values.description,
|
|
3688
3682
|
active: values.active
|
|
3689
3683
|
});
|
|
3690
3684
|
} else {
|
|
3691
|
-
await
|
|
3685
|
+
await _chunkL5F5ZN5Fjs.StripeProductService.createProduct({
|
|
3692
3686
|
id: _uuid.v4.call(void 0, ),
|
|
3693
3687
|
name: values.name,
|
|
3694
3688
|
description: values.description,
|
|
@@ -3703,15 +3697,15 @@ function ProductEditor({ product, open, onOpenChange, onSuccess }) {
|
|
|
3703
3697
|
setIsSubmitting(false);
|
|
3704
3698
|
}
|
|
3705
3699
|
}, "onSubmit");
|
|
3706
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3707
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3708
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3709
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3700
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.DialogContent, { className: "max-w-2xl", children: [
|
|
3701
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.DialogHeader, { children: [
|
|
3702
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.DialogTitle, { children: product ? "Edit Product" : "Create Product" }),
|
|
3703
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.DialogDescription, { children: product ? `Update the details for ${product.name}` : "Create a new product to offer to your customers" })
|
|
3710
3704
|
] }),
|
|
3711
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3712
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3705
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Form, { ...form, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { onSubmit: form.handleSubmit(onSubmit), className: "flex flex-col gap-y-4", children: [
|
|
3706
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.FormInput, { form, id: "name", name: "Product Name", placeholder: "Enter product name", isRequired: true }),
|
|
3713
3707
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3714
|
-
|
|
3708
|
+
_chunkQPWHMXE2js.FormTextarea,
|
|
3715
3709
|
{
|
|
3716
3710
|
form,
|
|
3717
3711
|
id: "description",
|
|
@@ -3720,8 +3714,8 @@ function ProductEditor({ product, open, onOpenChange, onSuccess }) {
|
|
|
3720
3714
|
className: "min-h-32"
|
|
3721
3715
|
}
|
|
3722
3716
|
),
|
|
3723
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3724
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3717
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.FormCheckbox, { form, id: "active", name: "Active" }),
|
|
3718
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.CommonEditorButtons, { isEdit: !!product, form, disabled: isSubmitting, setOpen: onOpenChange })
|
|
3725
3719
|
] }) })
|
|
3726
3720
|
] }) });
|
|
3727
3721
|
}
|
|
@@ -3744,7 +3738,7 @@ function ProductsList({ products, onProductsChange }) {
|
|
|
3744
3738
|
}
|
|
3745
3739
|
setArchivingProductId(productToArchive.id);
|
|
3746
3740
|
try {
|
|
3747
|
-
const _archivedProduct = await
|
|
3741
|
+
const _archivedProduct = await _chunkL5F5ZN5Fjs.StripeProductService.archiveProduct({ id: productToArchive.id });
|
|
3748
3742
|
setProductToArchive(null);
|
|
3749
3743
|
onProductsChange();
|
|
3750
3744
|
} catch (_error) {
|
|
@@ -3759,7 +3753,7 @@ function ProductsList({ products, onProductsChange }) {
|
|
|
3759
3753
|
}
|
|
3760
3754
|
setReactivatingProductId(productToReactivate.id);
|
|
3761
3755
|
try {
|
|
3762
|
-
const _reactivatedProduct = await
|
|
3756
|
+
const _reactivatedProduct = await _chunkL5F5ZN5Fjs.StripeProductService.reactivateProduct({ id: productToReactivate.id });
|
|
3763
3757
|
setProductToReactivate(null);
|
|
3764
3758
|
onProductsChange();
|
|
3765
3759
|
} catch (_error) {
|
|
@@ -3788,12 +3782,12 @@ function ProductsList({ products, onProductsChange }) {
|
|
|
3788
3782
|
] })
|
|
3789
3783
|
] }),
|
|
3790
3784
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-2", children: [
|
|
3791
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3785
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.Button, { variant: "outline", size: "sm", onClick: () => setEditingProduct(product), children: [
|
|
3792
3786
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Edit, { className: "h-4 w-4 mr-1" }),
|
|
3793
3787
|
"Edit"
|
|
3794
3788
|
] }),
|
|
3795
3789
|
product.active ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3796
|
-
|
|
3790
|
+
_chunkQPWHMXE2js.Button,
|
|
3797
3791
|
{
|
|
3798
3792
|
variant: "outline",
|
|
3799
3793
|
size: "sm",
|
|
@@ -3805,7 +3799,7 @@ function ProductsList({ products, onProductsChange }) {
|
|
|
3805
3799
|
]
|
|
3806
3800
|
}
|
|
3807
3801
|
) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3808
|
-
|
|
3802
|
+
_chunkQPWHMXE2js.Button,
|
|
3809
3803
|
{
|
|
3810
3804
|
variant: "outline",
|
|
3811
3805
|
size: "sm",
|
|
@@ -3817,7 +3811,7 @@ function ProductsList({ products, onProductsChange }) {
|
|
|
3817
3811
|
]
|
|
3818
3812
|
}
|
|
3819
3813
|
),
|
|
3820
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3814
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Button, { variant: "ghost", size: "sm", onClick: () => toggleExpand(product.id), children: isExpanded ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ChevronUp, { className: "h-5 w-5" }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ChevronDown, { className: "h-5 w-5" }) })
|
|
3821
3815
|
] })
|
|
3822
3816
|
] }),
|
|
3823
3817
|
isExpanded && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border-t bg-muted/30 p-6", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PricesList, { productId: product.id, onPricesChange: onProductsChange }) })
|
|
@@ -3835,19 +3829,19 @@ function ProductsList({ products, onProductsChange }) {
|
|
|
3835
3829
|
}
|
|
3836
3830
|
}
|
|
3837
3831
|
),
|
|
3838
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3839
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3840
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3841
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3832
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.AlertDialog, { open: !!productToArchive, onOpenChange: (open) => !open && setProductToArchive(null), children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.AlertDialogContent, { children: [
|
|
3833
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.AlertDialogHeader, { children: [
|
|
3834
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.AlertDialogTitle, { children: "Archive Product" }),
|
|
3835
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.AlertDialogDescription, { children: [
|
|
3842
3836
|
'Are you sure you want to archive "',
|
|
3843
|
-
_optionalChain([productToArchive, 'optionalAccess',
|
|
3837
|
+
_optionalChain([productToArchive, 'optionalAccess', _165 => _165.name]),
|
|
3844
3838
|
'"? This will deactivate it and it will no longer be available for new subscriptions.'
|
|
3845
3839
|
] })
|
|
3846
3840
|
] }),
|
|
3847
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3848
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3841
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.AlertDialogFooter, { children: [
|
|
3842
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.AlertDialogCancel, { disabled: !!archivingProductId, children: "Cancel" }),
|
|
3849
3843
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3850
|
-
|
|
3844
|
+
_chunkQPWHMXE2js.AlertDialogAction,
|
|
3851
3845
|
{
|
|
3852
3846
|
onClick: handleArchive,
|
|
3853
3847
|
disabled: !!archivingProductId,
|
|
@@ -3857,19 +3851,19 @@ function ProductsList({ products, onProductsChange }) {
|
|
|
3857
3851
|
)
|
|
3858
3852
|
] })
|
|
3859
3853
|
] }) }),
|
|
3860
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3861
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3862
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3863
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3854
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.AlertDialog, { open: !!productToReactivate, onOpenChange: (open) => !open && setProductToReactivate(null), children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.AlertDialogContent, { children: [
|
|
3855
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.AlertDialogHeader, { children: [
|
|
3856
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.AlertDialogTitle, { children: "Reactivate Product" }),
|
|
3857
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.AlertDialogDescription, { children: [
|
|
3864
3858
|
'Are you sure you want to reactivate "',
|
|
3865
|
-
_optionalChain([productToReactivate, 'optionalAccess',
|
|
3859
|
+
_optionalChain([productToReactivate, 'optionalAccess', _166 => _166.name]),
|
|
3866
3860
|
'"? This will make it available for new subscriptions again.'
|
|
3867
3861
|
] })
|
|
3868
3862
|
] }),
|
|
3869
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3870
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3863
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkQPWHMXE2js.AlertDialogFooter, { children: [
|
|
3864
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.AlertDialogCancel, { disabled: !!reactivatingProductId, children: "Cancel" }),
|
|
3871
3865
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3872
|
-
|
|
3866
|
+
_chunkQPWHMXE2js.AlertDialogAction,
|
|
3873
3867
|
{
|
|
3874
3868
|
onClick: handleReactivate,
|
|
3875
3869
|
disabled: !!reactivatingProductId,
|
|
@@ -3886,17 +3880,17 @@ _chunk7QVYU63Ejs.__name.call(void 0, ProductsList, "ProductsList");
|
|
|
3886
3880
|
// src/features/billing/stripe-product/components/containers/ProductsAdminContainer.tsx
|
|
3887
3881
|
|
|
3888
3882
|
function ProductsAdminContainer() {
|
|
3889
|
-
const { hasRole } =
|
|
3883
|
+
const { hasRole } = _chunkQPWHMXE2js.useCurrentUserContext.call(void 0, );
|
|
3890
3884
|
const [products, setProducts] = _react.useState.call(void 0, []);
|
|
3891
3885
|
const [loading, setLoading] = _react.useState.call(void 0, true);
|
|
3892
3886
|
const [showCreateProduct, setShowCreateProduct] = _react.useState.call(void 0, false);
|
|
3893
|
-
if (!hasRole(
|
|
3887
|
+
if (!hasRole(_chunkOODZEX6Pjs.getRoleId.call(void 0, ).Administrator)) {
|
|
3894
3888
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex h-64 items-center justify-center", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-red-600 font-semibold", children: "Permission denied. Administrator access required." }) });
|
|
3895
3889
|
}
|
|
3896
3890
|
const loadProducts = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
3897
3891
|
setLoading(true);
|
|
3898
3892
|
try {
|
|
3899
|
-
const fetchedProducts = await
|
|
3893
|
+
const fetchedProducts = await _chunkL5F5ZN5Fjs.StripeProductService.listProducts();
|
|
3900
3894
|
setProducts(fetchedProducts);
|
|
3901
3895
|
} catch (error) {
|
|
3902
3896
|
console.error("[ProductsAdminContainer] Failed to load products:", error);
|
|
@@ -3916,14 +3910,14 @@ function ProductsAdminContainer() {
|
|
|
3916
3910
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Package, { className: "h-8 w-8" }),
|
|
3917
3911
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h1", { className: "text-3xl font-bold", children: "Product & Price Management" })
|
|
3918
3912
|
] }),
|
|
3919
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3913
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Button, { onClick: () => setShowCreateProduct(true), children: "Create Product" })
|
|
3920
3914
|
] }),
|
|
3921
3915
|
products.length === 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "bg-muted/50 flex flex-col items-center justify-center gap-y-4 rounded-lg border-2 border-dashed p-12", children: [
|
|
3922
3916
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Package, { className: "text-muted-foreground h-16 w-16" }),
|
|
3923
3917
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "text-center", children: [
|
|
3924
3918
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "mb-2 text-xl font-semibold", children: "No products yet" }),
|
|
3925
3919
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-muted-foreground mb-4", children: "Create your first product to start offering subscriptions to your customers." }),
|
|
3926
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3920
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQPWHMXE2js.Button, { onClick: () => setShowCreateProduct(true), children: "Create Your First Product" })
|
|
3927
3921
|
] })
|
|
3928
3922
|
] }),
|
|
3929
3923
|
products.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ProductsList, { products, onProductsChange: loadProducts }),
|