@carlonicora/nextjs-jsonapi 1.32.2 → 1.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{BlockNoteEditor-76UO4RKT.js → BlockNoteEditor-CUXI6ZTZ.js} +13 -13
- package/dist/{BlockNoteEditor-76UO4RKT.js.map → BlockNoteEditor-CUXI6ZTZ.js.map} +1 -1
- package/dist/{BlockNoteEditor-EWOPRRJN.mjs → BlockNoteEditor-UTZ7F23J.mjs} +3 -3
- package/dist/billing/index.d.mts +6 -3
- package/dist/billing/index.d.ts +6 -3
- package/dist/billing/index.js +461 -380
- package/dist/billing/index.js.map +1 -1
- package/dist/billing/index.mjs +113 -32
- package/dist/billing/index.mjs.map +1 -1
- package/dist/{chunk-CCCAOXA2.mjs → chunk-53WT73E6.mjs} +55 -63
- package/dist/chunk-53WT73E6.mjs.map +1 -0
- package/dist/{chunk-YCP2OMFD.mjs → chunk-HWQBSVBT.mjs} +40 -7
- package/dist/chunk-HWQBSVBT.mjs.map +1 -0
- package/dist/{chunk-SS6ZCTYH.js → chunk-RSHCU3TI.js} +508 -516
- package/dist/chunk-RSHCU3TI.js.map +1 -0
- package/dist/{chunk-KYG2PIRB.js → chunk-TZRAOUAR.js} +118 -85
- package/dist/chunk-TZRAOUAR.js.map +1 -0
- package/dist/client/index.d.mts +7 -6
- package/dist/client/index.d.ts +7 -6
- package/dist/client/index.js +3 -3
- package/dist/client/index.mjs +2 -2
- package/dist/components/index.d.mts +4 -3
- package/dist/components/index.d.ts +4 -3
- package/dist/components/index.js +3 -3
- package/dist/components/index.mjs +2 -2
- package/dist/{config-CHwoRDOp.d.ts → config-BbaBV_yk.d.ts} +1 -1
- package/dist/{config-DiWyJzk9.d.mts → config-BxwhHdCD.d.mts} +1 -1
- package/dist/{content.interface-BSpowEiW.d.mts → content.interface-CWV0q4lZ.d.mts} +1 -1
- package/dist/{content.interface-DFQ7mkpL.d.ts → content.interface-CgUu4771.d.ts} +1 -1
- package/dist/contexts/index.d.mts +3 -2
- package/dist/contexts/index.d.ts +3 -2
- package/dist/contexts/index.js +3 -3
- package/dist/contexts/index.mjs +2 -2
- package/dist/core/index.d.mts +17 -8
- package/dist/core/index.d.ts +17 -8
- package/dist/core/index.js +6 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +5 -1
- package/dist/feature.interface-BxFFOPNq.d.mts +19 -0
- package/dist/feature.interface-CIWxo8NP.d.ts +19 -0
- package/dist/index.d.mts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -1
- package/dist/{notification.interface-D5MbtfZK.d.mts → notification.interface-DIln2r7X.d.mts} +2 -17
- package/dist/{notification.interface-CmKmObIU.d.ts → notification.interface-XARGKJAq.d.ts} +2 -17
- package/dist/{s3.service-CoC0k0iu.d.ts → s3.service-DcqkGrKD.d.ts} +12 -3
- package/dist/{s3.service-Duh9HW2n.d.mts → s3.service-ag6M_7GO.d.mts} +12 -3
- package/dist/scripts/generate-web-module/templates/pages/detail-page.template.js +1 -1
- package/dist/scripts/generate-web-module/templates/pages/detail-page.template.js.map +1 -1
- package/dist/scripts/generate-web-module/templates/pages/list-page.template.js +1 -1
- package/dist/scripts/generate-web-module/templates/pages/list-page.template.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 +3 -3
- package/dist/server/index.mjs +1 -1
- package/dist/{stripe-subscription.interface-BaZUngWe.d.ts → stripe-subscription.interface-Dm__xmvE.d.ts} +3 -0
- package/dist/{stripe-subscription.interface-Cm_It1fz.d.mts → stripe-subscription.interface-_VWPY2AA.d.mts} +3 -0
- package/dist/{useDataListRetriever-futhx3OP.d.mts → useDataListRetriever-BqJSFBck.d.mts} +1 -0
- package/dist/{useDataListRetriever-futhx3OP.d.ts → useDataListRetriever-BqJSFBck.d.ts} +1 -0
- package/dist/{useSocket-DUqGoPya.d.mts → useSocket-BILAdmZ0.d.mts} +1 -1
- package/dist/{useSocket-QuHa0ZmO.d.ts → useSocket-awibcC9B.d.ts} +1 -1
- package/package.json +1 -1
- package/scripts/generate-web-module/templates/pages/detail-page.template.ts +1 -1
- package/scripts/generate-web-module/templates/pages/list-page.template.ts +1 -1
- package/src/components/forms/DatePickerPopover.tsx +17 -15
- package/src/components/tables/ContentListTable.tsx +2 -2
- package/src/core/abstracts/AbstractService.ts +25 -0
- package/src/core/abstracts/ClientAbstractService.ts +10 -0
- package/src/features/billing/components/containers/BillingDashboardContainer.tsx +4 -1
- package/src/features/billing/stripe-invoice/components/details/InvoiceDetails.tsx +1 -1
- package/src/features/billing/stripe-invoice/components/lists/InvoicesList.tsx +1 -1
- package/src/features/billing/stripe-price/components/forms/PriceEditor.tsx +85 -1
- package/src/features/billing/stripe-price/data/stripe-price.interface.ts +3 -0
- package/src/features/billing/stripe-price/data/stripe-price.ts +18 -0
- package/src/features/billing/stripe-subscription/components/containers/SubscriptionsContainer.tsx +5 -2
- package/src/features/billing/stripe-subscription/components/forms/CancelSubscriptionDialog.tsx +5 -18
- package/src/features/billing/stripe-subscription/components/lists/SubscriptionsList.tsx +1 -1
- package/src/features/billing/stripe-subscription/components/widgets/ProductPricingList.tsx +16 -12
- package/src/features/billing/stripe-subscription/components/wizards/SubscriptionWizard.tsx +14 -3
- package/src/features/billing/stripe-subscription/components/wizards/WizardStepPlanSelection.tsx +14 -9
- package/src/features/billing/stripe-subscription/components/wizards/WizardStepReview.tsx +1 -1
- package/src/features/billing/stripe-subscription/data/stripe-subscription.service.ts +2 -2
- package/src/features/billing/stripe-usage/components/lists/UsageHistoryTable.tsx +1 -1
- package/src/features/company/components/details/TokenStatusIndicator.tsx +4 -6
- package/src/features/company/hooks/useSubscriptionStatus.ts +18 -0
- package/src/features/content/hooks/useContentTableStructure.tsx +1 -1
- package/src/features/user/contexts/CurrentUserContext.tsx +2 -1
- package/src/features/user/hooks/useUserTableStructure.tsx +1 -1
- package/src/hooks/useDataListRetriever.ts +13 -0
- package/src/shadcnui/ui/table.tsx +20 -49
- package/dist/chunk-CCCAOXA2.mjs.map +0 -1
- package/dist/chunk-KYG2PIRB.js.map +0 -1
- package/dist/chunk-SS6ZCTYH.js.map +0 -1
- package/dist/chunk-YCP2OMFD.mjs.map +0 -1
- /package/dist/{BlockNoteEditor-EWOPRRJN.mjs.map → BlockNoteEditor-UTZ7F23J.mjs.map} +0 -0
package/dist/billing/index.js
CHANGED
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
var
|
|
50
|
+
var _chunkRSHCU3TIjs = require('../chunk-RSHCU3TI.js');
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
|
|
@@ -60,7 +60,8 @@ var _chunk2PHWAL6Qjs = require('../chunk-2PHWAL6Q.js');
|
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
|
|
64
|
+
var _chunkTZRAOUARjs = require('../chunk-TZRAOUAR.js');
|
|
64
65
|
require('../chunk-LXKSUWAV.js');
|
|
65
66
|
require('../chunk-IBS6NI7D.js');
|
|
66
67
|
require('../chunk-FM6WRAN5.js');
|
|
@@ -120,41 +121,41 @@ function SubscriptionSummaryCard({
|
|
|
120
121
|
onManageClick
|
|
121
122
|
}) {
|
|
122
123
|
if (loading) {
|
|
123
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
124
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
125
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
124
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Card, { children: [
|
|
125
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
126
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardTitle, { className: "text-sm font-medium", children: "Subscriptions" }),
|
|
126
127
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-4 w-4 text-muted-foreground" })
|
|
127
128
|
] }),
|
|
128
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
129
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
130
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
131
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
129
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.CardContent, { children: [
|
|
130
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Skeleton, { className: "h-6 w-32 mb-2" }),
|
|
131
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Skeleton, { className: "h-4 w-24 mb-1" }),
|
|
132
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Skeleton, { className: "h-4 w-40" })
|
|
132
133
|
] })
|
|
133
134
|
] });
|
|
134
135
|
}
|
|
135
136
|
if (error) {
|
|
136
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
137
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
138
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
137
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Card, { children: [
|
|
138
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
139
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardTitle, { className: "text-sm font-medium", children: "Subscriptions" }),
|
|
139
140
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-4 w-4 text-muted-foreground" })
|
|
140
141
|
] }),
|
|
141
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
142
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-destructive", children: error }) })
|
|
142
143
|
] });
|
|
143
144
|
}
|
|
144
145
|
const activeSubscriptions = subscriptions.filter(
|
|
145
146
|
(sub) => sub.status === "active" /* ACTIVE */ || sub.status === "trialing" /* TRIALING */
|
|
146
147
|
);
|
|
147
148
|
const primarySubscription = activeSubscriptions[0];
|
|
148
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
149
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
150
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
149
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Card, { className: "cursor-pointer hover:bg-accent/50 transition-colors", onClick: onManageClick, children: [
|
|
150
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
151
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardTitle, { className: "text-sm font-medium", children: "Subscriptions" }),
|
|
151
152
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-4 w-4 text-muted-foreground" })
|
|
152
153
|
] }),
|
|
153
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
154
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardContent, { children: subscriptions.length === 0 ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
154
155
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold text-muted-foreground", children: "No active plan" }),
|
|
155
156
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: "Subscribe to get started" }),
|
|
156
157
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
157
|
-
|
|
158
|
+
_chunkRSHCU3TIjs.Button,
|
|
158
159
|
{
|
|
159
160
|
variant: "outline",
|
|
160
161
|
size: "sm",
|
|
@@ -172,7 +173,7 @@ function SubscriptionSummaryCard({
|
|
|
172
173
|
] }) : primarySubscription ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
173
174
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
|
|
174
175
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold", children: formatPlanName(primarySubscription) }),
|
|
175
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
176
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Badge, { variant: primarySubscription.cancelAtPeriodEnd ? "secondary" : getStatusBadgeVariant(primarySubscription.status), children: primarySubscription.cancelAtPeriodEnd ? "Canceling" : primarySubscription.status })
|
|
176
177
|
] }),
|
|
177
178
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-sm text-muted-foreground", children: [
|
|
178
179
|
formatPrice(_optionalChain([primarySubscription, 'access', _10 => _10.price, 'optionalAccess', _11 => _11.unitAmount]), _optionalChain([primarySubscription, 'access', _12 => _12.price, 'optionalAccess', _13 => _13.currency])),
|
|
@@ -216,36 +217,36 @@ function PaymentMethodSummaryCard({
|
|
|
216
217
|
onManageClick
|
|
217
218
|
}) {
|
|
218
219
|
if (loading) {
|
|
219
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
220
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
221
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
220
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Card, { children: [
|
|
221
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
222
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardTitle, { className: "text-sm font-medium", children: "Payment Method" }),
|
|
222
223
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Wallet, { className: "h-4 w-4 text-muted-foreground" })
|
|
223
224
|
] }),
|
|
224
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
225
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
226
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
225
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.CardContent, { children: [
|
|
226
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Skeleton, { className: "h-6 w-32 mb-2" }),
|
|
227
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Skeleton, { className: "h-4 w-24" })
|
|
227
228
|
] })
|
|
228
229
|
] });
|
|
229
230
|
}
|
|
230
231
|
if (error) {
|
|
231
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
232
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
233
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
232
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Card, { children: [
|
|
233
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
234
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardTitle, { className: "text-sm font-medium", children: "Payment Method" }),
|
|
234
235
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Wallet, { className: "h-4 w-4 text-muted-foreground" })
|
|
235
236
|
] }),
|
|
236
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
237
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-destructive", children: error }) })
|
|
237
238
|
] });
|
|
238
239
|
}
|
|
239
240
|
const defaultMethod = paymentMethods.find((pm) => pm.id === defaultPaymentMethodId) || paymentMethods[0];
|
|
240
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
241
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
242
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
241
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Card, { className: "cursor-pointer hover:bg-accent/50 transition-colors", onClick: onManageClick, children: [
|
|
242
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
243
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardTitle, { className: "text-sm font-medium", children: "Payment Method" }),
|
|
243
244
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Wallet, { className: "h-4 w-4 text-muted-foreground" })
|
|
244
245
|
] }),
|
|
245
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
246
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardContent, { children: paymentMethods.length === 0 ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
246
247
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold text-muted-foreground", children: "No payment method" }),
|
|
247
248
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: "Add a card to enable subscriptions" }),
|
|
248
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
249
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Button, { variant: "outline", size: "sm", className: "mt-2", onClick: (e) => {
|
|
249
250
|
e.stopPropagation();
|
|
250
251
|
onManageClick();
|
|
251
252
|
}, children: [
|
|
@@ -301,7 +302,7 @@ function CustomerInfoCard({ customer, loading, error }) {
|
|
|
301
302
|
e.stopPropagation();
|
|
302
303
|
setPortalLoading(true);
|
|
303
304
|
try {
|
|
304
|
-
const { url } = await
|
|
305
|
+
const { url } = await _chunkTZRAOUARjs.StripeCustomerService.createPortalSession();
|
|
305
306
|
window.open(url, "_blank");
|
|
306
307
|
} catch (err) {
|
|
307
308
|
console.error("[CustomerInfoCard] Failed to create portal session:", err);
|
|
@@ -310,52 +311,52 @@ function CustomerInfoCard({ customer, loading, error }) {
|
|
|
310
311
|
}
|
|
311
312
|
}, "handlePortalClick");
|
|
312
313
|
if (loading) {
|
|
313
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
314
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
315
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
314
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Card, { children: [
|
|
315
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
316
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardTitle, { className: "text-sm font-medium", children: "Billing Account" }),
|
|
316
317
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.User, { className: "h-4 w-4 text-muted-foreground" })
|
|
317
318
|
] }),
|
|
318
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
319
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
320
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
321
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
319
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.CardContent, { children: [
|
|
320
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Skeleton, { className: "h-6 w-32 mb-2" }),
|
|
321
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Skeleton, { className: "h-4 w-48 mb-1" }),
|
|
322
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Skeleton, { className: "h-4 w-24" })
|
|
322
323
|
] })
|
|
323
324
|
] });
|
|
324
325
|
}
|
|
325
326
|
if (error) {
|
|
326
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
327
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
328
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
327
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Card, { children: [
|
|
328
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
329
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardTitle, { className: "text-sm font-medium", children: "Billing Account" }),
|
|
329
330
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.User, { className: "h-4 w-4 text-muted-foreground" })
|
|
330
331
|
] }),
|
|
331
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
332
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-destructive", children: error }) })
|
|
332
333
|
] });
|
|
333
334
|
}
|
|
334
335
|
if (!customer) {
|
|
335
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
336
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
337
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
336
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Card, { children: [
|
|
337
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
338
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardTitle, { className: "text-sm font-medium", children: "Billing Account" }),
|
|
338
339
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.User, { className: "h-4 w-4 text-muted-foreground" })
|
|
339
340
|
] }),
|
|
340
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
341
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.CardContent, { children: [
|
|
341
342
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold text-muted-foreground", children: "Not set up" }),
|
|
342
343
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: "Billing account will be created when you subscribe" })
|
|
343
344
|
] })
|
|
344
345
|
] });
|
|
345
346
|
}
|
|
346
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
347
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
348
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
347
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Card, { children: [
|
|
348
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
349
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardTitle, { className: "text-sm font-medium", children: "Billing Account" }),
|
|
349
350
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.User, { className: "h-4 w-4 text-muted-foreground" })
|
|
350
351
|
] }),
|
|
351
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
352
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
352
353
|
customer.name && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold", children: customer.name }),
|
|
353
354
|
customer.email && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: customer.email }),
|
|
354
355
|
customer.balance !== void 0 && customer.balance !== 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-sm", children: [
|
|
355
356
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground", children: "Credit Balance: " }),
|
|
356
357
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: customer.balance < 0 ? "text-green-600" : "text-destructive", children: formatBalance(customer.balance, customer.currency) })
|
|
357
358
|
] }),
|
|
358
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
359
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Button, { variant: "outline", size: "sm", className: "mt-2", onClick: handlePortalClick, disabled: portalLoading, children: [
|
|
359
360
|
portalLoading ? "Loading..." : "Manage in Stripe Portal",
|
|
360
361
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ExternalLink, { className: "h-4 w-4 ml-1" })
|
|
361
362
|
] })
|
|
@@ -399,42 +400,42 @@ function formatAmount(amount, currency) {
|
|
|
399
400
|
_chunk7QVYU63Ejs.__name.call(void 0, formatAmount, "formatAmount");
|
|
400
401
|
function InvoicesSummaryCard({ invoices, loading, error, onViewAllClick }) {
|
|
401
402
|
if (loading) {
|
|
402
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
403
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
404
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
403
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Card, { children: [
|
|
404
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
405
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardTitle, { className: "text-sm font-medium", children: "Recent Invoices" }),
|
|
405
406
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ReceiptIcon, { className: "h-4 w-4 text-muted-foreground" })
|
|
406
407
|
] }),
|
|
407
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
408
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
409
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
410
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
408
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.CardContent, { children: [
|
|
409
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Skeleton, { className: "h-6 w-24 mb-2" }),
|
|
410
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Skeleton, { className: "h-4 w-32 mb-1" }),
|
|
411
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Skeleton, { className: "h-4 w-20" })
|
|
411
412
|
] })
|
|
412
413
|
] });
|
|
413
414
|
}
|
|
414
415
|
if (error) {
|
|
415
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
416
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
417
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
416
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Card, { children: [
|
|
417
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
418
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardTitle, { className: "text-sm font-medium", children: "Recent Invoices" }),
|
|
418
419
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ReceiptIcon, { className: "h-4 w-4 text-muted-foreground" })
|
|
419
420
|
] }),
|
|
420
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
421
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-destructive", children: error }) })
|
|
421
422
|
] });
|
|
422
423
|
}
|
|
423
424
|
const latestInvoice = invoices[0];
|
|
424
425
|
const paidInvoices = invoices.filter((inv) => inv.status === "paid" /* PAID */);
|
|
425
426
|
const openInvoices = invoices.filter((inv) => inv.status === "open" /* OPEN */);
|
|
426
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
427
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
428
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
427
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Card, { className: "cursor-pointer hover:bg-accent/50 transition-colors", onClick: onViewAllClick, children: [
|
|
428
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
429
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardTitle, { className: "text-sm font-medium", children: "Recent Invoices" }),
|
|
429
430
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ReceiptIcon, { className: "h-4 w-4 text-muted-foreground" })
|
|
430
431
|
] }),
|
|
431
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
432
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardContent, { children: invoices.length === 0 ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
432
433
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold text-muted-foreground", children: "No invoices yet" }),
|
|
433
434
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: "Invoices will appear after your first billing cycle" })
|
|
434
435
|
] }) : latestInvoice ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
435
436
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
|
|
436
437
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold", children: formatAmount(latestInvoice.total, latestInvoice.currency) }),
|
|
437
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
438
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Badge, { variant: getStatusBadgeVariant2(latestInvoice.status), children: latestInvoice.status })
|
|
438
439
|
] }),
|
|
439
440
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: latestInvoice.stripeInvoiceNumber || `Invoice from ${formatDate2(latestInvoice.periodStart)}` }),
|
|
440
441
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-4 text-xs text-muted-foreground", children: [
|
|
@@ -474,24 +475,24 @@ function BillingUsageSummaryCard({
|
|
|
474
475
|
onViewDetailsClick
|
|
475
476
|
}) {
|
|
476
477
|
if (loading) {
|
|
477
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
478
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
479
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
478
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Card, { children: [
|
|
479
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
480
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardTitle, { className: "text-sm font-medium", children: "Usage This Month" }),
|
|
480
481
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Activity, { className: "h-4 w-4 text-muted-foreground" })
|
|
481
482
|
] }),
|
|
482
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
483
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
484
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
483
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.CardContent, { children: [
|
|
484
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Skeleton, { className: "h-6 w-24 mb-2" }),
|
|
485
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Skeleton, { className: "h-4 w-32" })
|
|
485
486
|
] })
|
|
486
487
|
] });
|
|
487
488
|
}
|
|
488
489
|
if (error) {
|
|
489
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
490
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
491
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
490
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Card, { children: [
|
|
491
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
492
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardTitle, { className: "text-sm font-medium", children: "Usage This Month" }),
|
|
492
493
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Activity, { className: "h-4 w-4 text-muted-foreground" })
|
|
493
494
|
] }),
|
|
494
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
495
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-destructive", children: error }) })
|
|
495
496
|
] });
|
|
496
497
|
}
|
|
497
498
|
const totalUsage = Object.values(summaries).reduce((acc, summary) => {
|
|
@@ -499,12 +500,12 @@ function BillingUsageSummaryCard({
|
|
|
499
500
|
}, 0);
|
|
500
501
|
const primaryMeter = meters.find((m) => _optionalChain([summaries, 'access', _23 => _23[m.id], 'optionalAccess', _24 => _24.aggregatedValue]));
|
|
501
502
|
const primarySummary = primaryMeter ? summaries[primaryMeter.id] : null;
|
|
502
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
503
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
504
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
503
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Card, { className: "cursor-pointer hover:bg-accent/50 transition-colors", onClick: onViewDetailsClick, children: [
|
|
504
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
505
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardTitle, { className: "text-sm font-medium", children: "Usage This Month" }),
|
|
505
506
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Activity, { className: "h-4 w-4 text-muted-foreground" })
|
|
506
507
|
] }),
|
|
507
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
508
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardContent, { children: meters.length === 0 ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
508
509
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold text-muted-foreground", children: "No meters" }),
|
|
509
510
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: "No usage meters are configured" })
|
|
510
511
|
] }) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
@@ -556,7 +557,7 @@ function PaymentMethodForm({ onSuccess, onCancel, isLoading = false }) {
|
|
|
556
557
|
const fetchSetupIntent = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
557
558
|
setLoading(true);
|
|
558
559
|
try {
|
|
559
|
-
const intent = await
|
|
560
|
+
const intent = await _chunkTZRAOUARjs.StripeCustomerService.createSetupIntent();
|
|
560
561
|
setSetupIntent(intent);
|
|
561
562
|
} catch (err) {
|
|
562
563
|
console.error("[PaymentMethodForm] Failed to create setup intent:", err);
|
|
@@ -594,7 +595,7 @@ function PaymentMethodForm({ onSuccess, onCancel, isLoading = false }) {
|
|
|
594
595
|
return;
|
|
595
596
|
}
|
|
596
597
|
if (setAsDefault && _optionalChain([confirmedSetupIntent, 'optionalAccess', _25 => _25.payment_method])) {
|
|
597
|
-
await
|
|
598
|
+
await _chunkTZRAOUARjs.StripeCustomerService.setDefaultPaymentMethod({
|
|
598
599
|
paymentMethodId: typeof confirmedSetupIntent.payment_method === "string" ? confirmedSetupIntent.payment_method : confirmedSetupIntent.payment_method.id
|
|
599
600
|
});
|
|
600
601
|
}
|
|
@@ -610,7 +611,7 @@ function PaymentMethodForm({ onSuccess, onCancel, isLoading = false }) {
|
|
|
610
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..." }) });
|
|
611
612
|
}
|
|
612
613
|
if (!setupIntent && error) {
|
|
613
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
614
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Alert, { variant: "destructive", className: "bg-red-50 border-red-200", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.AlertDescription, { children: error }) });
|
|
614
615
|
}
|
|
615
616
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { onSubmit: handleSubmit, className: "flex flex-col gap-y-4", children: [
|
|
616
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,19 +635,19 @@ function PaymentMethodForm({ onSuccess, onCancel, isLoading = false }) {
|
|
|
634
635
|
) }),
|
|
635
636
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-2", children: [
|
|
636
637
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
637
|
-
|
|
638
|
+
_chunkRSHCU3TIjs.Checkbox,
|
|
638
639
|
{
|
|
639
640
|
id: "setAsDefault",
|
|
640
641
|
checked: setAsDefault,
|
|
641
642
|
onCheckedChange: (checked) => setSetAsDefault(!!checked)
|
|
642
643
|
}
|
|
643
644
|
),
|
|
644
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
645
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Label, { htmlFor: "setAsDefault", className: "text-sm font-normal", children: "Set as default payment method" })
|
|
645
646
|
] }),
|
|
646
|
-
error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
647
|
+
error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Alert, { variant: "destructive", className: "bg-red-50 border-red-200", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.AlertDescription, { children: error }) }),
|
|
647
648
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-end gap-x-2", children: [
|
|
648
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
649
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
649
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Button, { type: "button", variant: "outline", onClick: onCancel, disabled: isSubmitting || isLoading, children: "Cancel" }),
|
|
650
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Button, { type: "submit", disabled: !stripe || isSubmitting || isLoading, children: isSubmitting ? "Processing..." : "Add Card" })
|
|
650
651
|
] })
|
|
651
652
|
] });
|
|
652
653
|
}
|
|
@@ -662,10 +663,10 @@ function PaymentMethodEditor({ open, onOpenChange, onSuccess }) {
|
|
|
662
663
|
const handleCancel = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => {
|
|
663
664
|
onOpenChange(false);
|
|
664
665
|
}, "handleCancel");
|
|
665
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
666
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
667
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
668
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
666
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.DialogContent, { className: "max-w-md", children: [
|
|
667
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.DialogHeader, { children: [
|
|
668
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.DialogTitle, { children: "Add Payment Method" }),
|
|
669
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.DialogDescription, { children: "Add a new payment method to your account. Your card information is securely processed by Stripe." })
|
|
669
670
|
] }),
|
|
670
671
|
open && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
671
672
|
PaymentMethodForm,
|
|
@@ -695,7 +696,7 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
695
696
|
_react.useEffect.call(void 0, () => {
|
|
696
697
|
const loadCustomer = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
697
698
|
try {
|
|
698
|
-
const fetchedCustomer = await
|
|
699
|
+
const fetchedCustomer = await _chunkTZRAOUARjs.StripeCustomerService.getCustomer();
|
|
699
700
|
setCustomer(fetchedCustomer);
|
|
700
701
|
} catch (error) {
|
|
701
702
|
console.error("[PaymentMethodCard] Failed to load customer:", error);
|
|
@@ -712,7 +713,7 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
712
713
|
const handleSetDefault = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
713
714
|
setLoading(true);
|
|
714
715
|
try {
|
|
715
|
-
await
|
|
716
|
+
await _chunkTZRAOUARjs.StripeCustomerService.setDefaultPaymentMethod({ paymentMethodId: paymentMethod.id });
|
|
716
717
|
onUpdate();
|
|
717
718
|
} catch (error) {
|
|
718
719
|
console.error("[PaymentMethodCard] Failed to set as default:", error);
|
|
@@ -723,7 +724,7 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
723
724
|
const handleRemove = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
724
725
|
setLoading(true);
|
|
725
726
|
try {
|
|
726
|
-
await
|
|
727
|
+
await _chunkTZRAOUARjs.StripeCustomerService.removePaymentMethod({ paymentMethodId: paymentMethod.id });
|
|
727
728
|
setShowRemoveDialog(false);
|
|
728
729
|
onUpdate();
|
|
729
730
|
} catch (error) {
|
|
@@ -732,22 +733,22 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
732
733
|
}
|
|
733
734
|
}, "handleRemove");
|
|
734
735
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
735
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
736
|
-
isDefault && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
737
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
736
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Card, { className: "relative", children: [
|
|
737
|
+
isDefault && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Badge, { className: "absolute right-2 top-2 bg-green-100 text-green-800 hover:bg-green-100", children: "Default" }),
|
|
738
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.CardHeader, { className: "flex flex-row items-center justify-between pb-2", children: [
|
|
738
739
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-2", children: [
|
|
739
740
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-2xl", children: brandIcon }),
|
|
740
741
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-medium capitalize", children: brand })
|
|
741
742
|
] }),
|
|
742
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
743
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
744
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
745
|
-
!isDefault && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
746
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
743
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.DropdownMenu, { children: [
|
|
744
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.DropdownMenuTrigger, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Button, { render: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {}), nativeButton: false, variant: "ghost", size: "sm", disabled: loading, className: "h-8 w-8 p-0", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.MoreVertical, { className: "h-4 w-4" }) }) }),
|
|
745
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.DropdownMenuContent, { align: "end", children: [
|
|
746
|
+
!isDefault && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.DropdownMenuItem, { onClick: handleSetDefault, disabled: loading, children: "Set as Default" }),
|
|
747
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.DropdownMenuItem, { onClick: () => setShowRemoveDialog(true), disabled: loading, className: "text-red-600", children: "Remove" })
|
|
747
748
|
] })
|
|
748
749
|
] })
|
|
749
750
|
] }),
|
|
750
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
751
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-y-1", children: [
|
|
751
752
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-lg font-semibold", children: [
|
|
752
753
|
"\u2022\u2022\u2022\u2022 ",
|
|
753
754
|
last4
|
|
@@ -760,17 +761,17 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
760
761
|
] })
|
|
761
762
|
] }) })
|
|
762
763
|
] }),
|
|
763
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
764
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
765
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
766
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
764
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.AlertDialog, { open: showRemoveDialog, onOpenChange: setShowRemoveDialog, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.AlertDialogContent, { children: [
|
|
765
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.AlertDialogHeader, { children: [
|
|
766
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.AlertDialogTitle, { children: "Remove Payment Method" }),
|
|
767
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.AlertDialogDescription, { children: [
|
|
767
768
|
"Are you sure you want to remove this payment method? This action cannot be undone.",
|
|
768
769
|
isDefault && " This is your default payment method."
|
|
769
770
|
] })
|
|
770
771
|
] }),
|
|
771
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
772
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
773
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
772
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.AlertDialogFooter, { children: [
|
|
773
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.AlertDialogCancel, { disabled: loading, children: "Cancel" }),
|
|
774
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.AlertDialogAction, { onClick: handleRemove, disabled: loading, className: "bg-red-600 hover:bg-red-700", children: loading ? "Removing..." : "Remove" })
|
|
774
775
|
] })
|
|
775
776
|
] }) })
|
|
776
777
|
] });
|
|
@@ -793,7 +794,7 @@ function PaymentMethodsContainer() {
|
|
|
793
794
|
const loadPaymentMethods = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
794
795
|
setLoading(true);
|
|
795
796
|
try {
|
|
796
|
-
const fetchedPaymentMethods = await
|
|
797
|
+
const fetchedPaymentMethods = await _chunkTZRAOUARjs.StripeCustomerService.listPaymentMethods();
|
|
797
798
|
setPaymentMethods(fetchedPaymentMethods);
|
|
798
799
|
} catch (error) {
|
|
799
800
|
console.error("[PaymentMethodsContainer] Failed to load payment methods:", error);
|
|
@@ -813,14 +814,14 @@ function PaymentMethodsContainer() {
|
|
|
813
814
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-8 w-8" }),
|
|
814
815
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h1", { className: "text-3xl font-bold", children: "Payment Methods" })
|
|
815
816
|
] }),
|
|
816
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
817
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Button, { onClick: () => setShowAddPaymentMethod(true), children: "Add Payment Method" })
|
|
817
818
|
] }),
|
|
818
819
|
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: [
|
|
819
820
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-16 w-16 text-muted-foreground" }),
|
|
820
821
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "text-center", children: [
|
|
821
822
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "mb-2 text-xl font-semibold", children: "No payment methods" }),
|
|
822
823
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "mb-4 text-muted-foreground", children: "Add a payment method to enable subscriptions and secure checkout." }),
|
|
823
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
824
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Button, { onClick: () => setShowAddPaymentMethod(true), children: "Add Your First Card" })
|
|
824
825
|
] })
|
|
825
826
|
] }),
|
|
826
827
|
paymentMethods.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PaymentMethodsList, { paymentMethods, onUpdate: loadPaymentMethods }),
|
|
@@ -944,13 +945,13 @@ function InvoiceDetails({ invoice, open, onOpenChange, onInvoiceChange }) {
|
|
|
944
945
|
return invoice.stripeInvoiceId.slice(-8);
|
|
945
946
|
}, "getInvoiceNumber");
|
|
946
947
|
const productName = _optionalChain([invoice, 'access', _35 => _35.subscription, 'optionalAccess', _36 => _36.price, 'optionalAccess', _37 => _37.product, 'optionalAccess', _38 => _38.name]) || "Subscription";
|
|
947
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
948
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
949
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
948
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.DialogContent, { className: "max-w-2xl", children: [
|
|
949
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.DialogHeader, { children: [
|
|
950
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.DialogTitle, { children: [
|
|
950
951
|
"Invoice ",
|
|
951
952
|
getInvoiceNumber()
|
|
952
953
|
] }),
|
|
953
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
954
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.DialogDescription, { children: formatDate3(invoice.periodStart) })
|
|
954
955
|
] }),
|
|
955
956
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-6", children: [
|
|
956
957
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-3", children: [
|
|
@@ -981,7 +982,7 @@ function InvoiceDetails({ invoice, open, onOpenChange, onInvoiceChange }) {
|
|
|
981
982
|
] }),
|
|
982
983
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
983
984
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h4", { className: "text-sm font-medium text-muted-foreground mb-2", children: "Line Items" }),
|
|
984
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border rounded-lg overflow-
|
|
985
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border rounded-lg overflow-clip", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "table", { className: "w-full", children: [
|
|
985
986
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "thead", { className: "bg-muted", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "tr", { children: [
|
|
986
987
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "th", { className: "text-left p-3 text-sm font-medium", children: "Description" }),
|
|
987
988
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "th", { className: "text-right p-3 text-sm font-medium", children: "Amount" })
|
|
@@ -1015,15 +1016,15 @@ function InvoiceDetails({ invoice, open, onOpenChange, onInvoiceChange }) {
|
|
|
1015
1016
|
] })
|
|
1016
1017
|
] }),
|
|
1017
1018
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-wrap gap-2 pt-4 border-t", children: [
|
|
1018
|
-
invoice.stripePdfUrl && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1019
|
+
invoice.stripePdfUrl && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Button, { variant: "outline", onClick: handleDownloadPDF, children: [
|
|
1019
1020
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Download, { className: "mr-2 h-4 w-4" }),
|
|
1020
1021
|
"Download PDF"
|
|
1021
1022
|
] }),
|
|
1022
|
-
invoice.status === "open" /* OPEN */ && invoice.attempted && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1023
|
+
invoice.status === "open" /* OPEN */ && invoice.attempted && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Button, { variant: "default", onClick: handleRetryPayment, children: [
|
|
1023
1024
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.RefreshCw, { className: "mr-2 h-4 w-4" }),
|
|
1024
1025
|
"Retry Payment"
|
|
1025
1026
|
] }),
|
|
1026
|
-
invoice.stripeHostedInvoiceUrl && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1027
|
+
invoice.stripeHostedInvoiceUrl && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Button, { variant: "outline", onClick: handleViewInStripe, children: [
|
|
1027
1028
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ExternalLink, { className: "mr-2 h-4 w-4" }),
|
|
1028
1029
|
"View in Stripe"
|
|
1029
1030
|
] })
|
|
@@ -1047,30 +1048,30 @@ function InvoicesList({ invoices, onInvoicesChange }) {
|
|
|
1047
1048
|
return invoice.stripeInvoiceId.slice(-8);
|
|
1048
1049
|
}, "getInvoiceNumber");
|
|
1049
1050
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1050
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border rounded-lg overflow-
|
|
1051
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1052
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1053
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1054
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1055
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1056
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1051
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border rounded-lg overflow-clip", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Table, { children: [
|
|
1052
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableHeader, { className: "bg-muted", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.TableRow, { children: [
|
|
1053
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableHead, { children: "Invoice #" }),
|
|
1054
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableHead, { children: "Date" }),
|
|
1055
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableHead, { children: "Status" }),
|
|
1056
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableHead, { className: "text-right", children: "Amount" }),
|
|
1057
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableHead, { children: "Period" })
|
|
1057
1058
|
] }) }),
|
|
1058
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1059
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableBody, { children: invoices.map((invoice) => {
|
|
1059
1060
|
const invoiceNumber = getInvoiceNumber(invoice);
|
|
1060
1061
|
const date = formatDate3(invoice.periodStart);
|
|
1061
1062
|
const amount = formatCurrency(invoice.total, invoice.currency);
|
|
1062
1063
|
const period = `${formatDate3(invoice.periodStart)} - ${formatDate3(invoice.periodEnd)}`;
|
|
1063
1064
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1064
|
-
|
|
1065
|
+
_chunkRSHCU3TIjs.TableRow,
|
|
1065
1066
|
{
|
|
1066
1067
|
onClick: () => handleRowClick(invoice),
|
|
1067
1068
|
className: "cursor-pointer hover:bg-muted/50",
|
|
1068
1069
|
children: [
|
|
1069
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1070
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1071
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1072
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1073
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1070
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableCell, { className: "font-medium", children: invoiceNumber }),
|
|
1071
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableCell, { className: "text-muted-foreground text-sm", children: date }),
|
|
1072
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableCell, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, InvoiceStatusBadge, { status: invoice.status }) }),
|
|
1073
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableCell, { className: "text-right font-medium", children: amount }),
|
|
1074
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableCell, { className: "text-muted-foreground text-sm", children: period })
|
|
1074
1075
|
]
|
|
1075
1076
|
},
|
|
1076
1077
|
invoice.id
|
|
@@ -1103,7 +1104,7 @@ function InvoicesContainer() {
|
|
|
1103
1104
|
setLoading(true);
|
|
1104
1105
|
try {
|
|
1105
1106
|
const params = statusFilter !== "all" ? { status: statusFilter } : void 0;
|
|
1106
|
-
const data = await
|
|
1107
|
+
const data = await _chunkTZRAOUARjs.StripeInvoiceService.listInvoices(params);
|
|
1107
1108
|
setInvoices(data);
|
|
1108
1109
|
} catch (error) {
|
|
1109
1110
|
console.error("[InvoicesContainer] Failed to load invoices:", error);
|
|
@@ -1119,12 +1120,12 @@ function InvoicesContainer() {
|
|
|
1119
1120
|
setStatusFilter(value);
|
|
1120
1121
|
}, "handleFilterChange");
|
|
1121
1122
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-4", children: [
|
|
1122
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1123
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1124
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1125
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1126
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1127
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1123
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Tabs, { value: statusFilter, onValueChange: handleFilterChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.TabsList, { children: [
|
|
1124
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TabsTrigger, { value: "all", children: "All" }),
|
|
1125
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TabsTrigger, { value: "paid" /* PAID */, children: "Paid" }),
|
|
1126
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TabsTrigger, { value: "open" /* OPEN */, children: "Open" }),
|
|
1127
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TabsTrigger, { value: "void" /* VOID */, children: "Void" }),
|
|
1128
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TabsTrigger, { value: "uncollectible" /* UNCOLLECTIBLE */, children: "Uncollectible" })
|
|
1128
1129
|
] }) }),
|
|
1129
1130
|
loading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-center py-8 text-muted-foreground", children: "Loading invoices..." }),
|
|
1130
1131
|
!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: [
|
|
@@ -1153,7 +1154,6 @@ var _reacthookform = require('react-hook-form');
|
|
|
1153
1154
|
var _zod3 = require('zod');
|
|
1154
1155
|
|
|
1155
1156
|
var formSchema = _zod3.z.object({
|
|
1156
|
-
cancelImmediately: _zod3.z.boolean(),
|
|
1157
1157
|
reason: _zod3.z.string().optional()
|
|
1158
1158
|
});
|
|
1159
1159
|
function CancelSubscriptionDialog({
|
|
@@ -1166,17 +1166,15 @@ function CancelSubscriptionDialog({
|
|
|
1166
1166
|
const form = _reacthookform.useForm.call(void 0, {
|
|
1167
1167
|
resolver: _zod.zodResolver.call(void 0, formSchema),
|
|
1168
1168
|
defaultValues: {
|
|
1169
|
-
cancelImmediately: false,
|
|
1170
1169
|
reason: ""
|
|
1171
1170
|
}
|
|
1172
1171
|
});
|
|
1173
|
-
const cancelImmediately = form.watch("cancelImmediately");
|
|
1174
1172
|
const onSubmit = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async (values) => {
|
|
1175
1173
|
setIsSubmitting(true);
|
|
1176
1174
|
try {
|
|
1177
|
-
await
|
|
1175
|
+
await _chunkTZRAOUARjs.StripeSubscriptionService.cancelSubscription({
|
|
1178
1176
|
id: subscription.id,
|
|
1179
|
-
cancelImmediately:
|
|
1177
|
+
cancelImmediately: false
|
|
1180
1178
|
});
|
|
1181
1179
|
onSuccess();
|
|
1182
1180
|
onOpenChange(false);
|
|
@@ -1187,20 +1185,19 @@ function CancelSubscriptionDialog({
|
|
|
1187
1185
|
}
|
|
1188
1186
|
}, "onSubmit");
|
|
1189
1187
|
const periodEndDate = formatDate3(subscription.currentPeriodEnd);
|
|
1190
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1191
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1192
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1193
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1188
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.DialogContent, { className: "max-w-md", children: [
|
|
1189
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.DialogHeader, { children: [
|
|
1190
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.DialogTitle, { children: "Cancel Subscription" }),
|
|
1191
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.DialogDescription, { children: "Are you sure you want to cancel this subscription? This action cannot be undone." })
|
|
1194
1192
|
] }),
|
|
1195
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1196
|
-
/* @__PURE__ */ _jsxruntime.
|
|
1197
|
-
cancelImmediately ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "bg-red-50 border border-red-200 rounded-lg p-3 text-sm text-red-800", children: "Your subscription will be canceled immediately and you will lose access right away." }) : /* @__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: [
|
|
1193
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Form, { ...form, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { onSubmit: form.handleSubmit(onSubmit), className: "flex flex-col gap-y-4", children: [
|
|
1194
|
+
/* @__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
1195
|
"Your subscription will remain active until ",
|
|
1199
1196
|
periodEndDate,
|
|
1200
1197
|
". You can continue using the service until then."
|
|
1201
1198
|
] }),
|
|
1202
1199
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1203
|
-
|
|
1200
|
+
_chunkRSHCU3TIjs.FormTextarea,
|
|
1204
1201
|
{
|
|
1205
1202
|
form,
|
|
1206
1203
|
id: "reason",
|
|
@@ -1210,8 +1207,8 @@ function CancelSubscriptionDialog({
|
|
|
1210
1207
|
}
|
|
1211
1208
|
),
|
|
1212
1209
|
/* @__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,
|
|
1210
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Button, { type: "button", variant: "outline", onClick: () => onOpenChange(false), disabled: isSubmitting, children: "Keep Subscription" }),
|
|
1211
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Button, { type: "submit", variant: "destructive", disabled: isSubmitting, children: isSubmitting ? "Canceling..." : "Confirm Cancellation" })
|
|
1215
1212
|
] })
|
|
1216
1213
|
] }) })
|
|
1217
1214
|
] }) });
|
|
@@ -1302,7 +1299,7 @@ function SubscriptionDetails({
|
|
|
1302
1299
|
const handlePause = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
1303
1300
|
setIsProcessing(true);
|
|
1304
1301
|
try {
|
|
1305
|
-
await
|
|
1302
|
+
await _chunkTZRAOUARjs.StripeSubscriptionService.pauseSubscription({ subscriptionId: subscription.id });
|
|
1306
1303
|
onSubscriptionChange();
|
|
1307
1304
|
} catch (error) {
|
|
1308
1305
|
console.error("[SubscriptionDetails] Failed to pause subscription:", error);
|
|
@@ -1313,7 +1310,7 @@ function SubscriptionDetails({
|
|
|
1313
1310
|
const handleResume = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
1314
1311
|
setIsProcessing(true);
|
|
1315
1312
|
try {
|
|
1316
|
-
await
|
|
1313
|
+
await _chunkTZRAOUARjs.StripeSubscriptionService.resumeSubscription({ subscriptionId: subscription.id });
|
|
1317
1314
|
onSubscriptionChange();
|
|
1318
1315
|
} catch (error) {
|
|
1319
1316
|
console.error("[SubscriptionDetails] Failed to resume subscription:", error);
|
|
@@ -1323,7 +1320,7 @@ function SubscriptionDetails({
|
|
|
1323
1320
|
}, "handleResume");
|
|
1324
1321
|
const handleManageViaPortal = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
1325
1322
|
try {
|
|
1326
|
-
const { url } = await
|
|
1323
|
+
const { url } = await _chunkTZRAOUARjs.StripeCustomerService.createPortalSession();
|
|
1327
1324
|
window.open(url, "_blank");
|
|
1328
1325
|
} catch (error) {
|
|
1329
1326
|
console.error("[SubscriptionDetails] Failed to create portal session:", error);
|
|
@@ -1333,10 +1330,10 @@ function SubscriptionDetails({
|
|
|
1333
1330
|
const canResume = subscription.status === "paused" /* PAUSED */;
|
|
1334
1331
|
const canCancel = subscription.status === "active" /* ACTIVE */ || subscription.status === "trialing" /* TRIALING */ || subscription.status === "paused" /* PAUSED */;
|
|
1335
1332
|
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,
|
|
1333
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.DialogContent, { className: "max-w-2xl", children: [
|
|
1334
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.DialogHeader, { children: [
|
|
1335
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.DialogTitle, { children: "Subscription Details" }),
|
|
1336
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.DialogDescription, { children: "View and manage your subscription" })
|
|
1340
1337
|
] }),
|
|
1341
1338
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-6", children: [
|
|
1342
1339
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-3", children: [
|
|
@@ -1372,11 +1369,11 @@ function SubscriptionDetails({
|
|
|
1372
1369
|
"."
|
|
1373
1370
|
] }) }),
|
|
1374
1371
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-wrap gap-2 pt-4 border-t", children: [
|
|
1375
|
-
onChangePlan && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1376
|
-
canPause && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1377
|
-
canResume && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1378
|
-
canCancel && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1379
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1372
|
+
onChangePlan && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Button, { variant: "default", onClick: () => onChangePlan(subscription), children: "Change Plan" }),
|
|
1373
|
+
canPause && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Button, { variant: "outline", onClick: handlePause, disabled: isProcessing, children: isProcessing ? "Pausing..." : "Pause" }),
|
|
1374
|
+
canResume && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Button, { variant: "outline", onClick: handleResume, disabled: isProcessing, children: isProcessing ? "Resuming..." : "Resume" }),
|
|
1375
|
+
canCancel && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Button, { variant: "destructive", onClick: () => setShowCancel(true), children: "Cancel" }),
|
|
1376
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Button, { variant: "outline", onClick: handleManageViaPortal, children: "Manage via Portal" })
|
|
1380
1377
|
] })
|
|
1381
1378
|
] })
|
|
1382
1379
|
] }) }),
|
|
@@ -1423,27 +1420,27 @@ function SubscriptionsList({ subscriptions, onSubscriptionsChange, onChangePlan
|
|
|
1423
1420
|
setSelectedSub(subscription);
|
|
1424
1421
|
}, "handleRowClick");
|
|
1425
1422
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1426
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border rounded-lg overflow-
|
|
1427
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1428
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1429
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1430
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1431
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1423
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border rounded-lg overflow-clip", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Table, { children: [
|
|
1424
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableHeader, { className: "bg-muted", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.TableRow, { children: [
|
|
1425
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableHead, { children: "Status" }),
|
|
1426
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableHead, { children: "Plan" }),
|
|
1427
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableHead, { children: "Period" }),
|
|
1428
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableHead, { className: "text-right", children: "Amount" })
|
|
1432
1429
|
] }) }),
|
|
1433
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1430
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableBody, { children: subscriptions.map((subscription) => {
|
|
1434
1431
|
const price = subscription.price;
|
|
1435
1432
|
const amount = _optionalChain([price, 'optionalAccess', _48 => _48.unitAmount]) ? formatCurrency(price.unitAmount, price.currency) : "N/A";
|
|
1436
1433
|
const period = `${formatDate3(subscription.currentPeriodStart)} - ${formatDate3(subscription.currentPeriodEnd)}`;
|
|
1437
1434
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1438
|
-
|
|
1435
|
+
_chunkRSHCU3TIjs.TableRow,
|
|
1439
1436
|
{
|
|
1440
1437
|
onClick: () => handleRowClick(subscription),
|
|
1441
1438
|
className: "cursor-pointer hover:bg-muted/50",
|
|
1442
1439
|
children: [
|
|
1443
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1444
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1445
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1446
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1440
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableCell, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SubscriptionStatusBadge, { status: subscription.status, cancelAtPeriodEnd: subscription.cancelAtPeriodEnd }) }),
|
|
1441
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableCell, { className: "font-medium", children: formatPlanName3(price) }),
|
|
1442
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableCell, { className: "text-muted-foreground text-sm", children: period }),
|
|
1443
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableCell, { className: "text-right font-medium", children: amount })
|
|
1447
1444
|
]
|
|
1448
1445
|
},
|
|
1449
1446
|
subscription.id
|
|
@@ -1472,13 +1469,13 @@ _chunk7QVYU63Ejs.__name.call(void 0, SubscriptionsList, "SubscriptionsList");
|
|
|
1472
1469
|
|
|
1473
1470
|
// src/features/billing/stripe-subscription/components/containers/SubscriptionsContainer.tsx
|
|
1474
1471
|
|
|
1475
|
-
function SubscriptionsContainer({ onOpenWizard }) {
|
|
1472
|
+
function SubscriptionsContainer({ onOpenWizard, hasActiveRecurringSubscription }) {
|
|
1476
1473
|
const [subscriptions, setSubscriptions] = _react.useState.call(void 0, []);
|
|
1477
1474
|
const [loading, setLoading] = _react.useState.call(void 0, true);
|
|
1478
1475
|
const loadSubscriptions = _react.useCallback.call(void 0, async () => {
|
|
1479
1476
|
setLoading(true);
|
|
1480
1477
|
try {
|
|
1481
|
-
const fetchedSubscriptions = await
|
|
1478
|
+
const fetchedSubscriptions = await _chunkTZRAOUARjs.StripeSubscriptionService.listSubscriptions();
|
|
1482
1479
|
setSubscriptions(fetchedSubscriptions);
|
|
1483
1480
|
} catch (error) {
|
|
1484
1481
|
console.error("[SubscriptionsContainer] Failed to load subscriptions:", error);
|
|
@@ -1501,7 +1498,7 @@ function SubscriptionsContainer({ onOpenWizard }) {
|
|
|
1501
1498
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-8 w-8" }),
|
|
1502
1499
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h1", { className: "text-3xl font-bold", children: "Subscriptions" })
|
|
1503
1500
|
] }),
|
|
1504
|
-
subscriptions.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1501
|
+
subscriptions.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Button, { onClick: () => _optionalChain([onOpenWizard, 'optionalCall', _49 => _49()]), children: hasActiveRecurringSubscription ? "Purchase Add-ons" : "Subscribe to a Plan" })
|
|
1505
1502
|
] }),
|
|
1506
1503
|
criticalSubscriptions.map((subscription) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BillingAlertBanner, { subscription }, subscription.id)),
|
|
1507
1504
|
subscriptions.length === 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col items-center justify-center py-12 space-y-4", children: [
|
|
@@ -1509,7 +1506,7 @@ function SubscriptionsContainer({ onOpenWizard }) {
|
|
|
1509
1506
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "text-center", children: [
|
|
1510
1507
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-xl font-semibold mb-2", children: "No Active Subscriptions" }),
|
|
1511
1508
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-muted-foreground mb-6", children: "Choose a subscription plan to get started with our services." }),
|
|
1512
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1509
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Button, { onClick: () => _optionalChain([onOpenWizard, 'optionalCall', _50 => _50()]), children: "Subscribe to a Plan" })
|
|
1513
1510
|
] })
|
|
1514
1511
|
] }),
|
|
1515
1512
|
subscriptions.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -1530,9 +1527,9 @@ function IntervalToggle({ value, onChange, hasMonthly, hasYearly }) {
|
|
|
1530
1527
|
if (!hasMonthly || !hasYearly) {
|
|
1531
1528
|
return null;
|
|
1532
1529
|
}
|
|
1533
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1534
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1535
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1530
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Tabs, { value, onValueChange: (v) => onChange(v), children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.TabsList, { children: [
|
|
1531
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TabsTrigger, { value: "month", children: "Monthly" }),
|
|
1532
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TabsTrigger, { value: "year", children: "Yearly" })
|
|
1536
1533
|
] }) });
|
|
1537
1534
|
}
|
|
1538
1535
|
_chunk7QVYU63Ejs.__name.call(void 0, IntervalToggle, "IntervalToggle");
|
|
@@ -1557,7 +1554,7 @@ function PricingCard({ price, isCurrentPlan = false, isSelected = false, isDisab
|
|
|
1557
1554
|
}
|
|
1558
1555
|
}, "handleClick");
|
|
1559
1556
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1560
|
-
|
|
1557
|
+
_chunkRSHCU3TIjs.Card,
|
|
1561
1558
|
{
|
|
1562
1559
|
role: "radio",
|
|
1563
1560
|
"aria-checked": isSelected,
|
|
@@ -1565,7 +1562,7 @@ function PricingCard({ price, isCurrentPlan = false, isSelected = false, isDisab
|
|
|
1565
1562
|
tabIndex: isDisabled ? -1 : 0,
|
|
1566
1563
|
onKeyDown: handleKeyDown,
|
|
1567
1564
|
onClick: handleClick,
|
|
1568
|
-
className:
|
|
1565
|
+
className: _chunkTZRAOUARjs.cn.call(void 0,
|
|
1569
1566
|
"relative cursor-pointer transition-all duration-200 flex flex-col h-full",
|
|
1570
1567
|
"focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
1571
1568
|
isCurrentPlan && "bg-muted/30",
|
|
@@ -1575,9 +1572,9 @@ function PricingCard({ price, isCurrentPlan = false, isSelected = false, isDisab
|
|
|
1575
1572
|
isLoading && "pointer-events-none"
|
|
1576
1573
|
),
|
|
1577
1574
|
children: [
|
|
1578
|
-
isCurrentPlan && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1579
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1580
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1575
|
+
isCurrentPlan && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Badge, { variant: "secondary", className: "absolute top-2 right-2", children: "Current" }),
|
|
1576
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardHeader, { className: "pb-2", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "font-semibold text-lg", children: description }) }),
|
|
1577
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.CardContent, { className: "pb-4 grow", children: [
|
|
1581
1578
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mb-4", children: [
|
|
1582
1579
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-3xl font-bold", children: formattedPrice }),
|
|
1583
1580
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground ml-1", children: interval })
|
|
@@ -1587,8 +1584,8 @@ function PricingCard({ price, isCurrentPlan = false, isSelected = false, isDisab
|
|
|
1587
1584
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm text-muted-foreground", children: feature })
|
|
1588
1585
|
] }, index)) })
|
|
1589
1586
|
] }),
|
|
1590
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1591
|
-
|
|
1587
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardFooter, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1588
|
+
_chunkRSHCU3TIjs.Button,
|
|
1592
1589
|
{
|
|
1593
1590
|
variant: isCurrentPlan ? "secondary" : isSelected ? "default" : "outline",
|
|
1594
1591
|
className: "w-full",
|
|
@@ -1669,7 +1666,8 @@ function ProductPricingList({
|
|
|
1669
1666
|
loadingPriceId,
|
|
1670
1667
|
loading = false,
|
|
1671
1668
|
onSelectPrice,
|
|
1672
|
-
hideRecurringPrices = false
|
|
1669
|
+
hideRecurringPrices = false,
|
|
1670
|
+
hideOneTimePrices = false
|
|
1673
1671
|
}) {
|
|
1674
1672
|
if (loading) {
|
|
1675
1673
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ProductPricingListSkeleton, {});
|
|
@@ -1684,13 +1682,16 @@ function ProductPricingList({
|
|
|
1684
1682
|
if (!aRecurring && bRecurring) return 1;
|
|
1685
1683
|
return 0;
|
|
1686
1684
|
});
|
|
1687
|
-
|
|
1688
|
-
...product,
|
|
1689
|
-
stripePrices: (product.stripePrices || []).filter((price) => price.priceType !== "recurring")
|
|
1690
|
-
})).filter((product) => product.stripePrices.length > 0) : sortedProducts;
|
|
1691
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "space-y-6", children: filteredProducts.map((product) => {
|
|
1685
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "space-y-6", children: sortedProducts.map((product) => {
|
|
1692
1686
|
const allPrices = product.stripePrices || [];
|
|
1693
|
-
|
|
1687
|
+
let pricesToFilter = allPrices;
|
|
1688
|
+
if (hideRecurringPrices) {
|
|
1689
|
+
pricesToFilter = pricesToFilter.filter((price) => price.priceType !== "recurring");
|
|
1690
|
+
}
|
|
1691
|
+
if (hideOneTimePrices) {
|
|
1692
|
+
pricesToFilter = pricesToFilter.filter((price) => price.priceType !== "one_time");
|
|
1693
|
+
}
|
|
1694
|
+
const filteredPrices = getFilteredPrices(pricesToFilter, selectedInterval);
|
|
1694
1695
|
if (filteredPrices.length === 0) {
|
|
1695
1696
|
return null;
|
|
1696
1697
|
}
|
|
@@ -1711,15 +1712,15 @@ function ProductPricingList({
|
|
|
1711
1712
|
_chunk7QVYU63Ejs.__name.call(void 0, ProductPricingList, "ProductPricingList");
|
|
1712
1713
|
function ProductPricingListSkeleton() {
|
|
1713
1714
|
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: [
|
|
1714
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1715
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Skeleton, { className: "h-6 w-32" }),
|
|
1715
1716
|
/* @__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: [
|
|
1716
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1717
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1717
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Skeleton, { className: "h-6 w-24" }),
|
|
1718
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Skeleton, { className: "h-8 w-32" }),
|
|
1718
1719
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
1719
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1720
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1720
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Skeleton, { className: "h-4 w-full" }),
|
|
1721
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Skeleton, { className: "h-4 w-3/4" })
|
|
1721
1722
|
] }),
|
|
1722
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1723
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Skeleton, { className: "h-10 w-full" })
|
|
1723
1724
|
] }, cardIndex)) })
|
|
1724
1725
|
] }, rowIndex)) });
|
|
1725
1726
|
}
|
|
@@ -1774,8 +1775,8 @@ function SubscriptionConfirmation({ price, isLoading, onConfirm, onCancel }) {
|
|
|
1774
1775
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: feature })
|
|
1775
1776
|
] }, index)) }),
|
|
1776
1777
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-end gap-3 pt-2 border-t border-accent/30", children: [
|
|
1777
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1778
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1778
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Button, { variant: "outline", onClick: onCancel, disabled: isLoading, children: "Cancel" }),
|
|
1779
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Button, { onClick: onConfirm, disabled: isLoading, children: isLoading ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1779
1780
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Loader2, { className: "h-4 w-4 animate-spin mr-2" }),
|
|
1780
1781
|
"Processing..."
|
|
1781
1782
|
] }) : "Subscribe" })
|
|
@@ -1834,7 +1835,7 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
1834
1835
|
onCloseRef.current = onClose;
|
|
1835
1836
|
const checkPaymentMethod = _react.useCallback.call(void 0, async () => {
|
|
1836
1837
|
try {
|
|
1837
|
-
const methods = await
|
|
1838
|
+
const methods = await _chunkTZRAOUARjs.StripeCustomerService.listPaymentMethods();
|
|
1838
1839
|
dispatch({ type: "SET_HAS_PAYMENT_METHOD", hasMethod: methods.length > 0 });
|
|
1839
1840
|
} catch (error) {
|
|
1840
1841
|
console.error("[useSubscriptionWizard] Failed to check payment methods:", error);
|
|
@@ -1856,7 +1857,7 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
1856
1857
|
try {
|
|
1857
1858
|
await checkPaymentMethod();
|
|
1858
1859
|
if (subscription && state.selectedPrice.id !== _optionalChain([subscription, 'access', _61 => _61.price, 'optionalAccess', _62 => _62.id])) {
|
|
1859
|
-
const preview = await
|
|
1860
|
+
const preview = await _chunkTZRAOUARjs.StripeSubscriptionService.getProrationPreview({
|
|
1860
1861
|
subscriptionId: subscription.id,
|
|
1861
1862
|
newPriceId: state.selectedPrice.id
|
|
1862
1863
|
});
|
|
@@ -1876,12 +1877,12 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
1876
1877
|
dispatch({ type: "SET_ERROR", error: null });
|
|
1877
1878
|
try {
|
|
1878
1879
|
if (subscription) {
|
|
1879
|
-
await
|
|
1880
|
+
await _chunkTZRAOUARjs.StripeSubscriptionService.changePlan({
|
|
1880
1881
|
id: subscription.id,
|
|
1881
1882
|
newPriceId: state.selectedPrice.id
|
|
1882
1883
|
});
|
|
1883
1884
|
} else {
|
|
1884
|
-
await
|
|
1885
|
+
await _chunkTZRAOUARjs.StripeSubscriptionService.createSubscription({
|
|
1885
1886
|
id: _uuid.v4.call(void 0, ),
|
|
1886
1887
|
priceId: state.selectedPrice.id
|
|
1887
1888
|
});
|
|
@@ -1994,6 +1995,7 @@ function WizardStepPlanSelection({
|
|
|
1994
1995
|
selectedInterval,
|
|
1995
1996
|
currentPriceId,
|
|
1996
1997
|
hideRecurringPrices,
|
|
1998
|
+
hideOneTimePrices,
|
|
1997
1999
|
onSelectPrice,
|
|
1998
2000
|
onIntervalChange,
|
|
1999
2001
|
onNext,
|
|
@@ -2004,7 +2006,7 @@ function WizardStepPlanSelection({
|
|
|
2004
2006
|
_react.useEffect.call(void 0, () => {
|
|
2005
2007
|
const loadProducts = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2006
2008
|
try {
|
|
2007
|
-
const fetchedProducts = await
|
|
2009
|
+
const fetchedProducts = await _chunkTZRAOUARjs.StripeProductService.listProducts({ active: true });
|
|
2008
2010
|
setProducts(fetchedProducts);
|
|
2009
2011
|
} catch (error) {
|
|
2010
2012
|
console.error("[WizardStepPlanSelection] Failed to load products:", error);
|
|
@@ -2033,7 +2035,7 @@ function WizardStepPlanSelection({
|
|
|
2033
2035
|
onSelectPrice(price);
|
|
2034
2036
|
}, "handleSelectPrice");
|
|
2035
2037
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-6", children: [
|
|
2036
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex justify-center", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2038
|
+
!hideRecurringPrices && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex justify-center", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2037
2039
|
IntervalToggle,
|
|
2038
2040
|
{
|
|
2039
2041
|
value: selectedInterval,
|
|
@@ -2051,10 +2053,11 @@ function WizardStepPlanSelection({
|
|
|
2051
2053
|
selectedPriceId: _optionalChain([selectedPrice, 'optionalAccess', _75 => _75.id]),
|
|
2052
2054
|
loading,
|
|
2053
2055
|
hideRecurringPrices,
|
|
2056
|
+
hideOneTimePrices,
|
|
2054
2057
|
onSelectPrice: handleSelectPrice
|
|
2055
2058
|
}
|
|
2056
2059
|
),
|
|
2057
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex justify-end pt-4 border-t", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2060
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex justify-end pt-4 border-t", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Button, { onClick: onNext, disabled: !selectedPrice || isProcessing, children: isProcessing ? "Loading..." : "Next: Review" }) })
|
|
2058
2061
|
] });
|
|
2059
2062
|
}
|
|
2060
2063
|
_chunk7QVYU63Ejs.__name.call(void 0, WizardStepPlanSelection, "WizardStepPlanSelection");
|
|
@@ -2101,7 +2104,7 @@ function WizardStepReview({
|
|
|
2101
2104
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-blue-700", children: "Your next charge will be adjusted to account for the plan change." }),
|
|
2102
2105
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between text-sm", children: [
|
|
2103
2106
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-blue-600", children: "Amount due now:" }),
|
|
2104
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "font-medium text-blue-800", children: formatCurrency(prorationPreview.
|
|
2107
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "font-medium text-blue-800", children: formatCurrency(prorationPreview.immediateCharge, prorationPreview.currency) })
|
|
2105
2108
|
] })
|
|
2106
2109
|
] }),
|
|
2107
2110
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border rounded-lg p-4", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between items-center", children: [
|
|
@@ -2109,16 +2112,16 @@ function WizardStepReview({
|
|
|
2109
2112
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h4", { className: "font-medium", children: "Payment Method" }),
|
|
2110
2113
|
/* @__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" })
|
|
2111
2114
|
] }),
|
|
2112
|
-
!hasPaymentMethod && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2115
|
+
!hasPaymentMethod && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Button, { variant: "outline", onClick: onAddPaymentMethod, children: "Add Payment Method" })
|
|
2113
2116
|
] }) }),
|
|
2114
|
-
error && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2117
|
+
error && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Alert, { variant: "destructive", children: [
|
|
2115
2118
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.AlertCircle, { className: "h-4 w-4" }),
|
|
2116
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2119
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.AlertDescription, { children: error })
|
|
2117
2120
|
] }),
|
|
2118
2121
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between pt-4 border-t", children: [
|
|
2119
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2122
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Button, { variant: "outline", onClick: onBack, disabled: isProcessing, children: "Back" }),
|
|
2120
2123
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2121
|
-
|
|
2124
|
+
_chunkRSHCU3TIjs.Button,
|
|
2122
2125
|
{
|
|
2123
2126
|
onClick: hasPaymentMethod ? onConfirm : onAddPaymentMethod,
|
|
2124
2127
|
disabled: isProcessing,
|
|
@@ -2184,12 +2187,14 @@ function SubscriptionWizard({
|
|
|
2184
2187
|
actions.reset();
|
|
2185
2188
|
}
|
|
2186
2189
|
}, [open, actions.reset]);
|
|
2187
|
-
const
|
|
2188
|
-
const
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2190
|
+
const isPurchasingAddons = hasActiveRecurringSubscription && !subscription;
|
|
2191
|
+
const isChangePlanMode = !!subscription;
|
|
2192
|
+
const dialogTitle = subscription ? "Change Subscription Plan" : isPurchasingAddons ? "Purchase Add-ons" : "Subscribe to a Plan";
|
|
2193
|
+
const dialogDescription = subscription ? "Select a new plan for your subscription" : isPurchasingAddons ? "Select one-time products to purchase" : "Choose a subscription plan to get started";
|
|
2194
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.DialogContent, { className: "max-w-2xl", children: [
|
|
2195
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.DialogHeader, { children: [
|
|
2196
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.DialogTitle, { children: dialogTitle }),
|
|
2197
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.DialogDescription, { children: dialogDescription })
|
|
2193
2198
|
] }),
|
|
2194
2199
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, WizardProgressIndicator, { currentStep: state.step }),
|
|
2195
2200
|
state.step === "plan-selection" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -2198,7 +2203,8 @@ function SubscriptionWizard({
|
|
|
2198
2203
|
selectedPrice: state.selectedPrice,
|
|
2199
2204
|
selectedInterval: state.selectedInterval,
|
|
2200
2205
|
currentPriceId: _optionalChain([subscription, 'optionalAccess', _82 => _82.price, 'optionalAccess', _83 => _83.id]),
|
|
2201
|
-
hideRecurringPrices:
|
|
2206
|
+
hideRecurringPrices: isPurchasingAddons,
|
|
2207
|
+
hideOneTimePrices: isChangePlanMode,
|
|
2202
2208
|
onSelectPrice: actions.selectPrice,
|
|
2203
2209
|
onIntervalChange: actions.setInterval,
|
|
2204
2210
|
onNext: actions.goToReview,
|
|
@@ -2265,15 +2271,15 @@ function UsageSummaryCard({ meter, summary }) {
|
|
|
2265
2271
|
const progressWidth = percentage !== null ? Math.min(percentage, 100) : 0;
|
|
2266
2272
|
const displayName = meter.displayName || meter.eventName;
|
|
2267
2273
|
const hasLimit = limit !== null && limit !== void 0;
|
|
2268
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2269
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2274
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Card, { children: [
|
|
2275
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.CardHeader, { className: "flex flex-row items-center gap-x-3 pb-3", children: [
|
|
2270
2276
|
/* @__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" }) }),
|
|
2271
2277
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col", children: [
|
|
2272
2278
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "font-semibold", children: displayName }),
|
|
2273
2279
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-gray-500", children: meter.id })
|
|
2274
2280
|
] })
|
|
2275
2281
|
] }),
|
|
2276
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2282
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.CardContent, { className: "flex flex-col gap-y-4", children: [
|
|
2277
2283
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
2278
2284
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-3xl font-bold", children: currentUsage.toLocaleString() }),
|
|
2279
2285
|
hasLimit && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-sm text-gray-500", children: [
|
|
@@ -2320,14 +2326,14 @@ function UsageContainer() {
|
|
|
2320
2326
|
const loadUsageData = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2321
2327
|
setLoading(true);
|
|
2322
2328
|
try {
|
|
2323
|
-
const fetchedSubscriptions = await
|
|
2329
|
+
const fetchedSubscriptions = await _chunkTZRAOUARjs.StripeSubscriptionService.listSubscriptions();
|
|
2324
2330
|
setSubscriptions(fetchedSubscriptions);
|
|
2325
2331
|
const hasMeteredSubscriptions2 = fetchedSubscriptions.some((sub) => _optionalChain([sub, 'access', _87 => _87.price, 'optionalAccess', _88 => _88.recurring, 'optionalAccess', _89 => _89.usageType]) === "metered");
|
|
2326
2332
|
if (!hasMeteredSubscriptions2) {
|
|
2327
2333
|
setLoading(false);
|
|
2328
2334
|
return;
|
|
2329
2335
|
}
|
|
2330
|
-
const fetchedMeters = await
|
|
2336
|
+
const fetchedMeters = await _chunkTZRAOUARjs.StripeUsageService.listMeters();
|
|
2331
2337
|
setMeters(fetchedMeters);
|
|
2332
2338
|
const summariesMap = {};
|
|
2333
2339
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -2335,7 +2341,7 @@ function UsageContainer() {
|
|
|
2335
2341
|
const endOfMonth = new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59, 999);
|
|
2336
2342
|
for (const meter of fetchedMeters) {
|
|
2337
2343
|
try {
|
|
2338
|
-
const meterSummaries = await
|
|
2344
|
+
const meterSummaries = await _chunkTZRAOUARjs.StripeUsageService.getMeterSummaries({
|
|
2339
2345
|
meterId: meter.id,
|
|
2340
2346
|
startTime: startOfMonth,
|
|
2341
2347
|
endTime: endOfMonth
|
|
@@ -2401,21 +2407,21 @@ function UsageHistoryTable({ usageRecords }) {
|
|
|
2401
2407
|
}
|
|
2402
2408
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-y-4", children: [
|
|
2403
2409
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { className: "text-xl font-semibold", children: "Usage History" }),
|
|
2404
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "overflow-
|
|
2405
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2406
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2407
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2408
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2409
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2410
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "overflow-clip rounded-lg border", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Table, { children: [
|
|
2411
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableHeader, { className: "bg-muted", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.TableRow, { children: [
|
|
2412
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableHead, { children: "Date & Time" }),
|
|
2413
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableHead, { children: "Meter Event" }),
|
|
2414
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableHead, { className: "text-right", children: "Quantity" }),
|
|
2415
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableHead, { children: "Event ID" })
|
|
2410
2416
|
] }) }),
|
|
2411
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2417
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableBody, { children: usageRecords.map((record) => {
|
|
2412
2418
|
const dateTime = formatDateTime(record.timestamp);
|
|
2413
2419
|
const quantity = record.quantity.toLocaleString();
|
|
2414
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2415
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2416
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2417
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2418
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2420
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.TableRow, { children: [
|
|
2421
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableCell, { className: "font-medium", children: dateTime }),
|
|
2422
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableCell, { className: "text-muted-foreground", children: record.meterEventName }),
|
|
2423
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableCell, { className: "text-right font-medium", children: quantity }),
|
|
2424
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.TableCell, { className: "text-muted-foreground text-sm font-mono", children: record.stripeEventId })
|
|
2419
2425
|
] }, record.id);
|
|
2420
2426
|
}) })
|
|
2421
2427
|
] }) })
|
|
@@ -2432,8 +2438,8 @@ function BillingDetailModal({
|
|
|
2432
2438
|
children,
|
|
2433
2439
|
className
|
|
2434
2440
|
}) {
|
|
2435
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2436
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2441
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.DialogContent, { className: _nullishCoalesce(className, () => ( "max-w-4xl max-h-[90vh] overflow-y-auto")), children: [
|
|
2442
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.DialogHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.DialogTitle, { children: title }) }),
|
|
2437
2443
|
children
|
|
2438
2444
|
] }) });
|
|
2439
2445
|
}
|
|
@@ -2450,7 +2456,7 @@ function BillingAlertBanner({ subscription, onUpdatePayment, onAddPayment }) {
|
|
|
2450
2456
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "font-semibold text-red-900", children: "Payment Failed" }),
|
|
2451
2457
|
/* @__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." })
|
|
2452
2458
|
] }),
|
|
2453
|
-
onUpdatePayment && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2459
|
+
onUpdatePayment && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Button, { variant: "outline", size: "sm", onClick: onUpdatePayment, className: "border-red-300 text-red-700", children: "Update Payment Method" })
|
|
2454
2460
|
] });
|
|
2455
2461
|
}
|
|
2456
2462
|
if (subscription.status === "trialing" /* TRIALING */ && subscription.trialEnd) {
|
|
@@ -2470,7 +2476,7 @@ function BillingAlertBanner({ subscription, onUpdatePayment, onAddPayment }) {
|
|
|
2470
2476
|
". Add a payment method to continue your subscription."
|
|
2471
2477
|
] })
|
|
2472
2478
|
] }),
|
|
2473
|
-
onAddPayment && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2479
|
+
onAddPayment && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Button, { variant: "outline", size: "sm", onClick: onAddPayment, className: "border-yellow-300 text-yellow-700", children: "Add Payment Method" })
|
|
2474
2480
|
] });
|
|
2475
2481
|
}
|
|
2476
2482
|
}
|
|
@@ -2521,7 +2527,7 @@ function BillingDashboardContainer() {
|
|
|
2521
2527
|
setNoCustomerExists(false);
|
|
2522
2528
|
let customer = null;
|
|
2523
2529
|
try {
|
|
2524
|
-
customer = await
|
|
2530
|
+
customer = await _chunkTZRAOUARjs.StripeCustomerService.getCustomer();
|
|
2525
2531
|
setData((prev) => ({ ...prev, customer }));
|
|
2526
2532
|
setErrors((prev) => ({ ...prev, customer: null }));
|
|
2527
2533
|
setNoCustomerExists(false);
|
|
@@ -2546,7 +2552,7 @@ function BillingDashboardContainer() {
|
|
|
2546
2552
|
if (customer) {
|
|
2547
2553
|
const fetchSubscriptions = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2548
2554
|
try {
|
|
2549
|
-
const subscriptions2 = await
|
|
2555
|
+
const subscriptions2 = await _chunkTZRAOUARjs.StripeSubscriptionService.listSubscriptions();
|
|
2550
2556
|
setData((prev) => ({ ...prev, subscriptions: subscriptions2 }));
|
|
2551
2557
|
setErrors((prev) => ({ ...prev, subscriptions: null }));
|
|
2552
2558
|
return subscriptions2;
|
|
@@ -2560,7 +2566,7 @@ function BillingDashboardContainer() {
|
|
|
2560
2566
|
}, "fetchSubscriptions");
|
|
2561
2567
|
const fetchPaymentMethods = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2562
2568
|
try {
|
|
2563
|
-
const paymentMethods = await
|
|
2569
|
+
const paymentMethods = await _chunkTZRAOUARjs.StripeCustomerService.listPaymentMethods();
|
|
2564
2570
|
setData((prev) => ({ ...prev, paymentMethods }));
|
|
2565
2571
|
setErrors((prev) => ({ ...prev, paymentMethods: null }));
|
|
2566
2572
|
} catch (error) {
|
|
@@ -2572,7 +2578,7 @@ function BillingDashboardContainer() {
|
|
|
2572
2578
|
}, "fetchPaymentMethods");
|
|
2573
2579
|
const fetchInvoices = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2574
2580
|
try {
|
|
2575
|
-
const invoices = await
|
|
2581
|
+
const invoices = await _chunkTZRAOUARjs.StripeInvoiceService.listInvoices();
|
|
2576
2582
|
setData((prev) => ({ ...prev, invoices }));
|
|
2577
2583
|
setErrors((prev) => ({ ...prev, invoices: null }));
|
|
2578
2584
|
} catch (error) {
|
|
@@ -2596,7 +2602,7 @@ function BillingDashboardContainer() {
|
|
|
2596
2602
|
const handleCreateCustomer = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2597
2603
|
setCreatingCustomer(true);
|
|
2598
2604
|
try {
|
|
2599
|
-
await
|
|
2605
|
+
await _chunkTZRAOUARjs.StripeCustomerService.createCustomer();
|
|
2600
2606
|
setNoCustomerExists(false);
|
|
2601
2607
|
await fetchAllData();
|
|
2602
2608
|
} catch (error) {
|
|
@@ -2608,7 +2614,7 @@ function BillingDashboardContainer() {
|
|
|
2608
2614
|
}, "handleCreateCustomer");
|
|
2609
2615
|
const fetchUsageData = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2610
2616
|
try {
|
|
2611
|
-
const meters = await
|
|
2617
|
+
const meters = await _chunkTZRAOUARjs.StripeUsageService.listMeters();
|
|
2612
2618
|
setData((prev) => ({ ...prev, meters }));
|
|
2613
2619
|
const summariesMap = {};
|
|
2614
2620
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -2616,7 +2622,7 @@ function BillingDashboardContainer() {
|
|
|
2616
2622
|
const endOfMonth = new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59, 999);
|
|
2617
2623
|
for (const meter of meters) {
|
|
2618
2624
|
try {
|
|
2619
|
-
const meterSummaries = await
|
|
2625
|
+
const meterSummaries = await _chunkTZRAOUARjs.StripeUsageService.getMeterSummaries({
|
|
2620
2626
|
meterId: meter.id,
|
|
2621
2627
|
startTime: startOfMonth,
|
|
2622
2628
|
endTime: endOfMonth
|
|
@@ -2694,18 +2700,18 @@ function BillingDashboardContainer() {
|
|
|
2694
2700
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Wallet, { className: "h-8 w-8" }),
|
|
2695
2701
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h1", { className: "text-3xl font-bold", children: "Billing" })
|
|
2696
2702
|
] }),
|
|
2697
|
-
isInitialLoading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2698
|
-
noCustomerExists && !isInitialLoading && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2699
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2703
|
+
isInitialLoading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Card, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.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" }) }) }),
|
|
2704
|
+
noCustomerExists && !isInitialLoading && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Card, { children: [
|
|
2705
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.CardHeader, { className: "text-center", children: [
|
|
2700
2706
|
/* @__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" }) }),
|
|
2701
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2702
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2707
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardTitle, { children: "Set Up Billing" }),
|
|
2708
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardDescription, { children: "Your company doesn't have a billing account yet. Set one up to manage subscriptions, payment methods, and view invoices." })
|
|
2703
2709
|
] }),
|
|
2704
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2710
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardContent, { className: "flex justify-center pb-8", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Button, { onClick: handleCreateCustomer, disabled: creatingCustomer, size: "lg", children: creatingCustomer ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
2705
2711
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Loader2, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
2706
2712
|
"Setting up..."
|
|
2707
2713
|
] }) : "Set Up Billing Account" }) }),
|
|
2708
|
-
errors.customer && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2714
|
+
errors.customer && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CardContent, { className: "pt-0", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-center text-sm text-destructive", children: errors.customer }) })
|
|
2709
2715
|
] }),
|
|
2710
2716
|
!noCustomerExists && !isInitialLoading && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
2711
2717
|
criticalSubscriptions.map((subscription) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -2777,7 +2783,13 @@ function BillingDashboardContainer() {
|
|
|
2777
2783
|
open: activeModal === "subscriptions",
|
|
2778
2784
|
onOpenChange: handleModalClose,
|
|
2779
2785
|
title: getModalTitle("subscriptions"),
|
|
2780
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2786
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2787
|
+
SubscriptionsContainer,
|
|
2788
|
+
{
|
|
2789
|
+
onOpenWizard: handleOpenWizard,
|
|
2790
|
+
hasActiveRecurringSubscription
|
|
2791
|
+
}
|
|
2792
|
+
)
|
|
2781
2793
|
}
|
|
2782
2794
|
),
|
|
2783
2795
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -2865,6 +2877,18 @@ _chunk7QVYU63Ejs.__name.call(void 0, isStripeConfigured, "isStripeConfigured");
|
|
|
2865
2877
|
|
|
2866
2878
|
function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
2867
2879
|
const [isSubmitting, setIsSubmitting] = _react.useState.call(void 0, false);
|
|
2880
|
+
const [allFeatures, setAllFeatures] = _react.useState.call(void 0, []);
|
|
2881
|
+
_react.useEffect.call(void 0, () => {
|
|
2882
|
+
const fetchFeatures = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2883
|
+
try {
|
|
2884
|
+
const features = await _chunkTZRAOUARjs.FeatureService.findMany({});
|
|
2885
|
+
setAllFeatures(features);
|
|
2886
|
+
} catch (error) {
|
|
2887
|
+
console.error("[PriceEditor] Failed to fetch features:", error);
|
|
2888
|
+
}
|
|
2889
|
+
}, "fetchFeatures");
|
|
2890
|
+
fetchFeatures();
|
|
2891
|
+
}, []);
|
|
2868
2892
|
const formSchema2 = _zod3.z.object({
|
|
2869
2893
|
unitAmount: _zod3.z.preprocess(
|
|
2870
2894
|
(val) => typeof val === "string" ? parseFloat(val) : val,
|
|
@@ -2881,41 +2905,50 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
2881
2905
|
active: _zod3.z.boolean(),
|
|
2882
2906
|
description: _zod3.z.string().optional(),
|
|
2883
2907
|
features: _zod3.z.array(_zod3.z.string()),
|
|
2884
|
-
token: _zod3.z.string()
|
|
2908
|
+
token: _zod3.z.string(),
|
|
2909
|
+
featureIds: _zod3.z.array(_zod3.z.string())
|
|
2885
2910
|
});
|
|
2886
2911
|
const isEditMode = !!price;
|
|
2887
2912
|
const defaultUnitAmount = _optionalChain([price, 'optionalAccess', _104 => _104.unitAmount]) ? price.unitAmount / 100 : 0;
|
|
2913
|
+
const coreFeatureIds = allFeatures.filter((f) => f.isCore).map((f) => f.id);
|
|
2914
|
+
const defaultFeatureIds = [.../* @__PURE__ */ new Set([..._nullishCoalesce(_optionalChain([price, 'optionalAccess', _105 => _105.priceFeatures, 'optionalAccess', _106 => _106.map, 'call', _107 => _107((f) => f.id)]), () => ( [])), ...coreFeatureIds])];
|
|
2888
2915
|
const form = _reacthookform.useForm.call(void 0, {
|
|
2889
2916
|
resolver: _zod.zodResolver.call(void 0, formSchema2),
|
|
2890
2917
|
defaultValues: {
|
|
2891
2918
|
unitAmount: defaultUnitAmount,
|
|
2892
|
-
currency: _optionalChain([price, 'optionalAccess',
|
|
2893
|
-
interval: _optionalChain([price, 'optionalAccess',
|
|
2894
|
-
intervalCount: _optionalChain([price, 'optionalAccess',
|
|
2895
|
-
usageType: _optionalChain([price, 'optionalAccess',
|
|
2896
|
-
nickname: _optionalChain([price, 'optionalAccess',
|
|
2897
|
-
active: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
2898
|
-
description: _optionalChain([price, 'optionalAccess',
|
|
2899
|
-
features: _optionalChain([price, 'optionalAccess',
|
|
2900
|
-
token: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
2919
|
+
currency: _optionalChain([price, 'optionalAccess', _108 => _108.currency]) || "usd",
|
|
2920
|
+
interval: _optionalChain([price, 'optionalAccess', _109 => _109.priceType]) === "one_time" ? "one_time" : _optionalChain([price, 'optionalAccess', _110 => _110.recurring, 'optionalAccess', _111 => _111.interval]) || "month",
|
|
2921
|
+
intervalCount: _optionalChain([price, 'optionalAccess', _112 => _112.recurring, 'optionalAccess', _113 => _113.intervalCount]) || 1,
|
|
2922
|
+
usageType: _optionalChain([price, 'optionalAccess', _114 => _114.recurring, 'optionalAccess', _115 => _115.usageType]) || "licensed",
|
|
2923
|
+
nickname: _optionalChain([price, 'optionalAccess', _116 => _116.nickname]) || "",
|
|
2924
|
+
active: _nullishCoalesce(_optionalChain([price, 'optionalAccess', _117 => _117.active]), () => ( true)),
|
|
2925
|
+
description: _optionalChain([price, 'optionalAccess', _118 => _118.description]) || "",
|
|
2926
|
+
features: _optionalChain([price, 'optionalAccess', _119 => _119.features]) || [],
|
|
2927
|
+
token: _nullishCoalesce(_optionalChain([price, 'optionalAccess', _120 => _120.token, 'optionalAccess', _121 => _121.toString, 'call', _122 => _122()]), () => ( "")),
|
|
2928
|
+
featureIds: defaultFeatureIds
|
|
2901
2929
|
}
|
|
2902
2930
|
});
|
|
2903
2931
|
_react.useEffect.call(void 0, () => {
|
|
2904
2932
|
if (open) {
|
|
2933
|
+
const currentCoreFeatureIds = allFeatures.filter((f) => f.isCore).map((f) => f.id);
|
|
2934
|
+
const resetFeatureIds = [
|
|
2935
|
+
.../* @__PURE__ */ new Set([..._nullishCoalesce(_optionalChain([price, 'optionalAccess', _123 => _123.priceFeatures, 'optionalAccess', _124 => _124.map, 'call', _125 => _125((f) => f.id)]), () => ( [])), ...currentCoreFeatureIds])
|
|
2936
|
+
];
|
|
2905
2937
|
form.reset({
|
|
2906
|
-
unitAmount: _optionalChain([price, 'optionalAccess',
|
|
2907
|
-
currency: _optionalChain([price, 'optionalAccess',
|
|
2908
|
-
interval: _optionalChain([price, 'optionalAccess',
|
|
2909
|
-
intervalCount: _optionalChain([price, 'optionalAccess',
|
|
2910
|
-
usageType: _optionalChain([price, 'optionalAccess',
|
|
2911
|
-
nickname: _optionalChain([price, 'optionalAccess',
|
|
2912
|
-
active: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
2913
|
-
description: _optionalChain([price, 'optionalAccess',
|
|
2914
|
-
features: _optionalChain([price, 'optionalAccess',
|
|
2915
|
-
token: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
2938
|
+
unitAmount: _optionalChain([price, 'optionalAccess', _126 => _126.unitAmount]) ? price.unitAmount / 100 : 0,
|
|
2939
|
+
currency: _optionalChain([price, 'optionalAccess', _127 => _127.currency]) || "usd",
|
|
2940
|
+
interval: _optionalChain([price, 'optionalAccess', _128 => _128.priceType]) === "one_time" ? "one_time" : _optionalChain([price, 'optionalAccess', _129 => _129.recurring, 'optionalAccess', _130 => _130.interval]) || "month",
|
|
2941
|
+
intervalCount: _optionalChain([price, 'optionalAccess', _131 => _131.recurring, 'optionalAccess', _132 => _132.intervalCount]) || 1,
|
|
2942
|
+
usageType: _optionalChain([price, 'optionalAccess', _133 => _133.recurring, 'optionalAccess', _134 => _134.usageType]) || "licensed",
|
|
2943
|
+
nickname: _optionalChain([price, 'optionalAccess', _135 => _135.nickname]) || "",
|
|
2944
|
+
active: _nullishCoalesce(_optionalChain([price, 'optionalAccess', _136 => _136.active]), () => ( true)),
|
|
2945
|
+
description: _optionalChain([price, 'optionalAccess', _137 => _137.description]) || "",
|
|
2946
|
+
features: _optionalChain([price, 'optionalAccess', _138 => _138.features]) || [],
|
|
2947
|
+
token: _nullishCoalesce(_optionalChain([price, 'optionalAccess', _139 => _139.token, 'optionalAccess', _140 => _140.toString, 'call', _141 => _141()]), () => ( "")),
|
|
2948
|
+
featureIds: resetFeatureIds
|
|
2916
2949
|
});
|
|
2917
2950
|
}
|
|
2918
|
-
}, [open, _optionalChain([price, 'optionalAccess',
|
|
2951
|
+
}, [open, _optionalChain([price, 'optionalAccess', _142 => _142.id]), allFeatures]);
|
|
2919
2952
|
const watchInterval = form.watch("interval");
|
|
2920
2953
|
const isRecurring = watchInterval !== "one_time";
|
|
2921
2954
|
const onSubmit = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async (values) => {
|
|
@@ -2923,12 +2956,14 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
2923
2956
|
try {
|
|
2924
2957
|
const unitAmountInCents = Math.round(values.unitAmount * 100);
|
|
2925
2958
|
if (isEditMode) {
|
|
2926
|
-
await
|
|
2959
|
+
await _chunkTZRAOUARjs.StripePriceService.updatePrice({
|
|
2927
2960
|
id: price.id,
|
|
2928
2961
|
nickname: values.nickname || void 0,
|
|
2929
2962
|
description: values.description || void 0,
|
|
2930
2963
|
features: values.features.filter((f) => f.trim()) || void 0,
|
|
2931
|
-
token: values.token ? parseInt(values.token, 10) : void 0
|
|
2964
|
+
token: values.token ? parseInt(values.token, 10) : void 0,
|
|
2965
|
+
// Only include featureIds for recurring prices (one-time prices don't support platform features)
|
|
2966
|
+
..._optionalChain([price, 'optionalAccess', _143 => _143.priceType]) === "recurring" ? { featureIds: values.featureIds } : {}
|
|
2932
2967
|
});
|
|
2933
2968
|
} else {
|
|
2934
2969
|
const createInput = {
|
|
@@ -2957,7 +2992,10 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
2957
2992
|
if (values.token) {
|
|
2958
2993
|
createInput.token = parseInt(values.token, 10);
|
|
2959
2994
|
}
|
|
2960
|
-
|
|
2995
|
+
if (isRecurring && values.featureIds.length > 0) {
|
|
2996
|
+
createInput.featureIds = values.featureIds;
|
|
2997
|
+
}
|
|
2998
|
+
await _chunkTZRAOUARjs.StripePriceService.createPrice(createInput);
|
|
2961
2999
|
}
|
|
2962
3000
|
onSuccess();
|
|
2963
3001
|
onOpenChange(false);
|
|
@@ -2983,10 +3021,10 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
2983
3021
|
{ id: "licensed", text: "Licensed (per unit)" },
|
|
2984
3022
|
{ id: "metered", text: "Metered (usage-based)" }
|
|
2985
3023
|
];
|
|
2986
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2987
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2988
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2989
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3024
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.DialogContent, { className: "max-w-2xl", children: [
|
|
3025
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.DialogHeader, { children: [
|
|
3026
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.DialogTitle, { children: isEditMode ? "Edit Price" : "Create Price" }),
|
|
3027
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.DialogDescription, { children: isEditMode ? "Update the price details. Note: Only nickname and active status can be changed." : "Create a new price for this product" })
|
|
2990
3028
|
] }),
|
|
2991
3029
|
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: [
|
|
2992
3030
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.AlertCircle, { className: "h-5 w-5 text-blue-600 flex-shrink-0 mt-0.5" }),
|
|
@@ -2995,10 +3033,10 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
2995
3033
|
/* @__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." })
|
|
2996
3034
|
] })
|
|
2997
3035
|
] }),
|
|
2998
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3036
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Form, { ...form, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { onSubmit: form.handleSubmit(onSubmit), className: "flex flex-col gap-y-4", children: [
|
|
2999
3037
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid grid-cols-2 gap-x-4", children: [
|
|
3000
3038
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3001
|
-
|
|
3039
|
+
_chunkRSHCU3TIjs.FormInput,
|
|
3002
3040
|
{
|
|
3003
3041
|
form,
|
|
3004
3042
|
id: "unitAmount",
|
|
@@ -3008,10 +3046,10 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
3008
3046
|
isRequired: true
|
|
3009
3047
|
}
|
|
3010
3048
|
),
|
|
3011
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3049
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.FormSelect, { form, id: "currency", name: "Currency", values: currencyOptions, disabled: isEditMode })
|
|
3012
3050
|
] }),
|
|
3013
3051
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3014
|
-
|
|
3052
|
+
_chunkRSHCU3TIjs.FormSelect,
|
|
3015
3053
|
{
|
|
3016
3054
|
form,
|
|
3017
3055
|
id: "interval",
|
|
@@ -3022,7 +3060,7 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
3022
3060
|
),
|
|
3023
3061
|
isRecurring && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid grid-cols-2 gap-x-4", children: [
|
|
3024
3062
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3025
|
-
|
|
3063
|
+
_chunkRSHCU3TIjs.FormInput,
|
|
3026
3064
|
{
|
|
3027
3065
|
form,
|
|
3028
3066
|
id: "intervalCount",
|
|
@@ -3033,7 +3071,7 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
3033
3071
|
}
|
|
3034
3072
|
),
|
|
3035
3073
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3036
|
-
|
|
3074
|
+
_chunkRSHCU3TIjs.FormSelect,
|
|
3037
3075
|
{
|
|
3038
3076
|
form,
|
|
3039
3077
|
id: "usageType",
|
|
@@ -3044,7 +3082,7 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
3044
3082
|
)
|
|
3045
3083
|
] }),
|
|
3046
3084
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3047
|
-
|
|
3085
|
+
_chunkRSHCU3TIjs.FormInput,
|
|
3048
3086
|
{
|
|
3049
3087
|
form,
|
|
3050
3088
|
id: "nickname",
|
|
@@ -3053,7 +3091,7 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
3053
3091
|
}
|
|
3054
3092
|
),
|
|
3055
3093
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3056
|
-
|
|
3094
|
+
_chunkRSHCU3TIjs.FormTextarea,
|
|
3057
3095
|
{
|
|
3058
3096
|
form,
|
|
3059
3097
|
id: "description",
|
|
@@ -3062,13 +3100,13 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
3062
3100
|
className: "min-h-24"
|
|
3063
3101
|
}
|
|
3064
3102
|
),
|
|
3065
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3103
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.FormInput, { form, id: "token", name: "Token (optional)", placeholder: "Enter token value" }),
|
|
3066
3104
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
3067
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3105
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Label, { children: "Features (optional)" }),
|
|
3068
3106
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
3069
3107
|
form.watch("features").map((_, index) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex gap-2", children: [
|
|
3070
3108
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3071
|
-
|
|
3109
|
+
_chunkRSHCU3TIjs.Input,
|
|
3072
3110
|
{
|
|
3073
3111
|
...form.register(`features.${index}`),
|
|
3074
3112
|
placeholder: `Feature ${index + 1}`,
|
|
@@ -3076,7 +3114,7 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
3076
3114
|
}
|
|
3077
3115
|
),
|
|
3078
3116
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3079
|
-
|
|
3117
|
+
_chunkRSHCU3TIjs.Button,
|
|
3080
3118
|
{
|
|
3081
3119
|
type: "button",
|
|
3082
3120
|
variant: "outline",
|
|
@@ -3093,7 +3131,7 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
3093
3131
|
)
|
|
3094
3132
|
] }, index)),
|
|
3095
3133
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3096
|
-
|
|
3134
|
+
_chunkRSHCU3TIjs.Button,
|
|
3097
3135
|
{
|
|
3098
3136
|
type: "button",
|
|
3099
3137
|
variant: "outline",
|
|
@@ -3111,8 +3149,51 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
3111
3149
|
)
|
|
3112
3150
|
] })
|
|
3113
3151
|
] }),
|
|
3114
|
-
/* @__PURE__ */ _jsxruntime.
|
|
3115
|
-
|
|
3152
|
+
isRecurring && allFeatures.length > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
3153
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Label, { children: "Platform Features" }),
|
|
3154
|
+
/* @__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) => {
|
|
3155
|
+
const isCore = feature.isCore;
|
|
3156
|
+
const isChecked = form.watch("featureIds").includes(feature.id);
|
|
3157
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center space-x-2", children: [
|
|
3158
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3159
|
+
"input",
|
|
3160
|
+
{
|
|
3161
|
+
type: "checkbox",
|
|
3162
|
+
id: `feature-${feature.id}`,
|
|
3163
|
+
checked: isChecked,
|
|
3164
|
+
disabled: isCore,
|
|
3165
|
+
onChange: (e) => {
|
|
3166
|
+
const currentIds = form.getValues("featureIds");
|
|
3167
|
+
if (e.target.checked) {
|
|
3168
|
+
form.setValue("featureIds", [...currentIds, feature.id]);
|
|
3169
|
+
} else {
|
|
3170
|
+
if (!isCore) {
|
|
3171
|
+
form.setValue(
|
|
3172
|
+
"featureIds",
|
|
3173
|
+
currentIds.filter((id) => id !== feature.id)
|
|
3174
|
+
);
|
|
3175
|
+
}
|
|
3176
|
+
}
|
|
3177
|
+
},
|
|
3178
|
+
className: "h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary disabled:opacity-50"
|
|
3179
|
+
}
|
|
3180
|
+
),
|
|
3181
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3182
|
+
"label",
|
|
3183
|
+
{
|
|
3184
|
+
htmlFor: `feature-${feature.id}`,
|
|
3185
|
+
className: `text-sm ${isCore ? "text-muted-foreground" : ""}`,
|
|
3186
|
+
children: [
|
|
3187
|
+
feature.name,
|
|
3188
|
+
isCore && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "ml-2 text-xs text-muted-foreground", children: "(Core - Required)" })
|
|
3189
|
+
]
|
|
3190
|
+
}
|
|
3191
|
+
)
|
|
3192
|
+
] }, feature.id);
|
|
3193
|
+
}) })
|
|
3194
|
+
] }),
|
|
3195
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.FormCheckbox, { form, id: "active", name: "Active" }),
|
|
3196
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CommonEditorButtons, { isEdit: isEditMode, form, disabled: isSubmitting, setOpen: onOpenChange })
|
|
3116
3197
|
] }) })
|
|
3117
3198
|
] }) });
|
|
3118
3199
|
}
|
|
@@ -3134,7 +3215,7 @@ function PricesList({ productId, onPricesChange }) {
|
|
|
3134
3215
|
const loadPrices = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
3135
3216
|
setLoading(true);
|
|
3136
3217
|
try {
|
|
3137
|
-
const fetchedPrices = await
|
|
3218
|
+
const fetchedPrices = await _chunkTZRAOUARjs.StripePriceService.listPrices({ productId });
|
|
3138
3219
|
setPrices(fetchedPrices);
|
|
3139
3220
|
} catch (error) {
|
|
3140
3221
|
console.error("[PricesList] Failed to load prices:", error);
|
|
@@ -3151,7 +3232,7 @@ function PricesList({ productId, onPricesChange }) {
|
|
|
3151
3232
|
}
|
|
3152
3233
|
setArchivingPriceId(priceToArchive.id);
|
|
3153
3234
|
try {
|
|
3154
|
-
await
|
|
3235
|
+
await _chunkTZRAOUARjs.StripePriceService.archivePrice({ id: priceToArchive.id });
|
|
3155
3236
|
setPriceToArchive(null);
|
|
3156
3237
|
await loadPrices();
|
|
3157
3238
|
onPricesChange();
|
|
@@ -3167,7 +3248,7 @@ function PricesList({ productId, onPricesChange }) {
|
|
|
3167
3248
|
}
|
|
3168
3249
|
setReactivatingPriceId(priceToReactivate.id);
|
|
3169
3250
|
try {
|
|
3170
|
-
await
|
|
3251
|
+
await _chunkTZRAOUARjs.StripePriceService.reactivatePrice({ id: priceToReactivate.id });
|
|
3171
3252
|
setPriceToReactivate(null);
|
|
3172
3253
|
await loadPrices();
|
|
3173
3254
|
onPricesChange();
|
|
@@ -3198,12 +3279,12 @@ function PricesList({ productId, onPricesChange }) {
|
|
|
3198
3279
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-y-4", children: [
|
|
3199
3280
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-between mb-4", children: [
|
|
3200
3281
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h4", { className: "text-lg font-semibold", children: "Prices" }),
|
|
3201
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3282
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Button, { size: "sm", onClick: () => setShowCreatePrice(true), children: "Add Price" })
|
|
3202
3283
|
] }),
|
|
3203
3284
|
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: [
|
|
3204
3285
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.DollarSign, { className: "text-muted-foreground h-12 w-12" }),
|
|
3205
3286
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-muted-foreground text-sm", children: "No prices yet. Add a price to enable subscriptions." }),
|
|
3206
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3287
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Button, { size: "sm", onClick: () => setShowCreatePrice(true), children: "Add Price" })
|
|
3207
3288
|
] }),
|
|
3208
3289
|
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) => {
|
|
3209
3290
|
const isArchiving = archivingPriceId === price.id;
|
|
@@ -3212,9 +3293,9 @@ function PricesList({ productId, onPricesChange }) {
|
|
|
3212
3293
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-start justify-between mb-3", children: [
|
|
3213
3294
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.DollarSign, { className: "h-5 w-5 text-primary" }),
|
|
3214
3295
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex gap-1", children: [
|
|
3215
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3296
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.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" }) }),
|
|
3216
3297
|
price.active ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3217
|
-
|
|
3298
|
+
_chunkRSHCU3TIjs.Button,
|
|
3218
3299
|
{
|
|
3219
3300
|
variant: "ghost",
|
|
3220
3301
|
size: "sm",
|
|
@@ -3224,7 +3305,7 @@ function PricesList({ productId, onPricesChange }) {
|
|
|
3224
3305
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Archive, { className: "h-4 w-4" })
|
|
3225
3306
|
}
|
|
3226
3307
|
) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3227
|
-
|
|
3308
|
+
_chunkRSHCU3TIjs.Button,
|
|
3228
3309
|
{
|
|
3229
3310
|
variant: "ghost",
|
|
3230
3311
|
size: "sm",
|
|
@@ -3241,10 +3322,10 @@ function PricesList({ productId, onPricesChange }) {
|
|
|
3241
3322
|
" ",
|
|
3242
3323
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-sm font-normal", children: formatInterval2(price) })
|
|
3243
3324
|
] }) }),
|
|
3244
|
-
_optionalChain([price, 'access',
|
|
3325
|
+
_optionalChain([price, 'access', _144 => _144.metadata, 'optionalAccess', _145 => _145.nickname]) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm font-medium mb-2", children: price.metadata.nickname }),
|
|
3245
3326
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-wrap gap-2", children: [
|
|
3246
3327
|
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" }),
|
|
3247
|
-
_optionalChain([price, 'access',
|
|
3328
|
+
_optionalChain([price, 'access', _146 => _146.recurring, 'optionalAccess', _147 => _147.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" }),
|
|
3248
3329
|
/* @__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 })
|
|
3249
3330
|
] })
|
|
3250
3331
|
] }, price.id);
|
|
@@ -3275,20 +3356,20 @@ function PricesList({ productId, onPricesChange }) {
|
|
|
3275
3356
|
}
|
|
3276
3357
|
}
|
|
3277
3358
|
),
|
|
3278
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3279
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3280
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3281
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3359
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.AlertDialog, { open: !!priceToArchive, onOpenChange: (open) => !open && setPriceToArchive(null), children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.AlertDialogContent, { children: [
|
|
3360
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.AlertDialogHeader, { children: [
|
|
3361
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.AlertDialogTitle, { children: "Archive Price" }),
|
|
3362
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.AlertDialogDescription, { children: [
|
|
3282
3363
|
"Are you sure you want to archive the price for",
|
|
3283
3364
|
" ",
|
|
3284
3365
|
priceToArchive && `${formatCurrency(priceToArchive.unitAmount, priceToArchive.currency)} ${formatInterval2(priceToArchive)}`,
|
|
3285
3366
|
"? This will prevent new subscriptions but existing ones will continue."
|
|
3286
3367
|
] })
|
|
3287
3368
|
] }),
|
|
3288
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3289
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3369
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.AlertDialogFooter, { children: [
|
|
3370
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.AlertDialogCancel, { disabled: !!archivingPriceId, children: "Cancel" }),
|
|
3290
3371
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3291
|
-
|
|
3372
|
+
_chunkRSHCU3TIjs.AlertDialogAction,
|
|
3292
3373
|
{
|
|
3293
3374
|
onClick: handleArchive,
|
|
3294
3375
|
disabled: !!archivingPriceId,
|
|
@@ -3298,20 +3379,20 @@ function PricesList({ productId, onPricesChange }) {
|
|
|
3298
3379
|
)
|
|
3299
3380
|
] })
|
|
3300
3381
|
] }) }),
|
|
3301
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3302
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3303
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3304
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3382
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.AlertDialog, { open: !!priceToReactivate, onOpenChange: (open) => !open && setPriceToReactivate(null), children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.AlertDialogContent, { children: [
|
|
3383
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.AlertDialogHeader, { children: [
|
|
3384
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.AlertDialogTitle, { children: "Reactivate Price" }),
|
|
3385
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.AlertDialogDescription, { children: [
|
|
3305
3386
|
"Are you sure you want to reactivate the price for",
|
|
3306
3387
|
" ",
|
|
3307
3388
|
priceToReactivate && `${formatCurrency(priceToReactivate.unitAmount, priceToReactivate.currency)} ${formatInterval2(priceToReactivate)}`,
|
|
3308
3389
|
"? This will allow new subscriptions again."
|
|
3309
3390
|
] })
|
|
3310
3391
|
] }),
|
|
3311
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3312
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3392
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.AlertDialogFooter, { children: [
|
|
3393
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.AlertDialogCancel, { disabled: !!reactivatingPriceId, children: "Cancel" }),
|
|
3313
3394
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3314
|
-
|
|
3395
|
+
_chunkRSHCU3TIjs.AlertDialogAction,
|
|
3315
3396
|
{
|
|
3316
3397
|
onClick: handleReactivate,
|
|
3317
3398
|
disabled: !!reactivatingPriceId,
|
|
@@ -3346,23 +3427,23 @@ function ProductEditor({ product, open, onOpenChange, onSuccess }) {
|
|
|
3346
3427
|
const form = _reacthookform.useForm.call(void 0, {
|
|
3347
3428
|
resolver: _zod.zodResolver.call(void 0, formSchema2),
|
|
3348
3429
|
defaultValues: {
|
|
3349
|
-
name: _optionalChain([product, 'optionalAccess',
|
|
3350
|
-
description: _optionalChain([product, 'optionalAccess',
|
|
3351
|
-
active: _nullishCoalesce(_optionalChain([product, 'optionalAccess',
|
|
3430
|
+
name: _optionalChain([product, 'optionalAccess', _148 => _148.name]) || "",
|
|
3431
|
+
description: _optionalChain([product, 'optionalAccess', _149 => _149.description]) || "",
|
|
3432
|
+
active: _nullishCoalesce(_optionalChain([product, 'optionalAccess', _150 => _150.active]), () => ( true))
|
|
3352
3433
|
}
|
|
3353
3434
|
});
|
|
3354
3435
|
const onSubmit = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async (values) => {
|
|
3355
3436
|
setIsSubmitting(true);
|
|
3356
3437
|
try {
|
|
3357
3438
|
if (product) {
|
|
3358
|
-
await
|
|
3439
|
+
await _chunkTZRAOUARjs.StripeProductService.updateProduct({
|
|
3359
3440
|
id: product.id,
|
|
3360
3441
|
name: values.name,
|
|
3361
3442
|
description: values.description,
|
|
3362
3443
|
active: values.active
|
|
3363
3444
|
});
|
|
3364
3445
|
} else {
|
|
3365
|
-
await
|
|
3446
|
+
await _chunkTZRAOUARjs.StripeProductService.createProduct({
|
|
3366
3447
|
id: _uuid.v4.call(void 0, ),
|
|
3367
3448
|
name: values.name,
|
|
3368
3449
|
description: values.description,
|
|
@@ -3377,15 +3458,15 @@ function ProductEditor({ product, open, onOpenChange, onSuccess }) {
|
|
|
3377
3458
|
setIsSubmitting(false);
|
|
3378
3459
|
}
|
|
3379
3460
|
}, "onSubmit");
|
|
3380
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3381
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3382
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3383
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3461
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.DialogContent, { className: "max-w-2xl", children: [
|
|
3462
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.DialogHeader, { children: [
|
|
3463
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.DialogTitle, { children: product ? "Edit Product" : "Create Product" }),
|
|
3464
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.DialogDescription, { children: product ? `Update the details for ${product.name}` : "Create a new product to offer to your customers" })
|
|
3384
3465
|
] }),
|
|
3385
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3386
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3466
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Form, { ...form, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { onSubmit: form.handleSubmit(onSubmit), className: "flex flex-col gap-y-4", children: [
|
|
3467
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.FormInput, { form, id: "name", name: "Product Name", placeholder: "Enter product name", isRequired: true }),
|
|
3387
3468
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3388
|
-
|
|
3469
|
+
_chunkRSHCU3TIjs.FormTextarea,
|
|
3389
3470
|
{
|
|
3390
3471
|
form,
|
|
3391
3472
|
id: "description",
|
|
@@ -3394,8 +3475,8 @@ function ProductEditor({ product, open, onOpenChange, onSuccess }) {
|
|
|
3394
3475
|
className: "min-h-32"
|
|
3395
3476
|
}
|
|
3396
3477
|
),
|
|
3397
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3398
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3478
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.FormCheckbox, { form, id: "active", name: "Active" }),
|
|
3479
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.CommonEditorButtons, { isEdit: !!product, form, disabled: isSubmitting, setOpen: onOpenChange })
|
|
3399
3480
|
] }) })
|
|
3400
3481
|
] }) });
|
|
3401
3482
|
}
|
|
@@ -3418,7 +3499,7 @@ function ProductsList({ products, onProductsChange }) {
|
|
|
3418
3499
|
}
|
|
3419
3500
|
setArchivingProductId(productToArchive.id);
|
|
3420
3501
|
try {
|
|
3421
|
-
const archivedProduct = await
|
|
3502
|
+
const archivedProduct = await _chunkTZRAOUARjs.StripeProductService.archiveProduct({ id: productToArchive.id });
|
|
3422
3503
|
setProductToArchive(null);
|
|
3423
3504
|
onProductsChange();
|
|
3424
3505
|
} catch (error) {
|
|
@@ -3433,7 +3514,7 @@ function ProductsList({ products, onProductsChange }) {
|
|
|
3433
3514
|
}
|
|
3434
3515
|
setReactivatingProductId(productToReactivate.id);
|
|
3435
3516
|
try {
|
|
3436
|
-
const reactivatedProduct = await
|
|
3517
|
+
const reactivatedProduct = await _chunkTZRAOUARjs.StripeProductService.reactivateProduct({ id: productToReactivate.id });
|
|
3437
3518
|
setProductToReactivate(null);
|
|
3438
3519
|
onProductsChange();
|
|
3439
3520
|
} catch (error) {
|
|
@@ -3462,12 +3543,12 @@ function ProductsList({ products, onProductsChange }) {
|
|
|
3462
3543
|
] })
|
|
3463
3544
|
] }),
|
|
3464
3545
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-2", children: [
|
|
3465
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3546
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.Button, { variant: "outline", size: "sm", onClick: () => setEditingProduct(product), children: [
|
|
3466
3547
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Edit, { className: "h-4 w-4 mr-1" }),
|
|
3467
3548
|
"Edit"
|
|
3468
3549
|
] }),
|
|
3469
3550
|
product.active ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3470
|
-
|
|
3551
|
+
_chunkRSHCU3TIjs.Button,
|
|
3471
3552
|
{
|
|
3472
3553
|
variant: "outline",
|
|
3473
3554
|
size: "sm",
|
|
@@ -3479,7 +3560,7 @@ function ProductsList({ products, onProductsChange }) {
|
|
|
3479
3560
|
]
|
|
3480
3561
|
}
|
|
3481
3562
|
) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3482
|
-
|
|
3563
|
+
_chunkRSHCU3TIjs.Button,
|
|
3483
3564
|
{
|
|
3484
3565
|
variant: "outline",
|
|
3485
3566
|
size: "sm",
|
|
@@ -3491,7 +3572,7 @@ function ProductsList({ products, onProductsChange }) {
|
|
|
3491
3572
|
]
|
|
3492
3573
|
}
|
|
3493
3574
|
),
|
|
3494
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3575
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.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" }) })
|
|
3495
3576
|
] })
|
|
3496
3577
|
] }),
|
|
3497
3578
|
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 }) })
|
|
@@ -3509,19 +3590,19 @@ function ProductsList({ products, onProductsChange }) {
|
|
|
3509
3590
|
}
|
|
3510
3591
|
}
|
|
3511
3592
|
),
|
|
3512
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3513
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3514
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3515
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3593
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.AlertDialog, { open: !!productToArchive, onOpenChange: (open) => !open && setProductToArchive(null), children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.AlertDialogContent, { children: [
|
|
3594
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.AlertDialogHeader, { children: [
|
|
3595
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.AlertDialogTitle, { children: "Archive Product" }),
|
|
3596
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.AlertDialogDescription, { children: [
|
|
3516
3597
|
'Are you sure you want to archive "',
|
|
3517
|
-
_optionalChain([productToArchive, 'optionalAccess',
|
|
3598
|
+
_optionalChain([productToArchive, 'optionalAccess', _151 => _151.name]),
|
|
3518
3599
|
'"? This will deactivate it and it will no longer be available for new subscriptions.'
|
|
3519
3600
|
] })
|
|
3520
3601
|
] }),
|
|
3521
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3522
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3602
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.AlertDialogFooter, { children: [
|
|
3603
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.AlertDialogCancel, { disabled: !!archivingProductId, children: "Cancel" }),
|
|
3523
3604
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3524
|
-
|
|
3605
|
+
_chunkRSHCU3TIjs.AlertDialogAction,
|
|
3525
3606
|
{
|
|
3526
3607
|
onClick: handleArchive,
|
|
3527
3608
|
disabled: !!archivingProductId,
|
|
@@ -3531,19 +3612,19 @@ function ProductsList({ products, onProductsChange }) {
|
|
|
3531
3612
|
)
|
|
3532
3613
|
] })
|
|
3533
3614
|
] }) }),
|
|
3534
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3535
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3536
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3537
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3615
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.AlertDialog, { open: !!productToReactivate, onOpenChange: (open) => !open && setProductToReactivate(null), children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.AlertDialogContent, { children: [
|
|
3616
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.AlertDialogHeader, { children: [
|
|
3617
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.AlertDialogTitle, { children: "Reactivate Product" }),
|
|
3618
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.AlertDialogDescription, { children: [
|
|
3538
3619
|
'Are you sure you want to reactivate "',
|
|
3539
|
-
_optionalChain([productToReactivate, 'optionalAccess',
|
|
3620
|
+
_optionalChain([productToReactivate, 'optionalAccess', _152 => _152.name]),
|
|
3540
3621
|
'"? This will make it available for new subscriptions again.'
|
|
3541
3622
|
] })
|
|
3542
3623
|
] }),
|
|
3543
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3544
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3624
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkRSHCU3TIjs.AlertDialogFooter, { children: [
|
|
3625
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.AlertDialogCancel, { disabled: !!reactivatingProductId, children: "Cancel" }),
|
|
3545
3626
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3546
|
-
|
|
3627
|
+
_chunkRSHCU3TIjs.AlertDialogAction,
|
|
3547
3628
|
{
|
|
3548
3629
|
onClick: handleReactivate,
|
|
3549
3630
|
disabled: !!reactivatingProductId,
|
|
@@ -3560,7 +3641,7 @@ _chunk7QVYU63Ejs.__name.call(void 0, ProductsList, "ProductsList");
|
|
|
3560
3641
|
// src/features/billing/stripe-product/components/containers/ProductsAdminContainer.tsx
|
|
3561
3642
|
|
|
3562
3643
|
function ProductsAdminContainer() {
|
|
3563
|
-
const { hasRole } =
|
|
3644
|
+
const { hasRole } = _chunkRSHCU3TIjs.useCurrentUserContext.call(void 0, );
|
|
3564
3645
|
const [products, setProducts] = _react.useState.call(void 0, []);
|
|
3565
3646
|
const [loading, setLoading] = _react.useState.call(void 0, true);
|
|
3566
3647
|
const [showCreateProduct, setShowCreateProduct] = _react.useState.call(void 0, false);
|
|
@@ -3570,7 +3651,7 @@ function ProductsAdminContainer() {
|
|
|
3570
3651
|
const loadProducts = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
3571
3652
|
setLoading(true);
|
|
3572
3653
|
try {
|
|
3573
|
-
const fetchedProducts = await
|
|
3654
|
+
const fetchedProducts = await _chunkTZRAOUARjs.StripeProductService.listProducts();
|
|
3574
3655
|
setProducts(fetchedProducts);
|
|
3575
3656
|
} catch (error) {
|
|
3576
3657
|
console.error("[ProductsAdminContainer] Failed to load products:", error);
|
|
@@ -3590,14 +3671,14 @@ function ProductsAdminContainer() {
|
|
|
3590
3671
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Package, { className: "h-8 w-8" }),
|
|
3591
3672
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h1", { className: "text-3xl font-bold", children: "Product & Price Management" })
|
|
3592
3673
|
] }),
|
|
3593
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3674
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Button, { onClick: () => setShowCreateProduct(true), children: "Create Product" })
|
|
3594
3675
|
] }),
|
|
3595
3676
|
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: [
|
|
3596
3677
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Package, { className: "text-muted-foreground h-16 w-16" }),
|
|
3597
3678
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "text-center", children: [
|
|
3598
3679
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "mb-2 text-xl font-semibold", children: "No products yet" }),
|
|
3599
3680
|
/* @__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." }),
|
|
3600
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3681
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRSHCU3TIjs.Button, { onClick: () => setShowCreateProduct(true), children: "Create Your First Product" })
|
|
3601
3682
|
] })
|
|
3602
3683
|
] }),
|
|
3603
3684
|
products.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ProductsList, { products, onProductsChange: loadProducts }),
|