@carlonicora/nextjs-jsonapi 1.27.0 → 1.28.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-5NYZBYPY.js → BlockNoteEditor-CAUNVZUF.js} +13 -13
- package/dist/{BlockNoteEditor-5NYZBYPY.js.map → BlockNoteEditor-CAUNVZUF.js.map} +1 -1
- package/dist/{BlockNoteEditor-B6K7OEN6.mjs → BlockNoteEditor-EOA4OEVX.mjs} +3 -3
- package/dist/billing/index.d.mts +1 -1
- package/dist/billing/index.d.ts +1 -1
- package/dist/billing/index.js +359 -352
- package/dist/billing/index.js.map +1 -1
- package/dist/billing/index.mjs +12 -5
- package/dist/billing/index.mjs.map +1 -1
- package/dist/{chunk-ZR26XYRO.js → chunk-IXI4GAKB.js} +427 -427
- package/dist/{chunk-ZR26XYRO.js.map → chunk-IXI4GAKB.js.map} +1 -1
- package/dist/{chunk-NAB52T2P.mjs → chunk-ORFXBO7F.mjs} +9 -1
- package/dist/chunk-ORFXBO7F.mjs.map +1 -0
- package/dist/{chunk-RU4GQIB6.mjs → chunk-PYASRX75.mjs} +3 -3
- package/dist/{chunk-2VZZFQP4.js → chunk-TSEU4KZ2.js} +9 -1
- package/dist/chunk-TSEU4KZ2.js.map +1 -0
- package/dist/client/index.js +3 -3
- package/dist/client/index.mjs +2 -2
- package/dist/components/index.js +3 -3
- package/dist/components/index.mjs +2 -2
- package/dist/contexts/index.js +3 -3
- package/dist/contexts/index.mjs +2 -2
- package/dist/core/index.d.mts +4 -2
- package/dist/core/index.d.ts +4 -2
- package/dist/core/index.js +2 -2
- package/dist/core/index.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/dist/server/index.js +3 -3
- package/dist/server/index.mjs +1 -1
- package/dist/{stripe-subscription.interface-CNTsrbAx.d.ts → stripe-subscription.interface-BaZUngWe.d.ts} +2 -0
- package/dist/{stripe-subscription.interface-CFtupgYh.d.mts → stripe-subscription.interface-Cm_It1fz.d.mts} +2 -0
- package/package.json +1 -1
- package/src/features/billing/stripe-price/components/forms/PriceEditor.tsx +11 -1
- package/src/features/billing/stripe-price/data/stripe-price.interface.ts +2 -0
- package/src/features/billing/stripe-price/data/stripe-price.ts +10 -0
- package/dist/chunk-2VZZFQP4.js.map +0 -1
- package/dist/chunk-NAB52T2P.mjs.map +0 -1
- /package/dist/{BlockNoteEditor-B6K7OEN6.mjs.map → BlockNoteEditor-EOA4OEVX.mjs.map} +0 -0
- /package/dist/{chunk-RU4GQIB6.mjs.map → chunk-PYASRX75.mjs.map} +0 -0
package/dist/billing/index.js
CHANGED
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
|
|
51
|
-
var
|
|
51
|
+
var _chunkIXI4GAKBjs = require('../chunk-IXI4GAKB.js');
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
|
|
@@ -61,7 +61,7 @@ var _chunkEW6QPMN3js = require('../chunk-EW6QPMN3.js');
|
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
var
|
|
64
|
+
var _chunkTSEU4KZ2js = require('../chunk-TSEU4KZ2.js');
|
|
65
65
|
require('../chunk-LXKSUWAV.js');
|
|
66
66
|
require('../chunk-IBS6NI7D.js');
|
|
67
67
|
require('../chunk-FM6WRAN5.js');
|
|
@@ -121,41 +121,41 @@ function SubscriptionSummaryCard({
|
|
|
121
121
|
onManageClick
|
|
122
122
|
}) {
|
|
123
123
|
if (loading) {
|
|
124
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
125
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
126
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
124
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Card, { children: [
|
|
125
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
126
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardTitle, { className: "text-sm font-medium", children: "Subscriptions" }),
|
|
127
127
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-4 w-4 text-muted-foreground" })
|
|
128
128
|
] }),
|
|
129
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
130
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
131
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
132
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
129
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.CardContent, { children: [
|
|
130
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Skeleton, { className: "h-6 w-32 mb-2" }),
|
|
131
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Skeleton, { className: "h-4 w-24 mb-1" }),
|
|
132
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Skeleton, { className: "h-4 w-40" })
|
|
133
133
|
] })
|
|
134
134
|
] });
|
|
135
135
|
}
|
|
136
136
|
if (error) {
|
|
137
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
138
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
139
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
137
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Card, { children: [
|
|
138
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
139
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardTitle, { className: "text-sm font-medium", children: "Subscriptions" }),
|
|
140
140
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-4 w-4 text-muted-foreground" })
|
|
141
141
|
] }),
|
|
142
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
142
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-destructive", children: error }) })
|
|
143
143
|
] });
|
|
144
144
|
}
|
|
145
145
|
const activeSubscriptions = subscriptions.filter(
|
|
146
146
|
(sub) => sub.status === "active" /* ACTIVE */ || sub.status === "trialing" /* TRIALING */
|
|
147
147
|
);
|
|
148
148
|
const primarySubscription = activeSubscriptions[0];
|
|
149
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
150
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
151
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
149
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Card, { className: "cursor-pointer hover:bg-accent/50 transition-colors", onClick: onManageClick, children: [
|
|
150
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
151
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardTitle, { className: "text-sm font-medium", children: "Subscriptions" }),
|
|
152
152
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-4 w-4 text-muted-foreground" })
|
|
153
153
|
] }),
|
|
154
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
154
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardContent, { children: subscriptions.length === 0 ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
155
155
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold text-muted-foreground", children: "No active plan" }),
|
|
156
156
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: "Subscribe to get started" }),
|
|
157
157
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
158
|
-
|
|
158
|
+
_chunkIXI4GAKBjs.Button,
|
|
159
159
|
{
|
|
160
160
|
variant: "outline",
|
|
161
161
|
size: "sm",
|
|
@@ -173,7 +173,7 @@ function SubscriptionSummaryCard({
|
|
|
173
173
|
] }) : primarySubscription ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
174
174
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
|
|
175
175
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold", children: formatPlanName(primarySubscription) }),
|
|
176
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
176
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Badge, { variant: primarySubscription.cancelAtPeriodEnd ? "secondary" : getStatusBadgeVariant(primarySubscription.status), children: primarySubscription.cancelAtPeriodEnd ? "Canceling" : primarySubscription.status })
|
|
177
177
|
] }),
|
|
178
178
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-sm text-muted-foreground", children: [
|
|
179
179
|
formatPrice(_optionalChain([primarySubscription, 'access', _10 => _10.price, 'optionalAccess', _11 => _11.unitAmount]), _optionalChain([primarySubscription, 'access', _12 => _12.price, 'optionalAccess', _13 => _13.currency])),
|
|
@@ -217,36 +217,36 @@ function PaymentMethodSummaryCard({
|
|
|
217
217
|
onManageClick
|
|
218
218
|
}) {
|
|
219
219
|
if (loading) {
|
|
220
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
221
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
222
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
220
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Card, { children: [
|
|
221
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
222
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardTitle, { className: "text-sm font-medium", children: "Payment Method" }),
|
|
223
223
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Wallet, { className: "h-4 w-4 text-muted-foreground" })
|
|
224
224
|
] }),
|
|
225
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
226
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
227
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
225
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.CardContent, { children: [
|
|
226
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Skeleton, { className: "h-6 w-32 mb-2" }),
|
|
227
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Skeleton, { className: "h-4 w-24" })
|
|
228
228
|
] })
|
|
229
229
|
] });
|
|
230
230
|
}
|
|
231
231
|
if (error) {
|
|
232
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
233
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
234
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
232
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Card, { children: [
|
|
233
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
234
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardTitle, { className: "text-sm font-medium", children: "Payment Method" }),
|
|
235
235
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Wallet, { className: "h-4 w-4 text-muted-foreground" })
|
|
236
236
|
] }),
|
|
237
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
237
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-destructive", children: error }) })
|
|
238
238
|
] });
|
|
239
239
|
}
|
|
240
240
|
const defaultMethod = paymentMethods.find((pm) => pm.id === defaultPaymentMethodId) || paymentMethods[0];
|
|
241
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
242
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
243
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
241
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Card, { className: "cursor-pointer hover:bg-accent/50 transition-colors", onClick: onManageClick, children: [
|
|
242
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
243
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardTitle, { className: "text-sm font-medium", children: "Payment Method" }),
|
|
244
244
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Wallet, { className: "h-4 w-4 text-muted-foreground" })
|
|
245
245
|
] }),
|
|
246
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
246
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardContent, { children: paymentMethods.length === 0 ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
247
247
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold text-muted-foreground", children: "No payment method" }),
|
|
248
248
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: "Add a card to enable subscriptions" }),
|
|
249
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
249
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Button, { variant: "outline", size: "sm", className: "mt-2", onClick: (e) => {
|
|
250
250
|
e.stopPropagation();
|
|
251
251
|
onManageClick();
|
|
252
252
|
}, children: [
|
|
@@ -302,7 +302,7 @@ function CustomerInfoCard({ customer, loading, error }) {
|
|
|
302
302
|
e.stopPropagation();
|
|
303
303
|
setPortalLoading(true);
|
|
304
304
|
try {
|
|
305
|
-
const { url } = await
|
|
305
|
+
const { url } = await _chunkTSEU4KZ2js.StripeCustomerService.createPortalSession();
|
|
306
306
|
window.open(url, "_blank");
|
|
307
307
|
} catch (err) {
|
|
308
308
|
console.error("[CustomerInfoCard] Failed to create portal session:", err);
|
|
@@ -311,52 +311,52 @@ function CustomerInfoCard({ customer, loading, error }) {
|
|
|
311
311
|
}
|
|
312
312
|
}, "handlePortalClick");
|
|
313
313
|
if (loading) {
|
|
314
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
315
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
316
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
314
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Card, { children: [
|
|
315
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
316
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardTitle, { className: "text-sm font-medium", children: "Billing Account" }),
|
|
317
317
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.User, { className: "h-4 w-4 text-muted-foreground" })
|
|
318
318
|
] }),
|
|
319
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
320
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
321
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
322
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
319
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.CardContent, { children: [
|
|
320
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Skeleton, { className: "h-6 w-32 mb-2" }),
|
|
321
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Skeleton, { className: "h-4 w-48 mb-1" }),
|
|
322
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Skeleton, { className: "h-4 w-24" })
|
|
323
323
|
] })
|
|
324
324
|
] });
|
|
325
325
|
}
|
|
326
326
|
if (error) {
|
|
327
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
328
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
329
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
327
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Card, { children: [
|
|
328
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
329
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardTitle, { className: "text-sm font-medium", children: "Billing Account" }),
|
|
330
330
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.User, { className: "h-4 w-4 text-muted-foreground" })
|
|
331
331
|
] }),
|
|
332
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
332
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-destructive", children: error }) })
|
|
333
333
|
] });
|
|
334
334
|
}
|
|
335
335
|
if (!customer) {
|
|
336
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
337
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
338
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
336
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Card, { children: [
|
|
337
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
338
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardTitle, { className: "text-sm font-medium", children: "Billing Account" }),
|
|
339
339
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.User, { className: "h-4 w-4 text-muted-foreground" })
|
|
340
340
|
] }),
|
|
341
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
341
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.CardContent, { children: [
|
|
342
342
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold text-muted-foreground", children: "Not set up" }),
|
|
343
343
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: "Billing account will be created when you subscribe" })
|
|
344
344
|
] })
|
|
345
345
|
] });
|
|
346
346
|
}
|
|
347
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
348
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
349
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
347
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Card, { children: [
|
|
348
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
349
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardTitle, { className: "text-sm font-medium", children: "Billing Account" }),
|
|
350
350
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.User, { className: "h-4 w-4 text-muted-foreground" })
|
|
351
351
|
] }),
|
|
352
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
352
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
353
353
|
customer.name && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold", children: customer.name }),
|
|
354
354
|
customer.email && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: customer.email }),
|
|
355
355
|
customer.balance !== void 0 && customer.balance !== 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-sm", children: [
|
|
356
356
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground", children: "Credit Balance: " }),
|
|
357
357
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: customer.balance < 0 ? "text-green-600" : "text-destructive", children: formatBalance(customer.balance, customer.currency) })
|
|
358
358
|
] }),
|
|
359
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
359
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Button, { variant: "outline", size: "sm", className: "mt-2", onClick: handlePortalClick, disabled: portalLoading, children: [
|
|
360
360
|
portalLoading ? "Loading..." : "Manage in Stripe Portal",
|
|
361
361
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ExternalLink, { className: "h-4 w-4 ml-1" })
|
|
362
362
|
] })
|
|
@@ -400,42 +400,42 @@ function formatAmount(amount, currency) {
|
|
|
400
400
|
_chunk7QVYU63Ejs.__name.call(void 0, formatAmount, "formatAmount");
|
|
401
401
|
function InvoicesSummaryCard({ invoices, loading, error, onViewAllClick }) {
|
|
402
402
|
if (loading) {
|
|
403
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
404
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
405
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
403
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Card, { children: [
|
|
404
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
405
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardTitle, { className: "text-sm font-medium", children: "Recent Invoices" }),
|
|
406
406
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ReceiptIcon, { className: "h-4 w-4 text-muted-foreground" })
|
|
407
407
|
] }),
|
|
408
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
409
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
410
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
411
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
408
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.CardContent, { children: [
|
|
409
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Skeleton, { className: "h-6 w-24 mb-2" }),
|
|
410
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Skeleton, { className: "h-4 w-32 mb-1" }),
|
|
411
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Skeleton, { className: "h-4 w-20" })
|
|
412
412
|
] })
|
|
413
413
|
] });
|
|
414
414
|
}
|
|
415
415
|
if (error) {
|
|
416
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
417
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
418
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
416
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Card, { children: [
|
|
417
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
418
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardTitle, { className: "text-sm font-medium", children: "Recent Invoices" }),
|
|
419
419
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ReceiptIcon, { className: "h-4 w-4 text-muted-foreground" })
|
|
420
420
|
] }),
|
|
421
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
421
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-destructive", children: error }) })
|
|
422
422
|
] });
|
|
423
423
|
}
|
|
424
424
|
const latestInvoice = invoices[0];
|
|
425
425
|
const paidInvoices = invoices.filter((inv) => inv.status === "paid" /* PAID */);
|
|
426
426
|
const openInvoices = invoices.filter((inv) => inv.status === "open" /* OPEN */);
|
|
427
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
428
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
429
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
427
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Card, { className: "cursor-pointer hover:bg-accent/50 transition-colors", onClick: onViewAllClick, children: [
|
|
428
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
429
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardTitle, { className: "text-sm font-medium", children: "Recent Invoices" }),
|
|
430
430
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ReceiptIcon, { className: "h-4 w-4 text-muted-foreground" })
|
|
431
431
|
] }),
|
|
432
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
432
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardContent, { children: invoices.length === 0 ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
433
433
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold text-muted-foreground", children: "No invoices yet" }),
|
|
434
434
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: "Invoices will appear after your first billing cycle" })
|
|
435
435
|
] }) : latestInvoice ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
436
436
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
|
|
437
437
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold", children: formatAmount(latestInvoice.total, latestInvoice.currency) }),
|
|
438
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
438
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Badge, { variant: getStatusBadgeVariant2(latestInvoice.status), children: latestInvoice.status })
|
|
439
439
|
] }),
|
|
440
440
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: latestInvoice.stripeInvoiceNumber || `Invoice from ${formatDate2(latestInvoice.periodStart)}` }),
|
|
441
441
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-4 text-xs text-muted-foreground", children: [
|
|
@@ -475,24 +475,24 @@ function BillingUsageSummaryCard({
|
|
|
475
475
|
onViewDetailsClick
|
|
476
476
|
}) {
|
|
477
477
|
if (loading) {
|
|
478
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
479
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
480
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
478
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Card, { children: [
|
|
479
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
480
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardTitle, { className: "text-sm font-medium", children: "Usage This Month" }),
|
|
481
481
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Activity, { className: "h-4 w-4 text-muted-foreground" })
|
|
482
482
|
] }),
|
|
483
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
484
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
485
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
483
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.CardContent, { children: [
|
|
484
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Skeleton, { className: "h-6 w-24 mb-2" }),
|
|
485
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Skeleton, { className: "h-4 w-32" })
|
|
486
486
|
] })
|
|
487
487
|
] });
|
|
488
488
|
}
|
|
489
489
|
if (error) {
|
|
490
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
491
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
492
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
490
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Card, { children: [
|
|
491
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
492
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardTitle, { className: "text-sm font-medium", children: "Usage This Month" }),
|
|
493
493
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Activity, { className: "h-4 w-4 text-muted-foreground" })
|
|
494
494
|
] }),
|
|
495
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
495
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-destructive", children: error }) })
|
|
496
496
|
] });
|
|
497
497
|
}
|
|
498
498
|
const totalUsage = Object.values(summaries).reduce((acc, summary) => {
|
|
@@ -500,12 +500,12 @@ function BillingUsageSummaryCard({
|
|
|
500
500
|
}, 0);
|
|
501
501
|
const primaryMeter = meters.find((m) => _optionalChain([summaries, 'access', _23 => _23[m.id], 'optionalAccess', _24 => _24.aggregatedValue]));
|
|
502
502
|
const primarySummary = primaryMeter ? summaries[primaryMeter.id] : null;
|
|
503
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
504
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
505
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
503
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Card, { className: "cursor-pointer hover:bg-accent/50 transition-colors", onClick: onViewDetailsClick, children: [
|
|
504
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
505
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardTitle, { className: "text-sm font-medium", children: "Usage This Month" }),
|
|
506
506
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Activity, { className: "h-4 w-4 text-muted-foreground" })
|
|
507
507
|
] }),
|
|
508
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
508
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardContent, { children: meters.length === 0 ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
509
509
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold text-muted-foreground", children: "No meters" }),
|
|
510
510
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: "No usage meters are configured" })
|
|
511
511
|
] }) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
@@ -556,7 +556,7 @@ function PaymentMethodEditor({ open, onOpenChange, onSuccess }) {
|
|
|
556
556
|
const fetchSetupIntent = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
557
557
|
setLoading(true);
|
|
558
558
|
try {
|
|
559
|
-
const intent = await
|
|
559
|
+
const intent = await _chunkTSEU4KZ2js.StripeCustomerService.createSetupIntent();
|
|
560
560
|
setSetupIntent(intent);
|
|
561
561
|
} catch (err) {
|
|
562
562
|
console.error("[PaymentMethodEditor] Failed to create setup intent:", err);
|
|
@@ -596,7 +596,7 @@ function PaymentMethodEditor({ open, onOpenChange, onSuccess }) {
|
|
|
596
596
|
return;
|
|
597
597
|
}
|
|
598
598
|
if (setAsDefault && _optionalChain([confirmedSetupIntent, 'optionalAccess', _25 => _25.payment_method])) {
|
|
599
|
-
await
|
|
599
|
+
await _chunkTSEU4KZ2js.StripeCustomerService.setDefaultPaymentMethod({
|
|
600
600
|
paymentMethodId: typeof confirmedSetupIntent.payment_method === "string" ? confirmedSetupIntent.payment_method : confirmedSetupIntent.payment_method.id
|
|
601
601
|
});
|
|
602
602
|
}
|
|
@@ -609,10 +609,10 @@ function PaymentMethodEditor({ open, onOpenChange, onSuccess }) {
|
|
|
609
609
|
setIsSubmitting(false);
|
|
610
610
|
}
|
|
611
611
|
}, "handleSubmit");
|
|
612
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
613
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
614
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
615
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
612
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.DialogContent, { className: "max-w-md", children: [
|
|
613
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.DialogHeader, { children: [
|
|
614
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.DialogTitle, { children: "Add Payment Method" }),
|
|
615
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.DialogDescription, { children: "Add a new payment method to your account. Your card information is securely processed by Stripe." })
|
|
616
616
|
] }),
|
|
617
617
|
loading && /* @__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..." }) }),
|
|
618
618
|
!loading && setupIntent && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { onSubmit: handleSubmit, className: "flex flex-col gap-y-4", children: [
|
|
@@ -637,22 +637,22 @@ function PaymentMethodEditor({ open, onOpenChange, onSuccess }) {
|
|
|
637
637
|
) }),
|
|
638
638
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-2", children: [
|
|
639
639
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
640
|
-
|
|
640
|
+
_chunkIXI4GAKBjs.Checkbox,
|
|
641
641
|
{
|
|
642
642
|
id: "setAsDefault",
|
|
643
643
|
checked: setAsDefault,
|
|
644
644
|
onCheckedChange: (checked) => setSetAsDefault(!!checked)
|
|
645
645
|
}
|
|
646
646
|
),
|
|
647
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
647
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Label, { htmlFor: "setAsDefault", className: "text-sm font-normal", children: "Set as default payment method" })
|
|
648
648
|
] }),
|
|
649
|
-
error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
649
|
+
error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Alert, { variant: "destructive", className: "bg-red-50 border-red-200", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.AlertDescription, { children: error }) }),
|
|
650
650
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-end gap-x-2", children: [
|
|
651
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
652
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
651
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Button, { type: "button", variant: "outline", onClick: () => onOpenChange(false), disabled: isSubmitting, children: "Cancel" }),
|
|
652
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Button, { type: "submit", disabled: !stripe || isSubmitting, children: isSubmitting ? "Processing..." : "Add Card" })
|
|
653
653
|
] })
|
|
654
654
|
] }),
|
|
655
|
-
!loading && !setupIntent && error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
655
|
+
!loading && !setupIntent && error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Alert, { variant: "destructive", className: "bg-red-50 border-red-200", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.AlertDescription, { children: error }) })
|
|
656
656
|
] }) });
|
|
657
657
|
}
|
|
658
658
|
_chunk7QVYU63Ejs.__name.call(void 0, PaymentMethodEditor, "PaymentMethodEditor");
|
|
@@ -674,7 +674,7 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
674
674
|
_react.useEffect.call(void 0, () => {
|
|
675
675
|
const loadCustomer = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
676
676
|
try {
|
|
677
|
-
const fetchedCustomer = await
|
|
677
|
+
const fetchedCustomer = await _chunkTSEU4KZ2js.StripeCustomerService.getCustomer();
|
|
678
678
|
setCustomer(fetchedCustomer);
|
|
679
679
|
} catch (error) {
|
|
680
680
|
console.error("[PaymentMethodCard] Failed to load customer:", error);
|
|
@@ -691,7 +691,7 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
691
691
|
const handleSetDefault = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
692
692
|
setLoading(true);
|
|
693
693
|
try {
|
|
694
|
-
await
|
|
694
|
+
await _chunkTSEU4KZ2js.StripeCustomerService.setDefaultPaymentMethod({ paymentMethodId: paymentMethod.id });
|
|
695
695
|
onUpdate();
|
|
696
696
|
} catch (error) {
|
|
697
697
|
console.error("[PaymentMethodCard] Failed to set as default:", error);
|
|
@@ -702,7 +702,7 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
702
702
|
const handleRemove = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
703
703
|
setLoading(true);
|
|
704
704
|
try {
|
|
705
|
-
await
|
|
705
|
+
await _chunkTSEU4KZ2js.StripeCustomerService.removePaymentMethod({ paymentMethodId: paymentMethod.id });
|
|
706
706
|
setShowRemoveDialog(false);
|
|
707
707
|
onUpdate();
|
|
708
708
|
} catch (error) {
|
|
@@ -711,22 +711,22 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
711
711
|
}
|
|
712
712
|
}, "handleRemove");
|
|
713
713
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
714
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
715
|
-
isDefault && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
716
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
714
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Card, { className: "relative", children: [
|
|
715
|
+
isDefault && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Badge, { className: "absolute right-2 top-2 bg-green-100 text-green-800 hover:bg-green-100", children: "Default" }),
|
|
716
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.CardHeader, { className: "flex flex-row items-center justify-between pb-2", children: [
|
|
717
717
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-2", children: [
|
|
718
718
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-2xl", children: brandIcon }),
|
|
719
719
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-medium capitalize", children: brand })
|
|
720
720
|
] }),
|
|
721
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
722
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
723
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
724
|
-
!isDefault && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
725
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
721
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.DropdownMenu, { children: [
|
|
722
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.DropdownMenuTrigger, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.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" }) }) }),
|
|
723
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.DropdownMenuContent, { align: "end", children: [
|
|
724
|
+
!isDefault && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.DropdownMenuItem, { onClick: handleSetDefault, disabled: loading, children: "Set as Default" }),
|
|
725
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.DropdownMenuItem, { onClick: () => setShowRemoveDialog(true), disabled: loading, className: "text-red-600", children: "Remove" })
|
|
726
726
|
] })
|
|
727
727
|
] })
|
|
728
728
|
] }),
|
|
729
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
729
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-y-1", children: [
|
|
730
730
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-lg font-semibold", children: [
|
|
731
731
|
"\u2022\u2022\u2022\u2022 ",
|
|
732
732
|
last4
|
|
@@ -739,17 +739,17 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
739
739
|
] })
|
|
740
740
|
] }) })
|
|
741
741
|
] }),
|
|
742
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
743
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
744
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
745
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
742
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.AlertDialog, { open: showRemoveDialog, onOpenChange: setShowRemoveDialog, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.AlertDialogContent, { children: [
|
|
743
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.AlertDialogHeader, { children: [
|
|
744
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.AlertDialogTitle, { children: "Remove Payment Method" }),
|
|
745
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.AlertDialogDescription, { children: [
|
|
746
746
|
"Are you sure you want to remove this payment method? This action cannot be undone.",
|
|
747
747
|
isDefault && " This is your default payment method."
|
|
748
748
|
] })
|
|
749
749
|
] }),
|
|
750
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
751
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
752
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
750
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.AlertDialogFooter, { children: [
|
|
751
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.AlertDialogCancel, { disabled: loading, children: "Cancel" }),
|
|
752
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.AlertDialogAction, { onClick: handleRemove, disabled: loading, className: "bg-red-600 hover:bg-red-700", children: loading ? "Removing..." : "Remove" })
|
|
753
753
|
] })
|
|
754
754
|
] }) })
|
|
755
755
|
] });
|
|
@@ -772,7 +772,7 @@ function PaymentMethodsContainer() {
|
|
|
772
772
|
const loadPaymentMethods = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
773
773
|
setLoading(true);
|
|
774
774
|
try {
|
|
775
|
-
const fetchedPaymentMethods = await
|
|
775
|
+
const fetchedPaymentMethods = await _chunkTSEU4KZ2js.StripeCustomerService.listPaymentMethods();
|
|
776
776
|
setPaymentMethods(fetchedPaymentMethods);
|
|
777
777
|
} catch (error) {
|
|
778
778
|
console.error("[PaymentMethodsContainer] Failed to load payment methods:", error);
|
|
@@ -792,14 +792,14 @@ function PaymentMethodsContainer() {
|
|
|
792
792
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-8 w-8" }),
|
|
793
793
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h1", { className: "text-3xl font-bold", children: "Payment Methods" })
|
|
794
794
|
] }),
|
|
795
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
795
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Button, { onClick: () => setShowAddPaymentMethod(true), children: "Add Payment Method" })
|
|
796
796
|
] }),
|
|
797
797
|
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: [
|
|
798
798
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-16 w-16 text-muted-foreground" }),
|
|
799
799
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "text-center", children: [
|
|
800
800
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "mb-2 text-xl font-semibold", children: "No payment methods" }),
|
|
801
801
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "mb-4 text-muted-foreground", children: "Add a payment method to enable subscriptions and secure checkout." }),
|
|
802
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
802
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Button, { onClick: () => setShowAddPaymentMethod(true), children: "Add Your First Card" })
|
|
803
803
|
] })
|
|
804
804
|
] }),
|
|
805
805
|
paymentMethods.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PaymentMethodsList, { paymentMethods, onUpdate: loadPaymentMethods }),
|
|
@@ -923,13 +923,13 @@ function InvoiceDetails({ invoice, open, onOpenChange, onInvoiceChange }) {
|
|
|
923
923
|
return invoice.stripeInvoiceId.slice(-8);
|
|
924
924
|
}, "getInvoiceNumber");
|
|
925
925
|
const productName = _optionalChain([invoice, 'access', _35 => _35.subscription, 'optionalAccess', _36 => _36.price, 'optionalAccess', _37 => _37.product, 'optionalAccess', _38 => _38.name]) || "Subscription";
|
|
926
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
927
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
928
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
926
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.DialogContent, { className: "max-w-2xl", children: [
|
|
927
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.DialogHeader, { children: [
|
|
928
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.DialogTitle, { children: [
|
|
929
929
|
"Invoice ",
|
|
930
930
|
getInvoiceNumber()
|
|
931
931
|
] }),
|
|
932
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
932
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.DialogDescription, { children: formatDate3(invoice.periodStart) })
|
|
933
933
|
] }),
|
|
934
934
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-6", children: [
|
|
935
935
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-3", children: [
|
|
@@ -994,15 +994,15 @@ function InvoiceDetails({ invoice, open, onOpenChange, onInvoiceChange }) {
|
|
|
994
994
|
] })
|
|
995
995
|
] }),
|
|
996
996
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-wrap gap-2 pt-4 border-t", children: [
|
|
997
|
-
invoice.stripePdfUrl && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
997
|
+
invoice.stripePdfUrl && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Button, { variant: "outline", onClick: handleDownloadPDF, children: [
|
|
998
998
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Download, { className: "mr-2 h-4 w-4" }),
|
|
999
999
|
"Download PDF"
|
|
1000
1000
|
] }),
|
|
1001
|
-
invoice.status === "open" /* OPEN */ && invoice.attempted && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1001
|
+
invoice.status === "open" /* OPEN */ && invoice.attempted && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Button, { variant: "default", onClick: handleRetryPayment, children: [
|
|
1002
1002
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.RefreshCw, { className: "mr-2 h-4 w-4" }),
|
|
1003
1003
|
"Retry Payment"
|
|
1004
1004
|
] }),
|
|
1005
|
-
invoice.stripeHostedInvoiceUrl && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1005
|
+
invoice.stripeHostedInvoiceUrl && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Button, { variant: "outline", onClick: handleViewInStripe, children: [
|
|
1006
1006
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ExternalLink, { className: "mr-2 h-4 w-4" }),
|
|
1007
1007
|
"View in Stripe"
|
|
1008
1008
|
] })
|
|
@@ -1026,30 +1026,30 @@ function InvoicesList({ invoices, onInvoicesChange }) {
|
|
|
1026
1026
|
return invoice.stripeInvoiceId.slice(-8);
|
|
1027
1027
|
}, "getInvoiceNumber");
|
|
1028
1028
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1029
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border rounded-lg overflow-hidden", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1030
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1031
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1032
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1033
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1034
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1035
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1029
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border rounded-lg overflow-hidden", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Table, { children: [
|
|
1030
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableHeader, { className: "bg-muted", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.TableRow, { children: [
|
|
1031
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableHead, { children: "Invoice #" }),
|
|
1032
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableHead, { children: "Date" }),
|
|
1033
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableHead, { children: "Status" }),
|
|
1034
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableHead, { className: "text-right", children: "Amount" }),
|
|
1035
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableHead, { children: "Period" })
|
|
1036
1036
|
] }) }),
|
|
1037
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1037
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableBody, { children: invoices.map((invoice) => {
|
|
1038
1038
|
const invoiceNumber = getInvoiceNumber(invoice);
|
|
1039
1039
|
const date = formatDate3(invoice.periodStart);
|
|
1040
1040
|
const amount = formatCurrency(invoice.total, invoice.currency);
|
|
1041
1041
|
const period = `${formatDate3(invoice.periodStart)} - ${formatDate3(invoice.periodEnd)}`;
|
|
1042
1042
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1043
|
-
|
|
1043
|
+
_chunkIXI4GAKBjs.TableRow,
|
|
1044
1044
|
{
|
|
1045
1045
|
onClick: () => handleRowClick(invoice),
|
|
1046
1046
|
className: "cursor-pointer hover:bg-muted/50",
|
|
1047
1047
|
children: [
|
|
1048
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1049
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1050
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1051
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1052
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1048
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableCell, { className: "font-medium", children: invoiceNumber }),
|
|
1049
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableCell, { className: "text-muted-foreground text-sm", children: date }),
|
|
1050
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableCell, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, InvoiceStatusBadge, { status: invoice.status }) }),
|
|
1051
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableCell, { className: "text-right font-medium", children: amount }),
|
|
1052
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableCell, { className: "text-muted-foreground text-sm", children: period })
|
|
1053
1053
|
]
|
|
1054
1054
|
},
|
|
1055
1055
|
invoice.id
|
|
@@ -1082,7 +1082,7 @@ function InvoicesContainer() {
|
|
|
1082
1082
|
setLoading(true);
|
|
1083
1083
|
try {
|
|
1084
1084
|
const params = statusFilter !== "all" ? { status: statusFilter } : void 0;
|
|
1085
|
-
const data = await
|
|
1085
|
+
const data = await _chunkTSEU4KZ2js.StripeInvoiceService.listInvoices(params);
|
|
1086
1086
|
setInvoices(data);
|
|
1087
1087
|
} catch (error) {
|
|
1088
1088
|
console.error("[InvoicesContainer] Failed to load invoices:", error);
|
|
@@ -1098,12 +1098,12 @@ function InvoicesContainer() {
|
|
|
1098
1098
|
setStatusFilter(value);
|
|
1099
1099
|
}, "handleFilterChange");
|
|
1100
1100
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-4", children: [
|
|
1101
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1102
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1103
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1104
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1105
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1106
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1101
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Tabs, { value: statusFilter, onValueChange: handleFilterChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.TabsList, { children: [
|
|
1102
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TabsTrigger, { value: "all", children: "All" }),
|
|
1103
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TabsTrigger, { value: "paid" /* PAID */, children: "Paid" }),
|
|
1104
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TabsTrigger, { value: "open" /* OPEN */, children: "Open" }),
|
|
1105
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TabsTrigger, { value: "void" /* VOID */, children: "Void" }),
|
|
1106
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TabsTrigger, { value: "uncollectible" /* UNCOLLECTIBLE */, children: "Uncollectible" })
|
|
1107
1107
|
] }) }),
|
|
1108
1108
|
loading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-center py-8 text-muted-foreground", children: "Loading invoices..." }),
|
|
1109
1109
|
!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: [
|
|
@@ -1212,7 +1212,7 @@ function CancelSubscriptionDialog({
|
|
|
1212
1212
|
const onSubmit = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async (values) => {
|
|
1213
1213
|
setIsSubmitting(true);
|
|
1214
1214
|
try {
|
|
1215
|
-
await
|
|
1215
|
+
await _chunkTSEU4KZ2js.StripeSubscriptionService.cancelSubscription({
|
|
1216
1216
|
id: subscription.id,
|
|
1217
1217
|
cancelImmediately: values.cancelImmediately
|
|
1218
1218
|
});
|
|
@@ -1225,20 +1225,20 @@ function CancelSubscriptionDialog({
|
|
|
1225
1225
|
}
|
|
1226
1226
|
}, "onSubmit");
|
|
1227
1227
|
const periodEndDate = formatDate3(subscription.currentPeriodEnd);
|
|
1228
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1229
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1230
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1231
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1228
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.DialogContent, { className: "max-w-md", children: [
|
|
1229
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.DialogHeader, { children: [
|
|
1230
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.DialogTitle, { children: "Cancel Subscription" }),
|
|
1231
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.DialogDescription, { children: "Are you sure you want to cancel this subscription? This action cannot be undone." })
|
|
1232
1232
|
] }),
|
|
1233
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1234
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1233
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Form, { ...form, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { onSubmit: form.handleSubmit(onSubmit), className: "flex flex-col gap-y-4", children: [
|
|
1234
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.FormCheckbox, { form, id: "cancelImmediately", name: "Cancel Immediately" }),
|
|
1235
1235
|
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: [
|
|
1236
1236
|
"Your subscription will remain active until ",
|
|
1237
1237
|
periodEndDate,
|
|
1238
1238
|
". You can continue using the service until then."
|
|
1239
1239
|
] }),
|
|
1240
1240
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1241
|
-
|
|
1241
|
+
_chunkIXI4GAKBjs.FormTextarea,
|
|
1242
1242
|
{
|
|
1243
1243
|
form,
|
|
1244
1244
|
id: "reason",
|
|
@@ -1248,8 +1248,8 @@ function CancelSubscriptionDialog({
|
|
|
1248
1248
|
}
|
|
1249
1249
|
),
|
|
1250
1250
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex gap-x-2 justify-end pt-2", children: [
|
|
1251
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1252
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1251
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Button, { type: "button", variant: "outline", onClick: () => onOpenChange(false), disabled: isSubmitting, children: "Keep Subscription" }),
|
|
1252
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Button, { type: "submit", variant: "destructive", disabled: isSubmitting, children: isSubmitting ? "Canceling..." : "Confirm Cancellation" })
|
|
1253
1253
|
] })
|
|
1254
1254
|
] }) })
|
|
1255
1255
|
] }) });
|
|
@@ -1281,7 +1281,7 @@ function PricingCard({ price, isCurrentPlan = false, isSelected = false, isDisab
|
|
|
1281
1281
|
}
|
|
1282
1282
|
}, "handleClick");
|
|
1283
1283
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1284
|
-
|
|
1284
|
+
_chunkIXI4GAKBjs.Card,
|
|
1285
1285
|
{
|
|
1286
1286
|
role: "radio",
|
|
1287
1287
|
"aria-checked": isSelected,
|
|
@@ -1289,7 +1289,7 @@ function PricingCard({ price, isCurrentPlan = false, isSelected = false, isDisab
|
|
|
1289
1289
|
tabIndex: isDisabled ? -1 : 0,
|
|
1290
1290
|
onKeyDown: handleKeyDown,
|
|
1291
1291
|
onClick: handleClick,
|
|
1292
|
-
className:
|
|
1292
|
+
className: _chunkTSEU4KZ2js.cn.call(void 0,
|
|
1293
1293
|
"relative cursor-pointer transition-all duration-200 flex flex-col h-full",
|
|
1294
1294
|
"focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
1295
1295
|
isCurrentPlan && "bg-muted/30",
|
|
@@ -1299,9 +1299,9 @@ function PricingCard({ price, isCurrentPlan = false, isSelected = false, isDisab
|
|
|
1299
1299
|
isLoading && "pointer-events-none"
|
|
1300
1300
|
),
|
|
1301
1301
|
children: [
|
|
1302
|
-
isCurrentPlan && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1303
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1304
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1302
|
+
isCurrentPlan && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Badge, { variant: "secondary", className: "absolute top-2 right-2", children: "Current" }),
|
|
1303
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardHeader, { className: "pb-2", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "font-semibold text-lg", children: description }) }),
|
|
1304
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.CardContent, { className: "pb-4 grow", children: [
|
|
1305
1305
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mb-4", children: [
|
|
1306
1306
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-3xl font-bold", children: formattedPrice }),
|
|
1307
1307
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground ml-1", children: interval })
|
|
@@ -1311,8 +1311,8 @@ function PricingCard({ price, isCurrentPlan = false, isSelected = false, isDisab
|
|
|
1311
1311
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm text-muted-foreground", children: feature })
|
|
1312
1312
|
] }, index)) })
|
|
1313
1313
|
] }),
|
|
1314
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1315
|
-
|
|
1314
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardFooter, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1315
|
+
_chunkIXI4GAKBjs.Button,
|
|
1316
1316
|
{
|
|
1317
1317
|
variant: isCurrentPlan ? "secondary" : isSelected ? "default" : "outline",
|
|
1318
1318
|
className: "w-full",
|
|
@@ -1366,26 +1366,26 @@ function PricingCardsGrid({
|
|
|
1366
1366
|
_chunk7QVYU63Ejs.__name.call(void 0, PricingCardsGrid, "PricingCardsGrid");
|
|
1367
1367
|
function PricingCardsGridSkeleton() {
|
|
1368
1368
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "space-y-8", children: [1, 2].map((productIndex) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-4", children: [
|
|
1369
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1370
|
-
/* @__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,
|
|
1371
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1372
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1369
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Skeleton, { className: "h-6 w-32" }),
|
|
1370
|
+
/* @__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, _chunkIXI4GAKBjs.Card, { className: "animate-pulse", children: [
|
|
1371
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardHeader, { className: "pb-2", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Skeleton, { className: "h-5 w-24" }) }),
|
|
1372
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.CardContent, { className: "pb-4", children: [
|
|
1373
1373
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mb-4", children: [
|
|
1374
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1375
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1374
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Skeleton, { className: "h-9 w-20 inline-block" }),
|
|
1375
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Skeleton, { className: "h-4 w-12 inline-block ml-2" })
|
|
1376
1376
|
] }),
|
|
1377
1377
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
1378
1378
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
|
|
1379
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1380
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1379
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Skeleton, { className: "h-4 w-4 rounded-full" }),
|
|
1380
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Skeleton, { className: "h-4 w-32" })
|
|
1381
1381
|
] }),
|
|
1382
1382
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
|
|
1383
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1384
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1383
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Skeleton, { className: "h-4 w-4 rounded-full" }),
|
|
1384
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Skeleton, { className: "h-4 w-28" })
|
|
1385
1385
|
] })
|
|
1386
1386
|
] })
|
|
1387
1387
|
] }),
|
|
1388
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1388
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardFooter, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Skeleton, { className: "h-9 w-full" }) })
|
|
1389
1389
|
] }, cardIndex)) })
|
|
1390
1390
|
] }, productIndex)) });
|
|
1391
1391
|
}
|
|
@@ -1449,7 +1449,7 @@ function SubscriptionEditor({
|
|
|
1449
1449
|
}
|
|
1450
1450
|
setLoadingPaymentMethods(true);
|
|
1451
1451
|
try {
|
|
1452
|
-
const paymentMethods = await
|
|
1452
|
+
const paymentMethods = await _chunkTSEU4KZ2js.StripeCustomerService.listPaymentMethods();
|
|
1453
1453
|
const hasMethod = paymentMethods.length > 0;
|
|
1454
1454
|
setHasPaymentMethod(hasMethod);
|
|
1455
1455
|
} catch (error) {
|
|
@@ -1467,7 +1467,7 @@ function SubscriptionEditor({
|
|
|
1467
1467
|
const loadData = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
1468
1468
|
setLoading(true);
|
|
1469
1469
|
try {
|
|
1470
|
-
const fetchedProducts = await
|
|
1470
|
+
const fetchedProducts = await _chunkTSEU4KZ2js.StripeProductService.listProducts({ active: true });
|
|
1471
1471
|
const grouped = /* @__PURE__ */ new Map();
|
|
1472
1472
|
for (const product of fetchedProducts) {
|
|
1473
1473
|
if (product.stripePrices && product.stripePrices.length > 0) {
|
|
@@ -1494,7 +1494,7 @@ function SubscriptionEditor({
|
|
|
1494
1494
|
}
|
|
1495
1495
|
setLoadingProration(true);
|
|
1496
1496
|
try {
|
|
1497
|
-
const preview = await
|
|
1497
|
+
const preview = await _chunkTSEU4KZ2js.StripeSubscriptionService.getProrationPreview({
|
|
1498
1498
|
subscriptionId: subscription.id,
|
|
1499
1499
|
newPriceId: selectedPriceId
|
|
1500
1500
|
});
|
|
@@ -1518,7 +1518,7 @@ function SubscriptionEditor({
|
|
|
1518
1518
|
setPaymentError(null);
|
|
1519
1519
|
setPaymentConfirmationState("idle");
|
|
1520
1520
|
try {
|
|
1521
|
-
const result = await
|
|
1521
|
+
const result = await _chunkTSEU4KZ2js.StripeSubscriptionService.createSubscription({
|
|
1522
1522
|
id: _uuid.v4.call(void 0, ),
|
|
1523
1523
|
priceId
|
|
1524
1524
|
});
|
|
@@ -1532,7 +1532,7 @@ function SubscriptionEditor({
|
|
|
1532
1532
|
setLoadingPriceId(null);
|
|
1533
1533
|
return;
|
|
1534
1534
|
}
|
|
1535
|
-
await
|
|
1535
|
+
await _chunkTSEU4KZ2js.StripeSubscriptionService.syncSubscription({
|
|
1536
1536
|
subscriptionId: result.subscription.id
|
|
1537
1537
|
});
|
|
1538
1538
|
}
|
|
@@ -1558,7 +1558,7 @@ function SubscriptionEditor({
|
|
|
1558
1558
|
if (!subscription || !selectedPriceId) return;
|
|
1559
1559
|
setLoadingPriceId(selectedPriceId);
|
|
1560
1560
|
try {
|
|
1561
|
-
await
|
|
1561
|
+
await _chunkTSEU4KZ2js.StripeSubscriptionService.changePlan({
|
|
1562
1562
|
id: subscription.id,
|
|
1563
1563
|
newPriceId: selectedPriceId
|
|
1564
1564
|
});
|
|
@@ -1574,16 +1574,16 @@ function SubscriptionEditor({
|
|
|
1574
1574
|
setSelectedPriceId(null);
|
|
1575
1575
|
setProrationPreview(null);
|
|
1576
1576
|
}, "handleCancel");
|
|
1577
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1578
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1579
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1580
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1577
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.DialogContent, { className: "max-w-4xl max-h-[90vh] overflow-y-auto", children: [
|
|
1578
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.DialogHeader, { children: [
|
|
1579
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.DialogTitle, { children: subscription ? "Change Plan" : "Subscribe to a Plan" }),
|
|
1580
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.DialogDescription, { children: subscription ? "Select a new plan to switch to. You'll see a proration preview before confirming." : "Choose a plan to start your subscription." })
|
|
1581
1581
|
] }),
|
|
1582
|
-
loadingPaymentMethods && !subscription ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex items-center justify-center py-8", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-muted-foreground", children: "Checking payment methods..." }) }) : !hasPaymentMethod && !subscription ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1583
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1584
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1582
|
+
loadingPaymentMethods && !subscription ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex items-center justify-center py-8", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-muted-foreground", children: "Checking payment methods..." }) }) : !hasPaymentMethod && !subscription ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Alert, { variant: "destructive", children: [
|
|
1583
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.AlertTitle, { children: "Payment Method Required" }),
|
|
1584
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.AlertDescription, { className: "mt-2", children: [
|
|
1585
1585
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "mb-4", children: paymentRequiredError ? "Your subscription could not be created because no payment method is on file." : "You need to add a payment method before you can subscribe to a plan." }),
|
|
1586
|
-
onAddPaymentMethod && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1586
|
+
onAddPaymentMethod && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Button, { onClick: onAddPaymentMethod, variant: "outline", children: "Add Payment Method" })
|
|
1587
1587
|
] })
|
|
1588
1588
|
] }) : paymentConfirmationState === "confirming" || isConfirming ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col items-center justify-center py-12 space-y-4", children: [
|
|
1589
1589
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Loader2, { className: "h-8 w-8 animate-spin text-primary" }),
|
|
@@ -1597,12 +1597,12 @@ function SubscriptionEditor({
|
|
|
1597
1597
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "font-medium text-green-600", children: "Payment successful!" }),
|
|
1598
1598
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: "Your subscription is now active." })
|
|
1599
1599
|
] })
|
|
1600
|
-
] }) : paymentConfirmationState === "error" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "space-y-4", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1601
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1602
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1600
|
+
] }) : paymentConfirmationState === "error" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "space-y-4", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Alert, { variant: "destructive", children: [
|
|
1601
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.AlertTitle, { children: "Payment Failed" }),
|
|
1602
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.AlertDescription, { className: "mt-2", children: [
|
|
1603
1603
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "mb-4", children: paymentError || "We couldn't process your payment. Please try again." }),
|
|
1604
1604
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1605
|
-
|
|
1605
|
+
_chunkIXI4GAKBjs.Button,
|
|
1606
1606
|
{
|
|
1607
1607
|
onClick: () => {
|
|
1608
1608
|
setPaymentConfirmationState("idle");
|
|
@@ -1631,8 +1631,8 @@ function SubscriptionEditor({
|
|
|
1631
1631
|
isEditMode && prorationPreview && !loadingProration && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-4", children: [
|
|
1632
1632
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ProrationPreview, { preview: prorationPreview }),
|
|
1633
1633
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-end gap-3", children: [
|
|
1634
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1635
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1634
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Button, { variant: "outline", onClick: handleCancel, disabled: !!loadingPriceId, children: "Cancel" }),
|
|
1635
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Button, { onClick: handleConfirmPlanChange, disabled: !!loadingPriceId, children: loadingPriceId ? "Processing..." : "Confirm Plan Change" })
|
|
1636
1636
|
] })
|
|
1637
1637
|
] })
|
|
1638
1638
|
] })
|
|
@@ -1730,7 +1730,7 @@ function SubscriptionDetails({
|
|
|
1730
1730
|
const handlePause = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
1731
1731
|
setIsProcessing(true);
|
|
1732
1732
|
try {
|
|
1733
|
-
await
|
|
1733
|
+
await _chunkTSEU4KZ2js.StripeSubscriptionService.pauseSubscription({ subscriptionId: subscription.id });
|
|
1734
1734
|
onSubscriptionChange();
|
|
1735
1735
|
} catch (error) {
|
|
1736
1736
|
console.error("[SubscriptionDetails] Failed to pause subscription:", error);
|
|
@@ -1741,7 +1741,7 @@ function SubscriptionDetails({
|
|
|
1741
1741
|
const handleResume = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
1742
1742
|
setIsProcessing(true);
|
|
1743
1743
|
try {
|
|
1744
|
-
await
|
|
1744
|
+
await _chunkTSEU4KZ2js.StripeSubscriptionService.resumeSubscription({ subscriptionId: subscription.id });
|
|
1745
1745
|
onSubscriptionChange();
|
|
1746
1746
|
} catch (error) {
|
|
1747
1747
|
console.error("[SubscriptionDetails] Failed to resume subscription:", error);
|
|
@@ -1751,7 +1751,7 @@ function SubscriptionDetails({
|
|
|
1751
1751
|
}, "handleResume");
|
|
1752
1752
|
const handleManageViaPortal = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
1753
1753
|
try {
|
|
1754
|
-
const { url } = await
|
|
1754
|
+
const { url } = await _chunkTSEU4KZ2js.StripeCustomerService.createPortalSession();
|
|
1755
1755
|
window.open(url, "_blank");
|
|
1756
1756
|
} catch (error) {
|
|
1757
1757
|
console.error("[SubscriptionDetails] Failed to create portal session:", error);
|
|
@@ -1761,10 +1761,10 @@ function SubscriptionDetails({
|
|
|
1761
1761
|
const canResume = subscription.status === "paused" /* PAUSED */;
|
|
1762
1762
|
const canCancel = subscription.status === "active" /* ACTIVE */ || subscription.status === "trialing" /* TRIALING */ || subscription.status === "paused" /* PAUSED */;
|
|
1763
1763
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1764
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1765
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1766
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1767
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1764
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.DialogContent, { className: "max-w-2xl", children: [
|
|
1765
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.DialogHeader, { children: [
|
|
1766
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.DialogTitle, { children: "Subscription Details" }),
|
|
1767
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.DialogDescription, { children: "View and manage your subscription" })
|
|
1768
1768
|
] }),
|
|
1769
1769
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-6", children: [
|
|
1770
1770
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-3", children: [
|
|
@@ -1800,11 +1800,11 @@ function SubscriptionDetails({
|
|
|
1800
1800
|
"."
|
|
1801
1801
|
] }) }),
|
|
1802
1802
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-wrap gap-2 pt-4 border-t", children: [
|
|
1803
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1804
|
-
canPause && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1805
|
-
canResume && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1806
|
-
canCancel && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1807
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1803
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Button, { variant: "default", onClick: () => setShowEdit(true), children: "Change Plan" }),
|
|
1804
|
+
canPause && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Button, { variant: "outline", onClick: handlePause, disabled: isProcessing, children: isProcessing ? "Pausing..." : "Pause" }),
|
|
1805
|
+
canResume && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Button, { variant: "outline", onClick: handleResume, disabled: isProcessing, children: isProcessing ? "Resuming..." : "Resume" }),
|
|
1806
|
+
canCancel && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Button, { variant: "destructive", onClick: () => setShowCancel(true), children: "Cancel" }),
|
|
1807
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Button, { variant: "outline", onClick: handleManageViaPortal, children: "Manage via Portal" })
|
|
1808
1808
|
] })
|
|
1809
1809
|
] })
|
|
1810
1810
|
] }) }),
|
|
@@ -1863,27 +1863,27 @@ function SubscriptionsList({ subscriptions, onSubscriptionsChange }) {
|
|
|
1863
1863
|
setSelectedSub(subscription);
|
|
1864
1864
|
}, "handleRowClick");
|
|
1865
1865
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1866
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border rounded-lg overflow-hidden", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1867
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1868
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1869
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1870
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1871
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1866
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border rounded-lg overflow-hidden", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Table, { children: [
|
|
1867
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableHeader, { className: "bg-muted", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.TableRow, { children: [
|
|
1868
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableHead, { children: "Status" }),
|
|
1869
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableHead, { children: "Plan" }),
|
|
1870
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableHead, { children: "Period" }),
|
|
1871
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableHead, { className: "text-right", children: "Amount" })
|
|
1872
1872
|
] }) }),
|
|
1873
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1873
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableBody, { children: subscriptions.map((subscription) => {
|
|
1874
1874
|
const price = subscription.price;
|
|
1875
1875
|
const amount = _optionalChain([price, 'optionalAccess', _56 => _56.unitAmount]) ? formatCurrency(price.unitAmount, price.currency) : "N/A";
|
|
1876
1876
|
const period = `${formatDate3(subscription.currentPeriodStart)} - ${formatDate3(subscription.currentPeriodEnd)}`;
|
|
1877
1877
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1878
|
-
|
|
1878
|
+
_chunkIXI4GAKBjs.TableRow,
|
|
1879
1879
|
{
|
|
1880
1880
|
onClick: () => handleRowClick(subscription),
|
|
1881
1881
|
className: "cursor-pointer hover:bg-muted/50",
|
|
1882
1882
|
children: [
|
|
1883
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1884
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1885
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1886
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1883
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableCell, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SubscriptionStatusBadge, { status: subscription.status, cancelAtPeriodEnd: subscription.cancelAtPeriodEnd }) }),
|
|
1884
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableCell, { className: "font-medium", children: formatPlanName3(price) }),
|
|
1885
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableCell, { className: "text-muted-foreground text-sm", children: period }),
|
|
1886
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableCell, { className: "text-right font-medium", children: amount })
|
|
1887
1887
|
]
|
|
1888
1888
|
},
|
|
1889
1889
|
subscription.id
|
|
@@ -1925,7 +1925,7 @@ function SubscriptionsContainer() {
|
|
|
1925
1925
|
const loadSubscriptions = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
1926
1926
|
setLoading(true);
|
|
1927
1927
|
try {
|
|
1928
|
-
const fetchedSubscriptions = await
|
|
1928
|
+
const fetchedSubscriptions = await _chunkTSEU4KZ2js.StripeSubscriptionService.listSubscriptions();
|
|
1929
1929
|
setSubscriptions(fetchedSubscriptions);
|
|
1930
1930
|
} catch (error) {
|
|
1931
1931
|
console.error("[SubscriptionsContainer] Failed to load subscriptions:", error);
|
|
@@ -1936,7 +1936,7 @@ function SubscriptionsContainer() {
|
|
|
1936
1936
|
const loadPricingData = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
1937
1937
|
setLoadingPricing(true);
|
|
1938
1938
|
try {
|
|
1939
|
-
const fetchedProducts = await
|
|
1939
|
+
const fetchedProducts = await _chunkTSEU4KZ2js.StripeProductService.listProducts({ active: true });
|
|
1940
1940
|
const grouped = /* @__PURE__ */ new Map();
|
|
1941
1941
|
for (const product of fetchedProducts) {
|
|
1942
1942
|
if (product.stripePrices && product.stripePrices.length > 0) {
|
|
@@ -1953,7 +1953,7 @@ function SubscriptionsContainer() {
|
|
|
1953
1953
|
}, "loadPricingData");
|
|
1954
1954
|
const checkPaymentMethod = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
1955
1955
|
try {
|
|
1956
|
-
const paymentMethods = await
|
|
1956
|
+
const paymentMethods = await _chunkTSEU4KZ2js.StripeCustomerService.listPaymentMethods();
|
|
1957
1957
|
const hasMethod = paymentMethods.length > 0;
|
|
1958
1958
|
setHasPaymentMethod(hasMethod);
|
|
1959
1959
|
} catch (error) {
|
|
@@ -1966,7 +1966,7 @@ function SubscriptionsContainer() {
|
|
|
1966
1966
|
setPaymentError(null);
|
|
1967
1967
|
setPaymentConfirmationState("idle");
|
|
1968
1968
|
try {
|
|
1969
|
-
const result = await
|
|
1969
|
+
const result = await _chunkTSEU4KZ2js.StripeSubscriptionService.createSubscription({
|
|
1970
1970
|
id: _uuid.v4.call(void 0, ),
|
|
1971
1971
|
priceId
|
|
1972
1972
|
});
|
|
@@ -1980,7 +1980,7 @@ function SubscriptionsContainer() {
|
|
|
1980
1980
|
setCreatingSubscription(false);
|
|
1981
1981
|
return;
|
|
1982
1982
|
}
|
|
1983
|
-
await
|
|
1983
|
+
await _chunkTSEU4KZ2js.StripeSubscriptionService.syncSubscription({
|
|
1984
1984
|
subscriptionId: result.subscription.id
|
|
1985
1985
|
});
|
|
1986
1986
|
}
|
|
@@ -2038,7 +2038,7 @@ function SubscriptionsContainer() {
|
|
|
2038
2038
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-8 w-8" }),
|
|
2039
2039
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h1", { className: "text-3xl font-bold", children: "Subscriptions" })
|
|
2040
2040
|
] }),
|
|
2041
|
-
subscriptions.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2041
|
+
subscriptions.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Button, { onClick: () => setShowCreateSubscription(true), children: "Subscribe to a Plan" })
|
|
2042
2042
|
] }),
|
|
2043
2043
|
criticalSubscriptions.map((subscription) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BillingAlertBanner, { subscription }, subscription.id)),
|
|
2044
2044
|
subscriptions.length === 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-6", children: [
|
|
@@ -2056,12 +2056,12 @@ function SubscriptionsContainer() {
|
|
|
2056
2056
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: "Your subscription is now active." })
|
|
2057
2057
|
] })
|
|
2058
2058
|
] }),
|
|
2059
|
-
paymentConfirmationState === "error" && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2060
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2061
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2059
|
+
paymentConfirmationState === "error" && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Alert, { variant: "destructive", children: [
|
|
2060
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.AlertTitle, { children: "Payment Failed" }),
|
|
2061
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.AlertDescription, { className: "mt-2", children: [
|
|
2062
2062
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "mb-4", children: paymentError || "We couldn't process your payment. Please try again." }),
|
|
2063
2063
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2064
|
-
|
|
2064
|
+
_chunkIXI4GAKBjs.Button,
|
|
2065
2065
|
{
|
|
2066
2066
|
onClick: () => {
|
|
2067
2067
|
setPaymentConfirmationState("idle");
|
|
@@ -2155,15 +2155,15 @@ function UsageSummaryCard({ meter, summary }) {
|
|
|
2155
2155
|
const progressWidth = percentage !== null ? Math.min(percentage, 100) : 0;
|
|
2156
2156
|
const displayName = meter.displayName || meter.eventName;
|
|
2157
2157
|
const hasLimit = limit !== null && limit !== void 0;
|
|
2158
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2159
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2158
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Card, { children: [
|
|
2159
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.CardHeader, { className: "flex flex-row items-center gap-x-3 pb-3", children: [
|
|
2160
2160
|
/* @__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" }) }),
|
|
2161
2161
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col", children: [
|
|
2162
2162
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "font-semibold", children: displayName }),
|
|
2163
2163
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-gray-500", children: meter.id })
|
|
2164
2164
|
] })
|
|
2165
2165
|
] }),
|
|
2166
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2166
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.CardContent, { className: "flex flex-col gap-y-4", children: [
|
|
2167
2167
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
2168
2168
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-3xl font-bold", children: currentUsage.toLocaleString() }),
|
|
2169
2169
|
hasLimit && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-sm text-gray-500", children: [
|
|
@@ -2210,14 +2210,14 @@ function UsageContainer() {
|
|
|
2210
2210
|
const loadUsageData = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2211
2211
|
setLoading(true);
|
|
2212
2212
|
try {
|
|
2213
|
-
const fetchedSubscriptions = await
|
|
2213
|
+
const fetchedSubscriptions = await _chunkTSEU4KZ2js.StripeSubscriptionService.listSubscriptions();
|
|
2214
2214
|
setSubscriptions(fetchedSubscriptions);
|
|
2215
2215
|
const hasMeteredSubscriptions2 = fetchedSubscriptions.some((sub) => _optionalChain([sub, 'access', _64 => _64.price, 'optionalAccess', _65 => _65.recurring, 'optionalAccess', _66 => _66.usageType]) === "metered");
|
|
2216
2216
|
if (!hasMeteredSubscriptions2) {
|
|
2217
2217
|
setLoading(false);
|
|
2218
2218
|
return;
|
|
2219
2219
|
}
|
|
2220
|
-
const fetchedMeters = await
|
|
2220
|
+
const fetchedMeters = await _chunkTSEU4KZ2js.StripeUsageService.listMeters();
|
|
2221
2221
|
setMeters(fetchedMeters);
|
|
2222
2222
|
const summariesMap = {};
|
|
2223
2223
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -2225,7 +2225,7 @@ function UsageContainer() {
|
|
|
2225
2225
|
const endOfMonth = new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59, 999);
|
|
2226
2226
|
for (const meter of fetchedMeters) {
|
|
2227
2227
|
try {
|
|
2228
|
-
const meterSummaries = await
|
|
2228
|
+
const meterSummaries = await _chunkTSEU4KZ2js.StripeUsageService.getMeterSummaries({
|
|
2229
2229
|
meterId: meter.id,
|
|
2230
2230
|
startTime: startOfMonth,
|
|
2231
2231
|
endTime: endOfMonth
|
|
@@ -2291,21 +2291,21 @@ function UsageHistoryTable({ usageRecords }) {
|
|
|
2291
2291
|
}
|
|
2292
2292
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-y-4", children: [
|
|
2293
2293
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { className: "text-xl font-semibold", children: "Usage History" }),
|
|
2294
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "overflow-hidden rounded-lg border", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2295
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2296
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2297
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2298
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2299
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2294
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "overflow-hidden rounded-lg border", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Table, { children: [
|
|
2295
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableHeader, { className: "bg-muted", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.TableRow, { children: [
|
|
2296
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableHead, { children: "Date & Time" }),
|
|
2297
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableHead, { children: "Meter Event" }),
|
|
2298
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableHead, { className: "text-right", children: "Quantity" }),
|
|
2299
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableHead, { children: "Event ID" })
|
|
2300
2300
|
] }) }),
|
|
2301
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2301
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableBody, { children: usageRecords.map((record) => {
|
|
2302
2302
|
const dateTime = formatDateTime(record.timestamp);
|
|
2303
2303
|
const quantity = record.quantity.toLocaleString();
|
|
2304
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2305
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2306
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2307
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2308
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2304
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.TableRow, { children: [
|
|
2305
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableCell, { className: "font-medium", children: dateTime }),
|
|
2306
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableCell, { className: "text-muted-foreground", children: record.meterEventName }),
|
|
2307
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableCell, { className: "text-right font-medium", children: quantity }),
|
|
2308
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.TableCell, { className: "text-muted-foreground text-sm font-mono", children: record.stripeEventId })
|
|
2309
2309
|
] }, record.id);
|
|
2310
2310
|
}) })
|
|
2311
2311
|
] }) })
|
|
@@ -2322,8 +2322,8 @@ function BillingDetailModal({
|
|
|
2322
2322
|
children,
|
|
2323
2323
|
className
|
|
2324
2324
|
}) {
|
|
2325
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2326
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2325
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.DialogContent, { className: _nullishCoalesce(className, () => ( "max-w-4xl max-h-[90vh] overflow-y-auto")), children: [
|
|
2326
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.DialogHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.DialogTitle, { children: title }) }),
|
|
2327
2327
|
children
|
|
2328
2328
|
] }) });
|
|
2329
2329
|
}
|
|
@@ -2340,7 +2340,7 @@ function BillingAlertBanner({ subscription, onUpdatePayment, onAddPayment }) {
|
|
|
2340
2340
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "font-semibold text-red-900", children: "Payment Failed" }),
|
|
2341
2341
|
/* @__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." })
|
|
2342
2342
|
] }),
|
|
2343
|
-
onUpdatePayment && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2343
|
+
onUpdatePayment && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Button, { variant: "outline", size: "sm", onClick: onUpdatePayment, className: "border-red-300 text-red-700", children: "Update Payment Method" })
|
|
2344
2344
|
] });
|
|
2345
2345
|
}
|
|
2346
2346
|
if (subscription.status === "trialing" /* TRIALING */ && subscription.trialEnd) {
|
|
@@ -2360,7 +2360,7 @@ function BillingAlertBanner({ subscription, onUpdatePayment, onAddPayment }) {
|
|
|
2360
2360
|
". Add a payment method to continue your subscription."
|
|
2361
2361
|
] })
|
|
2362
2362
|
] }),
|
|
2363
|
-
onAddPayment && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2363
|
+
onAddPayment && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Button, { variant: "outline", size: "sm", onClick: onAddPayment, className: "border-yellow-300 text-yellow-700", children: "Add Payment Method" })
|
|
2364
2364
|
] });
|
|
2365
2365
|
}
|
|
2366
2366
|
}
|
|
@@ -2403,7 +2403,7 @@ function BillingDashboardContainer() {
|
|
|
2403
2403
|
setNoCustomerExists(false);
|
|
2404
2404
|
let customer = null;
|
|
2405
2405
|
try {
|
|
2406
|
-
customer = await
|
|
2406
|
+
customer = await _chunkTSEU4KZ2js.StripeCustomerService.getCustomer();
|
|
2407
2407
|
setData((prev) => ({ ...prev, customer }));
|
|
2408
2408
|
setErrors((prev) => ({ ...prev, customer: null }));
|
|
2409
2409
|
setNoCustomerExists(false);
|
|
@@ -2428,7 +2428,7 @@ function BillingDashboardContainer() {
|
|
|
2428
2428
|
if (customer) {
|
|
2429
2429
|
const fetchSubscriptions = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2430
2430
|
try {
|
|
2431
|
-
const subscriptions2 = await
|
|
2431
|
+
const subscriptions2 = await _chunkTSEU4KZ2js.StripeSubscriptionService.listSubscriptions();
|
|
2432
2432
|
setData((prev) => ({ ...prev, subscriptions: subscriptions2 }));
|
|
2433
2433
|
setErrors((prev) => ({ ...prev, subscriptions: null }));
|
|
2434
2434
|
return subscriptions2;
|
|
@@ -2442,7 +2442,7 @@ function BillingDashboardContainer() {
|
|
|
2442
2442
|
}, "fetchSubscriptions");
|
|
2443
2443
|
const fetchPaymentMethods = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2444
2444
|
try {
|
|
2445
|
-
const paymentMethods = await
|
|
2445
|
+
const paymentMethods = await _chunkTSEU4KZ2js.StripeCustomerService.listPaymentMethods();
|
|
2446
2446
|
setData((prev) => ({ ...prev, paymentMethods }));
|
|
2447
2447
|
setErrors((prev) => ({ ...prev, paymentMethods: null }));
|
|
2448
2448
|
} catch (error) {
|
|
@@ -2454,7 +2454,7 @@ function BillingDashboardContainer() {
|
|
|
2454
2454
|
}, "fetchPaymentMethods");
|
|
2455
2455
|
const fetchInvoices = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2456
2456
|
try {
|
|
2457
|
-
const invoices = await
|
|
2457
|
+
const invoices = await _chunkTSEU4KZ2js.StripeInvoiceService.listInvoices();
|
|
2458
2458
|
setData((prev) => ({ ...prev, invoices }));
|
|
2459
2459
|
setErrors((prev) => ({ ...prev, invoices: null }));
|
|
2460
2460
|
} catch (error) {
|
|
@@ -2478,7 +2478,7 @@ function BillingDashboardContainer() {
|
|
|
2478
2478
|
const handleCreateCustomer = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2479
2479
|
setCreatingCustomer(true);
|
|
2480
2480
|
try {
|
|
2481
|
-
await
|
|
2481
|
+
await _chunkTSEU4KZ2js.StripeCustomerService.createCustomer();
|
|
2482
2482
|
setNoCustomerExists(false);
|
|
2483
2483
|
await fetchAllData();
|
|
2484
2484
|
} catch (error) {
|
|
@@ -2490,7 +2490,7 @@ function BillingDashboardContainer() {
|
|
|
2490
2490
|
}, "handleCreateCustomer");
|
|
2491
2491
|
const fetchUsageData = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2492
2492
|
try {
|
|
2493
|
-
const meters = await
|
|
2493
|
+
const meters = await _chunkTSEU4KZ2js.StripeUsageService.listMeters();
|
|
2494
2494
|
setData((prev) => ({ ...prev, meters }));
|
|
2495
2495
|
const summariesMap = {};
|
|
2496
2496
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -2498,7 +2498,7 @@ function BillingDashboardContainer() {
|
|
|
2498
2498
|
const endOfMonth = new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59, 999);
|
|
2499
2499
|
for (const meter of meters) {
|
|
2500
2500
|
try {
|
|
2501
|
-
const meterSummaries = await
|
|
2501
|
+
const meterSummaries = await _chunkTSEU4KZ2js.StripeUsageService.getMeterSummaries({
|
|
2502
2502
|
meterId: meter.id,
|
|
2503
2503
|
startTime: startOfMonth,
|
|
2504
2504
|
endTime: endOfMonth
|
|
@@ -2560,18 +2560,18 @@ function BillingDashboardContainer() {
|
|
|
2560
2560
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Wallet, { className: "h-8 w-8" }),
|
|
2561
2561
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h1", { className: "text-3xl font-bold", children: "Billing" })
|
|
2562
2562
|
] }),
|
|
2563
|
-
isInitialLoading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2564
|
-
noCustomerExists && !isInitialLoading && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2565
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2563
|
+
isInitialLoading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Card, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.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" }) }) }),
|
|
2564
|
+
noCustomerExists && !isInitialLoading && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Card, { children: [
|
|
2565
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.CardHeader, { className: "text-center", children: [
|
|
2566
2566
|
/* @__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" }) }),
|
|
2567
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2568
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2567
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardTitle, { children: "Set Up Billing" }),
|
|
2568
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardDescription, { children: "Your company doesn't have a billing account yet. Set one up to manage subscriptions, payment methods, and view invoices." })
|
|
2569
2569
|
] }),
|
|
2570
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2570
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardContent, { className: "flex justify-center pb-8", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Button, { onClick: handleCreateCustomer, disabled: creatingCustomer, size: "lg", children: creatingCustomer ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
2571
2571
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Loader2, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
2572
2572
|
"Setting up..."
|
|
2573
2573
|
] }) : "Set Up Billing Account" }) }),
|
|
2574
|
-
errors.customer && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2574
|
+
errors.customer && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CardContent, { className: "pt-0", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-center text-sm text-destructive", children: errors.customer }) })
|
|
2575
2575
|
] }),
|
|
2576
2576
|
!noCustomerExists && !isInitialLoading && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
2577
2577
|
criticalSubscriptions.map((subscription) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -2730,7 +2730,8 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
2730
2730
|
nickname: _zod3.z.string().optional(),
|
|
2731
2731
|
active: _zod3.z.boolean(),
|
|
2732
2732
|
description: _zod3.z.string().optional(),
|
|
2733
|
-
features: _zod3.z.array(_zod3.z.string())
|
|
2733
|
+
features: _zod3.z.array(_zod3.z.string()),
|
|
2734
|
+
token: _zod3.z.string()
|
|
2734
2735
|
});
|
|
2735
2736
|
const isEditMode = !!price;
|
|
2736
2737
|
const defaultUnitAmount = _optionalChain([price, 'optionalAccess', _79 => _79.unitAmount]) ? price.unitAmount / 100 : 0;
|
|
@@ -2745,7 +2746,8 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
2745
2746
|
nickname: _optionalChain([price, 'optionalAccess', _88 => _88.nickname]) || "",
|
|
2746
2747
|
active: _nullishCoalesce(_optionalChain([price, 'optionalAccess', _89 => _89.active]), () => ( true)),
|
|
2747
2748
|
description: _optionalChain([price, 'optionalAccess', _90 => _90.description]) || "",
|
|
2748
|
-
features: _optionalChain([price, 'optionalAccess', _91 => _91.features]) || []
|
|
2749
|
+
features: _optionalChain([price, 'optionalAccess', _91 => _91.features]) || [],
|
|
2750
|
+
token: _nullishCoalesce(_optionalChain([price, 'optionalAccess', _92 => _92.token, 'optionalAccess', _93 => _93.toString, 'call', _94 => _94()]), () => ( ""))
|
|
2749
2751
|
}
|
|
2750
2752
|
});
|
|
2751
2753
|
const watchInterval = form.watch("interval");
|
|
@@ -2755,11 +2757,12 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
2755
2757
|
try {
|
|
2756
2758
|
const unitAmountInCents = Math.round(values.unitAmount * 100);
|
|
2757
2759
|
if (isEditMode) {
|
|
2758
|
-
await
|
|
2760
|
+
await _chunkTSEU4KZ2js.StripePriceService.updatePrice({
|
|
2759
2761
|
id: price.id,
|
|
2760
2762
|
nickname: values.nickname || void 0,
|
|
2761
2763
|
description: values.description || void 0,
|
|
2762
|
-
features: values.features.filter((f) => f.trim()) || void 0
|
|
2764
|
+
features: values.features.filter((f) => f.trim()) || void 0,
|
|
2765
|
+
token: values.token ? parseInt(values.token, 10) : void 0
|
|
2763
2766
|
});
|
|
2764
2767
|
} else {
|
|
2765
2768
|
const createInput = {
|
|
@@ -2785,7 +2788,10 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
2785
2788
|
if (filteredFeatures.length > 0) {
|
|
2786
2789
|
createInput.features = filteredFeatures;
|
|
2787
2790
|
}
|
|
2788
|
-
|
|
2791
|
+
if (values.token) {
|
|
2792
|
+
createInput.token = parseInt(values.token, 10);
|
|
2793
|
+
}
|
|
2794
|
+
await _chunkTSEU4KZ2js.StripePriceService.createPrice(createInput);
|
|
2789
2795
|
}
|
|
2790
2796
|
onSuccess();
|
|
2791
2797
|
onOpenChange(false);
|
|
@@ -2811,10 +2817,10 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
2811
2817
|
{ id: "licensed", text: "Licensed (per unit)" },
|
|
2812
2818
|
{ id: "metered", text: "Metered (usage-based)" }
|
|
2813
2819
|
];
|
|
2814
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2815
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2816
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2817
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2820
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.DialogContent, { className: "max-w-2xl", children: [
|
|
2821
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.DialogHeader, { children: [
|
|
2822
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.DialogTitle, { children: isEditMode ? "Edit Price" : "Create Price" }),
|
|
2823
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.DialogDescription, { children: isEditMode ? "Update the price details. Note: Only nickname and active status can be changed." : "Create a new price for this product" })
|
|
2818
2824
|
] }),
|
|
2819
2825
|
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: [
|
|
2820
2826
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.AlertCircle, { className: "h-5 w-5 text-blue-600 flex-shrink-0 mt-0.5" }),
|
|
@@ -2823,10 +2829,10 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
2823
2829
|
/* @__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." })
|
|
2824
2830
|
] })
|
|
2825
2831
|
] }),
|
|
2826
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2832
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Form, { ...form, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { onSubmit: form.handleSubmit(onSubmit), className: "flex flex-col gap-y-4", children: [
|
|
2827
2833
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid grid-cols-2 gap-x-4", children: [
|
|
2828
2834
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2829
|
-
|
|
2835
|
+
_chunkIXI4GAKBjs.FormInput,
|
|
2830
2836
|
{
|
|
2831
2837
|
form,
|
|
2832
2838
|
id: "unitAmount",
|
|
@@ -2836,10 +2842,10 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
2836
2842
|
isRequired: true
|
|
2837
2843
|
}
|
|
2838
2844
|
),
|
|
2839
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2845
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.FormSelect, { form, id: "currency", name: "Currency", values: currencyOptions, disabled: isEditMode })
|
|
2840
2846
|
] }),
|
|
2841
2847
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2842
|
-
|
|
2848
|
+
_chunkIXI4GAKBjs.FormSelect,
|
|
2843
2849
|
{
|
|
2844
2850
|
form,
|
|
2845
2851
|
id: "interval",
|
|
@@ -2850,7 +2856,7 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
2850
2856
|
),
|
|
2851
2857
|
isRecurring && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid grid-cols-2 gap-x-4", children: [
|
|
2852
2858
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2853
|
-
|
|
2859
|
+
_chunkIXI4GAKBjs.FormInput,
|
|
2854
2860
|
{
|
|
2855
2861
|
form,
|
|
2856
2862
|
id: "intervalCount",
|
|
@@ -2861,7 +2867,7 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
2861
2867
|
}
|
|
2862
2868
|
),
|
|
2863
2869
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2864
|
-
|
|
2870
|
+
_chunkIXI4GAKBjs.FormSelect,
|
|
2865
2871
|
{
|
|
2866
2872
|
form,
|
|
2867
2873
|
id: "usageType",
|
|
@@ -2872,7 +2878,7 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
2872
2878
|
)
|
|
2873
2879
|
] }),
|
|
2874
2880
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2875
|
-
|
|
2881
|
+
_chunkIXI4GAKBjs.FormInput,
|
|
2876
2882
|
{
|
|
2877
2883
|
form,
|
|
2878
2884
|
id: "nickname",
|
|
@@ -2881,7 +2887,7 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
2881
2887
|
}
|
|
2882
2888
|
),
|
|
2883
2889
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2884
|
-
|
|
2890
|
+
_chunkIXI4GAKBjs.FormTextarea,
|
|
2885
2891
|
{
|
|
2886
2892
|
form,
|
|
2887
2893
|
id: "description",
|
|
@@ -2890,12 +2896,13 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
2890
2896
|
className: "min-h-24"
|
|
2891
2897
|
}
|
|
2892
2898
|
),
|
|
2899
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.FormInput, { form, id: "token", name: "Token (optional)", placeholder: "Enter token value" }),
|
|
2893
2900
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
2894
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2901
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Label, { children: "Features (optional)" }),
|
|
2895
2902
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
2896
2903
|
form.watch("features").map((_, index) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex gap-2", children: [
|
|
2897
2904
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2898
|
-
|
|
2905
|
+
_chunkIXI4GAKBjs.Input,
|
|
2899
2906
|
{
|
|
2900
2907
|
...form.register(`features.${index}`),
|
|
2901
2908
|
placeholder: `Feature ${index + 1}`,
|
|
@@ -2903,7 +2910,7 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
2903
2910
|
}
|
|
2904
2911
|
),
|
|
2905
2912
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2906
|
-
|
|
2913
|
+
_chunkIXI4GAKBjs.Button,
|
|
2907
2914
|
{
|
|
2908
2915
|
type: "button",
|
|
2909
2916
|
variant: "outline",
|
|
@@ -2920,7 +2927,7 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
2920
2927
|
)
|
|
2921
2928
|
] }, index)),
|
|
2922
2929
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2923
|
-
|
|
2930
|
+
_chunkIXI4GAKBjs.Button,
|
|
2924
2931
|
{
|
|
2925
2932
|
type: "button",
|
|
2926
2933
|
variant: "outline",
|
|
@@ -2938,8 +2945,8 @@ function PriceEditor({ productId, price, open, onOpenChange, onSuccess }) {
|
|
|
2938
2945
|
)
|
|
2939
2946
|
] })
|
|
2940
2947
|
] }),
|
|
2941
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2942
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2948
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.FormCheckbox, { form, id: "active", name: "Active" }),
|
|
2949
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CommonEditorButtons, { isEdit: isEditMode, form, disabled: isSubmitting, setOpen: onOpenChange })
|
|
2943
2950
|
] }) })
|
|
2944
2951
|
] }) });
|
|
2945
2952
|
}
|
|
@@ -2961,7 +2968,7 @@ function PricesList({ productId, onPricesChange }) {
|
|
|
2961
2968
|
const loadPrices = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2962
2969
|
setLoading(true);
|
|
2963
2970
|
try {
|
|
2964
|
-
const fetchedPrices = await
|
|
2971
|
+
const fetchedPrices = await _chunkTSEU4KZ2js.StripePriceService.listPrices({ productId });
|
|
2965
2972
|
setPrices(fetchedPrices);
|
|
2966
2973
|
} catch (error) {
|
|
2967
2974
|
console.error("[PricesList] Failed to load prices:", error);
|
|
@@ -2978,7 +2985,7 @@ function PricesList({ productId, onPricesChange }) {
|
|
|
2978
2985
|
}
|
|
2979
2986
|
setArchivingPriceId(priceToArchive.id);
|
|
2980
2987
|
try {
|
|
2981
|
-
await
|
|
2988
|
+
await _chunkTSEU4KZ2js.StripePriceService.archivePrice({ id: priceToArchive.id });
|
|
2982
2989
|
setPriceToArchive(null);
|
|
2983
2990
|
await loadPrices();
|
|
2984
2991
|
onPricesChange();
|
|
@@ -2994,7 +3001,7 @@ function PricesList({ productId, onPricesChange }) {
|
|
|
2994
3001
|
}
|
|
2995
3002
|
setReactivatingPriceId(priceToReactivate.id);
|
|
2996
3003
|
try {
|
|
2997
|
-
await
|
|
3004
|
+
await _chunkTSEU4KZ2js.StripePriceService.reactivatePrice({ id: priceToReactivate.id });
|
|
2998
3005
|
setPriceToReactivate(null);
|
|
2999
3006
|
await loadPrices();
|
|
3000
3007
|
onPricesChange();
|
|
@@ -3025,12 +3032,12 @@ function PricesList({ productId, onPricesChange }) {
|
|
|
3025
3032
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-y-4", children: [
|
|
3026
3033
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-between mb-4", children: [
|
|
3027
3034
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h4", { className: "text-lg font-semibold", children: "Prices" }),
|
|
3028
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3035
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Button, { size: "sm", onClick: () => setShowCreatePrice(true), children: "Add Price" })
|
|
3029
3036
|
] }),
|
|
3030
3037
|
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: [
|
|
3031
3038
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.DollarSign, { className: "text-muted-foreground h-12 w-12" }),
|
|
3032
3039
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-muted-foreground text-sm", children: "No prices yet. Add a price to enable subscriptions." }),
|
|
3033
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3040
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Button, { size: "sm", onClick: () => setShowCreatePrice(true), children: "Add Price" })
|
|
3034
3041
|
] }),
|
|
3035
3042
|
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) => {
|
|
3036
3043
|
const isArchiving = archivingPriceId === price.id;
|
|
@@ -3039,9 +3046,9 @@ function PricesList({ productId, onPricesChange }) {
|
|
|
3039
3046
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-start justify-between mb-3", children: [
|
|
3040
3047
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.DollarSign, { className: "h-5 w-5 text-primary" }),
|
|
3041
3048
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex gap-1", children: [
|
|
3042
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3049
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.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" }) }),
|
|
3043
3050
|
price.active ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3044
|
-
|
|
3051
|
+
_chunkIXI4GAKBjs.Button,
|
|
3045
3052
|
{
|
|
3046
3053
|
variant: "ghost",
|
|
3047
3054
|
size: "sm",
|
|
@@ -3051,7 +3058,7 @@ function PricesList({ productId, onPricesChange }) {
|
|
|
3051
3058
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Archive, { className: "h-4 w-4" })
|
|
3052
3059
|
}
|
|
3053
3060
|
) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3054
|
-
|
|
3061
|
+
_chunkIXI4GAKBjs.Button,
|
|
3055
3062
|
{
|
|
3056
3063
|
variant: "ghost",
|
|
3057
3064
|
size: "sm",
|
|
@@ -3068,10 +3075,10 @@ function PricesList({ productId, onPricesChange }) {
|
|
|
3068
3075
|
" ",
|
|
3069
3076
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-sm font-normal", children: formatInterval2(price) })
|
|
3070
3077
|
] }) }),
|
|
3071
|
-
_optionalChain([price, 'access',
|
|
3078
|
+
_optionalChain([price, 'access', _95 => _95.metadata, 'optionalAccess', _96 => _96.nickname]) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm font-medium mb-2", children: price.metadata.nickname }),
|
|
3072
3079
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-wrap gap-2", children: [
|
|
3073
3080
|
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" }),
|
|
3074
|
-
_optionalChain([price, 'access',
|
|
3081
|
+
_optionalChain([price, 'access', _97 => _97.recurring, 'optionalAccess', _98 => _98.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" }),
|
|
3075
3082
|
/* @__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 })
|
|
3076
3083
|
] })
|
|
3077
3084
|
] }, price.id);
|
|
@@ -3102,20 +3109,20 @@ function PricesList({ productId, onPricesChange }) {
|
|
|
3102
3109
|
}
|
|
3103
3110
|
}
|
|
3104
3111
|
),
|
|
3105
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3106
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3107
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3108
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3112
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.AlertDialog, { open: !!priceToArchive, onOpenChange: (open) => !open && setPriceToArchive(null), children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.AlertDialogContent, { children: [
|
|
3113
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.AlertDialogHeader, { children: [
|
|
3114
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.AlertDialogTitle, { children: "Archive Price" }),
|
|
3115
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.AlertDialogDescription, { children: [
|
|
3109
3116
|
"Are you sure you want to archive the price for",
|
|
3110
3117
|
" ",
|
|
3111
3118
|
priceToArchive && `${formatCurrency(priceToArchive.unitAmount, priceToArchive.currency)} ${formatInterval2(priceToArchive)}`,
|
|
3112
3119
|
"? This will prevent new subscriptions but existing ones will continue."
|
|
3113
3120
|
] })
|
|
3114
3121
|
] }),
|
|
3115
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3116
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3122
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.AlertDialogFooter, { children: [
|
|
3123
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.AlertDialogCancel, { disabled: !!archivingPriceId, children: "Cancel" }),
|
|
3117
3124
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3118
|
-
|
|
3125
|
+
_chunkIXI4GAKBjs.AlertDialogAction,
|
|
3119
3126
|
{
|
|
3120
3127
|
onClick: handleArchive,
|
|
3121
3128
|
disabled: !!archivingPriceId,
|
|
@@ -3125,20 +3132,20 @@ function PricesList({ productId, onPricesChange }) {
|
|
|
3125
3132
|
)
|
|
3126
3133
|
] })
|
|
3127
3134
|
] }) }),
|
|
3128
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3129
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3130
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3131
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3135
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.AlertDialog, { open: !!priceToReactivate, onOpenChange: (open) => !open && setPriceToReactivate(null), children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.AlertDialogContent, { children: [
|
|
3136
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.AlertDialogHeader, { children: [
|
|
3137
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.AlertDialogTitle, { children: "Reactivate Price" }),
|
|
3138
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.AlertDialogDescription, { children: [
|
|
3132
3139
|
"Are you sure you want to reactivate the price for",
|
|
3133
3140
|
" ",
|
|
3134
3141
|
priceToReactivate && `${formatCurrency(priceToReactivate.unitAmount, priceToReactivate.currency)} ${formatInterval2(priceToReactivate)}`,
|
|
3135
3142
|
"? This will allow new subscriptions again."
|
|
3136
3143
|
] })
|
|
3137
3144
|
] }),
|
|
3138
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3139
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3145
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.AlertDialogFooter, { children: [
|
|
3146
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.AlertDialogCancel, { disabled: !!reactivatingPriceId, children: "Cancel" }),
|
|
3140
3147
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3141
|
-
|
|
3148
|
+
_chunkIXI4GAKBjs.AlertDialogAction,
|
|
3142
3149
|
{
|
|
3143
3150
|
onClick: handleReactivate,
|
|
3144
3151
|
disabled: !!reactivatingPriceId,
|
|
@@ -3173,23 +3180,23 @@ function ProductEditor({ product, open, onOpenChange, onSuccess }) {
|
|
|
3173
3180
|
const form = _reacthookform.useForm.call(void 0, {
|
|
3174
3181
|
resolver: _zod.zodResolver.call(void 0, formSchema2),
|
|
3175
3182
|
defaultValues: {
|
|
3176
|
-
name: _optionalChain([product, 'optionalAccess',
|
|
3177
|
-
description: _optionalChain([product, 'optionalAccess',
|
|
3178
|
-
active: _nullishCoalesce(_optionalChain([product, 'optionalAccess',
|
|
3183
|
+
name: _optionalChain([product, 'optionalAccess', _99 => _99.name]) || "",
|
|
3184
|
+
description: _optionalChain([product, 'optionalAccess', _100 => _100.description]) || "",
|
|
3185
|
+
active: _nullishCoalesce(_optionalChain([product, 'optionalAccess', _101 => _101.active]), () => ( true))
|
|
3179
3186
|
}
|
|
3180
3187
|
});
|
|
3181
3188
|
const onSubmit = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async (values) => {
|
|
3182
3189
|
setIsSubmitting(true);
|
|
3183
3190
|
try {
|
|
3184
3191
|
if (product) {
|
|
3185
|
-
await
|
|
3192
|
+
await _chunkTSEU4KZ2js.StripeProductService.updateProduct({
|
|
3186
3193
|
id: product.id,
|
|
3187
3194
|
name: values.name,
|
|
3188
3195
|
description: values.description,
|
|
3189
3196
|
active: values.active
|
|
3190
3197
|
});
|
|
3191
3198
|
} else {
|
|
3192
|
-
await
|
|
3199
|
+
await _chunkTSEU4KZ2js.StripeProductService.createProduct({
|
|
3193
3200
|
id: _uuid.v4.call(void 0, ),
|
|
3194
3201
|
name: values.name,
|
|
3195
3202
|
description: values.description,
|
|
@@ -3204,15 +3211,15 @@ function ProductEditor({ product, open, onOpenChange, onSuccess }) {
|
|
|
3204
3211
|
setIsSubmitting(false);
|
|
3205
3212
|
}
|
|
3206
3213
|
}, "onSubmit");
|
|
3207
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3208
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3209
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3210
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3214
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.DialogContent, { className: "max-w-2xl", children: [
|
|
3215
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.DialogHeader, { children: [
|
|
3216
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.DialogTitle, { children: product ? "Edit Product" : "Create Product" }),
|
|
3217
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.DialogDescription, { children: product ? `Update the details for ${product.name}` : "Create a new product to offer to your customers" })
|
|
3211
3218
|
] }),
|
|
3212
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3213
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3219
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Form, { ...form, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { onSubmit: form.handleSubmit(onSubmit), className: "flex flex-col gap-y-4", children: [
|
|
3220
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.FormInput, { form, id: "name", name: "Product Name", placeholder: "Enter product name", isRequired: true }),
|
|
3214
3221
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3215
|
-
|
|
3222
|
+
_chunkIXI4GAKBjs.FormTextarea,
|
|
3216
3223
|
{
|
|
3217
3224
|
form,
|
|
3218
3225
|
id: "description",
|
|
@@ -3221,8 +3228,8 @@ function ProductEditor({ product, open, onOpenChange, onSuccess }) {
|
|
|
3221
3228
|
className: "min-h-32"
|
|
3222
3229
|
}
|
|
3223
3230
|
),
|
|
3224
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3225
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3231
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.FormCheckbox, { form, id: "active", name: "Active" }),
|
|
3232
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.CommonEditorButtons, { isEdit: !!product, form, disabled: isSubmitting, setOpen: onOpenChange })
|
|
3226
3233
|
] }) })
|
|
3227
3234
|
] }) });
|
|
3228
3235
|
}
|
|
@@ -3245,7 +3252,7 @@ function ProductsList({ products, onProductsChange }) {
|
|
|
3245
3252
|
}
|
|
3246
3253
|
setArchivingProductId(productToArchive.id);
|
|
3247
3254
|
try {
|
|
3248
|
-
const archivedProduct = await
|
|
3255
|
+
const archivedProduct = await _chunkTSEU4KZ2js.StripeProductService.archiveProduct({ id: productToArchive.id });
|
|
3249
3256
|
setProductToArchive(null);
|
|
3250
3257
|
onProductsChange();
|
|
3251
3258
|
} catch (error) {
|
|
@@ -3260,7 +3267,7 @@ function ProductsList({ products, onProductsChange }) {
|
|
|
3260
3267
|
}
|
|
3261
3268
|
setReactivatingProductId(productToReactivate.id);
|
|
3262
3269
|
try {
|
|
3263
|
-
const reactivatedProduct = await
|
|
3270
|
+
const reactivatedProduct = await _chunkTSEU4KZ2js.StripeProductService.reactivateProduct({ id: productToReactivate.id });
|
|
3264
3271
|
setProductToReactivate(null);
|
|
3265
3272
|
onProductsChange();
|
|
3266
3273
|
} catch (error) {
|
|
@@ -3289,12 +3296,12 @@ function ProductsList({ products, onProductsChange }) {
|
|
|
3289
3296
|
] })
|
|
3290
3297
|
] }),
|
|
3291
3298
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-2", children: [
|
|
3292
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3299
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.Button, { variant: "outline", size: "sm", onClick: () => setEditingProduct(product), children: [
|
|
3293
3300
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Edit, { className: "h-4 w-4 mr-1" }),
|
|
3294
3301
|
"Edit"
|
|
3295
3302
|
] }),
|
|
3296
3303
|
product.active ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3297
|
-
|
|
3304
|
+
_chunkIXI4GAKBjs.Button,
|
|
3298
3305
|
{
|
|
3299
3306
|
variant: "outline",
|
|
3300
3307
|
size: "sm",
|
|
@@ -3306,7 +3313,7 @@ function ProductsList({ products, onProductsChange }) {
|
|
|
3306
3313
|
]
|
|
3307
3314
|
}
|
|
3308
3315
|
) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3309
|
-
|
|
3316
|
+
_chunkIXI4GAKBjs.Button,
|
|
3310
3317
|
{
|
|
3311
3318
|
variant: "outline",
|
|
3312
3319
|
size: "sm",
|
|
@@ -3318,7 +3325,7 @@ function ProductsList({ products, onProductsChange }) {
|
|
|
3318
3325
|
]
|
|
3319
3326
|
}
|
|
3320
3327
|
),
|
|
3321
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3328
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.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" }) })
|
|
3322
3329
|
] })
|
|
3323
3330
|
] }),
|
|
3324
3331
|
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 }) })
|
|
@@ -3336,19 +3343,19 @@ function ProductsList({ products, onProductsChange }) {
|
|
|
3336
3343
|
}
|
|
3337
3344
|
}
|
|
3338
3345
|
),
|
|
3339
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3340
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3341
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3342
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3346
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.AlertDialog, { open: !!productToArchive, onOpenChange: (open) => !open && setProductToArchive(null), children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.AlertDialogContent, { children: [
|
|
3347
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.AlertDialogHeader, { children: [
|
|
3348
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.AlertDialogTitle, { children: "Archive Product" }),
|
|
3349
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.AlertDialogDescription, { children: [
|
|
3343
3350
|
'Are you sure you want to archive "',
|
|
3344
|
-
_optionalChain([productToArchive, 'optionalAccess',
|
|
3351
|
+
_optionalChain([productToArchive, 'optionalAccess', _102 => _102.name]),
|
|
3345
3352
|
'"? This will deactivate it and it will no longer be available for new subscriptions.'
|
|
3346
3353
|
] })
|
|
3347
3354
|
] }),
|
|
3348
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3349
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3355
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.AlertDialogFooter, { children: [
|
|
3356
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.AlertDialogCancel, { disabled: !!archivingProductId, children: "Cancel" }),
|
|
3350
3357
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3351
|
-
|
|
3358
|
+
_chunkIXI4GAKBjs.AlertDialogAction,
|
|
3352
3359
|
{
|
|
3353
3360
|
onClick: handleArchive,
|
|
3354
3361
|
disabled: !!archivingProductId,
|
|
@@ -3358,19 +3365,19 @@ function ProductsList({ products, onProductsChange }) {
|
|
|
3358
3365
|
)
|
|
3359
3366
|
] })
|
|
3360
3367
|
] }) }),
|
|
3361
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3362
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3363
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3364
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3368
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.AlertDialog, { open: !!productToReactivate, onOpenChange: (open) => !open && setProductToReactivate(null), children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.AlertDialogContent, { children: [
|
|
3369
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.AlertDialogHeader, { children: [
|
|
3370
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.AlertDialogTitle, { children: "Reactivate Product" }),
|
|
3371
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.AlertDialogDescription, { children: [
|
|
3365
3372
|
'Are you sure you want to reactivate "',
|
|
3366
|
-
_optionalChain([productToReactivate, 'optionalAccess',
|
|
3373
|
+
_optionalChain([productToReactivate, 'optionalAccess', _103 => _103.name]),
|
|
3367
3374
|
'"? This will make it available for new subscriptions again.'
|
|
3368
3375
|
] })
|
|
3369
3376
|
] }),
|
|
3370
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3371
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3377
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkIXI4GAKBjs.AlertDialogFooter, { children: [
|
|
3378
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.AlertDialogCancel, { disabled: !!reactivatingProductId, children: "Cancel" }),
|
|
3372
3379
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3373
|
-
|
|
3380
|
+
_chunkIXI4GAKBjs.AlertDialogAction,
|
|
3374
3381
|
{
|
|
3375
3382
|
onClick: handleReactivate,
|
|
3376
3383
|
disabled: !!reactivatingProductId,
|
|
@@ -3387,7 +3394,7 @@ _chunk7QVYU63Ejs.__name.call(void 0, ProductsList, "ProductsList");
|
|
|
3387
3394
|
// src/features/billing/stripe-product/components/containers/ProductsAdminContainer.tsx
|
|
3388
3395
|
|
|
3389
3396
|
function ProductsAdminContainer() {
|
|
3390
|
-
const { hasRole } =
|
|
3397
|
+
const { hasRole } = _chunkIXI4GAKBjs.useCurrentUserContext.call(void 0, );
|
|
3391
3398
|
const [products, setProducts] = _react.useState.call(void 0, []);
|
|
3392
3399
|
const [loading, setLoading] = _react.useState.call(void 0, true);
|
|
3393
3400
|
const [showCreateProduct, setShowCreateProduct] = _react.useState.call(void 0, false);
|
|
@@ -3397,7 +3404,7 @@ function ProductsAdminContainer() {
|
|
|
3397
3404
|
const loadProducts = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
3398
3405
|
setLoading(true);
|
|
3399
3406
|
try {
|
|
3400
|
-
const fetchedProducts = await
|
|
3407
|
+
const fetchedProducts = await _chunkTSEU4KZ2js.StripeProductService.listProducts();
|
|
3401
3408
|
setProducts(fetchedProducts);
|
|
3402
3409
|
} catch (error) {
|
|
3403
3410
|
console.error("[ProductsAdminContainer] Failed to load products:", error);
|
|
@@ -3417,14 +3424,14 @@ function ProductsAdminContainer() {
|
|
|
3417
3424
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Package, { className: "h-8 w-8" }),
|
|
3418
3425
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h1", { className: "text-3xl font-bold", children: "Product & Price Management" })
|
|
3419
3426
|
] }),
|
|
3420
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3427
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Button, { onClick: () => setShowCreateProduct(true), children: "Create Product" })
|
|
3421
3428
|
] }),
|
|
3422
3429
|
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: [
|
|
3423
3430
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Package, { className: "text-muted-foreground h-16 w-16" }),
|
|
3424
3431
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "text-center", children: [
|
|
3425
3432
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "mb-2 text-xl font-semibold", children: "No products yet" }),
|
|
3426
3433
|
/* @__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." }),
|
|
3427
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3434
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkIXI4GAKBjs.Button, { onClick: () => setShowCreateProduct(true), children: "Create Your First Product" })
|
|
3428
3435
|
] })
|
|
3429
3436
|
] }),
|
|
3430
3437
|
products.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ProductsList, { products, onProductsChange: loadProducts }),
|