@carlonicora/nextjs-jsonapi 3.11.0 → 3.13.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/{AssistantInterface-DwdBzS9f.d.ts → AssistantInterface-RvZzlcA_.d.ts} +2 -0
- package/dist/{AssistantInterface-DMh-zApr.d.mts → AssistantInterface-jL56dyNc.d.mts} +2 -0
- package/dist/{AssistantMessageInterface-0zyVingf.d.ts → AssistantMessageInterface-CuaMDs2i.d.ts} +1 -1
- package/dist/{AssistantMessageInterface-ddyG114R.d.mts → AssistantMessageInterface-Du3ShThp.d.mts} +1 -1
- package/dist/{BlockNoteEditor-XOVNTXDY.js → BlockNoteEditor-CFVSHS46.js} +19 -19
- package/dist/{BlockNoteEditor-XOVNTXDY.js.map → BlockNoteEditor-CFVSHS46.js.map} +1 -1
- package/dist/{BlockNoteEditor-NBHDEZ7W.mjs → BlockNoteEditor-SERY337S.mjs} +4 -4
- package/dist/{BlockNoteViewer-C2UUOBAF.js → BlockNoteViewer-CWFPYYIU.js} +3 -3
- package/dist/{BlockNoteViewer-C2UUOBAF.js.map → BlockNoteViewer-CWFPYYIU.js.map} +1 -1
- package/dist/{BlockNoteViewer-TYLVTIUD.mjs → BlockNoteViewer-P2VKEFRN.mjs} +2 -2
- package/dist/{ai-connection.module-28f-hux0.d.mts → HandbookSectionInterface-BOxIdBdd.d.mts} +54 -1
- package/dist/{ai-connection.module-Bqwh_DnR.d.ts → HandbookSectionInterface-CAXxbDw0.d.ts} +54 -1
- package/dist/{auth.interface-B6ZQLGjS.d.ts → auth.interface-BC1jp_ni.d.ts} +1 -1
- package/dist/{auth.interface-jYD8Gc4P.d.mts → auth.interface-dR2-6gPM.d.mts} +1 -1
- package/dist/billing/index.d.mts +27 -0
- package/dist/billing/index.d.ts +27 -0
- package/dist/billing/index.js +697 -450
- package/dist/billing/index.js.map +1 -1
- package/dist/billing/index.mjs +282 -35
- package/dist/billing/index.mjs.map +1 -1
- package/dist/{chunk-6J2SQZ3G.js → chunk-IB7DTXWG.js} +847 -129
- package/dist/chunk-IB7DTXWG.js.map +1 -0
- package/dist/{chunk-YN4LOVL4.js → chunk-LVE3BJ6K.js} +2106 -1109
- package/dist/chunk-LVE3BJ6K.js.map +1 -0
- package/dist/{chunk-M5QAHSCY.mjs → chunk-OSFYCSTW.mjs} +725 -7
- package/dist/chunk-OSFYCSTW.mjs.map +1 -0
- package/dist/{chunk-XNGI4HDZ.mjs → chunk-UQXE3SME.mjs} +2100 -1103
- package/dist/chunk-UQXE3SME.mjs.map +1 -0
- package/dist/{chunk-IMSIVIIC.mjs → chunk-VZKJIAND.mjs} +2 -2
- package/dist/{chunk-V6CGCARD.js → chunk-XH4IURUD.js} +7 -7
- package/dist/{chunk-V6CGCARD.js.map → chunk-XH4IURUD.js.map} +1 -1
- package/dist/client/index.d.mts +2 -2
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.js +4 -4
- package/dist/client/index.mjs +3 -3
- package/dist/components/index.d.mts +258 -7
- package/dist/components/index.d.ts +258 -7
- package/dist/components/index.js +30 -4
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +29 -3
- package/dist/contexts/index.d.mts +17 -5
- package/dist/contexts/index.d.ts +17 -5
- package/dist/contexts/index.js +4 -4
- package/dist/contexts/index.mjs +3 -3
- package/dist/core/index.d.mts +493 -12
- package/dist/core/index.d.ts +493 -12
- package/dist/core/index.js +38 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +37 -1
- package/dist/features/help/index.js +37 -37
- package/dist/features/help/index.mjs +3 -3
- package/dist/features/tokenusage/index.js +101 -101
- package/dist/features/tokenusage/index.mjs +3 -3
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +39 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -2
- package/dist/{notification.interface-DYF56CtE.d.ts → notification.interface-CjzV_KII.d.ts} +1 -1
- package/dist/{notification.interface-BWOCvKRP.d.mts → notification.interface-MnRt1Tjm.d.mts} +1 -1
- package/dist/{s3.service-D_dswjgz.d.mts → s3.service-C0Yq2Sx3.d.mts} +2 -2
- package/dist/{s3.service-DserU9VK.d.ts → s3.service-CUGarZs3.d.ts} +2 -2
- package/dist/server/index.d.mts +3 -3
- package/dist/server/index.d.ts +3 -3
- package/dist/server/index.js +3 -3
- package/dist/server/index.mjs +1 -1
- package/dist/{useSocket-BZG9oX-L.d.mts → useSocket-BcH7l7B8.d.mts} +1 -1
- package/dist/{useSocket-CiyTtYFj.d.ts → useSocket-DCZd_eJk.d.ts} +1 -1
- package/package.json +1 -1
- package/src/components/containers/ReactMarkdownContainer.tsx +61 -11
- package/src/components/index.ts +1 -0
- package/src/core/index.ts +5 -0
- package/src/core/registry/ModuleRegistry.ts +4 -0
- package/src/features/assistant/components/parts/AssistantComposer.tsx +22 -3
- package/src/features/assistant/components/parts/AssistantSidebar.tsx +13 -3
- package/src/features/assistant/components/parts/AssistantThreadHeader.tsx +10 -3
- package/src/features/assistant/contexts/AssistantContext.tsx +30 -3
- package/src/features/assistant/contexts/__tests__/AssistantContext.spec.tsx +32 -0
- package/src/features/assistant/data/Assistant.ts +2 -0
- package/src/features/assistant/data/AssistantInterface.ts +2 -0
- package/src/features/assistant/data/AssistantService.ts +4 -0
- package/src/features/assistant-message/components/parts/MessageSourcesContainer.tsx +5 -1
- package/src/features/assistant-message/data/AssistantMessage.ts +27 -2
- package/src/features/billing/i18n-keys.ts +7 -0
- package/src/features/billing/stripe-price/components/forms/PriceEditor.tsx +108 -2
- package/src/features/billing/stripe-price/components/forms/__tests__/PriceEditor.spec.tsx +182 -0
- package/src/features/billing/stripe-price/components/lists/PricesList.tsx +152 -25
- package/src/features/billing/stripe-price/components/lists/__tests__/PricesList.spec.tsx +268 -0
- package/src/features/billing/stripe-price/data/__tests__/stripe-price.transfer.spec.ts +265 -0
- package/src/features/billing/stripe-price/data/stripe-price.fields.ts +1 -0
- package/src/features/billing/stripe-price/data/stripe-price.transfer.ts +194 -0
- package/src/features/billing/stripe-price/hooks/useStripePriceTableStructure.tsx +66 -2
- package/src/features/content/data/content.interface.ts +1 -1
- package/src/features/handbook/HandbookPageModule.ts +41 -0
- package/src/features/handbook/HandbookSectionModule.ts +35 -0
- package/src/features/handbook/HandbookThreadMessageModule.ts +21 -0
- package/src/features/handbook/HandbookThreadModule.ts +29 -0
- package/src/features/handbook/components/containers/HandbookAdminContainer.tsx +17 -0
- package/src/features/handbook/components/containers/HandbookAskContainer.tsx +142 -0
- package/src/features/handbook/components/containers/HandbookAskSheet.tsx +149 -0
- package/src/features/handbook/components/containers/HandbookPageContainer.tsx +143 -0
- package/src/features/handbook/components/containers/__tests__/HandbookAskContainer.spec.tsx +268 -0
- package/src/features/handbook/components/containers/__tests__/HandbookAskSheet.spec.tsx +143 -0
- package/src/features/handbook/components/containers/__tests__/HandbookPageContainer.spec.tsx +288 -0
- package/src/features/handbook/components/details/HandbookPageDetails.tsx +27 -0
- package/src/features/handbook/components/details/HandbookPageNeighbours.tsx +72 -0
- package/src/features/handbook/components/details/HandbookPageToc.tsx +165 -0
- package/src/features/handbook/components/forms/HandbookSyncButton.tsx +43 -0
- package/src/features/handbook/components/forms/__tests__/HandbookSyncButton.spec.tsx +42 -0
- package/src/features/handbook/components/index.ts +12 -0
- package/src/features/handbook/components/lists/HandbookContents.tsx +196 -0
- package/src/features/handbook/components/lists/HandbookSectionGroup.tsx +153 -0
- package/src/features/handbook/components/lists/__tests__/HandbookContents.spec.tsx +247 -0
- package/src/features/handbook/components/parts/HandbookIndexStatus.tsx +62 -0
- package/src/features/handbook/components/parts/HandbookPageNavigator.tsx +143 -0
- package/src/features/handbook/contexts/HandbookContext.tsx +109 -0
- package/src/features/handbook/contexts/__tests__/HandbookContext.spec.tsx +131 -0
- package/src/features/handbook/data/HandbookPage.spec.ts +136 -0
- package/src/features/handbook/data/HandbookPage.ts +99 -0
- package/src/features/handbook/data/HandbookPageFields.ts +31 -0
- package/src/features/handbook/data/HandbookPageInput.ts +8 -0
- package/src/features/handbook/data/HandbookPageInterface.ts +29 -0
- package/src/features/handbook/data/HandbookPageService.ts +60 -0
- package/src/features/handbook/data/HandbookSection.spec.ts +58 -0
- package/src/features/handbook/data/HandbookSection.ts +73 -0
- package/src/features/handbook/data/HandbookSectionInput.ts +12 -0
- package/src/features/handbook/data/HandbookSectionInterface.ts +26 -0
- package/src/features/handbook/data/HandbookSectionService.ts +26 -0
- package/src/features/handbook/data/HandbookThread.ts +114 -0
- package/src/features/handbook/data/HandbookThreadInterface.ts +31 -0
- package/src/features/handbook/data/HandbookThreadMessage.ts +144 -0
- package/src/features/handbook/data/HandbookThreadMessageInterface.ts +35 -0
- package/src/features/handbook/data/HandbookThreadMessageService.ts +30 -0
- package/src/features/handbook/data/HandbookThreadService.ts +86 -0
- package/src/features/handbook/data/__tests__/HandbookThreadService.spec.ts +112 -0
- package/src/features/handbook/data/handbookDisplay.spec.ts +92 -0
- package/src/features/handbook/data/handbookDisplay.ts +55 -0
- package/src/features/handbook/data/index.ts +16 -0
- package/src/features/handbook/hooks/__tests__/useHandbookAsk.spec.ts +198 -0
- package/src/features/handbook/hooks/useHandbookAsk.ts +213 -0
- package/src/features/handbook/i18n-keys.ts +46 -0
- package/src/features/handbook/index.ts +7 -0
- package/src/features/how-to/components/forms/HowToEditor.tsx +0 -1
- package/src/features/how-to/components/forms/HowToReindexButton.spec.tsx +84 -0
- package/src/features/how-to/components/forms/HowToReindexButton.tsx +46 -0
- package/src/features/how-to/components/index.ts +1 -0
- package/src/features/how-to/components/lists/HowToList.tsx +5 -1
- package/src/features/how-to/data/HowTo.spec.ts +61 -1
- package/src/features/how-to/data/HowToService.ts +13 -0
- package/dist/chunk-6J2SQZ3G.js.map +0 -1
- package/dist/chunk-M5QAHSCY.mjs.map +0 -1
- package/dist/chunk-XNGI4HDZ.mjs.map +0 -1
- package/dist/chunk-YN4LOVL4.js.map +0 -1
- /package/dist/{BlockNoteEditor-NBHDEZ7W.mjs.map → BlockNoteEditor-SERY337S.mjs.map} +0 -0
- /package/dist/{BlockNoteViewer-TYLVTIUD.mjs.map → BlockNoteViewer-P2VKEFRN.mjs.map} +0 -0
- /package/dist/{chunk-IMSIVIIC.mjs.map → chunk-VZKJIAND.mjs.map} +0 -0
package/dist/billing/index.js
CHANGED
|
@@ -62,12 +62,12 @@
|
|
|
62
62
|
|
|
63
63
|
|
|
64
64
|
|
|
65
|
-
var
|
|
65
|
+
var _chunkLVE3BJ6Kjs = require('../chunk-LVE3BJ6K.js');
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
|
|
70
|
-
var
|
|
70
|
+
var _chunkXH4IURUDjs = require('../chunk-XH4IURUD.js');
|
|
71
71
|
|
|
72
72
|
|
|
73
73
|
|
|
@@ -80,7 +80,8 @@ var _chunkV6CGCARDjs = require('../chunk-V6CGCARD.js');
|
|
|
80
80
|
|
|
81
81
|
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
|
|
84
|
+
var _chunkIB7DTXWGjs = require('../chunk-IB7DTXWG.js');
|
|
84
85
|
require('../chunk-LXKSUWAV.js');
|
|
85
86
|
require('../chunk-IBS6NI7D.js');
|
|
86
87
|
require('../chunk-LU7DJ4QF.js');
|
|
@@ -131,41 +132,41 @@ function SubscriptionSummaryCard({
|
|
|
131
132
|
onManageClick
|
|
132
133
|
}) {
|
|
133
134
|
if (loading) {
|
|
134
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
135
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
136
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
135
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Card, { children: [
|
|
136
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
137
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardTitle, { children: "Subscriptions" }),
|
|
137
138
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-4 w-4 text-muted-foreground" })
|
|
138
139
|
] }),
|
|
139
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
140
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
141
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
142
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
140
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.CardContent, { children: [
|
|
141
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Skeleton, { className: "h-6 w-32 mb-2" }),
|
|
142
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Skeleton, { className: "h-4 w-24 mb-1" }),
|
|
143
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Skeleton, { className: "h-4 w-40" })
|
|
143
144
|
] })
|
|
144
145
|
] });
|
|
145
146
|
}
|
|
146
147
|
if (error) {
|
|
147
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
148
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
149
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
148
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Card, { children: [
|
|
149
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
150
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardTitle, { children: "Subscriptions" }),
|
|
150
151
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-4 w-4 text-muted-foreground" })
|
|
151
152
|
] }),
|
|
152
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
153
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive text-xs/relaxed", children: error }) })
|
|
153
154
|
] });
|
|
154
155
|
}
|
|
155
156
|
const activeSubscriptions = subscriptions.filter(
|
|
156
157
|
(sub) => sub.status === "active" /* ACTIVE */ || sub.status === "trialing" /* TRIALING */
|
|
157
158
|
);
|
|
158
159
|
const primarySubscription = activeSubscriptions[0];
|
|
159
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
160
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
161
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
160
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Card, { className: "cursor-pointer hover:bg-accent/50 transition-colors", onClick: onManageClick, children: [
|
|
161
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
162
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardTitle, { children: "Subscriptions" }),
|
|
162
163
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-4 w-4 text-muted-foreground" })
|
|
163
164
|
] }),
|
|
164
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
165
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardContent, { children: subscriptions.length === 0 ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
165
166
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold text-muted-foreground", children: "No active plan" }),
|
|
166
167
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: "Subscribe to get started" }),
|
|
167
168
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
168
|
-
|
|
169
|
+
_chunkLVE3BJ6Kjs.Button,
|
|
169
170
|
{
|
|
170
171
|
variant: "outline",
|
|
171
172
|
size: "sm",
|
|
@@ -184,7 +185,7 @@ function SubscriptionSummaryCard({
|
|
|
184
185
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
|
|
185
186
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold", children: formatPlanName(primarySubscription) }),
|
|
186
187
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
187
|
-
|
|
188
|
+
_chunkLVE3BJ6Kjs.Badge,
|
|
188
189
|
{
|
|
189
190
|
variant: primarySubscription.cancelAtPeriodEnd ? "secondary" : getStatusBadgeVariant(primarySubscription.status),
|
|
190
191
|
children: primarySubscription.cancelAtPeriodEnd ? "Canceling" : primarySubscription.status
|
|
@@ -226,37 +227,37 @@ function PaymentMethodSummaryCard({
|
|
|
226
227
|
onManageClick
|
|
227
228
|
}) {
|
|
228
229
|
if (loading) {
|
|
229
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
230
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
231
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
230
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Card, { children: [
|
|
231
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
232
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardTitle, { children: "Payment Method" }),
|
|
232
233
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Wallet, { className: "h-4 w-4 text-muted-foreground" })
|
|
233
234
|
] }),
|
|
234
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
235
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
236
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
235
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.CardContent, { children: [
|
|
236
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Skeleton, { className: "h-6 w-32 mb-2" }),
|
|
237
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Skeleton, { className: "h-4 w-24" })
|
|
237
238
|
] })
|
|
238
239
|
] });
|
|
239
240
|
}
|
|
240
241
|
if (error) {
|
|
241
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
242
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
243
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
242
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Card, { children: [
|
|
243
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
244
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardTitle, { children: "Payment Method" }),
|
|
244
245
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Wallet, { className: "h-4 w-4 text-muted-foreground" })
|
|
245
246
|
] }),
|
|
246
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
247
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive text-xs/relaxed", children: error }) })
|
|
247
248
|
] });
|
|
248
249
|
}
|
|
249
250
|
const defaultMethod = paymentMethods.find((pm) => pm.id === defaultPaymentMethodId) || paymentMethods[0];
|
|
250
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
251
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
252
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
251
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Card, { className: "cursor-pointer hover:bg-accent/50 transition-colors", onClick: onManageClick, children: [
|
|
252
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
253
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardTitle, { children: "Payment Method" }),
|
|
253
254
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Wallet, { className: "h-4 w-4 text-muted-foreground" })
|
|
254
255
|
] }),
|
|
255
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
256
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardContent, { children: paymentMethods.length === 0 ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
256
257
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold text-muted-foreground", children: "No payment method" }),
|
|
257
258
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: "Add a card to enable subscriptions" }),
|
|
258
259
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
259
|
-
|
|
260
|
+
_chunkLVE3BJ6Kjs.Button,
|
|
260
261
|
{
|
|
261
262
|
variant: "outline",
|
|
262
263
|
size: "sm",
|
|
@@ -320,7 +321,7 @@ function CustomerInfoCard({ customer, loading, error }) {
|
|
|
320
321
|
e.stopPropagation();
|
|
321
322
|
setPortalLoading(true);
|
|
322
323
|
try {
|
|
323
|
-
const { url } = await
|
|
324
|
+
const { url } = await _chunkIB7DTXWGjs.StripeCustomerService.createPortalSession();
|
|
324
325
|
window.open(url, "_blank");
|
|
325
326
|
} catch (err) {
|
|
326
327
|
console.error("[CustomerInfoCard] Failed to create portal session:", err);
|
|
@@ -329,52 +330,52 @@ function CustomerInfoCard({ customer, loading, error }) {
|
|
|
329
330
|
}
|
|
330
331
|
}, "handlePortalClick");
|
|
331
332
|
if (loading) {
|
|
332
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
333
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
334
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
333
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Card, { children: [
|
|
334
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
335
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardTitle, { children: "Billing Account" }),
|
|
335
336
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.User, { className: "h-4 w-4 text-muted-foreground" })
|
|
336
337
|
] }),
|
|
337
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
338
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
339
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
340
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
338
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.CardContent, { children: [
|
|
339
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Skeleton, { className: "h-6 w-32 mb-2" }),
|
|
340
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Skeleton, { className: "h-4 w-48 mb-1" }),
|
|
341
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Skeleton, { className: "h-4 w-24" })
|
|
341
342
|
] })
|
|
342
343
|
] });
|
|
343
344
|
}
|
|
344
345
|
if (error) {
|
|
345
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
346
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
347
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
346
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Card, { children: [
|
|
347
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
348
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardTitle, { children: "Billing Account" }),
|
|
348
349
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.User, { className: "h-4 w-4 text-muted-foreground" })
|
|
349
350
|
] }),
|
|
350
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
351
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive text-xs/relaxed", children: error }) })
|
|
351
352
|
] });
|
|
352
353
|
}
|
|
353
354
|
if (!customer) {
|
|
354
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
355
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
356
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
355
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Card, { children: [
|
|
356
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
357
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardTitle, { children: "Billing Account" }),
|
|
357
358
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.User, { className: "h-4 w-4 text-muted-foreground" })
|
|
358
359
|
] }),
|
|
359
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
360
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.CardContent, { children: [
|
|
360
361
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold text-muted-foreground", children: "Not set up" }),
|
|
361
362
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: "Billing account will be created when you subscribe" })
|
|
362
363
|
] })
|
|
363
364
|
] });
|
|
364
365
|
}
|
|
365
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
366
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
367
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
366
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Card, { children: [
|
|
367
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
368
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardTitle, { children: "Billing Account" }),
|
|
368
369
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.User, { className: "h-4 w-4 text-muted-foreground" })
|
|
369
370
|
] }),
|
|
370
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
371
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
371
372
|
customer.name && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold", children: customer.name }),
|
|
372
373
|
customer.email && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: customer.email }),
|
|
373
374
|
customer.balance !== void 0 && customer.balance !== 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-sm", children: [
|
|
374
375
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground", children: "Credit Balance: " }),
|
|
375
376
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: customer.balance < 0 ? "text-success" : "text-destructive", children: formatBalance(customer.balance, customer.currency) })
|
|
376
377
|
] }),
|
|
377
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
378
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Button, { variant: "outline", size: "sm", className: "mt-2", onClick: handlePortalClick, disabled: portalLoading, children: [
|
|
378
379
|
portalLoading ? "Loading..." : "Manage in Stripe Portal",
|
|
379
380
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ExternalLink, { className: "h-4 w-4 ms-1" })
|
|
380
381
|
] })
|
|
@@ -418,42 +419,42 @@ function formatAmount(amount, currency) {
|
|
|
418
419
|
_chunk7QVYU63Ejs.__name.call(void 0, formatAmount, "formatAmount");
|
|
419
420
|
function InvoicesSummaryCard({ invoices, loading, error, onViewAllClick }) {
|
|
420
421
|
if (loading) {
|
|
421
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
422
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
423
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
422
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Card, { children: [
|
|
423
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
424
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardTitle, { children: "Recent Invoices" }),
|
|
424
425
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ReceiptIcon, { className: "h-4 w-4 text-muted-foreground" })
|
|
425
426
|
] }),
|
|
426
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
427
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
428
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
429
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
427
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.CardContent, { children: [
|
|
428
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Skeleton, { className: "h-6 w-24 mb-2" }),
|
|
429
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Skeleton, { className: "h-4 w-32 mb-1" }),
|
|
430
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Skeleton, { className: "h-4 w-20" })
|
|
430
431
|
] })
|
|
431
432
|
] });
|
|
432
433
|
}
|
|
433
434
|
if (error) {
|
|
434
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
435
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
436
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
435
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Card, { children: [
|
|
436
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
437
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardTitle, { children: "Recent Invoices" }),
|
|
437
438
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ReceiptIcon, { className: "h-4 w-4 text-muted-foreground" })
|
|
438
439
|
] }),
|
|
439
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
440
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive text-xs/relaxed", children: error }) })
|
|
440
441
|
] });
|
|
441
442
|
}
|
|
442
443
|
const latestInvoice = invoices[0];
|
|
443
444
|
const paidInvoices = invoices.filter((inv) => inv.status === "paid" /* PAID */);
|
|
444
445
|
const openInvoices = invoices.filter((inv) => inv.status === "open" /* OPEN */);
|
|
445
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
446
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
447
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
446
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Card, { className: "cursor-pointer hover:bg-accent/50 transition-colors", onClick: onViewAllClick, children: [
|
|
447
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
448
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardTitle, { children: "Recent Invoices" }),
|
|
448
449
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ReceiptIcon, { className: "h-4 w-4 text-muted-foreground" })
|
|
449
450
|
] }),
|
|
450
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
451
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardContent, { children: invoices.length === 0 ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
451
452
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold text-muted-foreground", children: "No invoices yet" }),
|
|
452
453
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: "Invoices will appear after your first billing cycle" })
|
|
453
454
|
] }) : latestInvoice ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
454
455
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
|
|
455
456
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold", children: formatAmount(latestInvoice.total, latestInvoice.currency) }),
|
|
456
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
457
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Badge, { variant: getStatusBadgeVariant2(latestInvoice.status), children: latestInvoice.status })
|
|
457
458
|
] }),
|
|
458
459
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: latestInvoice.stripeInvoiceNumber || `Invoice from ${formatDate2(latestInvoice.periodStart)}` }),
|
|
459
460
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-4 text-xs text-muted-foreground", children: [
|
|
@@ -493,24 +494,24 @@ function BillingUsageSummaryCard({
|
|
|
493
494
|
onViewDetailsClick
|
|
494
495
|
}) {
|
|
495
496
|
if (loading) {
|
|
496
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
497
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
498
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
497
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Card, { children: [
|
|
498
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
499
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardTitle, { children: "Usage This Month" }),
|
|
499
500
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Activity, { className: "h-4 w-4 text-muted-foreground" })
|
|
500
501
|
] }),
|
|
501
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
502
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
503
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
502
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.CardContent, { children: [
|
|
503
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Skeleton, { className: "h-6 w-24 mb-2" }),
|
|
504
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Skeleton, { className: "h-4 w-32" })
|
|
504
505
|
] })
|
|
505
506
|
] });
|
|
506
507
|
}
|
|
507
508
|
if (error) {
|
|
508
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
509
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
510
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
509
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Card, { children: [
|
|
510
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
511
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardTitle, { children: "Usage This Month" }),
|
|
511
512
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Activity, { className: "h-4 w-4 text-muted-foreground" })
|
|
512
513
|
] }),
|
|
513
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
514
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive text-xs/relaxed", children: error }) })
|
|
514
515
|
] });
|
|
515
516
|
}
|
|
516
517
|
const totalUsage = Object.values(summaries).reduce((acc, summary) => {
|
|
@@ -518,12 +519,12 @@ function BillingUsageSummaryCard({
|
|
|
518
519
|
}, 0);
|
|
519
520
|
const primaryMeter = meters.find((m) => _optionalChain([summaries, 'access', _17 => _17[m.id], 'optionalAccess', _18 => _18.aggregatedValue]));
|
|
520
521
|
const primarySummary = primaryMeter ? summaries[primaryMeter.id] : null;
|
|
521
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
522
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
523
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
522
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Card, { className: "cursor-pointer hover:bg-accent/50 transition-colors", onClick: onViewDetailsClick, children: [
|
|
523
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
524
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardTitle, { children: "Usage This Month" }),
|
|
524
525
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Activity, { className: "h-4 w-4 text-muted-foreground" })
|
|
525
526
|
] }),
|
|
526
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
527
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardContent, { children: meters.length === 0 ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
527
528
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xl font-bold text-muted-foreground", children: "No meters" }),
|
|
528
529
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground", children: "No usage meters are configured" })
|
|
529
530
|
] }) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
@@ -575,7 +576,7 @@ function PaymentMethodForm({ onSuccess, onCancel, isLoading = false }) {
|
|
|
575
576
|
const fetchSetupIntent = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
576
577
|
setLoading(true);
|
|
577
578
|
try {
|
|
578
|
-
const intent = await
|
|
579
|
+
const intent = await _chunkIB7DTXWGjs.StripeCustomerService.createSetupIntent();
|
|
579
580
|
setSetupIntent(intent);
|
|
580
581
|
} catch (err) {
|
|
581
582
|
console.error("[PaymentMethodForm] Failed to create setup intent:", err);
|
|
@@ -613,7 +614,7 @@ function PaymentMethodForm({ onSuccess, onCancel, isLoading = false }) {
|
|
|
613
614
|
return;
|
|
614
615
|
}
|
|
615
616
|
if (setAsDefault && _optionalChain([confirmedSetupIntent, 'optionalAccess', _19 => _19.payment_method])) {
|
|
616
|
-
await
|
|
617
|
+
await _chunkIB7DTXWGjs.StripeCustomerService.setDefaultPaymentMethod({
|
|
617
618
|
paymentMethodId: typeof confirmedSetupIntent.payment_method === "string" ? confirmedSetupIntent.payment_method : confirmedSetupIntent.payment_method.id
|
|
618
619
|
});
|
|
619
620
|
}
|
|
@@ -629,7 +630,7 @@ function PaymentMethodForm({ onSuccess, onCancel, isLoading = false }) {
|
|
|
629
630
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex items-center justify-center py-8", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-muted-foreground", children: "Loading payment form..." }) });
|
|
630
631
|
}
|
|
631
632
|
if (!setupIntent && error) {
|
|
632
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
633
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Alert, { variant: "destructive", className: "bg-red-50 border-red-200", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.AlertDescription, { children: error }) });
|
|
633
634
|
}
|
|
634
635
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { onSubmit: handleSubmit, className: "flex flex-col gap-y-4", children: [
|
|
635
636
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rounded-md border border-gray-300 p-3", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -652,13 +653,13 @@ function PaymentMethodForm({ onSuccess, onCancel, isLoading = false }) {
|
|
|
652
653
|
}
|
|
653
654
|
) }),
|
|
654
655
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-2", children: [
|
|
655
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
656
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
656
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Checkbox, { id: "setAsDefault", checked: setAsDefault, onCheckedChange: (checked) => setSetAsDefault(!!checked) }),
|
|
657
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Label, { htmlFor: "setAsDefault", className: "cursor-pointer font-normal", children: "Set as default payment method" })
|
|
657
658
|
] }),
|
|
658
|
-
error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
659
|
+
error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Alert, { variant: "destructive", className: "bg-red-50 border-red-200", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.AlertDescription, { children: error }) }),
|
|
659
660
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-end gap-x-2", children: [
|
|
660
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
661
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
661
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Button, { type: "button", variant: "outline", onClick: onCancel, disabled: isSubmitting || isLoading, children: "Cancel" }),
|
|
662
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Button, { type: "submit", disabled: !stripe || isSubmitting || isLoading, children: isSubmitting ? "Processing..." : "Add Card" })
|
|
662
663
|
] })
|
|
663
664
|
] });
|
|
664
665
|
}
|
|
@@ -674,10 +675,10 @@ function PaymentMethodEditor({ open, onOpenChange, onSuccess }) {
|
|
|
674
675
|
const handleCancel = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => {
|
|
675
676
|
onOpenChange(false);
|
|
676
677
|
}, "handleCancel");
|
|
677
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
678
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
679
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
680
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
678
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.DialogContent, { className: "max-w-md", children: [
|
|
679
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.DialogHeader, { children: [
|
|
680
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.DialogTitle, { children: "Add Payment Method" }),
|
|
681
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.DialogDescription, { children: "Add a new payment method to your account. Your card information is securely processed by Stripe." })
|
|
681
682
|
] }),
|
|
682
683
|
open && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PaymentMethodForm, { onSuccess: handleSuccess, onCancel: handleCancel })
|
|
683
684
|
] }) });
|
|
@@ -701,7 +702,7 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
701
702
|
_react.useEffect.call(void 0, () => {
|
|
702
703
|
const loadCustomer = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
703
704
|
try {
|
|
704
|
-
const fetchedCustomer = await
|
|
705
|
+
const fetchedCustomer = await _chunkIB7DTXWGjs.StripeCustomerService.getCustomer();
|
|
705
706
|
setCustomer(fetchedCustomer);
|
|
706
707
|
} catch (error) {
|
|
707
708
|
console.error("[PaymentMethodCard] Failed to load customer:", error);
|
|
@@ -718,7 +719,7 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
718
719
|
const handleSetDefault = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
719
720
|
setLoading(true);
|
|
720
721
|
try {
|
|
721
|
-
await
|
|
722
|
+
await _chunkIB7DTXWGjs.StripeCustomerService.setDefaultPaymentMethod({ paymentMethodId: paymentMethod.id });
|
|
722
723
|
onUpdate();
|
|
723
724
|
} catch (error) {
|
|
724
725
|
console.error("[PaymentMethodCard] Failed to set as default:", error);
|
|
@@ -729,7 +730,7 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
729
730
|
const handleRemove = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
730
731
|
setLoading(true);
|
|
731
732
|
try {
|
|
732
|
-
await
|
|
733
|
+
await _chunkIB7DTXWGjs.StripeCustomerService.removePaymentMethod({ paymentMethodId: paymentMethod.id });
|
|
733
734
|
setShowRemoveDialog(false);
|
|
734
735
|
onUpdate();
|
|
735
736
|
} catch (error) {
|
|
@@ -738,16 +739,16 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
738
739
|
}
|
|
739
740
|
}, "handleRemove");
|
|
740
741
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
741
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
742
|
-
isDefault && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
743
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
742
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Card, { className: "relative", children: [
|
|
743
|
+
isDefault && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Badge, { variant: "softGreen", className: "absolute end-2 top-2", children: "Default" }),
|
|
744
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.CardHeader, { className: "flex flex-row items-center justify-between pb-2", children: [
|
|
744
745
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-2", children: [
|
|
745
746
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-2xl", children: brandIcon }),
|
|
746
747
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-medium capitalize", children: brand })
|
|
747
748
|
] }),
|
|
748
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
749
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
750
|
-
|
|
749
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.DropdownMenu, { children: [
|
|
750
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.DropdownMenuTrigger, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
751
|
+
_chunkLVE3BJ6Kjs.Button,
|
|
751
752
|
{
|
|
752
753
|
render: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {}),
|
|
753
754
|
nativeButton: false,
|
|
@@ -758,10 +759,10 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
758
759
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.MoreVertical, { className: "h-4 w-4" })
|
|
759
760
|
}
|
|
760
761
|
) }),
|
|
761
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
762
|
-
!isDefault && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
762
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.DropdownMenuContent, { align: "end", children: [
|
|
763
|
+
!isDefault && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.DropdownMenuItem, { onClick: handleSetDefault, disabled: loading, children: "Set as Default" }),
|
|
763
764
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
764
|
-
|
|
765
|
+
_chunkLVE3BJ6Kjs.DropdownMenuItem,
|
|
765
766
|
{
|
|
766
767
|
onClick: () => setShowRemoveDialog(true),
|
|
767
768
|
disabled: loading,
|
|
@@ -772,7 +773,7 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
772
773
|
] })
|
|
773
774
|
] })
|
|
774
775
|
] }),
|
|
775
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
776
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardContent, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-y-1", children: [
|
|
776
777
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-lg font-semibold", children: [
|
|
777
778
|
"\u2022\u2022\u2022\u2022 ",
|
|
778
779
|
last4
|
|
@@ -785,17 +786,17 @@ function PaymentMethodCard({ paymentMethod, onUpdate }) {
|
|
|
785
786
|
] })
|
|
786
787
|
] }) })
|
|
787
788
|
] }),
|
|
788
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
789
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
790
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
791
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
789
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.AlertDialog, { open: showRemoveDialog, onOpenChange: setShowRemoveDialog, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.AlertDialogContent, { children: [
|
|
790
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.AlertDialogHeader, { children: [
|
|
791
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.AlertDialogTitle, { children: "Remove Payment Method" }),
|
|
792
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.AlertDialogDescription, { children: [
|
|
792
793
|
"Are you sure you want to remove this payment method? This action cannot be undone.",
|
|
793
794
|
isDefault && " This is your default payment method."
|
|
794
795
|
] })
|
|
795
796
|
] }),
|
|
796
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
797
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
798
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
797
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.AlertDialogFooter, { children: [
|
|
798
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.AlertDialogCancel, { disabled: loading, children: "Cancel" }),
|
|
799
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.AlertDialogAction, { onClick: handleRemove, disabled: loading, className: "bg-red-600 hover:bg-red-700", children: loading ? "Removing..." : "Remove" })
|
|
799
800
|
] })
|
|
800
801
|
] }) })
|
|
801
802
|
] });
|
|
@@ -818,7 +819,7 @@ function PaymentMethodsContainer() {
|
|
|
818
819
|
const loadPaymentMethods = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
819
820
|
setLoading(true);
|
|
820
821
|
try {
|
|
821
|
-
const fetchedPaymentMethods = await
|
|
822
|
+
const fetchedPaymentMethods = await _chunkIB7DTXWGjs.StripeCustomerService.listPaymentMethods();
|
|
822
823
|
setPaymentMethods(fetchedPaymentMethods);
|
|
823
824
|
} catch (error) {
|
|
824
825
|
console.error("[PaymentMethodsContainer] Failed to load payment methods:", error);
|
|
@@ -838,14 +839,14 @@ function PaymentMethodsContainer() {
|
|
|
838
839
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-8 w-8" }),
|
|
839
840
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h1", { className: "text-primary text-3xl font-semibold", children: "Payment Methods" })
|
|
840
841
|
] }),
|
|
841
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
842
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Button, { onClick: () => setShowAddPaymentMethod(true), children: "Add Payment Method" })
|
|
842
843
|
] }),
|
|
843
844
|
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: [
|
|
844
845
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-16 w-16 text-muted-foreground" }),
|
|
845
846
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "text-center", children: [
|
|
846
847
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "mb-2 text-sm font-medium", children: "No payment methods" }),
|
|
847
848
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "mb-4 text-muted-foreground", children: "Add a payment method to enable subscriptions and secure checkout." }),
|
|
848
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
849
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Button, { onClick: () => setShowAddPaymentMethod(true), children: "Add Your First Card" })
|
|
849
850
|
] })
|
|
850
851
|
] }),
|
|
851
852
|
paymentMethods.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PaymentMethodsList, { paymentMethods, onUpdate: loadPaymentMethods }),
|
|
@@ -913,7 +914,7 @@ var statusConfig = {
|
|
|
913
914
|
};
|
|
914
915
|
function InvoiceStatusBadge({ status }) {
|
|
915
916
|
const config = statusConfig[status] || statusConfig["draft" /* DRAFT */];
|
|
916
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
917
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Badge, { variant: config.variant, children: config.label });
|
|
917
918
|
}
|
|
918
919
|
_chunk7QVYU63Ejs.__name.call(void 0, InvoiceStatusBadge, "InvoiceStatusBadge");
|
|
919
920
|
|
|
@@ -944,13 +945,13 @@ function InvoiceDetails({
|
|
|
944
945
|
return invoice.stripeInvoiceId.slice(-8);
|
|
945
946
|
}, "getInvoiceNumber");
|
|
946
947
|
const productName = _optionalChain([invoice, 'access', _29 => _29.subscription, 'optionalAccess', _30 => _30.price, 'optionalAccess', _31 => _31.product, 'optionalAccess', _32 => _32.name]) || "Subscription";
|
|
947
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
948
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
949
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
948
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.DialogContent, { className: "max-w-2xl", children: [
|
|
949
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.DialogHeader, { children: [
|
|
950
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.DialogTitle, { children: [
|
|
950
951
|
"Invoice ",
|
|
951
952
|
getInvoiceNumber()
|
|
952
953
|
] }),
|
|
953
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
954
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.DialogDescription, { children: formatDate3(invoice.periodStart) })
|
|
954
955
|
] }),
|
|
955
956
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-6", children: [
|
|
956
957
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-3", children: [
|
|
@@ -988,42 +989,42 @@ function InvoiceDetails({
|
|
|
988
989
|
] }) }),
|
|
989
990
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "tbody", { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "tr", { className: "border-t", children: [
|
|
990
991
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "td", { className: "p-3", children: productName }),
|
|
991
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "td", { className: "p-3 text-end", children:
|
|
992
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "td", { className: "p-3 text-end", children: _chunkLVE3BJ6Kjs.formatCurrency.call(void 0, invoice.subtotal, invoice.currency) })
|
|
992
993
|
] }) })
|
|
993
994
|
] }) })
|
|
994
995
|
] }),
|
|
995
996
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2 border-t pt-4", children: [
|
|
996
997
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between", children: [
|
|
997
998
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: "Subtotal:" }),
|
|
998
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm", children:
|
|
999
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm", children: _chunkLVE3BJ6Kjs.formatCurrency.call(void 0, invoice.subtotal, invoice.currency) })
|
|
999
1000
|
] }),
|
|
1000
1001
|
invoice.tax !== void 0 && invoice.tax > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between", children: [
|
|
1001
1002
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: "Tax:" }),
|
|
1002
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm", children:
|
|
1003
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm", children: _chunkLVE3BJ6Kjs.formatCurrency.call(void 0, invoice.tax, invoice.currency) })
|
|
1003
1004
|
] }),
|
|
1004
1005
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between text-lg font-semibold border-t pt-2", children: [
|
|
1005
1006
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Total:" }),
|
|
1006
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children:
|
|
1007
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: _chunkLVE3BJ6Kjs.formatCurrency.call(void 0, invoice.total, invoice.currency) })
|
|
1007
1008
|
] }),
|
|
1008
1009
|
invoice.amountPaid > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between", children: [
|
|
1009
1010
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: "Amount Paid:" }),
|
|
1010
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm text-success", children:
|
|
1011
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm text-success", children: _chunkLVE3BJ6Kjs.formatCurrency.call(void 0, invoice.amountPaid, invoice.currency) })
|
|
1011
1012
|
] }),
|
|
1012
1013
|
invoice.amountRemaining > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between", children: [
|
|
1013
1014
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: "Amount Due:" }),
|
|
1014
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm text-destructive", children:
|
|
1015
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm text-destructive", children: _chunkLVE3BJ6Kjs.formatCurrency.call(void 0, invoice.amountRemaining, invoice.currency) })
|
|
1015
1016
|
] })
|
|
1016
1017
|
] }),
|
|
1017
1018
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-wrap gap-2 pt-4 border-t", children: [
|
|
1018
|
-
invoice.stripePdfUrl && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1019
|
+
invoice.stripePdfUrl && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Button, { variant: "outline", onClick: handleDownloadPDF, children: [
|
|
1019
1020
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Download, { className: "me-2 h-4 w-4" }),
|
|
1020
1021
|
"Download PDF"
|
|
1021
1022
|
] }),
|
|
1022
|
-
invoice.status === "open" /* OPEN */ && invoice.attempted && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1023
|
+
invoice.status === "open" /* OPEN */ && invoice.attempted && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Button, { variant: "default", onClick: handleRetryPayment, children: [
|
|
1023
1024
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.RefreshCw, { className: "me-2 h-4 w-4" }),
|
|
1024
1025
|
"Retry Payment"
|
|
1025
1026
|
] }),
|
|
1026
|
-
invoice.stripeHostedInvoiceUrl && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1027
|
+
invoice.stripeHostedInvoiceUrl && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Button, { variant: "outline", onClick: handleViewInStripe, children: [
|
|
1027
1028
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ExternalLink, { className: "me-2 h-4 w-4" }),
|
|
1028
1029
|
"View in Stripe"
|
|
1029
1030
|
] })
|
|
@@ -1047,30 +1048,30 @@ function InvoicesList({ invoices, onInvoicesChange }) {
|
|
|
1047
1048
|
return invoice.stripeInvoiceId.slice(-8);
|
|
1048
1049
|
}, "getInvoiceNumber");
|
|
1049
1050
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1050
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border rounded-lg overflow-clip", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1051
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1052
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1053
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1054
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1055
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1056
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1051
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border rounded-lg overflow-clip", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Table, { children: [
|
|
1052
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableHeader, { className: "bg-muted", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.TableRow, { children: [
|
|
1053
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableHead, { children: "Invoice #" }),
|
|
1054
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableHead, { children: "Date" }),
|
|
1055
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableHead, { children: "Status" }),
|
|
1056
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableHead, { className: "text-end", children: "Amount" }),
|
|
1057
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableHead, { children: "Period" })
|
|
1057
1058
|
] }) }),
|
|
1058
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1059
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableBody, { children: invoices.map((invoice) => {
|
|
1059
1060
|
const invoiceNumber = getInvoiceNumber(invoice);
|
|
1060
1061
|
const date = formatDate3(invoice.periodStart);
|
|
1061
|
-
const amount =
|
|
1062
|
+
const amount = _chunkLVE3BJ6Kjs.formatCurrency.call(void 0, invoice.total, invoice.currency);
|
|
1062
1063
|
const period = `${formatDate3(invoice.periodStart)} - ${formatDate3(invoice.periodEnd)}`;
|
|
1063
1064
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1064
|
-
|
|
1065
|
+
_chunkLVE3BJ6Kjs.TableRow,
|
|
1065
1066
|
{
|
|
1066
1067
|
onClick: () => handleRowClick(invoice),
|
|
1067
1068
|
className: "cursor-pointer hover:bg-muted/50",
|
|
1068
1069
|
children: [
|
|
1069
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1070
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1071
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1072
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1073
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1070
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableCell, { className: "font-medium", children: invoiceNumber }),
|
|
1071
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableCell, { className: "text-muted-foreground text-xs", children: date }),
|
|
1072
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableCell, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, InvoiceStatusBadge, { status: invoice.status }) }),
|
|
1073
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableCell, { className: "text-end font-medium", children: amount }),
|
|
1074
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableCell, { className: "text-muted-foreground text-xs", children: period })
|
|
1074
1075
|
]
|
|
1075
1076
|
},
|
|
1076
1077
|
invoice.id
|
|
@@ -1103,7 +1104,7 @@ function InvoicesContainer() {
|
|
|
1103
1104
|
setLoading(true);
|
|
1104
1105
|
try {
|
|
1105
1106
|
const params = statusFilter !== "all" ? { status: statusFilter } : void 0;
|
|
1106
|
-
const data = await
|
|
1107
|
+
const data = await _chunkIB7DTXWGjs.StripeInvoiceService.listInvoices(params);
|
|
1107
1108
|
setInvoices(data);
|
|
1108
1109
|
} catch (error) {
|
|
1109
1110
|
console.error("[InvoicesContainer] Failed to load invoices:", error);
|
|
@@ -1119,12 +1120,12 @@ function InvoicesContainer() {
|
|
|
1119
1120
|
setStatusFilter(value);
|
|
1120
1121
|
}, "handleFilterChange");
|
|
1121
1122
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-4", children: [
|
|
1122
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1123
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1124
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1125
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1126
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1127
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1123
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Tabs, { value: statusFilter, onValueChange: handleFilterChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.TabsList, { children: [
|
|
1124
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TabsTrigger, { value: "all", children: "All" }),
|
|
1125
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TabsTrigger, { value: "paid" /* PAID */, children: "Paid" }),
|
|
1126
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TabsTrigger, { value: "open" /* OPEN */, children: "Open" }),
|
|
1127
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TabsTrigger, { value: "void" /* VOID */, children: "Void" }),
|
|
1128
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TabsTrigger, { value: "uncollectible" /* UNCOLLECTIBLE */, children: "Uncollectible" })
|
|
1128
1129
|
] }) }),
|
|
1129
1130
|
loading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-center py-8 text-muted-foreground", children: "Loading invoices..." }),
|
|
1130
1131
|
!loading && invoices.length === 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "border border-dashed border-gray-300 rounded-lg p-8 text-center", children: [
|
|
@@ -1171,7 +1172,7 @@ function CancelSubscriptionDialog({
|
|
|
1171
1172
|
const onSubmit = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async (_values) => {
|
|
1172
1173
|
setIsSubmitting(true);
|
|
1173
1174
|
try {
|
|
1174
|
-
await
|
|
1175
|
+
await _chunkIB7DTXWGjs.StripeSubscriptionService.cancelSubscription({
|
|
1175
1176
|
id: subscription.id,
|
|
1176
1177
|
cancelImmediately: false
|
|
1177
1178
|
});
|
|
@@ -1184,19 +1185,19 @@ function CancelSubscriptionDialog({
|
|
|
1184
1185
|
}
|
|
1185
1186
|
}, "onSubmit");
|
|
1186
1187
|
const periodEndDate = formatDate3(subscription.currentPeriodEnd);
|
|
1187
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1188
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1189
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1190
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1188
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.DialogContent, { className: "max-w-md", children: [
|
|
1189
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.DialogHeader, { children: [
|
|
1190
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.DialogTitle, { children: "Cancel Subscription" }),
|
|
1191
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.DialogDescription, { children: "Are you sure you want to cancel this subscription? This action cannot be undone." })
|
|
1191
1192
|
] }),
|
|
1192
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1193
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Form, { ...form, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { onSubmit: form.handleSubmit(onSubmit), className: "flex flex-col gap-y-4", children: [
|
|
1193
1194
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "bg-primary/10 border-primary/30 text-foreground rounded-lg border p-3 text-sm", children: [
|
|
1194
1195
|
"Your subscription will remain active until ",
|
|
1195
1196
|
periodEndDate,
|
|
1196
1197
|
". You can continue using the service until then."
|
|
1197
1198
|
] }),
|
|
1198
1199
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1199
|
-
|
|
1200
|
+
_chunkLVE3BJ6Kjs.FormTextarea,
|
|
1200
1201
|
{
|
|
1201
1202
|
form,
|
|
1202
1203
|
id: "reason",
|
|
@@ -1206,8 +1207,8 @@ function CancelSubscriptionDialog({
|
|
|
1206
1207
|
}
|
|
1207
1208
|
),
|
|
1208
1209
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex gap-x-2 justify-end pt-2", children: [
|
|
1209
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1210
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1210
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Button, { type: "button", variant: "outline", onClick: () => onOpenChange(false), disabled: isSubmitting, children: "Keep Subscription" }),
|
|
1211
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Button, { type: "submit", variant: "destructive", disabled: isSubmitting, children: isSubmitting ? "Canceling..." : "Confirm Cancellation" })
|
|
1211
1212
|
] })
|
|
1212
1213
|
] }) })
|
|
1213
1214
|
] }) });
|
|
@@ -1256,7 +1257,7 @@ var cancelingConfig = {
|
|
|
1256
1257
|
};
|
|
1257
1258
|
function SubscriptionStatusBadge({ status, cancelAtPeriodEnd }) {
|
|
1258
1259
|
const config = cancelAtPeriodEnd ? cancelingConfig : statusConfig2[status] || statusConfig2["canceled" /* CANCELED */];
|
|
1259
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1260
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Badge, { variant: config.variant, children: config.label });
|
|
1260
1261
|
}
|
|
1261
1262
|
_chunk7QVYU63Ejs.__name.call(void 0, SubscriptionStatusBadge, "SubscriptionStatusBadge");
|
|
1262
1263
|
|
|
@@ -1283,7 +1284,7 @@ function formatPlanName2(price) {
|
|
|
1283
1284
|
_chunk7QVYU63Ejs.__name.call(void 0, formatPlanName2, "formatPlanName");
|
|
1284
1285
|
function formatBillingAmount(price) {
|
|
1285
1286
|
if (!_optionalChain([price, 'optionalAccess', _37 => _37.unitAmount])) return "N/A";
|
|
1286
|
-
return
|
|
1287
|
+
return _chunkLVE3BJ6Kjs.formatCurrency.call(void 0, price.unitAmount, price.currency);
|
|
1287
1288
|
}
|
|
1288
1289
|
_chunk7QVYU63Ejs.__name.call(void 0, formatBillingAmount, "formatBillingAmount");
|
|
1289
1290
|
function SubscriptionDetails({
|
|
@@ -1298,7 +1299,7 @@ function SubscriptionDetails({
|
|
|
1298
1299
|
const handlePause = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
1299
1300
|
setIsProcessing(true);
|
|
1300
1301
|
try {
|
|
1301
|
-
await
|
|
1302
|
+
await _chunkIB7DTXWGjs.StripeSubscriptionService.pauseSubscription({ subscriptionId: subscription.id });
|
|
1302
1303
|
onSubscriptionChange();
|
|
1303
1304
|
} catch (error) {
|
|
1304
1305
|
console.error("[SubscriptionDetails] Failed to pause subscription:", error);
|
|
@@ -1309,7 +1310,7 @@ function SubscriptionDetails({
|
|
|
1309
1310
|
const handleResume = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
1310
1311
|
setIsProcessing(true);
|
|
1311
1312
|
try {
|
|
1312
|
-
await
|
|
1313
|
+
await _chunkIB7DTXWGjs.StripeSubscriptionService.resumeSubscription({ subscriptionId: subscription.id });
|
|
1313
1314
|
onSubscriptionChange();
|
|
1314
1315
|
} catch (error) {
|
|
1315
1316
|
console.error("[SubscriptionDetails] Failed to resume subscription:", error);
|
|
@@ -1319,7 +1320,7 @@ function SubscriptionDetails({
|
|
|
1319
1320
|
}, "handleResume");
|
|
1320
1321
|
const handleManageViaPortal = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
1321
1322
|
try {
|
|
1322
|
-
const { url } = await
|
|
1323
|
+
const { url } = await _chunkIB7DTXWGjs.StripeCustomerService.createPortalSession();
|
|
1323
1324
|
window.open(url, "_blank");
|
|
1324
1325
|
} catch (error) {
|
|
1325
1326
|
console.error("[SubscriptionDetails] Failed to create portal session:", error);
|
|
@@ -1329,10 +1330,10 @@ function SubscriptionDetails({
|
|
|
1329
1330
|
const canResume = subscription.status === "paused" /* PAUSED */;
|
|
1330
1331
|
const canCancel = subscription.status === "active" /* ACTIVE */ || subscription.status === "trialing" /* TRIALING */ || subscription.status === "paused" /* PAUSED */;
|
|
1331
1332
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1332
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1333
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1334
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1335
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1333
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.DialogContent, { className: "max-w-2xl", children: [
|
|
1334
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.DialogHeader, { children: [
|
|
1335
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.DialogTitle, { children: "Subscription Details" }),
|
|
1336
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.DialogDescription, { children: "View and manage your subscription" })
|
|
1336
1337
|
] }),
|
|
1337
1338
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-6", children: [
|
|
1338
1339
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-3", children: [
|
|
@@ -1374,11 +1375,11 @@ function SubscriptionDetails({
|
|
|
1374
1375
|
"."
|
|
1375
1376
|
] }) }),
|
|
1376
1377
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-wrap gap-2 pt-4 border-t", children: [
|
|
1377
|
-
onChangePlan && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1378
|
-
canPause && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1379
|
-
canResume && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1380
|
-
canCancel && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1381
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1378
|
+
onChangePlan && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Button, { variant: "default", onClick: () => onChangePlan(subscription), children: "Change Plan" }),
|
|
1379
|
+
canPause && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Button, { variant: "outline", onClick: handlePause, disabled: isProcessing, children: isProcessing ? "Pausing..." : "Pause" }),
|
|
1380
|
+
canResume && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Button, { variant: "outline", onClick: handleResume, disabled: isProcessing, children: isProcessing ? "Resuming..." : "Resume" }),
|
|
1381
|
+
canCancel && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Button, { variant: "destructive", onClick: () => setShowCancel(true), children: "Cancel" }),
|
|
1382
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Button, { variant: "outline", onClick: handleManageViaPortal, children: "Manage via Portal" })
|
|
1382
1383
|
] })
|
|
1383
1384
|
] })
|
|
1384
1385
|
] }) }),
|
|
@@ -1425,36 +1426,36 @@ function SubscriptionsList({ subscriptions, onSubscriptionsChange, onChangePlan
|
|
|
1425
1426
|
setSelectedSub(subscription);
|
|
1426
1427
|
}, "handleRowClick");
|
|
1427
1428
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1428
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border rounded-lg overflow-clip", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1429
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1430
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1431
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1432
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1433
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1434
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1429
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border rounded-lg overflow-clip", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Table, { children: [
|
|
1430
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableHeader, { className: "bg-muted", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.TableRow, { children: [
|
|
1431
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableHead, { children: "Status" }),
|
|
1432
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableHead, { children: "Plan" }),
|
|
1433
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableHead, { children: "Period" }),
|
|
1434
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableHead, { className: "text-end", children: "Amount" }),
|
|
1435
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableHead, { className: "text-end", children: "Actions" })
|
|
1435
1436
|
] }) }),
|
|
1436
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1437
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableBody, { children: subscriptions.map((subscription) => {
|
|
1437
1438
|
const price = subscription.price;
|
|
1438
|
-
const amount = _optionalChain([price, 'optionalAccess', _42 => _42.unitAmount]) ?
|
|
1439
|
+
const amount = _optionalChain([price, 'optionalAccess', _42 => _42.unitAmount]) ? _chunkLVE3BJ6Kjs.formatCurrency.call(void 0, price.unitAmount, price.currency) : "0";
|
|
1439
1440
|
const period = `${formatDate3(subscription.currentPeriodStart)} - ${formatDate3(subscription.currentPeriodEnd)}`;
|
|
1440
1441
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1441
|
-
|
|
1442
|
+
_chunkLVE3BJ6Kjs.TableRow,
|
|
1442
1443
|
{
|
|
1443
1444
|
onClick: () => handleRowClick(subscription),
|
|
1444
1445
|
className: "cursor-pointer hover:bg-muted/50",
|
|
1445
1446
|
children: [
|
|
1446
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1447
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableCell, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1447
1448
|
SubscriptionStatusBadge,
|
|
1448
1449
|
{
|
|
1449
1450
|
status: subscription.status,
|
|
1450
1451
|
cancelAtPeriodEnd: subscription.cancelAtPeriodEnd
|
|
1451
1452
|
}
|
|
1452
1453
|
) }),
|
|
1453
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1454
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1455
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1456
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1457
|
-
|
|
1454
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableCell, { className: "font-medium", children: formatPlanName3(price) }),
|
|
1455
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableCell, { className: "text-muted-foreground text-sm", children: period }),
|
|
1456
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableCell, { className: "text-end font-medium", children: amount }),
|
|
1457
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableCell, { className: "text-end", children: (subscription.status === "active" /* ACTIVE */ || subscription.status === "trialing" /* TRIALING */) && onChangePlan && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1458
|
+
_chunkLVE3BJ6Kjs.Button,
|
|
1458
1459
|
{
|
|
1459
1460
|
size: "sm",
|
|
1460
1461
|
variant: "outline",
|
|
@@ -1499,7 +1500,7 @@ function SubscriptionsContainer({ onOpenWizard, hasActiveRecurringSubscription }
|
|
|
1499
1500
|
const loadSubscriptions = _react.useCallback.call(void 0, async () => {
|
|
1500
1501
|
setLoading(true);
|
|
1501
1502
|
try {
|
|
1502
|
-
const fetchedSubscriptions = await
|
|
1503
|
+
const fetchedSubscriptions = await _chunkIB7DTXWGjs.StripeSubscriptionService.listSubscriptions();
|
|
1503
1504
|
setSubscriptions(fetchedSubscriptions);
|
|
1504
1505
|
} catch (error) {
|
|
1505
1506
|
console.error("[SubscriptionsContainer] Failed to load subscriptions:", error);
|
|
@@ -1522,7 +1523,7 @@ function SubscriptionsContainer({ onOpenWizard, hasActiveRecurringSubscription }
|
|
|
1522
1523
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CreditCard, { className: "h-8 w-8" }),
|
|
1523
1524
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h1", { className: "text-primary text-3xl font-semibold", children: "Subscriptions" })
|
|
1524
1525
|
] }),
|
|
1525
|
-
subscriptions.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1526
|
+
subscriptions.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Button, { onClick: () => _optionalChain([onOpenWizard, 'optionalCall', _43 => _43()]), children: hasActiveRecurringSubscription ? "Purchase Add-ons" : "Subscribe to a Plan" })
|
|
1526
1527
|
] }),
|
|
1527
1528
|
criticalSubscriptions.map((subscription) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BillingAlertBanner, { subscription }, subscription.id)),
|
|
1528
1529
|
subscriptions.length === 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col items-center justify-center py-12 space-y-4", children: [
|
|
@@ -1530,7 +1531,7 @@ function SubscriptionsContainer({ onOpenWizard, hasActiveRecurringSubscription }
|
|
|
1530
1531
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "text-center", children: [
|
|
1531
1532
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-sm font-medium mb-2", children: "No Active Subscriptions" }),
|
|
1532
1533
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-muted-foreground mb-6", children: "Choose a subscription plan to get started with our services." }),
|
|
1533
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1534
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Button, { onClick: () => _optionalChain([onOpenWizard, 'optionalCall', _44 => _44()]), children: "Subscribe to a Plan" })
|
|
1534
1535
|
] })
|
|
1535
1536
|
] }),
|
|
1536
1537
|
subscriptions.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -1551,9 +1552,9 @@ function IntervalToggle({ value, onChange, hasMonthly, hasYearly }) {
|
|
|
1551
1552
|
if (!hasMonthly || !hasYearly) {
|
|
1552
1553
|
return null;
|
|
1553
1554
|
}
|
|
1554
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1555
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1556
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1555
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Tabs, { value, onValueChange: (v) => onChange(v), children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.TabsList, { children: [
|
|
1556
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TabsTrigger, { value: "month", children: "Monthly" }),
|
|
1557
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TabsTrigger, { value: "year", children: "Yearly" })
|
|
1557
1558
|
] }) });
|
|
1558
1559
|
}
|
|
1559
1560
|
_chunk7QVYU63Ejs.__name.call(void 0, IntervalToggle, "IntervalToggle");
|
|
@@ -1571,8 +1572,8 @@ function PricingCard({
|
|
|
1571
1572
|
}) {
|
|
1572
1573
|
const description = price.description || price.nickname || "Standard";
|
|
1573
1574
|
const features = price.features || [];
|
|
1574
|
-
const formattedPrice =
|
|
1575
|
-
const interval =
|
|
1575
|
+
const formattedPrice = _chunkLVE3BJ6Kjs.formatCurrency.call(void 0, price.unitAmount, price.currency);
|
|
1576
|
+
const interval = _chunkLVE3BJ6Kjs.formatInterval.call(void 0, price);
|
|
1576
1577
|
const handleKeyDown = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (e) => {
|
|
1577
1578
|
if ((e.key === "Enter" || e.key === " ") && !isDisabled && !isCurrentPlan) {
|
|
1578
1579
|
e.preventDefault();
|
|
@@ -1585,7 +1586,7 @@ function PricingCard({
|
|
|
1585
1586
|
}
|
|
1586
1587
|
}, "handleClick");
|
|
1587
1588
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1588
|
-
|
|
1589
|
+
_chunkLVE3BJ6Kjs.Card,
|
|
1589
1590
|
{
|
|
1590
1591
|
role: "radio",
|
|
1591
1592
|
"aria-checked": isSelected,
|
|
@@ -1593,7 +1594,7 @@ function PricingCard({
|
|
|
1593
1594
|
tabIndex: isDisabled ? -1 : 0,
|
|
1594
1595
|
onKeyDown: handleKeyDown,
|
|
1595
1596
|
onClick: handleClick,
|
|
1596
|
-
className:
|
|
1597
|
+
className: _chunkIB7DTXWGjs.cn.call(void 0,
|
|
1597
1598
|
"relative cursor-pointer transition-all duration-200 flex flex-col h-full",
|
|
1598
1599
|
"focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
1599
1600
|
isCurrentPlan && "bg-muted/30",
|
|
@@ -1603,9 +1604,9 @@ function PricingCard({
|
|
|
1603
1604
|
isLoading && "pointer-events-none"
|
|
1604
1605
|
),
|
|
1605
1606
|
children: [
|
|
1606
|
-
isCurrentPlan && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1607
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1608
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1607
|
+
isCurrentPlan && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Badge, { variant: "secondary", className: "absolute top-2 end-2", children: "Current" }),
|
|
1608
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardHeader, { className: "pb-2", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-sm font-medium", children: description }) }),
|
|
1609
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.CardContent, { className: "pb-4 grow", children: [
|
|
1609
1610
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mb-4", children: [
|
|
1610
1611
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-3xl font-bold", children: formattedPrice }),
|
|
1611
1612
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground ms-1", children: interval })
|
|
@@ -1615,8 +1616,8 @@ function PricingCard({
|
|
|
1615
1616
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm text-muted-foreground", children: feature })
|
|
1616
1617
|
] }, index)) })
|
|
1617
1618
|
] }),
|
|
1618
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1619
|
-
|
|
1619
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardFooter, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1620
|
+
_chunkLVE3BJ6Kjs.Button,
|
|
1620
1621
|
{
|
|
1621
1622
|
variant: isCurrentPlan ? "secondary" : isSelected ? "default" : "outline",
|
|
1622
1623
|
className: "w-full",
|
|
@@ -1644,7 +1645,7 @@ function ProductPricingRow({
|
|
|
1644
1645
|
return null;
|
|
1645
1646
|
}
|
|
1646
1647
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-3", children: [
|
|
1647
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1648
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.SectionHeader, { children: product.name }),
|
|
1648
1649
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1649
1650
|
"div",
|
|
1650
1651
|
{
|
|
@@ -1744,15 +1745,15 @@ function ProductPricingList({
|
|
|
1744
1745
|
_chunk7QVYU63Ejs.__name.call(void 0, ProductPricingList, "ProductPricingList");
|
|
1745
1746
|
function ProductPricingListSkeleton() {
|
|
1746
1747
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "space-y-6", children: [1, 2].map((rowIndex) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-3", children: [
|
|
1747
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1748
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Skeleton, { className: "h-6 w-32" }),
|
|
1748
1749
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4", children: [1, 2, 3].map((cardIndex) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "p-4 rounded-lg border animate-pulse space-y-3", children: [
|
|
1749
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1750
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1750
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Skeleton, { className: "h-6 w-24" }),
|
|
1751
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Skeleton, { className: "h-8 w-32" }),
|
|
1751
1752
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
1752
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1753
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1753
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Skeleton, { className: "h-4 w-full" }),
|
|
1754
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Skeleton, { className: "h-4 w-3/4" })
|
|
1754
1755
|
] }),
|
|
1755
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1756
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Skeleton, { className: "h-10 w-full" })
|
|
1756
1757
|
] }, cardIndex)) })
|
|
1757
1758
|
] }, rowIndex)) });
|
|
1758
1759
|
}
|
|
@@ -1766,18 +1767,18 @@ function ProrationPreview({ preview }) {
|
|
|
1766
1767
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
1767
1768
|
preview.lineItems.map((item, index) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between text-sm", children: [
|
|
1768
1769
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground", children: item.description }),
|
|
1769
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: `font-medium ${item.amount < 0 ? "text-success" : "text-foreground"}`, children:
|
|
1770
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: `font-medium ${item.amount < 0 ? "text-success" : "text-foreground"}`, children: _chunkLVE3BJ6Kjs.formatCurrency.call(void 0, item.amount, preview.currency) })
|
|
1770
1771
|
] }, index)),
|
|
1771
1772
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border-primary/30 mt-2 border-t pt-2", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between font-semibold", children: [
|
|
1772
1773
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-foreground", children: "Net Due Today" }),
|
|
1773
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-foreground", children:
|
|
1774
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-foreground", children: _chunkLVE3BJ6Kjs.formatCurrency.call(void 0, preview.immediateCharge, preview.currency) })
|
|
1774
1775
|
] }) }),
|
|
1775
1776
|
preview.lineItems.length > 0 && preview.lineItems[0].period && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "text-muted-foreground mt-2 text-xs", children: [
|
|
1776
1777
|
"Next invoice on ",
|
|
1777
1778
|
formatDate3(preview.lineItems[0].period.end),
|
|
1778
1779
|
" for",
|
|
1779
1780
|
" ",
|
|
1780
|
-
|
|
1781
|
+
_chunkLVE3BJ6Kjs.formatCurrency.call(void 0, preview.amountDue, preview.currency)
|
|
1781
1782
|
] })
|
|
1782
1783
|
] })
|
|
1783
1784
|
] });
|
|
@@ -1799,16 +1800,16 @@ function SubscriptionConfirmation({ price, isLoading, onConfirm, onCancel }) {
|
|
|
1799
1800
|
productDescription && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-sm text-muted-foreground", children: productDescription })
|
|
1800
1801
|
] }),
|
|
1801
1802
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "text-lg font-semibold", children: [
|
|
1802
|
-
|
|
1803
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-normal text-muted-foreground", children:
|
|
1803
|
+
_chunkLVE3BJ6Kjs.formatCurrency.call(void 0, price.unitAmount, price.currency),
|
|
1804
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-normal text-muted-foreground", children: _chunkLVE3BJ6Kjs.formatInterval.call(void 0, price) })
|
|
1804
1805
|
] }),
|
|
1805
1806
|
features.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "space-y-1", children: features.map((feature, index) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2 text-sm ", children: [
|
|
1806
1807
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Check, { className: "h-4 w-4 text-primary" }),
|
|
1807
1808
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: feature })
|
|
1808
1809
|
] }, index)) }),
|
|
1809
1810
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-end gap-3 pt-2 border-t border-accent/30", children: [
|
|
1810
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1811
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1811
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Button, { variant: "outline", onClick: onCancel, disabled: isLoading, children: "Cancel" }),
|
|
1812
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Button, { onClick: onConfirm, disabled: isLoading, children: isLoading ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1812
1813
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Loader2, { className: "h-4 w-4 animate-spin me-2" }),
|
|
1813
1814
|
"Processing..."
|
|
1814
1815
|
] }) : "Subscribe" })
|
|
@@ -1879,7 +1880,7 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
1879
1880
|
onCloseRef.current = onClose;
|
|
1880
1881
|
const checkPaymentMethod = _react.useCallback.call(void 0, async () => {
|
|
1881
1882
|
try {
|
|
1882
|
-
const methods = await
|
|
1883
|
+
const methods = await _chunkIB7DTXWGjs.StripeCustomerService.listPaymentMethods();
|
|
1883
1884
|
dispatch({ type: "SET_HAS_PAYMENT_METHOD", hasMethod: methods.length > 0 });
|
|
1884
1885
|
} catch (error) {
|
|
1885
1886
|
console.error("[useSubscriptionWizard] Failed to check payment methods:", error);
|
|
@@ -1903,7 +1904,7 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
1903
1904
|
const isTrialUpgrade = _optionalChain([subscription, 'optionalAccess', _55 => _55.status]) === "trialing" /* TRIALING */;
|
|
1904
1905
|
dispatch({ type: "SET_IS_TRIAL_SUBSCRIPTION", isTrial: isTrialUpgrade });
|
|
1905
1906
|
if (isTrialUpgrade && !state.hasPaymentMethod) {
|
|
1906
|
-
const methods = await
|
|
1907
|
+
const methods = await _chunkIB7DTXWGjs.StripeCustomerService.listPaymentMethods();
|
|
1907
1908
|
if (methods.length === 0) {
|
|
1908
1909
|
dispatch({ type: "SET_STEP", step: "payment-method" });
|
|
1909
1910
|
dispatch({
|
|
@@ -1914,7 +1915,7 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
1914
1915
|
}
|
|
1915
1916
|
}
|
|
1916
1917
|
if (subscription && state.selectedPrice.id !== _optionalChain([subscription, 'access', _56 => _56.price, 'optionalAccess', _57 => _57.id])) {
|
|
1917
|
-
const preview = await
|
|
1918
|
+
const preview = await _chunkIB7DTXWGjs.StripeSubscriptionService.getProrationPreview({
|
|
1918
1919
|
subscriptionId: subscription.id,
|
|
1919
1920
|
newPriceId: state.selectedPrice.id
|
|
1920
1921
|
});
|
|
@@ -1939,14 +1940,14 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
1939
1940
|
newPriceId: state.selectedPrice.id,
|
|
1940
1941
|
promotionCode: _optionalChain([state, 'access', _59 => _59.promotionCode, 'optionalAccess', _60 => _60.promotionCodeId])
|
|
1941
1942
|
};
|
|
1942
|
-
await
|
|
1943
|
+
await _chunkIB7DTXWGjs.StripeSubscriptionService.changePlan(changePlanParams);
|
|
1943
1944
|
} else {
|
|
1944
1945
|
const createParams = {
|
|
1945
1946
|
id: _uuid.v4.call(void 0, ),
|
|
1946
1947
|
priceId: state.selectedPrice.id,
|
|
1947
1948
|
promotionCode: _optionalChain([state, 'access', _61 => _61.promotionCode, 'optionalAccess', _62 => _62.promotionCodeId])
|
|
1948
1949
|
};
|
|
1949
|
-
await
|
|
1950
|
+
await _chunkIB7DTXWGjs.StripeSubscriptionService.createSubscription(createParams);
|
|
1950
1951
|
}
|
|
1951
1952
|
onSuccessRef.current();
|
|
1952
1953
|
onCloseRef.current();
|
|
@@ -1980,7 +1981,7 @@ function useSubscriptionWizard({ subscription, onSuccess, onClose }) {
|
|
|
1980
1981
|
dispatch({ type: "SET_VALIDATING_PROMO_CODE", isValidating: true });
|
|
1981
1982
|
dispatch({ type: "SET_PROMO_CODE_ERROR", error: null });
|
|
1982
1983
|
try {
|
|
1983
|
-
const result = await
|
|
1984
|
+
const result = await _chunkIB7DTXWGjs.StripePromotionCodeService.validatePromotionCode({
|
|
1984
1985
|
code,
|
|
1985
1986
|
stripePriceId: _optionalChain([state, 'access', _70 => _70.selectedPrice, 'optionalAccess', _71 => _71.id])
|
|
1986
1987
|
});
|
|
@@ -2087,7 +2088,7 @@ function WizardStepPlanSelection({
|
|
|
2087
2088
|
_react.useEffect.call(void 0, () => {
|
|
2088
2089
|
const loadProducts = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2089
2090
|
try {
|
|
2090
|
-
const fetchedProducts = await
|
|
2091
|
+
const fetchedProducts = await _chunkIB7DTXWGjs.StripeProductService.listProducts({ active: true });
|
|
2091
2092
|
setProducts(fetchedProducts);
|
|
2092
2093
|
} catch (error) {
|
|
2093
2094
|
console.error("[WizardStepPlanSelection] Failed to load products:", error);
|
|
@@ -2138,7 +2139,7 @@ function WizardStepPlanSelection({
|
|
|
2138
2139
|
onSelectPrice: handleSelectPrice
|
|
2139
2140
|
}
|
|
2140
2141
|
),
|
|
2141
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex justify-end pt-4 border-t", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2142
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex justify-end pt-4 border-t", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Button, { onClick: onNext, disabled: !selectedPrice || isProcessing, children: isProcessing ? "Loading..." : "Next: Review" }) })
|
|
2142
2143
|
] });
|
|
2143
2144
|
}
|
|
2144
2145
|
_chunk7QVYU63Ejs.__name.call(void 0, WizardStepPlanSelection, "WizardStepPlanSelection");
|
|
@@ -2199,7 +2200,7 @@ function PromoCodeInput({
|
|
|
2199
2200
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-success text-sm", children: formatDiscount(appliedCode) })
|
|
2200
2201
|
] }),
|
|
2201
2202
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2202
|
-
|
|
2203
|
+
_chunkLVE3BJ6Kjs.Button,
|
|
2203
2204
|
{
|
|
2204
2205
|
variant: "ghost",
|
|
2205
2206
|
size: "sm",
|
|
@@ -2216,7 +2217,7 @@ function PromoCodeInput({
|
|
|
2216
2217
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
|
|
2217
2218
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex gap-2", children: [
|
|
2218
2219
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2219
|
-
|
|
2220
|
+
_chunkLVE3BJ6Kjs.Input,
|
|
2220
2221
|
{
|
|
2221
2222
|
placeholder: "Enter promo code",
|
|
2222
2223
|
value: code,
|
|
@@ -2226,7 +2227,7 @@ function PromoCodeInput({
|
|
|
2226
2227
|
className: "flex-1"
|
|
2227
2228
|
}
|
|
2228
2229
|
),
|
|
2229
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2230
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Button, { variant: "outline", onClick: handleApply, disabled: disabled || isValidating || !code.trim(), children: isValidating ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Loader2, { className: "h-4 w-4 animate-spin" }) : "Apply" })
|
|
2230
2231
|
] }),
|
|
2231
2232
|
error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive text-xs/relaxed", children: error })
|
|
2232
2233
|
] });
|
|
@@ -2291,14 +2292,14 @@ function WizardStepReview({
|
|
|
2291
2292
|
return `${promotionCode.discountValue}% off`;
|
|
2292
2293
|
}
|
|
2293
2294
|
if (promotionCode.discountType === "amount_off" && promotionCode.discountValue) {
|
|
2294
|
-
return `${
|
|
2295
|
+
return `${_chunkLVE3BJ6Kjs.formatCurrency.call(void 0, promotionCode.discountValue, promotionCode.currency || selectedPrice.currency)} off`;
|
|
2295
2296
|
}
|
|
2296
2297
|
return null;
|
|
2297
2298
|
}, "getDiscountDescription");
|
|
2298
2299
|
const discountDescription = getDiscountDescription();
|
|
2299
2300
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-6", children: [
|
|
2300
2301
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "bg-muted/50 rounded-lg p-4 space-y-3", children: [
|
|
2301
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2302
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.SectionHeader, { children: "Selected Plan" }),
|
|
2302
2303
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between items-center", children: [
|
|
2303
2304
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
2304
2305
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "font-medium", children: _optionalChain([selectedPrice, 'access', _92 => _92.product, 'optionalAccess', _93 => _93.name]) }),
|
|
@@ -2306,10 +2307,10 @@ function WizardStepReview({
|
|
|
2306
2307
|
] }),
|
|
2307
2308
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "text-end", children: [
|
|
2308
2309
|
discountedPrice !== null ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
2309
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground line-through", children:
|
|
2310
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-success text-lg font-semibold", children:
|
|
2311
|
-
discountDescription && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2312
|
-
] }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "font-semibold text-lg", children:
|
|
2310
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground line-through", children: _chunkLVE3BJ6Kjs.formatCurrency.call(void 0, selectedPrice.unitAmount || 0, selectedPrice.currency) }),
|
|
2311
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-success text-lg font-semibold", children: _chunkLVE3BJ6Kjs.formatCurrency.call(void 0, discountedPrice, selectedPrice.currency) }),
|
|
2312
|
+
discountDescription && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Badge, { variant: "softGreen", children: discountDescription })
|
|
2313
|
+
] }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "font-semibold text-lg", children: _chunkLVE3BJ6Kjs.formatCurrency.call(void 0, selectedPrice.unitAmount || 0, selectedPrice.currency) }),
|
|
2313
2314
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: formatInterval2(selectedPrice) })
|
|
2314
2315
|
] })
|
|
2315
2316
|
] })
|
|
@@ -2324,9 +2325,9 @@ function WizardStepReview({
|
|
|
2324
2325
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between text-sm", children: [
|
|
2325
2326
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: `${isTrialUpgrade ? "text-warning" : "text-muted-foreground"}`, children: isTrialUpgrade ? "Amount to charge now:" : "Amount due now:" }),
|
|
2326
2327
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: `font-medium ${isTrialUpgrade ? "text-warning" : "text-foreground"}`, children: discountedImmediateCharge !== null ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
2327
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "line-through text-muted-foreground me-2", children:
|
|
2328
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-success", children:
|
|
2329
|
-
] }) :
|
|
2328
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "line-through text-muted-foreground me-2", children: _chunkLVE3BJ6Kjs.formatCurrency.call(void 0, prorationPreview.immediateCharge, prorationPreview.currency) }),
|
|
2329
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-success", children: _chunkLVE3BJ6Kjs.formatCurrency.call(void 0, discountedImmediateCharge, prorationPreview.currency) })
|
|
2330
|
+
] }) : _chunkLVE3BJ6Kjs.formatCurrency.call(void 0, prorationPreview.immediateCharge, prorationPreview.currency) })
|
|
2330
2331
|
] })
|
|
2331
2332
|
]
|
|
2332
2333
|
}
|
|
@@ -2350,15 +2351,15 @@ function WizardStepReview({
|
|
|
2350
2351
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h4", { className: "font-medium", children: "Payment Method" }),
|
|
2351
2352
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: hasPaymentMethod ? "A payment method is on file" : "No payment method on file" })
|
|
2352
2353
|
] }),
|
|
2353
|
-
!hasPaymentMethod && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2354
|
+
!hasPaymentMethod && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Button, { variant: "outline", onClick: onAddPaymentMethod, children: "Add Payment Method" })
|
|
2354
2355
|
] }) }),
|
|
2355
|
-
error && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2356
|
+
error && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Alert, { variant: "destructive", children: [
|
|
2356
2357
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.AlertCircle, { className: "h-4 w-4" }),
|
|
2357
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2358
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.AlertDescription, { children: error })
|
|
2358
2359
|
] }),
|
|
2359
2360
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-between pt-4 border-t", children: [
|
|
2360
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2361
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2361
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Button, { variant: "outline", onClick: onBack, disabled: isProcessing, children: "Back" }),
|
|
2362
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Button, { onClick: hasPaymentMethod ? onConfirm : onAddPaymentMethod, disabled: isProcessing, children: isProcessing ? "Processing..." : hasPaymentMethod ? isChangingPlan ? "Confirm Plan Change" : "Subscribe Now" : "Add Payment Method" })
|
|
2362
2363
|
] })
|
|
2363
2364
|
] });
|
|
2364
2365
|
}
|
|
@@ -2369,7 +2370,7 @@ _chunk7QVYU63Ejs.__name.call(void 0, WizardStepReview, "WizardStepReview");
|
|
|
2369
2370
|
function WizardStepPaymentMethod({ onBack, onSuccess, isProcessing }) {
|
|
2370
2371
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-6", children: [
|
|
2371
2372
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "text-center", children: [
|
|
2372
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2373
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.SectionHeader, { children: "Add Payment Method" }),
|
|
2373
2374
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-muted-foreground", children: "Enter your card details to complete your subscription" })
|
|
2374
2375
|
] }),
|
|
2375
2376
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, PaymentMethodForm, { onSuccess, onCancel: onBack, isLoading: isProcessing })
|
|
@@ -2411,10 +2412,10 @@ function SubscriptionWizard({
|
|
|
2411
2412
|
const isChangePlanMode = !!subscription;
|
|
2412
2413
|
const dialogTitle = subscription ? "Change Subscription Plan" : isPurchasingAddons ? "Purchase Add-ons" : "Subscribe to a Plan";
|
|
2413
2414
|
const dialogDescription = subscription ? "Select a new plan for your subscription" : isPurchasingAddons ? "Select one-time products to purchase" : "Choose a subscription plan to get started";
|
|
2414
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2415
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2416
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2417
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2415
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.DialogContent, { className: "max-w-2xl", children: [
|
|
2416
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.DialogHeader, { children: [
|
|
2417
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.DialogTitle, { children: dialogTitle }),
|
|
2418
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.DialogDescription, { children: dialogDescription })
|
|
2418
2419
|
] }),
|
|
2419
2420
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, WizardProgressIndicator, { currentStep: state.step }),
|
|
2420
2421
|
state.step === "plan-selection" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -2497,15 +2498,15 @@ function UsageSummaryCard({ meter, summary }) {
|
|
|
2497
2498
|
const progressWidth = percentage !== null ? Math.min(percentage, 100) : 0;
|
|
2498
2499
|
const displayName = meter.displayName || meter.eventName;
|
|
2499
2500
|
const hasLimit = limit !== null && limit !== void 0;
|
|
2500
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2501
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2501
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Card, { children: [
|
|
2502
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.CardHeader, { className: "flex flex-row items-center gap-x-3 pb-3", children: [
|
|
2502
2503
|
/* @__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" }) }),
|
|
2503
2504
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col", children: [
|
|
2504
2505
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-sm font-medium", children: displayName }),
|
|
2505
2506
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-muted-foreground text-xs", children: meter.id })
|
|
2506
2507
|
] })
|
|
2507
2508
|
] }),
|
|
2508
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2509
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.CardContent, { className: "flex flex-col gap-y-4", children: [
|
|
2509
2510
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
2510
2511
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-3xl font-bold", children: currentUsage.toLocaleString() }),
|
|
2511
2512
|
hasLimit && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-muted-foreground text-sm", children: [
|
|
@@ -2552,14 +2553,14 @@ function UsageContainer() {
|
|
|
2552
2553
|
const loadUsageData = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2553
2554
|
setLoading(true);
|
|
2554
2555
|
try {
|
|
2555
|
-
const fetchedSubscriptions = await
|
|
2556
|
+
const fetchedSubscriptions = await _chunkIB7DTXWGjs.StripeSubscriptionService.listSubscriptions();
|
|
2556
2557
|
setSubscriptions(fetchedSubscriptions);
|
|
2557
2558
|
const hasMeteredSubscriptions2 = fetchedSubscriptions.some((sub) => _optionalChain([sub, 'access', _99 => _99.price, 'optionalAccess', _100 => _100.recurring, 'optionalAccess', _101 => _101.usageType]) === "metered");
|
|
2558
2559
|
if (!hasMeteredSubscriptions2) {
|
|
2559
2560
|
setLoading(false);
|
|
2560
2561
|
return;
|
|
2561
2562
|
}
|
|
2562
|
-
const fetchedMeters = await
|
|
2563
|
+
const fetchedMeters = await _chunkIB7DTXWGjs.StripeUsageService.listMeters();
|
|
2563
2564
|
setMeters(fetchedMeters);
|
|
2564
2565
|
const summariesMap = {};
|
|
2565
2566
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -2567,7 +2568,7 @@ function UsageContainer() {
|
|
|
2567
2568
|
const endOfMonth = new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59, 999);
|
|
2568
2569
|
for (const meter of fetchedMeters) {
|
|
2569
2570
|
try {
|
|
2570
|
-
const meterSummaries = await
|
|
2571
|
+
const meterSummaries = await _chunkIB7DTXWGjs.StripeUsageService.getMeterSummaries({
|
|
2571
2572
|
meterId: meter.id,
|
|
2572
2573
|
startTime: startOfMonth,
|
|
2573
2574
|
endTime: endOfMonth
|
|
@@ -2632,22 +2633,22 @@ function UsageHistoryTable({ usageRecords }) {
|
|
|
2632
2633
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rounded-lg border p-8 text-center", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-muted-foreground", children: "No usage history available." }) });
|
|
2633
2634
|
}
|
|
2634
2635
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-y-4", children: [
|
|
2635
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2636
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "overflow-clip rounded-lg border", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2637
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2638
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2639
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2640
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2641
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2636
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.SectionHeader, { level: 2, children: "Usage History" }),
|
|
2637
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "overflow-clip rounded-lg border", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Table, { children: [
|
|
2638
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableHeader, { className: "bg-muted", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.TableRow, { children: [
|
|
2639
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableHead, { children: "Date & Time" }),
|
|
2640
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableHead, { children: "Meter Event" }),
|
|
2641
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableHead, { className: "text-end", children: "Quantity" }),
|
|
2642
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableHead, { children: "Event ID" })
|
|
2642
2643
|
] }) }),
|
|
2643
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2644
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableBody, { children: usageRecords.map((record) => {
|
|
2644
2645
|
const dateTime = formatDateTime(record.timestamp);
|
|
2645
2646
|
const quantity = record.quantity.toLocaleString();
|
|
2646
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2647
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2648
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2649
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2650
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2647
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.TableRow, { children: [
|
|
2648
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableCell, { className: "font-medium", children: dateTime }),
|
|
2649
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableCell, { className: "text-muted-foreground", children: record.meterEventName }),
|
|
2650
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableCell, { className: "text-end font-medium", children: quantity }),
|
|
2651
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.TableCell, { className: "text-muted-foreground text-sm tabular-nums", children: record.stripeEventId })
|
|
2651
2652
|
] }, record.id);
|
|
2652
2653
|
}) })
|
|
2653
2654
|
] }) })
|
|
@@ -2658,8 +2659,8 @@ _chunk7QVYU63Ejs.__name.call(void 0, UsageHistoryTable, "UsageHistoryTable");
|
|
|
2658
2659
|
// src/features/billing/components/modals/BillingDetailModal.tsx
|
|
2659
2660
|
|
|
2660
2661
|
function BillingDetailModal({ open, onOpenChange, title, children, className }) {
|
|
2661
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2662
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2662
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.DialogContent, { className: _nullishCoalesce(className, () => ( "max-w-4xl max-h-[90vh] overflow-y-auto")), children: [
|
|
2663
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.DialogHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.DialogTitle, { children: title }) }),
|
|
2663
2664
|
children
|
|
2664
2665
|
] }) });
|
|
2665
2666
|
}
|
|
@@ -2676,7 +2677,7 @@ function BillingAlertBanner({ subscription, onUpdatePayment, onAddPayment }) {
|
|
|
2676
2677
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-destructive text-sm font-medium", children: "Payment Failed" }),
|
|
2677
2678
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-destructive mt-1 text-sm", children: "Your last payment failed. Please update your payment method to avoid service interruption." })
|
|
2678
2679
|
] }),
|
|
2679
|
-
onUpdatePayment && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2680
|
+
onUpdatePayment && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Button, { variant: "outline", size: "sm", onClick: onUpdatePayment, className: "text-destructive border-red-300", children: "Update Payment Method" })
|
|
2680
2681
|
] });
|
|
2681
2682
|
}
|
|
2682
2683
|
if (subscription.status === "trialing" /* TRIALING */ && subscription.trialEnd) {
|
|
@@ -2696,7 +2697,7 @@ function BillingAlertBanner({ subscription, onUpdatePayment, onAddPayment }) {
|
|
|
2696
2697
|
". Add a payment method to continue your subscription."
|
|
2697
2698
|
] })
|
|
2698
2699
|
] }),
|
|
2699
|
-
onAddPayment && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2700
|
+
onAddPayment && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Button, { variant: "outline", size: "sm", onClick: onAddPayment, className: "text-warning border-yellow-300", children: "Add Payment Method" })
|
|
2700
2701
|
] });
|
|
2701
2702
|
}
|
|
2702
2703
|
}
|
|
@@ -2747,7 +2748,7 @@ function BillingDashboardContainer() {
|
|
|
2747
2748
|
setNoCustomerExists(false);
|
|
2748
2749
|
let customer = null;
|
|
2749
2750
|
try {
|
|
2750
|
-
customer = await
|
|
2751
|
+
customer = await _chunkIB7DTXWGjs.StripeCustomerService.getCustomer();
|
|
2751
2752
|
setData((prev) => ({ ...prev, customer }));
|
|
2752
2753
|
setErrors((prev) => ({ ...prev, customer: null }));
|
|
2753
2754
|
setNoCustomerExists(false);
|
|
@@ -2773,7 +2774,7 @@ function BillingDashboardContainer() {
|
|
|
2773
2774
|
}
|
|
2774
2775
|
const fetchSubscriptions = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2775
2776
|
try {
|
|
2776
|
-
const subscriptions2 = await
|
|
2777
|
+
const subscriptions2 = await _chunkIB7DTXWGjs.StripeSubscriptionService.listSubscriptions();
|
|
2777
2778
|
setData((prev) => ({ ...prev, subscriptions: subscriptions2 }));
|
|
2778
2779
|
setErrors((prev) => ({ ...prev, subscriptions: null }));
|
|
2779
2780
|
return subscriptions2;
|
|
@@ -2787,7 +2788,7 @@ function BillingDashboardContainer() {
|
|
|
2787
2788
|
}, "fetchSubscriptions");
|
|
2788
2789
|
const fetchPaymentMethods = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2789
2790
|
try {
|
|
2790
|
-
const paymentMethods = await
|
|
2791
|
+
const paymentMethods = await _chunkIB7DTXWGjs.StripeCustomerService.listPaymentMethods();
|
|
2791
2792
|
setData((prev) => ({ ...prev, paymentMethods }));
|
|
2792
2793
|
setErrors((prev) => ({ ...prev, paymentMethods: null }));
|
|
2793
2794
|
} catch (error) {
|
|
@@ -2799,7 +2800,7 @@ function BillingDashboardContainer() {
|
|
|
2799
2800
|
}, "fetchPaymentMethods");
|
|
2800
2801
|
const fetchInvoices = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2801
2802
|
try {
|
|
2802
|
-
const invoices = await
|
|
2803
|
+
const invoices = await _chunkIB7DTXWGjs.StripeInvoiceService.listInvoices();
|
|
2803
2804
|
setData((prev) => ({ ...prev, invoices }));
|
|
2804
2805
|
setErrors((prev) => ({ ...prev, invoices: null }));
|
|
2805
2806
|
} catch (error) {
|
|
@@ -2822,7 +2823,7 @@ function BillingDashboardContainer() {
|
|
|
2822
2823
|
const handleCreateCustomer = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2823
2824
|
setCreatingCustomer(true);
|
|
2824
2825
|
try {
|
|
2825
|
-
await
|
|
2826
|
+
await _chunkIB7DTXWGjs.StripeCustomerService.createCustomer();
|
|
2826
2827
|
setNoCustomerExists(false);
|
|
2827
2828
|
await fetchAllData();
|
|
2828
2829
|
} catch (error) {
|
|
@@ -2834,7 +2835,7 @@ function BillingDashboardContainer() {
|
|
|
2834
2835
|
}, "handleCreateCustomer");
|
|
2835
2836
|
const fetchUsageData = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
2836
2837
|
try {
|
|
2837
|
-
const meters = await
|
|
2838
|
+
const meters = await _chunkIB7DTXWGjs.StripeUsageService.listMeters();
|
|
2838
2839
|
setData((prev) => ({ ...prev, meters }));
|
|
2839
2840
|
const summariesMap = {};
|
|
2840
2841
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -2842,7 +2843,7 @@ function BillingDashboardContainer() {
|
|
|
2842
2843
|
const endOfMonth = new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59, 999);
|
|
2843
2844
|
for (const meter of meters) {
|
|
2844
2845
|
try {
|
|
2845
|
-
const meterSummaries = await
|
|
2846
|
+
const meterSummaries = await _chunkIB7DTXWGjs.StripeUsageService.getMeterSummaries({
|
|
2846
2847
|
meterId: meter.id,
|
|
2847
2848
|
startTime: startOfMonth,
|
|
2848
2849
|
endTime: endOfMonth
|
|
@@ -2920,18 +2921,18 @@ function BillingDashboardContainer() {
|
|
|
2920
2921
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Wallet, { className: "h-8 w-8" }),
|
|
2921
2922
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h1", { className: "text-primary text-3xl font-semibold", children: "Billing" })
|
|
2922
2923
|
] }),
|
|
2923
|
-
isInitialLoading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2924
|
-
noCustomerExists && !isInitialLoading && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2925
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2924
|
+
isInitialLoading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Card, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.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" }) }) }),
|
|
2925
|
+
noCustomerExists && !isInitialLoading && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Card, { children: [
|
|
2926
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.CardHeader, { className: "text-center", children: [
|
|
2926
2927
|
/* @__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" }) }),
|
|
2927
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2928
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2928
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardTitle, { children: "Set Up Billing" }),
|
|
2929
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardDescription, { children: "Your company doesn't have a billing account yet. Set one up to manage subscriptions, payment methods, and view invoices." })
|
|
2929
2930
|
] }),
|
|
2930
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2931
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardContent, { className: "flex justify-center pb-8", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Button, { onClick: handleCreateCustomer, disabled: creatingCustomer, size: "lg", children: creatingCustomer ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
2931
2932
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Loader2, { className: "me-2 h-4 w-4 animate-spin" }),
|
|
2932
2933
|
"Setting up..."
|
|
2933
2934
|
] }) : "Set Up Billing Account" }) }),
|
|
2934
|
-
errors.customer && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2935
|
+
errors.customer && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.CardContent, { className: "pt-0", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-center text-destructive text-xs/relaxed", children: errors.customer }) })
|
|
2935
2936
|
] }),
|
|
2936
2937
|
!noCustomerExists && !isInitialLoading && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
2937
2938
|
criticalSubscriptions.map((subscription) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -3073,7 +3074,7 @@ function getStripePromise(publishableKey) {
|
|
|
3073
3074
|
}
|
|
3074
3075
|
_chunk7QVYU63Ejs.__name.call(void 0, getStripePromise, "getStripePromise");
|
|
3075
3076
|
function StripeProvider({ children }) {
|
|
3076
|
-
const publishableKey =
|
|
3077
|
+
const publishableKey = _chunkXH4IURUDjs.getStripePublishableKey.call(void 0, );
|
|
3077
3078
|
const stripePromise = _react.useMemo.call(void 0, () => getStripePromise(publishableKey), [publishableKey]);
|
|
3078
3079
|
const options = _react.useMemo.call(void 0, () => ({}), []);
|
|
3079
3080
|
if (!publishableKey) {
|
|
@@ -3083,7 +3084,7 @@ function StripeProvider({ children }) {
|
|
|
3083
3084
|
}
|
|
3084
3085
|
_chunk7QVYU63Ejs.__name.call(void 0, StripeProvider, "StripeProvider");
|
|
3085
3086
|
function isStripeConfigured() {
|
|
3086
|
-
return !!
|
|
3087
|
+
return !!_chunkXH4IURUDjs.getStripePublishableKey.call(void 0, );
|
|
3087
3088
|
}
|
|
3088
3089
|
_chunk7QVYU63Ejs.__name.call(void 0, isStripeConfigured, "isStripeConfigured");
|
|
3089
3090
|
|
|
@@ -3103,12 +3104,12 @@ function PriceArchiver({ price }) {
|
|
|
3103
3104
|
const isArchived = !price.active;
|
|
3104
3105
|
const scope = isArchived ? "restore" : "archive";
|
|
3105
3106
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
3106
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3107
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Button, { variant: "outline", size: "sm", onClick: () => setOpen(true), children: [
|
|
3107
3108
|
isArchived ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.RotateCcwIcon, {}) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ArchiveIcon, {}),
|
|
3108
3109
|
t(`billing.admin.prices.${scope}.confirm`)
|
|
3109
3110
|
] }),
|
|
3110
3111
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3111
|
-
|
|
3112
|
+
_chunkLVE3BJ6Kjs.ConfirmDialog,
|
|
3112
3113
|
{
|
|
3113
3114
|
open,
|
|
3114
3115
|
onOpenChange: setOpen,
|
|
@@ -3122,7 +3123,7 @@ function PriceArchiver({ price }) {
|
|
|
3122
3123
|
if (isArchived) await restorePrice(price.id);
|
|
3123
3124
|
else await archivePrice(price.id);
|
|
3124
3125
|
} catch (error) {
|
|
3125
|
-
|
|
3126
|
+
_chunkLVE3BJ6Kjs.errorToast.call(void 0, { title: t(`billing.admin.prices.${scope}.title`), error });
|
|
3126
3127
|
throw error;
|
|
3127
3128
|
}
|
|
3128
3129
|
}
|
|
@@ -3144,6 +3145,7 @@ _chunk7QVYU63Ejs.__name.call(void 0, PriceArchiver, "PriceArchiver");
|
|
|
3144
3145
|
function PriceEditorInternal({
|
|
3145
3146
|
productId,
|
|
3146
3147
|
price,
|
|
3148
|
+
seed,
|
|
3147
3149
|
propagateChanges,
|
|
3148
3150
|
onSuccess,
|
|
3149
3151
|
trigger,
|
|
@@ -3153,14 +3155,14 @@ function PriceEditorInternal({
|
|
|
3153
3155
|
onDialogOpenChange
|
|
3154
3156
|
}) {
|
|
3155
3157
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
3156
|
-
const router =
|
|
3158
|
+
const router = _chunkXH4IURUDjs.useI18nRouter.call(void 0, );
|
|
3157
3159
|
const { createPrice, updatePrice, productId: contextProductId } = usePriceContext();
|
|
3158
3160
|
const [allFeatures, setAllFeatures] = _react.useState.call(void 0, []);
|
|
3159
3161
|
const isEdit = !!price;
|
|
3160
3162
|
const targetProductId = _nullishCoalesce(_nullishCoalesce(productId, () => ( _optionalChain([price, 'optionalAccess', _117 => _117.product, 'optionalAccess', _118 => _118.id]))), () => ( contextProductId));
|
|
3161
3163
|
_react.useEffect.call(void 0, () => {
|
|
3162
3164
|
const fetchFeatures = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async () => {
|
|
3163
|
-
setAllFeatures(await
|
|
3165
|
+
setAllFeatures(await _chunkIB7DTXWGjs.FeatureService.findMany({}));
|
|
3164
3166
|
}, "fetchFeatures");
|
|
3165
3167
|
void fetchFeatures();
|
|
3166
3168
|
}, []);
|
|
@@ -3207,26 +3209,74 @@ function PriceEditorInternal({
|
|
|
3207
3209
|
}),
|
|
3208
3210
|
[t]
|
|
3209
3211
|
);
|
|
3212
|
+
const resolvePlatformFeatures = _react.useCallback.call(void 0,
|
|
3213
|
+
(names) => {
|
|
3214
|
+
const ids = [];
|
|
3215
|
+
const unknown = [];
|
|
3216
|
+
for (const name of _nullishCoalesce(names, () => ( []))) {
|
|
3217
|
+
const match = allFeatures.find((feature) => feature.name === name);
|
|
3218
|
+
if (match) ids.push(match.id);
|
|
3219
|
+
else unknown.push(name);
|
|
3220
|
+
}
|
|
3221
|
+
return { ids, unknown };
|
|
3222
|
+
},
|
|
3223
|
+
[allFeatures]
|
|
3224
|
+
);
|
|
3210
3225
|
const getDefaultValues = _react.useCallback.call(void 0, () => {
|
|
3211
3226
|
const coreFeatureIds = allFeatures.filter((feature) => feature.isCore).map((feature) => feature.id);
|
|
3227
|
+
if (!price && seed) {
|
|
3228
|
+
return {
|
|
3229
|
+
unitAmount: seed.unitAmount / 100,
|
|
3230
|
+
currency: seed.currency,
|
|
3231
|
+
interval: seed.interval,
|
|
3232
|
+
intervalCount: _nullishCoalesce(seed.intervalCount, () => ( 1)),
|
|
3233
|
+
usageType: _nullishCoalesce(seed.usageType, () => ( "licensed")),
|
|
3234
|
+
nickname: _nullishCoalesce(seed.nickname, () => ( "")),
|
|
3235
|
+
isTrial: _nullishCoalesce(seed.isTrial, () => ( false)),
|
|
3236
|
+
description: _nullishCoalesce(seed.description, () => ( "")),
|
|
3237
|
+
features: _nullishCoalesce(seed.features, () => ( [])),
|
|
3238
|
+
// `.toString()`, for the same reason the schema keeps the token
|
|
3239
|
+
// pipeline string-based: a seeded `0` must survive as "0" and not be
|
|
3240
|
+
// dropped as falsy.
|
|
3241
|
+
token: _nullishCoalesce(_optionalChain([seed, 'access', _119 => _119.token, 'optionalAccess', _120 => _120.toString, 'call', _121 => _121()]), () => ( "")),
|
|
3242
|
+
featureIds: [.../* @__PURE__ */ new Set([...resolvePlatformFeatures(seed.platformFeatures).ids, ...coreFeatureIds])]
|
|
3243
|
+
};
|
|
3244
|
+
}
|
|
3212
3245
|
return {
|
|
3213
|
-
unitAmount: _optionalChain([price, 'optionalAccess',
|
|
3214
|
-
currency: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3215
|
-
interval: _optionalChain([price, 'optionalAccess',
|
|
3216
|
-
intervalCount: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3217
|
-
usageType: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3218
|
-
nickname: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3219
|
-
isTrial: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3220
|
-
description: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3221
|
-
features: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3222
|
-
token: _nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3223
|
-
featureIds: [.../* @__PURE__ */ new Set([..._nullishCoalesce(_optionalChain([price, 'optionalAccess',
|
|
3246
|
+
unitAmount: _optionalChain([price, 'optionalAccess', _122 => _122.unitAmount]) ? price.unitAmount / 100 : 0,
|
|
3247
|
+
currency: _nullishCoalesce(_optionalChain([price, 'optionalAccess', _123 => _123.currency]), () => ( "usd")),
|
|
3248
|
+
interval: _optionalChain([price, 'optionalAccess', _124 => _124.priceType]) === "one_time" ? "one_time" : _nullishCoalesce(_optionalChain([price, 'optionalAccess', _125 => _125.recurring, 'optionalAccess', _126 => _126.interval]), () => ( "month")),
|
|
3249
|
+
intervalCount: _nullishCoalesce(_optionalChain([price, 'optionalAccess', _127 => _127.recurring, 'optionalAccess', _128 => _128.intervalCount]), () => ( 1)),
|
|
3250
|
+
usageType: _nullishCoalesce(_optionalChain([price, 'optionalAccess', _129 => _129.recurring, 'optionalAccess', _130 => _130.usageType]), () => ( "licensed")),
|
|
3251
|
+
nickname: _nullishCoalesce(_optionalChain([price, 'optionalAccess', _131 => _131.nickname]), () => ( "")),
|
|
3252
|
+
isTrial: _nullishCoalesce(_optionalChain([price, 'optionalAccess', _132 => _132.isTrial]), () => ( false)),
|
|
3253
|
+
description: _nullishCoalesce(_optionalChain([price, 'optionalAccess', _133 => _133.description]), () => ( "")),
|
|
3254
|
+
features: _nullishCoalesce(_optionalChain([price, 'optionalAccess', _134 => _134.features]), () => ( [])),
|
|
3255
|
+
token: _nullishCoalesce(_optionalChain([price, 'optionalAccess', _135 => _135.token, 'optionalAccess', _136 => _136.toString, 'call', _137 => _137()]), () => ( "")),
|
|
3256
|
+
featureIds: [.../* @__PURE__ */ new Set([..._nullishCoalesce(_optionalChain([price, 'optionalAccess', _138 => _138.priceFeatures, 'optionalAccess', _139 => _139.map, 'call', _140 => _140((f) => f.id)]), () => ( [])), ...coreFeatureIds])]
|
|
3224
3257
|
};
|
|
3225
|
-
}, [price, allFeatures]);
|
|
3258
|
+
}, [price, seed, allFeatures, resolvePlatformFeatures]);
|
|
3226
3259
|
const form = _reacthookform.useForm.call(void 0, {
|
|
3227
3260
|
resolver: _zod.zodResolver.call(void 0, formSchema2),
|
|
3228
3261
|
defaultValues: getDefaultValues()
|
|
3229
3262
|
});
|
|
3263
|
+
const hasCaughtUpWithFeatures = _react.useRef.call(void 0, false);
|
|
3264
|
+
_react.useEffect.call(void 0, () => {
|
|
3265
|
+
if (isEdit || hasCaughtUpWithFeatures.current || allFeatures.length === 0) return;
|
|
3266
|
+
hasCaughtUpWithFeatures.current = true;
|
|
3267
|
+
if (form.formState.isDirty) return;
|
|
3268
|
+
form.reset(getDefaultValues());
|
|
3269
|
+
}, [allFeatures, isEdit, form, getDefaultValues]);
|
|
3270
|
+
const warnedUnknownFor = _react.useRef.call(void 0, void 0);
|
|
3271
|
+
_react.useEffect.call(void 0, () => {
|
|
3272
|
+
if (isEdit || !seed || allFeatures.length === 0) return;
|
|
3273
|
+
const fingerprint = JSON.stringify(_nullishCoalesce(seed.platformFeatures, () => ( [])));
|
|
3274
|
+
if (warnedUnknownFor.current === fingerprint) return;
|
|
3275
|
+
warnedUnknownFor.current = fingerprint;
|
|
3276
|
+
const { unknown } = resolvePlatformFeatures(seed.platformFeatures);
|
|
3277
|
+
if (unknown.length > 0)
|
|
3278
|
+
_chunkIB7DTXWGjs.showToast.call(void 0, t("billing.admin.prices.import.warnings.unknownFeatures", { features: unknown.join(", ") }));
|
|
3279
|
+
}, [seed, isEdit, allFeatures, resolvePlatformFeatures, t]);
|
|
3230
3280
|
const watchInterval = form.watch("interval");
|
|
3231
3281
|
const isRecurring = watchInterval !== "one_time";
|
|
3232
3282
|
const currencyOptions = [
|
|
@@ -3246,13 +3296,13 @@ function PriceEditorInternal({
|
|
|
3246
3296
|
{ id: "metered", text: t("billing.admin.prices.usage.metered") }
|
|
3247
3297
|
];
|
|
3248
3298
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3249
|
-
|
|
3299
|
+
_chunkLVE3BJ6Kjs.EditorSheet,
|
|
3250
3300
|
{
|
|
3251
3301
|
form,
|
|
3252
3302
|
entityType: t("billing.admin.prices.entity"),
|
|
3253
3303
|
entityName: price ? priceLabel(price) : void 0,
|
|
3254
3304
|
isEdit,
|
|
3255
|
-
module:
|
|
3305
|
+
module: _chunkIB7DTXWGjs.Modules.StripePrice,
|
|
3256
3306
|
size: "lg",
|
|
3257
3307
|
propagateChanges,
|
|
3258
3308
|
onSuccess,
|
|
@@ -3301,13 +3351,13 @@ function PriceEditorInternal({
|
|
|
3301
3351
|
dialogOpen,
|
|
3302
3352
|
onDialogOpenChange,
|
|
3303
3353
|
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-y-4", children: [
|
|
3304
|
-
isEdit && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3305
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3306
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3354
|
+
isEdit && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Alert, { children: [
|
|
3355
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.AlertTitle, { children: t("billing.admin.prices.immutability.title") }),
|
|
3356
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.AlertDescription, { children: t("billing.admin.prices.immutability.description") })
|
|
3307
3357
|
] }),
|
|
3308
3358
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid grid-cols-2 gap-x-4", children: [
|
|
3309
3359
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3310
|
-
|
|
3360
|
+
_chunkLVE3BJ6Kjs.FormInput,
|
|
3311
3361
|
{
|
|
3312
3362
|
form,
|
|
3313
3363
|
id: "unitAmount",
|
|
@@ -3319,7 +3369,7 @@ function PriceEditorInternal({
|
|
|
3319
3369
|
}
|
|
3320
3370
|
),
|
|
3321
3371
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3322
|
-
|
|
3372
|
+
_chunkLVE3BJ6Kjs.FormSelect,
|
|
3323
3373
|
{
|
|
3324
3374
|
form,
|
|
3325
3375
|
id: "currency",
|
|
@@ -3330,7 +3380,7 @@ function PriceEditorInternal({
|
|
|
3330
3380
|
)
|
|
3331
3381
|
] }),
|
|
3332
3382
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3333
|
-
|
|
3383
|
+
_chunkLVE3BJ6Kjs.FormSelect,
|
|
3334
3384
|
{
|
|
3335
3385
|
form,
|
|
3336
3386
|
id: "interval",
|
|
@@ -3341,7 +3391,7 @@ function PriceEditorInternal({
|
|
|
3341
3391
|
),
|
|
3342
3392
|
isRecurring && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid grid-cols-2 gap-x-4", children: [
|
|
3343
3393
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3344
|
-
|
|
3394
|
+
_chunkLVE3BJ6Kjs.FormInput,
|
|
3345
3395
|
{
|
|
3346
3396
|
form,
|
|
3347
3397
|
id: "intervalCount",
|
|
@@ -3352,7 +3402,7 @@ function PriceEditorInternal({
|
|
|
3352
3402
|
}
|
|
3353
3403
|
),
|
|
3354
3404
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3355
|
-
|
|
3405
|
+
_chunkLVE3BJ6Kjs.FormSelect,
|
|
3356
3406
|
{
|
|
3357
3407
|
form,
|
|
3358
3408
|
id: "usageType",
|
|
@@ -3363,7 +3413,7 @@ function PriceEditorInternal({
|
|
|
3363
3413
|
)
|
|
3364
3414
|
] }),
|
|
3365
3415
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3366
|
-
|
|
3416
|
+
_chunkLVE3BJ6Kjs.FormInput,
|
|
3367
3417
|
{
|
|
3368
3418
|
form,
|
|
3369
3419
|
id: "nickname",
|
|
@@ -3372,7 +3422,7 @@ function PriceEditorInternal({
|
|
|
3372
3422
|
}
|
|
3373
3423
|
),
|
|
3374
3424
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3375
|
-
|
|
3425
|
+
_chunkLVE3BJ6Kjs.FormTextarea,
|
|
3376
3426
|
{
|
|
3377
3427
|
form,
|
|
3378
3428
|
id: "description",
|
|
@@ -3382,7 +3432,7 @@ function PriceEditorInternal({
|
|
|
3382
3432
|
}
|
|
3383
3433
|
),
|
|
3384
3434
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3385
|
-
|
|
3435
|
+
_chunkLVE3BJ6Kjs.FormInput,
|
|
3386
3436
|
{
|
|
3387
3437
|
form,
|
|
3388
3438
|
id: "token",
|
|
@@ -3392,10 +3442,10 @@ function PriceEditorInternal({
|
|
|
3392
3442
|
}
|
|
3393
3443
|
),
|
|
3394
3444
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-y-2", children: [
|
|
3395
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3445
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.FieldLabel, { children: t("billing.admin.prices.fields.features") }),
|
|
3396
3446
|
form.watch("features").map((_, index) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex gap-2", children: [
|
|
3397
3447
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3398
|
-
|
|
3448
|
+
_chunkLVE3BJ6Kjs.Input,
|
|
3399
3449
|
{
|
|
3400
3450
|
...form.register(`features.${index}`),
|
|
3401
3451
|
placeholder: t("billing.admin.prices.placeholders.feature", { index: index + 1 }),
|
|
@@ -3403,7 +3453,7 @@ function PriceEditorInternal({
|
|
|
3403
3453
|
}
|
|
3404
3454
|
),
|
|
3405
3455
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3406
|
-
|
|
3456
|
+
_chunkLVE3BJ6Kjs.Button,
|
|
3407
3457
|
{
|
|
3408
3458
|
type: "button",
|
|
3409
3459
|
variant: "outline",
|
|
@@ -3418,7 +3468,7 @@ function PriceEditorInternal({
|
|
|
3418
3468
|
)
|
|
3419
3469
|
] }, index)),
|
|
3420
3470
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3421
|
-
|
|
3471
|
+
_chunkLVE3BJ6Kjs.Button,
|
|
3422
3472
|
{
|
|
3423
3473
|
type: "button",
|
|
3424
3474
|
variant: "outline",
|
|
@@ -3433,12 +3483,12 @@ function PriceEditorInternal({
|
|
|
3433
3483
|
)
|
|
3434
3484
|
] }),
|
|
3435
3485
|
isRecurring && allFeatures.length > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-y-2", children: [
|
|
3436
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3486
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.FieldLabel, { children: t("billing.admin.prices.fields.platformFeatures") }),
|
|
3437
3487
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex max-h-48 flex-col gap-y-2 overflow-y-auto rounded-md border p-4", children: allFeatures.map((feature) => {
|
|
3438
3488
|
const isChecked = form.watch("featureIds").includes(feature.id);
|
|
3439
3489
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-x-2", children: [
|
|
3440
3490
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3441
|
-
|
|
3491
|
+
_chunkLVE3BJ6Kjs.Checkbox,
|
|
3442
3492
|
{
|
|
3443
3493
|
id: `feature-${feature.id}`,
|
|
3444
3494
|
checked: isChecked,
|
|
@@ -3454,13 +3504,13 @@ function PriceEditorInternal({
|
|
|
3454
3504
|
}
|
|
3455
3505
|
}
|
|
3456
3506
|
),
|
|
3457
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3507
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.FieldLabel, { htmlFor: `feature-${feature.id}`, children: feature.name }),
|
|
3458
3508
|
feature.isCore && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-muted-foreground text-xs", children: t("billing.admin.prices.help.core") })
|
|
3459
3509
|
] }, feature.id);
|
|
3460
3510
|
}) })
|
|
3461
3511
|
] }),
|
|
3462
3512
|
isRecurring && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3463
|
-
|
|
3513
|
+
_chunkLVE3BJ6Kjs.FormCheckbox,
|
|
3464
3514
|
{
|
|
3465
3515
|
form,
|
|
3466
3516
|
id: "isTrial",
|
|
@@ -3503,7 +3553,7 @@ var defaultContextValue = {
|
|
|
3503
3553
|
productId: void 0
|
|
3504
3554
|
};
|
|
3505
3555
|
function priceLabel(price) {
|
|
3506
|
-
return _nullishCoalesce(price.nickname, () => ( `${
|
|
3556
|
+
return _nullishCoalesce(price.nickname, () => ( `${_chunkLVE3BJ6Kjs.formatCurrency.call(void 0, price.unitAmount, price.currency)} ${_chunkLVE3BJ6Kjs.formatInterval.call(void 0, price)}`.trim()));
|
|
3507
3557
|
}
|
|
3508
3558
|
_chunk7QVYU63Ejs.__name.call(void 0, priceLabel, "priceLabel");
|
|
3509
3559
|
var PriceProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({
|
|
@@ -3513,21 +3563,21 @@ var PriceProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({
|
|
|
3513
3563
|
productId: productIdProp
|
|
3514
3564
|
}) => {
|
|
3515
3565
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
3516
|
-
const generateUrl =
|
|
3517
|
-
const { hasRole } =
|
|
3566
|
+
const generateUrl = _chunkLVE3BJ6Kjs.usePageUrlGenerator.call(void 0, );
|
|
3567
|
+
const { hasRole } = _chunkLVE3BJ6Kjs.useCurrentUserContext.call(void 0, );
|
|
3518
3568
|
const [price, setPrice] = _react.useState.call(void 0,
|
|
3519
|
-
dehydratedPrice ?
|
|
3569
|
+
dehydratedPrice ? _chunkIB7DTXWGjs.rehydrate.call(void 0, _chunkIB7DTXWGjs.Modules.StripePrice, dehydratedPrice) : void 0
|
|
3520
3570
|
);
|
|
3521
3571
|
const [priceVersion, setPriceVersion] = _react.useState.call(void 0, 0);
|
|
3522
3572
|
const refreshPrices = _react.useCallback.call(void 0, () => setPriceVersion((value2) => value2 + 1), []);
|
|
3523
|
-
const productId = _nullishCoalesce(productIdProp, () => ( _optionalChain([price, 'optionalAccess',
|
|
3573
|
+
const productId = _nullishCoalesce(productIdProp, () => ( _optionalChain([price, 'optionalAccess', _141 => _141.product, 'optionalAccess', _142 => _142.id])));
|
|
3524
3574
|
const reloadPrice = _react.useCallback.call(void 0, async () => {
|
|
3525
|
-
if (!_optionalChain([price, 'optionalAccess',
|
|
3526
|
-
setPrice(await
|
|
3527
|
-
}, [_optionalChain([price, 'optionalAccess',
|
|
3575
|
+
if (!_optionalChain([price, 'optionalAccess', _143 => _143.id])) return;
|
|
3576
|
+
setPrice(await _chunkIB7DTXWGjs.StripePriceService.getPrice({ id: price.id }));
|
|
3577
|
+
}, [_optionalChain([price, 'optionalAccess', _144 => _144.id])]);
|
|
3528
3578
|
const createPrice = _react.useCallback.call(void 0,
|
|
3529
3579
|
async (input) => {
|
|
3530
|
-
const saved = await
|
|
3580
|
+
const saved = await _chunkIB7DTXWGjs.StripePriceService.createPrice(input);
|
|
3531
3581
|
refreshPrices();
|
|
3532
3582
|
return saved;
|
|
3533
3583
|
},
|
|
@@ -3535,7 +3585,7 @@ var PriceProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({
|
|
|
3535
3585
|
);
|
|
3536
3586
|
const updatePrice = _react.useCallback.call(void 0,
|
|
3537
3587
|
async (input) => {
|
|
3538
|
-
const saved = await
|
|
3588
|
+
const saved = await _chunkIB7DTXWGjs.StripePriceService.updatePrice(input);
|
|
3539
3589
|
setPrice(saved);
|
|
3540
3590
|
refreshPrices();
|
|
3541
3591
|
return saved;
|
|
@@ -3544,23 +3594,23 @@ var PriceProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({
|
|
|
3544
3594
|
);
|
|
3545
3595
|
const archivePrice = _react.useCallback.call(void 0,
|
|
3546
3596
|
async (id) => {
|
|
3547
|
-
const target = _nullishCoalesce(id, () => ( _optionalChain([price, 'optionalAccess',
|
|
3597
|
+
const target = _nullishCoalesce(id, () => ( _optionalChain([price, 'optionalAccess', _145 => _145.id])));
|
|
3548
3598
|
if (!target) return;
|
|
3549
|
-
await
|
|
3599
|
+
await _chunkIB7DTXWGjs.StripePriceService.archivePrice({ id: target });
|
|
3550
3600
|
await reloadPrice();
|
|
3551
3601
|
refreshPrices();
|
|
3552
3602
|
},
|
|
3553
|
-
[_optionalChain([price, 'optionalAccess',
|
|
3603
|
+
[_optionalChain([price, 'optionalAccess', _146 => _146.id]), reloadPrice, refreshPrices]
|
|
3554
3604
|
);
|
|
3555
3605
|
const restorePrice = _react.useCallback.call(void 0,
|
|
3556
3606
|
async (id) => {
|
|
3557
|
-
const target = _nullishCoalesce(id, () => ( _optionalChain([price, 'optionalAccess',
|
|
3607
|
+
const target = _nullishCoalesce(id, () => ( _optionalChain([price, 'optionalAccess', _147 => _147.id])));
|
|
3558
3608
|
if (!target) return;
|
|
3559
|
-
await
|
|
3609
|
+
await _chunkIB7DTXWGjs.StripePriceService.reactivatePrice({ id: target });
|
|
3560
3610
|
await reloadPrice();
|
|
3561
3611
|
refreshPrices();
|
|
3562
3612
|
},
|
|
3563
|
-
[_optionalChain([price, 'optionalAccess',
|
|
3613
|
+
[_optionalChain([price, 'optionalAccess', _148 => _148.id]), reloadPrice, refreshPrices]
|
|
3564
3614
|
);
|
|
3565
3615
|
const value = _react.useMemo.call(void 0,
|
|
3566
3616
|
() => ({
|
|
@@ -3580,12 +3630,12 @@ var PriceProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({
|
|
|
3580
3630
|
if (!publishChrome) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PriceContext.Provider, { value, children });
|
|
3581
3631
|
const breadcrumb = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => {
|
|
3582
3632
|
const items = [
|
|
3583
|
-
{ name: t("billing.admin.products.title"), href: generateUrl({ page:
|
|
3633
|
+
{ name: t("billing.admin.products.title"), href: generateUrl({ page: _chunkIB7DTXWGjs.Modules.StripeProduct }) }
|
|
3584
3634
|
];
|
|
3585
|
-
if (_optionalChain([price, 'optionalAccess',
|
|
3635
|
+
if (_optionalChain([price, 'optionalAccess', _149 => _149.product]))
|
|
3586
3636
|
items.push({
|
|
3587
3637
|
name: price.product.name,
|
|
3588
|
-
href: generateUrl({ page:
|
|
3638
|
+
href: generateUrl({ page: _chunkIB7DTXWGjs.Modules.StripeProduct, id: price.product.id })
|
|
3589
3639
|
});
|
|
3590
3640
|
if (price) items.push({ name: priceLabel(price) });
|
|
3591
3641
|
return items;
|
|
@@ -3594,7 +3644,7 @@ var PriceProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({
|
|
|
3594
3644
|
const response = { type: t("billing.admin.prices.title") };
|
|
3595
3645
|
if (!price) return response;
|
|
3596
3646
|
response.element = priceLabel(price);
|
|
3597
|
-
if (hasRole(
|
|
3647
|
+
if (hasRole(_chunkXH4IURUDjs.getRoleId.call(void 0, ).Administrator)) {
|
|
3598
3648
|
response.functions = [
|
|
3599
3649
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, PriceArchiver, { price }, "priceArchiver"),
|
|
3600
3650
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, PriceEditor, { price, propagateChanges: setPrice }, "priceEditor")
|
|
@@ -3602,7 +3652,7 @@ var PriceProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({
|
|
|
3602
3652
|
}
|
|
3603
3653
|
return response;
|
|
3604
3654
|
}, "title");
|
|
3605
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3655
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.SharedProvider, { value: { breadcrumbs: breadcrumb(), title: title() }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PriceContext.Provider, { value, children }) });
|
|
3606
3656
|
}, "PriceProvider");
|
|
3607
3657
|
var usePriceContext = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => _nullishCoalesce(_react.useContext.call(void 0, PriceContext), () => ( defaultContextValue)), "usePriceContext");
|
|
3608
3658
|
|
|
@@ -3622,12 +3672,12 @@ function ProductArchiver({ product }) {
|
|
|
3622
3672
|
const isArchived = !product.active;
|
|
3623
3673
|
const scope = isArchived ? "restore" : "archive";
|
|
3624
3674
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
3625
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3675
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Button, { variant: "outline", size: "sm", onClick: () => setOpen(true), children: [
|
|
3626
3676
|
isArchived ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.RotateCcwIcon, {}) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ArchiveIcon, {}),
|
|
3627
3677
|
t(`billing.admin.products.${scope}.confirm`)
|
|
3628
3678
|
] }),
|
|
3629
3679
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3630
|
-
|
|
3680
|
+
_chunkLVE3BJ6Kjs.ConfirmDialog,
|
|
3631
3681
|
{
|
|
3632
3682
|
open,
|
|
3633
3683
|
onOpenChange: setOpen,
|
|
@@ -3641,7 +3691,7 @@ function ProductArchiver({ product }) {
|
|
|
3641
3691
|
if (isArchived) await restoreProduct(product.id);
|
|
3642
3692
|
else await archiveProduct(product.id);
|
|
3643
3693
|
} catch (error) {
|
|
3644
|
-
|
|
3694
|
+
_chunkLVE3BJ6Kjs.errorToast.call(void 0, { title: t(`billing.admin.products.${scope}.title`), error });
|
|
3645
3695
|
throw error;
|
|
3646
3696
|
}
|
|
3647
3697
|
}
|
|
@@ -3670,7 +3720,7 @@ function ProductEditorInternal({
|
|
|
3670
3720
|
onDialogOpenChange
|
|
3671
3721
|
}) {
|
|
3672
3722
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
3673
|
-
const router =
|
|
3723
|
+
const router = _chunkXH4IURUDjs.useI18nRouter.call(void 0, );
|
|
3674
3724
|
const { createProduct, updateProduct } = useProductContext();
|
|
3675
3725
|
const isEdit = !!product;
|
|
3676
3726
|
const formSchema2 = _react.useMemo.call(void 0,
|
|
@@ -3683,9 +3733,9 @@ function ProductEditorInternal({
|
|
|
3683
3733
|
);
|
|
3684
3734
|
const getDefaultValues = _react.useCallback.call(void 0,
|
|
3685
3735
|
() => ({
|
|
3686
|
-
id: _nullishCoalesce(_optionalChain([product, 'optionalAccess',
|
|
3687
|
-
name: _nullishCoalesce(_optionalChain([product, 'optionalAccess',
|
|
3688
|
-
description: _nullishCoalesce(_optionalChain([product, 'optionalAccess',
|
|
3736
|
+
id: _nullishCoalesce(_optionalChain([product, 'optionalAccess', _150 => _150.id]), () => ( _uuid.v4.call(void 0, ))),
|
|
3737
|
+
name: _nullishCoalesce(_optionalChain([product, 'optionalAccess', _151 => _151.name]), () => ( "")),
|
|
3738
|
+
description: _nullishCoalesce(_optionalChain([product, 'optionalAccess', _152 => _152.description]), () => ( ""))
|
|
3689
3739
|
}),
|
|
3690
3740
|
[product]
|
|
3691
3741
|
);
|
|
@@ -3694,13 +3744,13 @@ function ProductEditorInternal({
|
|
|
3694
3744
|
defaultValues: getDefaultValues()
|
|
3695
3745
|
});
|
|
3696
3746
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3697
|
-
|
|
3747
|
+
_chunkLVE3BJ6Kjs.EditorSheet,
|
|
3698
3748
|
{
|
|
3699
3749
|
form,
|
|
3700
3750
|
entityType: t("billing.admin.products.entity"),
|
|
3701
|
-
entityName: _optionalChain([product, 'optionalAccess',
|
|
3751
|
+
entityName: _optionalChain([product, 'optionalAccess', _153 => _153.name]),
|
|
3702
3752
|
isEdit,
|
|
3703
|
-
module:
|
|
3753
|
+
module: _chunkIB7DTXWGjs.Modules.StripeProduct,
|
|
3704
3754
|
size: "md",
|
|
3705
3755
|
propagateChanges,
|
|
3706
3756
|
onSuccess,
|
|
@@ -3717,7 +3767,7 @@ function ProductEditorInternal({
|
|
|
3717
3767
|
onDialogOpenChange,
|
|
3718
3768
|
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-y-4", children: [
|
|
3719
3769
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3720
|
-
|
|
3770
|
+
_chunkLVE3BJ6Kjs.FormInput,
|
|
3721
3771
|
{
|
|
3722
3772
|
form,
|
|
3723
3773
|
id: "name",
|
|
@@ -3727,7 +3777,7 @@ function ProductEditorInternal({
|
|
|
3727
3777
|
}
|
|
3728
3778
|
),
|
|
3729
3779
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3730
|
-
|
|
3780
|
+
_chunkLVE3BJ6Kjs.FormTextarea,
|
|
3731
3781
|
{
|
|
3732
3782
|
form,
|
|
3733
3783
|
id: "description",
|
|
@@ -3771,20 +3821,20 @@ var defaultContextValue2 = {
|
|
|
3771
3821
|
};
|
|
3772
3822
|
var ProductProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({ children, dehydratedProduct, publishChrome = true }) => {
|
|
3773
3823
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
3774
|
-
const generateUrl =
|
|
3775
|
-
const { hasRole } =
|
|
3824
|
+
const generateUrl = _chunkLVE3BJ6Kjs.usePageUrlGenerator.call(void 0, );
|
|
3825
|
+
const { hasRole } = _chunkLVE3BJ6Kjs.useCurrentUserContext.call(void 0, );
|
|
3776
3826
|
const [product, setProduct] = _react.useState.call(void 0,
|
|
3777
|
-
dehydratedProduct ?
|
|
3827
|
+
dehydratedProduct ? _chunkIB7DTXWGjs.rehydrate.call(void 0, _chunkIB7DTXWGjs.Modules.StripeProduct, dehydratedProduct) : void 0
|
|
3778
3828
|
);
|
|
3779
3829
|
const [catalogueVersion, setCatalogueVersion] = _react.useState.call(void 0, 0);
|
|
3780
3830
|
const refreshCatalogue = _react.useCallback.call(void 0, () => setCatalogueVersion((value2) => value2 + 1), []);
|
|
3781
3831
|
const reloadProduct = _react.useCallback.call(void 0, async () => {
|
|
3782
|
-
if (!_optionalChain([product, 'optionalAccess',
|
|
3783
|
-
setProduct(await
|
|
3784
|
-
}, [_optionalChain([product, 'optionalAccess',
|
|
3832
|
+
if (!_optionalChain([product, 'optionalAccess', _154 => _154.id])) return;
|
|
3833
|
+
setProduct(await _chunkIB7DTXWGjs.StripeProductService.getProduct({ id: product.id }));
|
|
3834
|
+
}, [_optionalChain([product, 'optionalAccess', _155 => _155.id])]);
|
|
3785
3835
|
const createProduct = _react.useCallback.call(void 0,
|
|
3786
3836
|
async (input) => {
|
|
3787
|
-
const saved = await
|
|
3837
|
+
const saved = await _chunkIB7DTXWGjs.StripeProductService.createProduct(input);
|
|
3788
3838
|
refreshCatalogue();
|
|
3789
3839
|
return saved;
|
|
3790
3840
|
},
|
|
@@ -3792,7 +3842,7 @@ var ProductProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({ ch
|
|
|
3792
3842
|
);
|
|
3793
3843
|
const updateProduct = _react.useCallback.call(void 0,
|
|
3794
3844
|
async (input) => {
|
|
3795
|
-
const saved = await
|
|
3845
|
+
const saved = await _chunkIB7DTXWGjs.StripeProductService.updateProduct(input);
|
|
3796
3846
|
setProduct(saved);
|
|
3797
3847
|
refreshCatalogue();
|
|
3798
3848
|
return saved;
|
|
@@ -3801,23 +3851,23 @@ var ProductProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({ ch
|
|
|
3801
3851
|
);
|
|
3802
3852
|
const archiveProduct = _react.useCallback.call(void 0,
|
|
3803
3853
|
async (id) => {
|
|
3804
|
-
const target = _nullishCoalesce(id, () => ( _optionalChain([product, 'optionalAccess',
|
|
3854
|
+
const target = _nullishCoalesce(id, () => ( _optionalChain([product, 'optionalAccess', _156 => _156.id])));
|
|
3805
3855
|
if (!target) return;
|
|
3806
|
-
await
|
|
3856
|
+
await _chunkIB7DTXWGjs.StripeProductService.archiveProduct({ id: target });
|
|
3807
3857
|
await reloadProduct();
|
|
3808
3858
|
refreshCatalogue();
|
|
3809
3859
|
},
|
|
3810
|
-
[_optionalChain([product, 'optionalAccess',
|
|
3860
|
+
[_optionalChain([product, 'optionalAccess', _157 => _157.id]), reloadProduct, refreshCatalogue]
|
|
3811
3861
|
);
|
|
3812
3862
|
const restoreProduct = _react.useCallback.call(void 0,
|
|
3813
3863
|
async (id) => {
|
|
3814
|
-
const target = _nullishCoalesce(id, () => ( _optionalChain([product, 'optionalAccess',
|
|
3864
|
+
const target = _nullishCoalesce(id, () => ( _optionalChain([product, 'optionalAccess', _158 => _158.id])));
|
|
3815
3865
|
if (!target) return;
|
|
3816
|
-
await
|
|
3866
|
+
await _chunkIB7DTXWGjs.StripeProductService.reactivateProduct({ id: target });
|
|
3817
3867
|
await reloadProduct();
|
|
3818
3868
|
refreshCatalogue();
|
|
3819
3869
|
},
|
|
3820
|
-
[_optionalChain([product, 'optionalAccess',
|
|
3870
|
+
[_optionalChain([product, 'optionalAccess', _159 => _159.id]), reloadProduct, refreshCatalogue]
|
|
3821
3871
|
);
|
|
3822
3872
|
const value = _react.useMemo.call(void 0,
|
|
3823
3873
|
() => ({
|
|
@@ -3848,7 +3898,7 @@ var ProductProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({ ch
|
|
|
3848
3898
|
{
|
|
3849
3899
|
name: t("billing.admin.products.title"),
|
|
3850
3900
|
// Linked only when it is NOT the current page.
|
|
3851
|
-
...product ? { href: generateUrl({ page:
|
|
3901
|
+
...product ? { href: generateUrl({ page: _chunkIB7DTXWGjs.Modules.StripeProduct }) } : {}
|
|
3852
3902
|
}
|
|
3853
3903
|
];
|
|
3854
3904
|
if (product) items.push({ name: product.name });
|
|
@@ -3858,7 +3908,7 @@ var ProductProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({ ch
|
|
|
3858
3908
|
const response = { type: t("billing.admin.products.title") };
|
|
3859
3909
|
if (!product) return response;
|
|
3860
3910
|
response.element = product.name;
|
|
3861
|
-
if (hasRole(
|
|
3911
|
+
if (hasRole(_chunkXH4IURUDjs.getRoleId.call(void 0, ).Administrator)) {
|
|
3862
3912
|
response.functions = [
|
|
3863
3913
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ProductArchiver, { product }, "productArchiver"),
|
|
3864
3914
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ProductEditor, { product, propagateChanges: setProduct }, "productEditor")
|
|
@@ -3866,7 +3916,7 @@ var ProductProvider = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ({ ch
|
|
|
3866
3916
|
}
|
|
3867
3917
|
return response;
|
|
3868
3918
|
}, "title");
|
|
3869
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3919
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.SharedProvider, { value: { breadcrumbs: breadcrumb(), title: title() }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ProductContext.Provider, { value, children }) });
|
|
3870
3920
|
}, "ProductProvider");
|
|
3871
3921
|
var useProductContext = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, () => _nullishCoalesce(_react.useContext.call(void 0, ProductContext), () => ( defaultContextValue2)), "useProductContext");
|
|
3872
3922
|
|
|
@@ -3875,82 +3925,82 @@ var useProductContext = /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, ()
|
|
|
3875
3925
|
|
|
3876
3926
|
function PriceDetails() {
|
|
3877
3927
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
3878
|
-
const generateUrl =
|
|
3928
|
+
const generateUrl = _chunkLVE3BJ6Kjs.usePageUrlGenerator.call(void 0, );
|
|
3879
3929
|
const { price } = usePriceContext();
|
|
3880
3930
|
if (!price) return null;
|
|
3881
3931
|
const isRecurring = price.priceType === "recurring";
|
|
3882
3932
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-y-8", children: [
|
|
3883
3933
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-y-4", children: [
|
|
3884
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3934
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.SectionHeader, { children: t("billing.admin.prices.title") }),
|
|
3885
3935
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [
|
|
3886
3936
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3887
|
-
|
|
3937
|
+
_chunkLVE3BJ6Kjs.DetailField,
|
|
3888
3938
|
{
|
|
3889
3939
|
label: t("billing.admin.prices.fields.product"),
|
|
3890
|
-
value: price.product ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3940
|
+
value: price.product ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Link, { href: generateUrl({ page: _chunkIB7DTXWGjs.Modules.StripeProduct, id: price.product.id }), children: price.product.name }) : "\u2014"
|
|
3891
3941
|
}
|
|
3892
3942
|
),
|
|
3893
3943
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3894
|
-
|
|
3944
|
+
_chunkLVE3BJ6Kjs.DetailField,
|
|
3895
3945
|
{
|
|
3896
3946
|
label: t("billing.admin.prices.fields.status"),
|
|
3897
3947
|
value: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "flex flex-wrap items-center gap-1", children: [
|
|
3898
|
-
price.active ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3899
|
-
price.isTrial && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3948
|
+
price.active ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Badge, { variant: "softGreen", children: t("billing.admin.prices.status.active") }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Badge, { variant: "softGray", children: t("billing.admin.prices.status.archived") }),
|
|
3949
|
+
price.isTrial && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Badge, { variant: "softBlue", children: t("billing.admin.prices.badge.trial") })
|
|
3900
3950
|
] })
|
|
3901
3951
|
}
|
|
3902
3952
|
),
|
|
3903
3953
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3904
|
-
|
|
3954
|
+
_chunkLVE3BJ6Kjs.DetailField,
|
|
3905
3955
|
{
|
|
3906
3956
|
label: t("billing.admin.prices.fields.amount"),
|
|
3907
|
-
value: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tabular-nums", children:
|
|
3957
|
+
value: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tabular-nums", children: _chunkLVE3BJ6Kjs.formatCurrency.call(void 0, price.unitAmount, price.currency) })
|
|
3908
3958
|
}
|
|
3909
3959
|
),
|
|
3910
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3960
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.DetailField, { label: t("billing.admin.prices.fields.currency"), value: price.currency.toUpperCase() }),
|
|
3911
3961
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3912
|
-
|
|
3962
|
+
_chunkLVE3BJ6Kjs.DetailField,
|
|
3913
3963
|
{
|
|
3914
3964
|
label: t("billing.admin.prices.fields.type"),
|
|
3915
3965
|
value: isRecurring ? t("billing.admin.prices.type.recurring") : t("billing.admin.prices.type.oneTime")
|
|
3916
3966
|
}
|
|
3917
3967
|
),
|
|
3918
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3968
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.DetailField, { label: t("billing.admin.prices.fields.billing"), value: _chunkLVE3BJ6Kjs.formatInterval.call(void 0, price) }),
|
|
3919
3969
|
isRecurring && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3920
|
-
|
|
3970
|
+
_chunkLVE3BJ6Kjs.DetailField,
|
|
3921
3971
|
{
|
|
3922
3972
|
label: t("billing.admin.prices.fields.intervalCount"),
|
|
3923
|
-
value: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tabular-nums", children: _nullishCoalesce(_optionalChain([price, 'access',
|
|
3973
|
+
value: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tabular-nums", children: _nullishCoalesce(_optionalChain([price, 'access', _160 => _160.recurring, 'optionalAccess', _161 => _161.intervalCount]), () => ( 1)) })
|
|
3924
3974
|
}
|
|
3925
3975
|
),
|
|
3926
3976
|
isRecurring && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3927
|
-
|
|
3977
|
+
_chunkLVE3BJ6Kjs.DetailField,
|
|
3928
3978
|
{
|
|
3929
3979
|
label: t("billing.admin.prices.fields.usageType"),
|
|
3930
|
-
value: _optionalChain([price, 'access',
|
|
3980
|
+
value: _optionalChain([price, 'access', _162 => _162.recurring, 'optionalAccess', _163 => _163.usageType]) === "metered" ? t("billing.admin.prices.usage.metered") : t("billing.admin.prices.usage.licensed")
|
|
3931
3981
|
}
|
|
3932
3982
|
)
|
|
3933
3983
|
] })
|
|
3934
3984
|
] }),
|
|
3935
3985
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-y-4", children: [
|
|
3936
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3986
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.SectionHeader, { children: t("billing.admin.prices.fields.platformFeatures") }),
|
|
3937
3987
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [
|
|
3938
3988
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3939
|
-
|
|
3989
|
+
_chunkLVE3BJ6Kjs.DetailField,
|
|
3940
3990
|
{
|
|
3941
3991
|
label: t("billing.admin.prices.fields.token"),
|
|
3942
3992
|
value: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tabular-nums", children: _nullishCoalesce(price.token, () => ( "\u2014")) })
|
|
3943
3993
|
}
|
|
3944
3994
|
),
|
|
3945
3995
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3946
|
-
|
|
3996
|
+
_chunkLVE3BJ6Kjs.DetailField,
|
|
3947
3997
|
{
|
|
3948
3998
|
label: t("billing.admin.prices.fields.stripeId"),
|
|
3949
3999
|
value: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tabular-nums", children: price.stripePriceId })
|
|
3950
4000
|
}
|
|
3951
4001
|
),
|
|
3952
4002
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3953
|
-
|
|
4003
|
+
_chunkLVE3BJ6Kjs.DetailField,
|
|
3954
4004
|
{
|
|
3955
4005
|
label: t("billing.admin.prices.fields.description"),
|
|
3956
4006
|
value: _nullishCoalesce(price.description, () => ( "\u2014")),
|
|
@@ -3958,7 +4008,7 @@ function PriceDetails() {
|
|
|
3958
4008
|
}
|
|
3959
4009
|
),
|
|
3960
4010
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3961
|
-
|
|
4011
|
+
_chunkLVE3BJ6Kjs.DetailField,
|
|
3962
4012
|
{
|
|
3963
4013
|
label: t("billing.admin.prices.fields.features"),
|
|
3964
4014
|
className: "md:col-span-2",
|
|
@@ -3966,11 +4016,11 @@ function PriceDetails() {
|
|
|
3966
4016
|
}
|
|
3967
4017
|
),
|
|
3968
4018
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3969
|
-
|
|
4019
|
+
_chunkLVE3BJ6Kjs.DetailField,
|
|
3970
4020
|
{
|
|
3971
4021
|
label: t("billing.admin.prices.fields.platformFeatures"),
|
|
3972
4022
|
className: "md:col-span-2",
|
|
3973
|
-
value: price.priceFeatures.length > 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "flex flex-wrap items-center gap-1", children: price.priceFeatures.map((feature) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4023
|
+
value: price.priceFeatures.length > 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "flex flex-wrap items-center gap-1", children: price.priceFeatures.map((feature) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Badge, { variant: "softGray", children: feature.name }, feature.id)) }) : "\u2014"
|
|
3974
4024
|
}
|
|
3975
4025
|
)
|
|
3976
4026
|
] })
|
|
@@ -3984,7 +4034,7 @@ _chunk7QVYU63Ejs.__name.call(void 0, PriceDetails, "PriceDetails");
|
|
|
3984
4034
|
function PriceContainer() {
|
|
3985
4035
|
const { price } = usePriceContext();
|
|
3986
4036
|
if (!price) return null;
|
|
3987
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4037
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.RoundPageContainer, { module: _chunkIB7DTXWGjs.Modules.StripePrice, id: price.id, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PriceDetails, {}) });
|
|
3988
4038
|
}
|
|
3989
4039
|
_chunk7QVYU63Ejs.__name.call(void 0, PriceContainer, "PriceContainer");
|
|
3990
4040
|
|
|
@@ -3993,43 +4043,240 @@ _chunk7QVYU63Ejs.__name.call(void 0, PriceContainer, "PriceContainer");
|
|
|
3993
4043
|
|
|
3994
4044
|
|
|
3995
4045
|
|
|
4046
|
+
// src/features/billing/stripe-price/data/stripe-price.transfer.ts
|
|
4047
|
+
|
|
4048
|
+
var STRIPE_PRICE_TRANSFER_KIND = "stripe-price";
|
|
4049
|
+
var STRIPE_PRICE_TRANSFER_VERSION = 1;
|
|
4050
|
+
var SUPPORTED_VERSIONS = [STRIPE_PRICE_TRANSFER_VERSION];
|
|
4051
|
+
var seedSchema = _zod3.z.object({
|
|
4052
|
+
unitAmount: _zod3.z.number().min(0),
|
|
4053
|
+
currency: _zod3.z.string().min(1),
|
|
4054
|
+
interval: _zod3.z.enum(["one_time", "day", "week", "month", "year"]),
|
|
4055
|
+
intervalCount: _zod3.z.number().min(1).optional(),
|
|
4056
|
+
usageType: _zod3.z.enum(["licensed", "metered"]).optional(),
|
|
4057
|
+
nickname: _zod3.z.string().optional(),
|
|
4058
|
+
description: _zod3.z.string().optional(),
|
|
4059
|
+
features: _zod3.z.array(_zod3.z.string()).optional(),
|
|
4060
|
+
token: _zod3.z.number().optional(),
|
|
4061
|
+
isTrial: _zod3.z.boolean().optional(),
|
|
4062
|
+
platformFeatures: _zod3.z.array(_zod3.z.string()).optional()
|
|
4063
|
+
});
|
|
4064
|
+
function readOptional(read) {
|
|
4065
|
+
try {
|
|
4066
|
+
return read();
|
|
4067
|
+
} catch (e2) {
|
|
4068
|
+
return void 0;
|
|
4069
|
+
}
|
|
4070
|
+
}
|
|
4071
|
+
_chunk7QVYU63Ejs.__name.call(void 0, readOptional, "readOptional");
|
|
4072
|
+
function nonEmptyStrings(values) {
|
|
4073
|
+
if (!Array.isArray(values)) return [];
|
|
4074
|
+
return values.map((value) => value.trim()).filter((value) => value.length > 0);
|
|
4075
|
+
}
|
|
4076
|
+
_chunk7QVYU63Ejs.__name.call(void 0, nonEmptyStrings, "nonEmptyStrings");
|
|
4077
|
+
function priceToSeed(price) {
|
|
4078
|
+
const priceType = readOptional(() => price.priceType);
|
|
4079
|
+
const currency = readOptional(() => price.currency);
|
|
4080
|
+
const recurring = price.recurring;
|
|
4081
|
+
const interval = priceType === "one_time" ? "one_time" : _nullishCoalesce(_optionalChain([recurring, 'optionalAccess', _164 => _164.interval]), () => ( "month"));
|
|
4082
|
+
const seed = {
|
|
4083
|
+
unitAmount: _nullishCoalesce(price.unitAmount, () => ( 0)),
|
|
4084
|
+
currency: _nullishCoalesce(currency, () => ( "usd")),
|
|
4085
|
+
interval
|
|
4086
|
+
};
|
|
4087
|
+
if (interval !== "one_time") {
|
|
4088
|
+
if (typeof _optionalChain([recurring, 'optionalAccess', _165 => _165.intervalCount]) === "number") seed.intervalCount = recurring.intervalCount;
|
|
4089
|
+
if (_optionalChain([recurring, 'optionalAccess', _166 => _166.usageType])) seed.usageType = recurring.usageType;
|
|
4090
|
+
}
|
|
4091
|
+
const nickname = _optionalChain([price, 'access', _167 => _167.nickname, 'optionalAccess', _168 => _168.trim, 'call', _169 => _169()]);
|
|
4092
|
+
if (nickname) seed.nickname = nickname;
|
|
4093
|
+
const description = _optionalChain([price, 'access', _170 => _170.description, 'optionalAccess', _171 => _171.trim, 'call', _172 => _172()]);
|
|
4094
|
+
if (description) seed.description = description;
|
|
4095
|
+
const features = nonEmptyStrings(price.features);
|
|
4096
|
+
if (features.length > 0) seed.features = features;
|
|
4097
|
+
if (typeof price.token === "number" && !Number.isNaN(price.token)) seed.token = price.token;
|
|
4098
|
+
if (typeof price.isTrial === "boolean") seed.isTrial = price.isTrial;
|
|
4099
|
+
const platformFeatures = nonEmptyStrings(_optionalChain([price, 'access', _173 => _173.priceFeatures, 'optionalAccess', _174 => _174.map, 'call', _175 => _175((feature) => feature.name)]));
|
|
4100
|
+
if (platformFeatures.length > 0) seed.platformFeatures = platformFeatures;
|
|
4101
|
+
return seed;
|
|
4102
|
+
}
|
|
4103
|
+
_chunk7QVYU63Ejs.__name.call(void 0, priceToSeed, "priceToSeed");
|
|
4104
|
+
function buildStripePriceTransferDocument(price) {
|
|
4105
|
+
return {
|
|
4106
|
+
kind: STRIPE_PRICE_TRANSFER_KIND,
|
|
4107
|
+
version: STRIPE_PRICE_TRANSFER_VERSION,
|
|
4108
|
+
price: priceToSeed(price)
|
|
4109
|
+
};
|
|
4110
|
+
}
|
|
4111
|
+
_chunk7QVYU63Ejs.__name.call(void 0, buildStripePriceTransferDocument, "buildStripePriceTransferDocument");
|
|
4112
|
+
function slugify(value) {
|
|
4113
|
+
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
4114
|
+
}
|
|
4115
|
+
_chunk7QVYU63Ejs.__name.call(void 0, slugify, "slugify");
|
|
4116
|
+
function stripePriceTransferFilename(price) {
|
|
4117
|
+
const seed = priceToSeed(price);
|
|
4118
|
+
const fromNickname = seed.nickname ? slugify(seed.nickname) : "";
|
|
4119
|
+
const slug = fromNickname || slugify(`${seed.unitAmount}-${seed.currency}`);
|
|
4120
|
+
return `price-${slug || "export"}.json`;
|
|
4121
|
+
}
|
|
4122
|
+
_chunk7QVYU63Ejs.__name.call(void 0, stripePriceTransferFilename, "stripePriceTransferFilename");
|
|
4123
|
+
function parseStripePriceTransferDocument(raw) {
|
|
4124
|
+
let candidate;
|
|
4125
|
+
try {
|
|
4126
|
+
candidate = JSON.parse(raw);
|
|
4127
|
+
} catch (e3) {
|
|
4128
|
+
throw new Error("The file is not valid JSON.");
|
|
4129
|
+
}
|
|
4130
|
+
if (typeof candidate !== "object" || candidate === null || Array.isArray(candidate))
|
|
4131
|
+
throw new Error("The file is not a price transfer document.");
|
|
4132
|
+
const document2 = candidate;
|
|
4133
|
+
if (document2.kind !== STRIPE_PRICE_TRANSFER_KIND)
|
|
4134
|
+
throw new Error(
|
|
4135
|
+
`The file is not a price transfer document: expected kind "${STRIPE_PRICE_TRANSFER_KIND}", found ${JSON.stringify(document2.kind)}.`
|
|
4136
|
+
);
|
|
4137
|
+
if (typeof document2.version !== "number" || !SUPPORTED_VERSIONS.includes(document2.version))
|
|
4138
|
+
throw new Error(
|
|
4139
|
+
`Unsupported price transfer version ${JSON.stringify(document2.version)}. Supported: ${SUPPORTED_VERSIONS.join(", ")}.`
|
|
4140
|
+
);
|
|
4141
|
+
const parsed = seedSchema.safeParse(document2.price);
|
|
4142
|
+
if (!parsed.success) {
|
|
4143
|
+
const details = parsed.error.issues.map((issue) => `${issue.path.join(".") || "price"}: ${issue.message}`).join("; ");
|
|
4144
|
+
throw new Error(`The price in the file is not valid. ${details}`);
|
|
4145
|
+
}
|
|
4146
|
+
return {
|
|
4147
|
+
kind: STRIPE_PRICE_TRANSFER_KIND,
|
|
4148
|
+
version: STRIPE_PRICE_TRANSFER_VERSION,
|
|
4149
|
+
price: parsed.data
|
|
4150
|
+
};
|
|
4151
|
+
}
|
|
4152
|
+
_chunk7QVYU63Ejs.__name.call(void 0, parseStripePriceTransferDocument, "parseStripePriceTransferDocument");
|
|
4153
|
+
|
|
4154
|
+
// src/features/billing/stripe-price/components/lists/PricesList.tsx
|
|
4155
|
+
|
|
3996
4156
|
function PricesList({ productId, fullWidth }) {
|
|
3997
4157
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
3998
4158
|
const { priceVersion } = usePriceContext();
|
|
3999
|
-
const
|
|
4000
|
-
|
|
4159
|
+
const importInputRef = _react.useRef.call(void 0, null);
|
|
4160
|
+
const [seed, setSeed] = _react.useState.call(void 0, void 0);
|
|
4161
|
+
const [seedNonce, setSeedNonce] = _react.useState.call(void 0, 0);
|
|
4162
|
+
const data = _chunkLVE3BJ6Kjs.useDataListRetriever.call(void 0, {
|
|
4163
|
+
retriever: /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (params) => _chunkIB7DTXWGjs.StripePriceService.listPrices({ ...params, productId }), "retriever"),
|
|
4001
4164
|
retrieverParams: {},
|
|
4002
|
-
module:
|
|
4165
|
+
module: _chunkIB7DTXWGjs.Modules.StripePrice
|
|
4003
4166
|
});
|
|
4004
4167
|
_react.useEffect.call(void 0, () => {
|
|
4005
4168
|
if (priceVersion > 0) void data.refresh();
|
|
4006
4169
|
}, [priceVersion]);
|
|
4007
|
-
const
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4170
|
+
const openSeededEditor = _react.useCallback.call(void 0, (next) => {
|
|
4171
|
+
setSeed(next);
|
|
4172
|
+
setSeedNonce((nonce) => nonce + 1);
|
|
4173
|
+
}, []);
|
|
4174
|
+
const onClone = _react.useCallback.call(void 0,
|
|
4175
|
+
(price) => openSeededEditor(priceToSeed(price)),
|
|
4176
|
+
[openSeededEditor]
|
|
4177
|
+
);
|
|
4178
|
+
const onExport = _react.useCallback.call(void 0, (price) => {
|
|
4179
|
+
const text = JSON.stringify(buildStripePriceTransferDocument(price), null, 2);
|
|
4180
|
+
const blob = new Blob([text], { type: "application/json" });
|
|
4181
|
+
const url = URL.createObjectURL(blob);
|
|
4182
|
+
const a = document.createElement("a");
|
|
4183
|
+
a.href = url;
|
|
4184
|
+
a.download = stripePriceTransferFilename(price);
|
|
4185
|
+
a.click();
|
|
4186
|
+
URL.revokeObjectURL(url);
|
|
4187
|
+
}, []);
|
|
4188
|
+
const tableContext = _react.useMemo.call(void 0, () => ({ onClone, onExport }), [onClone, onExport]);
|
|
4189
|
+
const onImportFileChange = _react.useCallback.call(void 0,
|
|
4190
|
+
async (event) => {
|
|
4191
|
+
const input = event.target;
|
|
4192
|
+
const file = _optionalChain([input, 'access', _176 => _176.files, 'optionalAccess', _177 => _177[0]]);
|
|
4193
|
+
input.value = "";
|
|
4194
|
+
if (!file) return;
|
|
4195
|
+
try {
|
|
4196
|
+
const transfer = parseStripePriceTransferDocument(await file.text());
|
|
4197
|
+
openSeededEditor(transfer.price);
|
|
4198
|
+
} catch (error) {
|
|
4199
|
+
console.error("[PricesList] price import failed", error);
|
|
4200
|
+
_chunkLVE3BJ6Kjs.errorToast.call(void 0, {
|
|
4201
|
+
title: t("billing.admin.prices.import.errors.title"),
|
|
4202
|
+
error: t("billing.admin.prices.import.errors.invalid")
|
|
4203
|
+
});
|
|
4204
|
+
}
|
|
4205
|
+
},
|
|
4206
|
+
[openSeededEditor, t]
|
|
4207
|
+
);
|
|
4208
|
+
const functions = [
|
|
4209
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4210
|
+
PriceEditor,
|
|
4211
|
+
{
|
|
4212
|
+
productId,
|
|
4213
|
+
onSuccess: () => {
|
|
4214
|
+
}
|
|
4215
|
+
},
|
|
4216
|
+
"create-price"
|
|
4217
|
+
),
|
|
4218
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.Fragment, { children: [
|
|
4219
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkLVE3BJ6Kjs.Button, { variant: "outline", size: "sm", type: "button", onClick: () => _optionalChain([importInputRef, 'access', _178 => _178.current, 'optionalAccess', _179 => _179.click, 'call', _180 => _180()]), children: [
|
|
4220
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.UploadIcon, {}),
|
|
4221
|
+
t("billing.admin.prices.actions.import")
|
|
4222
|
+
] }),
|
|
4223
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4224
|
+
"input",
|
|
4025
4225
|
{
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4226
|
+
ref: importInputRef,
|
|
4227
|
+
type: "file",
|
|
4228
|
+
accept: "application/json",
|
|
4229
|
+
className: "hidden",
|
|
4230
|
+
onChange: onImportFileChange
|
|
4029
4231
|
}
|
|
4030
4232
|
)
|
|
4031
|
-
}
|
|
4032
|
-
|
|
4233
|
+
] }, "import-price")
|
|
4234
|
+
];
|
|
4235
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
4236
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4237
|
+
_chunkLVE3BJ6Kjs.ContentListTable,
|
|
4238
|
+
{
|
|
4239
|
+
data,
|
|
4240
|
+
fields: [
|
|
4241
|
+
"nickname" /* nickname */,
|
|
4242
|
+
"amount" /* amount */,
|
|
4243
|
+
"interval" /* interval */,
|
|
4244
|
+
"token" /* token */,
|
|
4245
|
+
"status" /* status */,
|
|
4246
|
+
"actions" /* actions */
|
|
4247
|
+
],
|
|
4248
|
+
tableGeneratorType: _chunkIB7DTXWGjs.Modules.StripePrice,
|
|
4249
|
+
functions,
|
|
4250
|
+
context: tableContext,
|
|
4251
|
+
fullWidth,
|
|
4252
|
+
title: t("billing.admin.prices.title"),
|
|
4253
|
+
emptyState: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4254
|
+
_chunkLVE3BJ6Kjs.EmptyState,
|
|
4255
|
+
{
|
|
4256
|
+
icon: _lucidereact.DollarSignIcon,
|
|
4257
|
+
title: t("billing.admin.prices.empty.title"),
|
|
4258
|
+
description: t("billing.admin.prices.empty.description")
|
|
4259
|
+
}
|
|
4260
|
+
)
|
|
4261
|
+
}
|
|
4262
|
+
),
|
|
4263
|
+
seed && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4264
|
+
PriceEditor,
|
|
4265
|
+
{
|
|
4266
|
+
productId,
|
|
4267
|
+
seed,
|
|
4268
|
+
dialogOpen: true,
|
|
4269
|
+
onDialogOpenChange: (open) => {
|
|
4270
|
+
if (!open) setSeed(void 0);
|
|
4271
|
+
},
|
|
4272
|
+
onSuccess: async () => {
|
|
4273
|
+
setSeed(void 0);
|
|
4274
|
+
await data.refresh();
|
|
4275
|
+
}
|
|
4276
|
+
},
|
|
4277
|
+
seedNonce
|
|
4278
|
+
)
|
|
4279
|
+
] });
|
|
4033
4280
|
}
|
|
4034
4281
|
_chunk7QVYU63Ejs.__name.call(void 0, PricesList, "PricesList");
|
|
4035
4282
|
|
|
@@ -4044,18 +4291,18 @@ function ProductDetails() {
|
|
|
4044
4291
|
const { product } = useProductContext();
|
|
4045
4292
|
if (!product) return null;
|
|
4046
4293
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-full flex-col gap-y-4", children: [
|
|
4047
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4294
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.SectionHeader, { children: t("billing.admin.products.tabs.details") }),
|
|
4048
4295
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [
|
|
4049
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4296
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.DetailField, { label: t("billing.admin.products.fields.name"), value: product.name }),
|
|
4050
4297
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4051
|
-
|
|
4298
|
+
_chunkLVE3BJ6Kjs.DetailField,
|
|
4052
4299
|
{
|
|
4053
4300
|
label: t("billing.admin.products.fields.status"),
|
|
4054
|
-
value: product.active ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4301
|
+
value: product.active ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Badge, { variant: "softGreen", children: t("billing.admin.products.status.active") }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.Badge, { variant: "softGray", children: t("billing.admin.products.status.archived") })
|
|
4055
4302
|
}
|
|
4056
4303
|
),
|
|
4057
4304
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4058
|
-
|
|
4305
|
+
_chunkLVE3BJ6Kjs.DetailField,
|
|
4059
4306
|
{
|
|
4060
4307
|
label: t("billing.admin.products.fields.description"),
|
|
4061
4308
|
value: _nullishCoalesce(product.description, () => ( "\u2014")),
|
|
@@ -4063,14 +4310,14 @@ function ProductDetails() {
|
|
|
4063
4310
|
}
|
|
4064
4311
|
),
|
|
4065
4312
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4066
|
-
|
|
4313
|
+
_chunkLVE3BJ6Kjs.DetailField,
|
|
4067
4314
|
{
|
|
4068
4315
|
label: t("billing.admin.products.fields.prices"),
|
|
4069
4316
|
value: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tabular-nums", children: product.stripePrices.length })
|
|
4070
4317
|
}
|
|
4071
4318
|
),
|
|
4072
4319
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4073
|
-
|
|
4320
|
+
_chunkLVE3BJ6Kjs.DetailField,
|
|
4074
4321
|
{
|
|
4075
4322
|
label: t("billing.admin.products.fields.stripeId"),
|
|
4076
4323
|
value: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tabular-nums", children: product.stripeProductId })
|
|
@@ -4088,9 +4335,9 @@ function ProductContainer() {
|
|
|
4088
4335
|
const { product } = useProductContext();
|
|
4089
4336
|
if (!product) return null;
|
|
4090
4337
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4091
|
-
|
|
4338
|
+
_chunkLVE3BJ6Kjs.RoundPageContainer,
|
|
4092
4339
|
{
|
|
4093
|
-
module:
|
|
4340
|
+
module: _chunkIB7DTXWGjs.Modules.StripeProduct,
|
|
4094
4341
|
id: product.id,
|
|
4095
4342
|
tabs: [
|
|
4096
4343
|
{
|
|
@@ -4099,7 +4346,7 @@ function ProductContainer() {
|
|
|
4099
4346
|
content: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ProductDetails, {})
|
|
4100
4347
|
},
|
|
4101
4348
|
{
|
|
4102
|
-
key:
|
|
4349
|
+
key: _chunkIB7DTXWGjs.Modules.StripePrice,
|
|
4103
4350
|
label: t("billing.admin.prices.title"),
|
|
4104
4351
|
// publishChrome={false}: SharedProvider REPLACES its value for the
|
|
4105
4352
|
// subtree (SharedContext.tsx:35-37), so a nested provider publishing
|
|
@@ -4123,26 +4370,26 @@ _chunk7QVYU63Ejs.__name.call(void 0, ProductContainer, "ProductContainer");
|
|
|
4123
4370
|
function ProductsList({ fullWidth } = {}) {
|
|
4124
4371
|
const t = _nextintl.useTranslations.call(void 0, );
|
|
4125
4372
|
const { catalogueVersion } = useProductContext();
|
|
4126
|
-
const data =
|
|
4127
|
-
retriever: /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (params) =>
|
|
4373
|
+
const data = _chunkLVE3BJ6Kjs.useDataListRetriever.call(void 0, {
|
|
4374
|
+
retriever: /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (params) => _chunkIB7DTXWGjs.StripeProductService.listProducts(params), "retriever"),
|
|
4128
4375
|
retrieverParams: {},
|
|
4129
|
-
module:
|
|
4376
|
+
module: _chunkIB7DTXWGjs.Modules.StripeProduct
|
|
4130
4377
|
});
|
|
4131
4378
|
_react.useEffect.call(void 0, () => {
|
|
4132
4379
|
if (catalogueVersion > 0) void data.refresh();
|
|
4133
4380
|
}, [catalogueVersion]);
|
|
4134
4381
|
const functions = [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ProductEditor, {}, "create-product")];
|
|
4135
4382
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4136
|
-
|
|
4383
|
+
_chunkLVE3BJ6Kjs.ContentListTable,
|
|
4137
4384
|
{
|
|
4138
4385
|
data,
|
|
4139
4386
|
fields: ["name" /* name */, "status" /* status */, "prices" /* prices */],
|
|
4140
|
-
tableGeneratorType:
|
|
4387
|
+
tableGeneratorType: _chunkIB7DTXWGjs.Modules.StripeProduct,
|
|
4141
4388
|
functions,
|
|
4142
4389
|
fullWidth,
|
|
4143
4390
|
title: t("billing.admin.products.title"),
|
|
4144
4391
|
emptyState: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4145
|
-
|
|
4392
|
+
_chunkLVE3BJ6Kjs.EmptyState,
|
|
4146
4393
|
{
|
|
4147
4394
|
icon: _lucidereact.PackageIcon,
|
|
4148
4395
|
title: t("billing.admin.products.empty.title"),
|
|
@@ -4157,7 +4404,7 @@ _chunk7QVYU63Ejs.__name.call(void 0, ProductsList, "ProductsList");
|
|
|
4157
4404
|
// src/features/billing/stripe-product/components/containers/ProductsListContainer.tsx
|
|
4158
4405
|
|
|
4159
4406
|
function ProductsListContainer() {
|
|
4160
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ProductProvider, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4407
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ProductProvider, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLVE3BJ6Kjs.RoundPageContainer, { module: _chunkIB7DTXWGjs.Modules.StripeProduct, fullWidth: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ProductsList, { fullWidth: true }) }) });
|
|
4161
4408
|
}
|
|
4162
4409
|
_chunk7QVYU63Ejs.__name.call(void 0, ProductsListContainer, "ProductsListContainer");
|
|
4163
4410
|
|
|
@@ -4215,5 +4462,5 @@ _chunk7QVYU63Ejs.__name.call(void 0, ProductsListContainer, "ProductsListContain
|
|
|
4215
4462
|
|
|
4216
4463
|
|
|
4217
4464
|
|
|
4218
|
-
exports.BillingAlertBanner = BillingAlertBanner; exports.BillingDashboardContainer = BillingDashboardContainer; exports.BillingDetailModal = BillingDetailModal; exports.BillingUsageSummaryCard = BillingUsageSummaryCard; exports.CancelSubscriptionDialog = CancelSubscriptionDialog; exports.CustomerInfoCard = CustomerInfoCard; exports.IntervalToggle = IntervalToggle; exports.InvoiceDetails = InvoiceDetails; exports.InvoiceStatusBadge = InvoiceStatusBadge; exports.InvoicesContainer = InvoicesContainer; exports.InvoicesList = InvoicesList; exports.InvoicesSummaryCard = InvoicesSummaryCard; exports.PaymentMethodCard = PaymentMethodCard; exports.PaymentMethodEditor = PaymentMethodEditor; exports.PaymentMethodForm = PaymentMethodForm; exports.PaymentMethodSummaryCard = PaymentMethodSummaryCard; exports.PaymentMethodsContainer = PaymentMethodsContainer; exports.PaymentMethodsList = PaymentMethodsList; exports.PriceArchiver = PriceArchiver; exports.PriceContainer = PriceContainer; exports.PriceDetails = PriceDetails; exports.PriceEditor = PriceEditor; exports.PriceProvider = PriceProvider; exports.PricesList = PricesList; exports.PricingCard = PricingCard; exports.ProductArchiver = ProductArchiver; exports.ProductContainer = ProductContainer; exports.ProductDetails = ProductDetails; exports.ProductEditor = ProductEditor; exports.ProductPricingList = ProductPricingList; exports.ProductPricingRow = ProductPricingRow; exports.ProductProvider = ProductProvider; exports.ProductsList = ProductsList; exports.ProductsListContainer = ProductsListContainer; exports.PromoCodeInput = PromoCodeInput; exports.ProrationPreview = ProrationPreview; exports.StripeProvider = StripeProvider; exports.SubscriptionConfirmation = SubscriptionConfirmation; exports.SubscriptionDetails = SubscriptionDetails; exports.SubscriptionStatusBadge = SubscriptionStatusBadge; exports.SubscriptionSummaryCard = SubscriptionSummaryCard; exports.SubscriptionsContainer = SubscriptionsContainer; exports.SubscriptionsList = SubscriptionsList; exports.UsageContainer = UsageContainer; exports.UsageHistoryTable = UsageHistoryTable; exports.UsageSummaryCard = UsageSummaryCard; exports.UsageSummaryCards = UsageSummaryCards; exports.formatCurrency =
|
|
4465
|
+
exports.BillingAlertBanner = BillingAlertBanner; exports.BillingDashboardContainer = BillingDashboardContainer; exports.BillingDetailModal = BillingDetailModal; exports.BillingUsageSummaryCard = BillingUsageSummaryCard; exports.CancelSubscriptionDialog = CancelSubscriptionDialog; exports.CustomerInfoCard = CustomerInfoCard; exports.IntervalToggle = IntervalToggle; exports.InvoiceDetails = InvoiceDetails; exports.InvoiceStatusBadge = InvoiceStatusBadge; exports.InvoicesContainer = InvoicesContainer; exports.InvoicesList = InvoicesList; exports.InvoicesSummaryCard = InvoicesSummaryCard; exports.PaymentMethodCard = PaymentMethodCard; exports.PaymentMethodEditor = PaymentMethodEditor; exports.PaymentMethodForm = PaymentMethodForm; exports.PaymentMethodSummaryCard = PaymentMethodSummaryCard; exports.PaymentMethodsContainer = PaymentMethodsContainer; exports.PaymentMethodsList = PaymentMethodsList; exports.PriceArchiver = PriceArchiver; exports.PriceContainer = PriceContainer; exports.PriceDetails = PriceDetails; exports.PriceEditor = PriceEditor; exports.PriceProvider = PriceProvider; exports.PricesList = PricesList; exports.PricingCard = PricingCard; exports.ProductArchiver = ProductArchiver; exports.ProductContainer = ProductContainer; exports.ProductDetails = ProductDetails; exports.ProductEditor = ProductEditor; exports.ProductPricingList = ProductPricingList; exports.ProductPricingRow = ProductPricingRow; exports.ProductProvider = ProductProvider; exports.ProductsList = ProductsList; exports.ProductsListContainer = ProductsListContainer; exports.PromoCodeInput = PromoCodeInput; exports.ProrationPreview = ProrationPreview; exports.StripeProvider = StripeProvider; exports.SubscriptionConfirmation = SubscriptionConfirmation; exports.SubscriptionDetails = SubscriptionDetails; exports.SubscriptionStatusBadge = SubscriptionStatusBadge; exports.SubscriptionSummaryCard = SubscriptionSummaryCard; exports.SubscriptionsContainer = SubscriptionsContainer; exports.SubscriptionsList = SubscriptionsList; exports.UsageContainer = UsageContainer; exports.UsageHistoryTable = UsageHistoryTable; exports.UsageSummaryCard = UsageSummaryCard; exports.UsageSummaryCards = UsageSummaryCards; exports.formatCurrency = _chunkLVE3BJ6Kjs.formatCurrency; exports.formatDate = formatDate3; exports.formatInterval = _chunkLVE3BJ6Kjs.formatInterval; exports.isStripeConfigured = isStripeConfigured; exports.priceLabel = priceLabel; exports.usePriceContext = usePriceContext; exports.useProductContext = useProductContext;
|
|
4219
4466
|
//# sourceMappingURL=index.js.map
|