autumn-js 0.1.35 → 0.1.36
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/libraries/react/AutumnContext.mjs +4 -4
- package/dist/libraries/react/BaseAutumnProvider.mjs +6 -6
- package/dist/libraries/react/ReactAutumnProvider.mjs +7 -7
- package/dist/libraries/react/{chunk-FW7AQFVX.mjs → chunk-5BTQDWG6.mjs} +1 -1
- package/dist/libraries/react/{chunk-WSX7HWKQ.mjs → chunk-6PLIVXZY.mjs} +1 -1
- package/dist/libraries/react/{chunk-RNIUZGWU.mjs → chunk-6U2XJZGO.mjs} +1 -1
- package/dist/libraries/react/{chunk-5TLRC3ED.mjs → chunk-AHIEANFE.mjs} +17 -17
- package/dist/libraries/react/{chunk-QEWVBDWJ.mjs → chunk-ATGLJHUN.mjs} +1 -1
- package/dist/libraries/react/{chunk-7FMBA5I4.mjs → chunk-BR56DHZ2.mjs} +1 -1
- package/dist/libraries/react/{chunk-Q7LVAQ5K.mjs → chunk-DJXOY3UC.mjs} +2 -2
- package/dist/libraries/react/{chunk-4KLTPVNG.mjs → chunk-FAG5HHVM.mjs} +2 -2
- package/dist/libraries/react/{chunk-P4GHLIEZ.mjs → chunk-FSJNDXTY.mjs} +452 -450
- package/dist/libraries/react/{chunk-4QVAJKUF.mjs → chunk-HNWWFCOW.mjs} +1 -1
- package/dist/libraries/react/{chunk-MHAXHLX4.mjs → chunk-KCO4V65K.mjs} +6 -6
- package/dist/libraries/react/{chunk-YKJYGNXR.mjs → chunk-NJRJLNGW.mjs} +1 -1
- package/dist/libraries/react/{chunk-2LZIBRD4.mjs → chunk-NPPSXTRQ.mjs} +2 -2
- package/dist/libraries/react/{chunk-HN7ULWIM.mjs → chunk-P4BHBYHL.mjs} +1 -1
- package/dist/libraries/react/{chunk-C3G5RW3Q.mjs → chunk-QFOYSJQW.mjs} +6 -6
- package/dist/libraries/react/{chunk-7T7IOMAA.mjs → chunk-W3YUWXSL.mjs} +2 -2
- package/dist/libraries/react/{chunk-FL4H464X.mjs → chunk-WJZUVBCL.mjs} +3 -3
- package/dist/libraries/react/{chunk-4YM2QKRI.mjs → chunk-WRYAEUUV.mjs} +1 -1
- package/dist/libraries/react/client/ReactAutumnClient.mjs +3 -3
- package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.mjs +25 -25
- package/dist/libraries/react/components/paywall-dialog/paywall-dialog-synced.mjs +25 -25
- package/dist/libraries/react/components/pricing-table/pricing-table-synced.mjs +25 -25
- package/dist/libraries/react/components/ui/accordion.mjs +3 -3
- package/dist/libraries/react/components/ui/button.d.mts +1 -1
- package/dist/libraries/react/components/ui/button.d.ts +1 -1
- package/dist/libraries/react/components/ui/dialog.mjs +4 -4
- package/dist/libraries/react/components/ui/popover.mjs +5 -5
- package/dist/libraries/react/components/ui/switch.mjs +3 -3
- package/dist/libraries/react/hooks/useAnalytics.mjs +5 -5
- package/dist/libraries/react/hooks/useCustomer.mjs +6 -6
- package/dist/libraries/react/hooks/useCustomerBase.mjs +5 -5
- package/dist/libraries/react/hooks/useEntity.mjs +6 -6
- package/dist/libraries/react/hooks/useEntityBase.mjs +5 -5
- package/dist/libraries/react/hooks/usePaywall.mjs +5 -5
- package/dist/libraries/react/hooks/usePricingTable.mjs +5 -5
- package/package.json +1 -1
- package/dist/libraries/react/{chunk-2GEDBGON.mjs → chunk-4XU63W7I.mjs} +11 -11
- package/dist/libraries/react/{chunk-5OBFJVZC.mjs → chunk-XGIQOMYH.mjs} +6 -6
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
import {
|
|
4
4
|
getPricingTableContent
|
|
5
5
|
} from "./chunk-URQMBRFZ.mjs";
|
|
6
|
+
import {
|
|
7
|
+
Accordion,
|
|
8
|
+
AccordionContent,
|
|
9
|
+
AccordionItem,
|
|
10
|
+
Header,
|
|
11
|
+
Trigger2
|
|
12
|
+
} from "./chunk-FAG5HHVM.mjs";
|
|
6
13
|
import {
|
|
7
14
|
Button
|
|
8
15
|
} from "./chunk-SWSFJTEQ.mjs";
|
|
@@ -11,7 +18,12 @@ import {
|
|
|
11
18
|
DialogContent,
|
|
12
19
|
DialogFooter,
|
|
13
20
|
DialogTitle
|
|
14
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-KCO4V65K.mjs";
|
|
22
|
+
import {
|
|
23
|
+
ArrowRight,
|
|
24
|
+
ChevronDown,
|
|
25
|
+
LoaderCircle
|
|
26
|
+
} from "./chunk-2OHJ6PS6.mjs";
|
|
15
27
|
import {
|
|
16
28
|
Input
|
|
17
29
|
} from "./chunk-GUM4HIGI.mjs";
|
|
@@ -19,474 +31,152 @@ import {
|
|
|
19
31
|
Popover,
|
|
20
32
|
PopoverContent,
|
|
21
33
|
PopoverTrigger
|
|
22
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-QFOYSJQW.mjs";
|
|
23
35
|
import {
|
|
24
36
|
Switch
|
|
25
|
-
} from "./chunk-
|
|
26
|
-
import {
|
|
27
|
-
getCheckoutContent
|
|
28
|
-
} from "./chunk-BLM4DAAR.mjs";
|
|
37
|
+
} from "./chunk-NPPSXTRQ.mjs";
|
|
29
38
|
import {
|
|
30
39
|
getPaywallContent
|
|
31
40
|
} from "./chunk-I5ZGIAIX.mjs";
|
|
32
41
|
import {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
AccordionItem,
|
|
36
|
-
Header,
|
|
37
|
-
Trigger2
|
|
38
|
-
} from "./chunk-4KLTPVNG.mjs";
|
|
42
|
+
getCheckoutContent
|
|
43
|
+
} from "./chunk-BLM4DAAR.mjs";
|
|
39
44
|
import {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
} from "./chunk-2OHJ6PS6.mjs";
|
|
45
|
+
loadingStyles,
|
|
46
|
+
spinnerStyles
|
|
47
|
+
} from "./chunk-WVKYZYFT.mjs";
|
|
44
48
|
import {
|
|
45
49
|
usePaywall
|
|
46
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-P4BHBYHL.mjs";
|
|
47
51
|
import {
|
|
48
52
|
usePricingTable
|
|
49
|
-
} from "./chunk-
|
|
50
|
-
import {
|
|
51
|
-
loadingStyles,
|
|
52
|
-
spinnerStyles
|
|
53
|
-
} from "./chunk-WVKYZYFT.mjs";
|
|
53
|
+
} from "./chunk-BR56DHZ2.mjs";
|
|
54
54
|
import {
|
|
55
55
|
cn
|
|
56
56
|
} from "./chunk-4J6OC4ZQ.mjs";
|
|
57
57
|
import {
|
|
58
58
|
useCustomer
|
|
59
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-DJXOY3UC.mjs";
|
|
60
60
|
|
|
61
61
|
// src/libraries/react/components/checkout-dialog/checkout-dialog-synced.tsx
|
|
62
|
-
import { useEffect, useState } from "react";
|
|
62
|
+
import { useEffect, useState as useState2 } from "react";
|
|
63
|
+
|
|
64
|
+
// src/libraries/react/components/paywall-dialog/paywall-dialog-synced.tsx
|
|
63
65
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
currency
|
|
71
|
-
}).format(amount);
|
|
72
|
-
};
|
|
73
|
-
function CheckoutDialog(params) {
|
|
74
|
-
const { attach } = useCustomer();
|
|
75
|
-
const [checkoutResult, setCheckoutResult] = useState(params?.checkoutResult);
|
|
76
|
-
useEffect(() => {
|
|
77
|
-
if (params.checkoutResult) {
|
|
78
|
-
setCheckoutResult(params.checkoutResult);
|
|
79
|
-
}
|
|
80
|
-
}, [params.checkoutResult]);
|
|
81
|
-
const [loading, setLoading] = useState(false);
|
|
82
|
-
if (!checkoutResult) {
|
|
66
|
+
function PaywallDialog(params) {
|
|
67
|
+
const { data: preview } = usePaywall({
|
|
68
|
+
featureId: params?.featureId,
|
|
69
|
+
entityId: params?.entityId
|
|
70
|
+
});
|
|
71
|
+
if (!params || !preview) {
|
|
83
72
|
return /* @__PURE__ */ jsx(Fragment, {});
|
|
84
73
|
}
|
|
85
74
|
const { open, setOpen } = params;
|
|
86
|
-
const { title, message } =
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
/* @__PURE__ */ jsx(
|
|
91
|
-
/* @__PURE__ */ jsx("div", { className: "au-px-6 au-mt-1 au-mb-4 au-text-muted-foreground", children: message }),
|
|
92
|
-
isPaid && checkoutResult && /* @__PURE__ */ jsx(
|
|
93
|
-
PriceInformation,
|
|
94
|
-
{
|
|
95
|
-
checkoutResult,
|
|
96
|
-
setCheckoutResult
|
|
97
|
-
}
|
|
98
|
-
),
|
|
99
|
-
/* @__PURE__ */ jsx(DialogFooter, { className: "au-flex au-flex-col sm:au-flex-row au-justify-between au-gap-x-4 au-py-2 au-pl-6 au-pr-3 au-bg-secondary au-border-t au-shadow-inner", children: /* @__PURE__ */ jsx(
|
|
75
|
+
const { title, message } = getPaywallContent(preview);
|
|
76
|
+
return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs(DialogContent, { className: "au-p-0 au-pt-4 au-gap-0 au-text-foreground au-overflow-hidden au-text-sm", children: [
|
|
77
|
+
/* @__PURE__ */ jsx(DialogTitle, { className: cn("au-font-bold au-text-xl au-px-6"), children: title }),
|
|
78
|
+
/* @__PURE__ */ jsx("div", { className: "au-px-6 au-my-2", children: message }),
|
|
79
|
+
/* @__PURE__ */ jsx(DialogFooter, { className: "au-flex au-flex-col sm:au-flex-row au-justify-between au-gap-x-4 au-py-2 au-mt-4 au-pl-6 au-pr-3 au-bg-secondary au-border-t", children: /* @__PURE__ */ jsx(
|
|
100
80
|
Button,
|
|
101
81
|
{
|
|
102
82
|
size: "sm",
|
|
83
|
+
className: "au-font-medium au-shadow au-transition au-min-w-20",
|
|
103
84
|
onClick: async () => {
|
|
104
|
-
setLoading(true);
|
|
105
|
-
const options = checkoutResult.options.map((option) => {
|
|
106
|
-
return {
|
|
107
|
-
featureId: option.feature_id,
|
|
108
|
-
quantity: option.quantity
|
|
109
|
-
};
|
|
110
|
-
});
|
|
111
|
-
await attach({
|
|
112
|
-
productId: checkoutResult.product.id,
|
|
113
|
-
...params.checkoutParams || {},
|
|
114
|
-
options
|
|
115
|
-
});
|
|
116
85
|
setOpen(false);
|
|
117
|
-
setLoading(false);
|
|
118
86
|
},
|
|
119
|
-
|
|
120
|
-
className: "au-min-w-16 au-flex au-items-center au-gap-2",
|
|
121
|
-
children: loading ? /* @__PURE__ */ jsx(LoaderCircle, { className: "au-w-4 au-h-4 au-animate-spin" }) : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("span", { className: "au-whitespace-nowrap au-flex au-gap-1", children: "Confirm" }) })
|
|
87
|
+
children: "Confirm"
|
|
122
88
|
}
|
|
123
89
|
) })
|
|
124
90
|
] }) });
|
|
125
91
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
92
|
+
|
|
93
|
+
// src/libraries/react/components/pricing-table/pricing-table-synced.tsx
|
|
94
|
+
import React from "react";
|
|
95
|
+
import { createContext, useContext, useState } from "react";
|
|
96
|
+
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
97
|
+
function PricingTable({
|
|
98
|
+
productDetails
|
|
129
99
|
}) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
)
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
function DueAmounts({ checkoutResult }) {
|
|
145
|
-
const { next_cycle, product } = checkoutResult;
|
|
146
|
-
const nextCycleAtStr = next_cycle ? new Date(next_cycle.starts_at).toLocaleDateString() : void 0;
|
|
147
|
-
const hasUsagePrice = product.items.some(
|
|
148
|
-
(item) => item.usage_model === "pay_per_use"
|
|
100
|
+
const { customer, checkout } = useCustomer({ errorOnNotFound: false });
|
|
101
|
+
const [isAnnual, setIsAnnual] = useState(false);
|
|
102
|
+
const { products, isLoading, error } = usePricingTable({ productDetails });
|
|
103
|
+
if (isLoading) {
|
|
104
|
+
return /* @__PURE__ */ jsx2("div", { style: loadingStyles, children: /* @__PURE__ */ jsx2(LoaderCircle, { style: spinnerStyles }) });
|
|
105
|
+
}
|
|
106
|
+
if (error) {
|
|
107
|
+
return /* @__PURE__ */ jsx2("div", { children: " Something went wrong..." });
|
|
108
|
+
}
|
|
109
|
+
const intervals = Array.from(
|
|
110
|
+
new Set(
|
|
111
|
+
products?.map((p) => p.properties?.interval_group).filter((i) => !!i)
|
|
112
|
+
)
|
|
149
113
|
);
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("p", { className: "au-text-md", children: [
|
|
161
|
-
"Due next cycle (",
|
|
162
|
-
nextCycleAtStr,
|
|
163
|
-
")"
|
|
164
|
-
] }) }),
|
|
165
|
-
/* @__PURE__ */ jsxs("p", { className: "au-text-md", children: [
|
|
166
|
-
formatCurrency({
|
|
167
|
-
amount: next_cycle.total,
|
|
168
|
-
currency: checkoutResult?.currency
|
|
169
|
-
}),
|
|
170
|
-
hasUsagePrice && /* @__PURE__ */ jsx("span", { children: " + usage prices" })
|
|
171
|
-
] })
|
|
172
|
-
] })
|
|
173
|
-
] });
|
|
174
|
-
}
|
|
175
|
-
function ProductItems({
|
|
176
|
-
checkoutResult,
|
|
177
|
-
setCheckoutResult
|
|
178
|
-
}) {
|
|
179
|
-
const isUpdateQuantity = checkoutResult?.product.scenario === "active" && checkoutResult.product.properties.updateable;
|
|
180
|
-
const isOneOff = checkoutResult?.product.properties.is_one_off;
|
|
181
|
-
return /* @__PURE__ */ jsxs("div", { className: "au-flex au-flex-col au-gap-2", children: [
|
|
182
|
-
/* @__PURE__ */ jsx("p", { className: "au-text-sm au-font-medium", children: "Price" }),
|
|
183
|
-
checkoutResult?.product.items.filter((item) => item.type !== "feature").map((item, index) => {
|
|
184
|
-
if (item.usage_model == "prepaid") {
|
|
185
|
-
return /* @__PURE__ */ jsx(
|
|
186
|
-
PrepaidItem,
|
|
187
|
-
{
|
|
188
|
-
item,
|
|
189
|
-
checkoutResult,
|
|
190
|
-
setCheckoutResult
|
|
191
|
-
},
|
|
192
|
-
index
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
if (isUpdateQuantity) {
|
|
196
|
-
return null;
|
|
114
|
+
const multiInterval = intervals.length > 1;
|
|
115
|
+
const intervalFilter = (product) => {
|
|
116
|
+
if (!product.properties?.interval_group) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
if (multiInterval) {
|
|
120
|
+
if (isAnnual) {
|
|
121
|
+
return product.properties?.interval_group === "year";
|
|
122
|
+
} else {
|
|
123
|
+
return product.properties?.interval_group === "month";
|
|
197
124
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
item.display?.secondary_text
|
|
204
|
-
] })
|
|
205
|
-
] }, index);
|
|
206
|
-
})
|
|
207
|
-
] });
|
|
208
|
-
}
|
|
209
|
-
function CheckoutLines({ checkoutResult }) {
|
|
210
|
-
return /* @__PURE__ */ jsx(Accordion, { type: "single", collapsible: true, children: /* @__PURE__ */ jsxs(AccordionItem, { value: "total", className: "au-border-b-0", children: [
|
|
211
|
-
/* @__PURE__ */ jsx(CustomAccordionTrigger, { className: "au-justify-between au-w-full au-my-0 au-py-0 au-border-none", children: /* @__PURE__ */ jsxs("div", { className: "au-cursor-pointer au-flex au-items-center au-gap-1 au-w-full au-justify-end", children: [
|
|
212
|
-
/* @__PURE__ */ jsx("p", { className: "au-font-light au-text-muted-foreground", children: "View details" }),
|
|
213
|
-
/* @__PURE__ */ jsx(
|
|
214
|
-
ChevronDown,
|
|
215
|
-
{
|
|
216
|
-
className: "au-text-muted-foreground au-mt-0.5 au-rotate-90 au-transition-transform au-duration-200 au-ease-in-out",
|
|
217
|
-
size: 14
|
|
218
|
-
}
|
|
219
|
-
)
|
|
220
|
-
] }) }),
|
|
221
|
-
/* @__PURE__ */ jsx(AccordionContent, { className: "au-mt-2 au-mb-0 au-pb-2 au-flex au-flex-col au-gap-2", children: checkoutResult?.lines.filter((line) => line.amount != 0).map((line, index) => {
|
|
222
|
-
return /* @__PURE__ */ jsxs("div", { className: "au-flex au-justify-between", children: [
|
|
223
|
-
/* @__PURE__ */ jsx("p", { className: "au-text-muted-foreground", children: line.description }),
|
|
224
|
-
/* @__PURE__ */ jsx("p", { className: "au-text-muted-foreground", children: new Intl.NumberFormat("en-US", {
|
|
225
|
-
style: "currency",
|
|
226
|
-
currency: checkoutResult?.currency
|
|
227
|
-
}).format(line.amount) })
|
|
228
|
-
] }, index);
|
|
229
|
-
}) })
|
|
230
|
-
] }) });
|
|
231
|
-
}
|
|
232
|
-
function CustomAccordionTrigger({
|
|
233
|
-
className,
|
|
234
|
-
children,
|
|
235
|
-
...props
|
|
236
|
-
}) {
|
|
237
|
-
return /* @__PURE__ */ jsx(Header, { className: "au-flex", children: /* @__PURE__ */ jsx(
|
|
238
|
-
Trigger2,
|
|
125
|
+
}
|
|
126
|
+
return true;
|
|
127
|
+
};
|
|
128
|
+
return /* @__PURE__ */ jsx2("div", { className: cn("au-root"), children: products && /* @__PURE__ */ jsx2(
|
|
129
|
+
PricingTableContainer,
|
|
239
130
|
{
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
),
|
|
245
|
-
|
|
246
|
-
|
|
131
|
+
products,
|
|
132
|
+
isAnnualToggle: isAnnual,
|
|
133
|
+
setIsAnnualToggle: setIsAnnual,
|
|
134
|
+
multiInterval,
|
|
135
|
+
children: products.filter(intervalFilter).map((product, index) => /* @__PURE__ */ jsx2(
|
|
136
|
+
PricingCard,
|
|
137
|
+
{
|
|
138
|
+
productId: product.id,
|
|
139
|
+
buttonProps: {
|
|
140
|
+
disabled: product.scenario === "active" && !product.properties.updateable || product.scenario === "scheduled",
|
|
141
|
+
onClick: async () => {
|
|
142
|
+
if (product.id && customer) {
|
|
143
|
+
await checkout({
|
|
144
|
+
productId: product.id,
|
|
145
|
+
dialog: CheckoutDialog
|
|
146
|
+
});
|
|
147
|
+
} else if (product.display?.button_url) {
|
|
148
|
+
window.open(product.display?.button_url, "_blank");
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
index
|
|
154
|
+
))
|
|
247
155
|
}
|
|
248
156
|
) });
|
|
249
157
|
}
|
|
250
|
-
var
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
);
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
newOptions.push({
|
|
273
|
-
featureId: item.feature_id,
|
|
274
|
-
quantity: Number(quantityInput) * billingUnits
|
|
275
|
-
});
|
|
276
|
-
const { data, error } = await checkout({
|
|
277
|
-
productId: checkoutResult.product.id,
|
|
278
|
-
options: newOptions,
|
|
279
|
-
dialog: CheckoutDialog
|
|
280
|
-
});
|
|
281
|
-
if (error) {
|
|
282
|
-
console.error(error);
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
setCheckoutResult(data);
|
|
286
|
-
} catch (error) {
|
|
287
|
-
console.error(error);
|
|
288
|
-
} finally {
|
|
289
|
-
setLoading(false);
|
|
290
|
-
setOpen(false);
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
const disableSelection = scenario === "renew";
|
|
294
|
-
return /* @__PURE__ */ jsxs("div", { className: "au-flex au-justify-between au-gap-2", children: [
|
|
295
|
-
/* @__PURE__ */ jsxs("div", { className: "au-flex au-gap-2 au-items-start", children: [
|
|
296
|
-
/* @__PURE__ */ jsx("p", { className: "au-text-muted-foreground au-whitespace-nowrap", children: item.feature?.name }),
|
|
297
|
-
/* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
|
|
298
|
-
/* @__PURE__ */ jsxs(
|
|
299
|
-
PopoverTrigger,
|
|
300
|
-
{
|
|
301
|
-
className: cn(
|
|
302
|
-
"au-text-muted-foreground au-text-xs au-px-1 au-py-0.5 au-rounded-md au-flex au-items-center au-gap-1 au-bg-accent/80 au-shrink-0",
|
|
303
|
-
disableSelection !== true && "hover:au-bg-accent hover:au-text-foreground"
|
|
304
|
-
),
|
|
305
|
-
disabled: disableSelection,
|
|
306
|
-
children: [
|
|
307
|
-
"Qty: ",
|
|
308
|
-
quantity,
|
|
309
|
-
/* @__PURE__ */ jsx(ChevronDown, { size: 12 })
|
|
310
|
-
]
|
|
311
|
-
}
|
|
312
|
-
),
|
|
313
|
-
/* @__PURE__ */ jsxs(
|
|
314
|
-
PopoverContent,
|
|
315
|
-
{
|
|
316
|
-
align: "start",
|
|
317
|
-
className: "au-w-80 au-text-sm au-p-4 au-pt-3 au-flex au-flex-col au-gap-4",
|
|
318
|
-
children: [
|
|
319
|
-
/* @__PURE__ */ jsxs("div", { className: "au-flex au-flex-col au-gap-1", children: [
|
|
320
|
-
/* @__PURE__ */ jsx("p", { className: "au-text-sm au-font-medium", children: item.feature?.name }),
|
|
321
|
-
/* @__PURE__ */ jsxs("p", { className: "au-text-muted-foreground", children: [
|
|
322
|
-
item.display?.primary_text,
|
|
323
|
-
" ",
|
|
324
|
-
item.display?.secondary_text
|
|
325
|
-
] })
|
|
326
|
-
] }),
|
|
327
|
-
/* @__PURE__ */ jsxs("div", { className: "au-flex au-justify-between au-items-end", children: [
|
|
328
|
-
/* @__PURE__ */ jsxs("div", { className: "au-flex au-gap-2 au-items-center", children: [
|
|
329
|
-
/* @__PURE__ */ jsx(
|
|
330
|
-
Input,
|
|
331
|
-
{
|
|
332
|
-
className: "au-h-7 au-w-16 focus:!au-ring-2",
|
|
333
|
-
value: quantityInput,
|
|
334
|
-
onChange: (e) => setQuantityInput(e.target.value)
|
|
335
|
-
}
|
|
336
|
-
),
|
|
337
|
-
/* @__PURE__ */ jsxs("p", { className: "au-text-muted-foreground", children: [
|
|
338
|
-
billingUnits > 1 && `x ${billingUnits} `,
|
|
339
|
-
item.feature?.name
|
|
340
|
-
] })
|
|
341
|
-
] }),
|
|
342
|
-
/* @__PURE__ */ jsx(
|
|
343
|
-
Button,
|
|
344
|
-
{
|
|
345
|
-
onClick: handleSave,
|
|
346
|
-
className: "au-w-14 !au-h-7 au-text-sm au-items-center au-bg-white au-text-foreground au-shadow-sm au-border au-border-zinc-200 hover:au-bg-zinc-100",
|
|
347
|
-
disabled: loading,
|
|
348
|
-
children: loading ? /* @__PURE__ */ jsx(LoaderCircle, { className: "au-text-muted-foreground au-animate-spin !au-w-4 !au-h-4" }) : "Save"
|
|
349
|
-
}
|
|
350
|
-
)
|
|
351
|
-
] })
|
|
352
|
-
]
|
|
353
|
-
}
|
|
354
|
-
)
|
|
355
|
-
] })
|
|
356
|
-
] }),
|
|
357
|
-
/* @__PURE__ */ jsxs("p", { className: "au-text-end", children: [
|
|
358
|
-
item.display?.primary_text,
|
|
359
|
-
" ",
|
|
360
|
-
item.display?.secondary_text
|
|
361
|
-
] })
|
|
362
|
-
] });
|
|
363
|
-
};
|
|
364
|
-
var PriceItem = ({
|
|
365
|
-
children,
|
|
366
|
-
className,
|
|
367
|
-
...props
|
|
368
|
-
}) => {
|
|
369
|
-
return /* @__PURE__ */ jsx(
|
|
370
|
-
"div",
|
|
371
|
-
{
|
|
372
|
-
className: cn(
|
|
373
|
-
"au-flex au-flex-col au-pb-4 sm:au-pb-0 au-gap-1 sm:au-flex-row au-justify-between sm:au-h-7 sm:au-gap-2 sm:au-items-center",
|
|
374
|
-
className
|
|
375
|
-
),
|
|
376
|
-
...props,
|
|
377
|
-
children
|
|
378
|
-
}
|
|
379
|
-
);
|
|
380
|
-
};
|
|
381
|
-
var PricingDialogButton = ({
|
|
382
|
-
children,
|
|
383
|
-
size,
|
|
384
|
-
onClick,
|
|
385
|
-
disabled,
|
|
386
|
-
className
|
|
387
|
-
}) => {
|
|
388
|
-
return /* @__PURE__ */ jsxs(
|
|
389
|
-
Button,
|
|
390
|
-
{
|
|
391
|
-
onClick,
|
|
392
|
-
disabled,
|
|
393
|
-
size,
|
|
394
|
-
className: cn(className, "au-shadow-sm au-shadow-stone-400"),
|
|
395
|
-
children: [
|
|
396
|
-
children,
|
|
397
|
-
/* @__PURE__ */ jsx(ArrowRight, { className: "!au-h-3" })
|
|
398
|
-
]
|
|
399
|
-
}
|
|
400
|
-
);
|
|
401
|
-
};
|
|
402
|
-
|
|
403
|
-
// src/libraries/react/components/pricing-table/pricing-table-synced.tsx
|
|
404
|
-
import React2 from "react";
|
|
405
|
-
import { createContext, useContext, useState as useState2 } from "react";
|
|
406
|
-
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
407
|
-
function PricingTable({
|
|
408
|
-
productDetails
|
|
409
|
-
}) {
|
|
410
|
-
const { customer, checkout } = useCustomer({ errorOnNotFound: false });
|
|
411
|
-
const [isAnnual, setIsAnnual] = useState2(false);
|
|
412
|
-
const { products, isLoading, error } = usePricingTable({ productDetails });
|
|
413
|
-
if (isLoading) {
|
|
414
|
-
return /* @__PURE__ */ jsx2("div", { style: loadingStyles, children: /* @__PURE__ */ jsx2(LoaderCircle, { style: spinnerStyles }) });
|
|
415
|
-
}
|
|
416
|
-
if (error) {
|
|
417
|
-
return /* @__PURE__ */ jsx2("div", { children: " Something went wrong..." });
|
|
418
|
-
}
|
|
419
|
-
const intervals = Array.from(
|
|
420
|
-
new Set(
|
|
421
|
-
products?.map((p) => p.properties?.interval_group).filter((i) => !!i)
|
|
422
|
-
)
|
|
423
|
-
);
|
|
424
|
-
const multiInterval = intervals.length > 1;
|
|
425
|
-
const intervalFilter = (product) => {
|
|
426
|
-
if (!product.properties?.interval_group) {
|
|
427
|
-
return true;
|
|
428
|
-
}
|
|
429
|
-
if (multiInterval) {
|
|
430
|
-
if (isAnnual) {
|
|
431
|
-
return product.properties?.interval_group === "year";
|
|
432
|
-
} else {
|
|
433
|
-
return product.properties?.interval_group === "month";
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
return true;
|
|
437
|
-
};
|
|
438
|
-
return /* @__PURE__ */ jsx2("div", { className: cn("au-root"), children: products && /* @__PURE__ */ jsx2(
|
|
439
|
-
PricingTableContainer,
|
|
440
|
-
{
|
|
441
|
-
products,
|
|
442
|
-
isAnnualToggle: isAnnual,
|
|
443
|
-
setIsAnnualToggle: setIsAnnual,
|
|
444
|
-
multiInterval,
|
|
445
|
-
children: products.filter(intervalFilter).map((product, index) => /* @__PURE__ */ jsx2(
|
|
446
|
-
PricingCard,
|
|
447
|
-
{
|
|
448
|
-
productId: product.id,
|
|
449
|
-
buttonProps: {
|
|
450
|
-
disabled: product.scenario === "active" && !product.properties.updateable || product.scenario === "scheduled",
|
|
451
|
-
onClick: async () => {
|
|
452
|
-
if (product.id && customer) {
|
|
453
|
-
await checkout({
|
|
454
|
-
productId: product.id,
|
|
455
|
-
dialog: CheckoutDialog
|
|
456
|
-
});
|
|
457
|
-
} else if (product.display?.button_url) {
|
|
458
|
-
window.open(product.display?.button_url, "_blank");
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
},
|
|
463
|
-
index
|
|
464
|
-
))
|
|
465
|
-
}
|
|
466
|
-
) });
|
|
467
|
-
}
|
|
468
|
-
var PricingTableContext = createContext({
|
|
469
|
-
isAnnualToggle: false,
|
|
470
|
-
setIsAnnualToggle: () => {
|
|
471
|
-
},
|
|
472
|
-
products: [],
|
|
473
|
-
showFeatures: true
|
|
474
|
-
});
|
|
475
|
-
var usePricingTableContext = (componentName) => {
|
|
476
|
-
const context = useContext(PricingTableContext);
|
|
477
|
-
if (context === void 0) {
|
|
478
|
-
throw new Error(`${componentName} must be used within <PricingTable />`);
|
|
479
|
-
}
|
|
480
|
-
return context;
|
|
481
|
-
};
|
|
482
|
-
var PricingTableContainer = ({
|
|
483
|
-
children,
|
|
484
|
-
products,
|
|
485
|
-
showFeatures = true,
|
|
486
|
-
className,
|
|
487
|
-
isAnnualToggle,
|
|
488
|
-
setIsAnnualToggle,
|
|
489
|
-
multiInterval
|
|
158
|
+
var PricingTableContext = createContext({
|
|
159
|
+
isAnnualToggle: false,
|
|
160
|
+
setIsAnnualToggle: () => {
|
|
161
|
+
},
|
|
162
|
+
products: [],
|
|
163
|
+
showFeatures: true
|
|
164
|
+
});
|
|
165
|
+
var usePricingTableContext = (componentName) => {
|
|
166
|
+
const context = useContext(PricingTableContext);
|
|
167
|
+
if (context === void 0) {
|
|
168
|
+
throw new Error(`${componentName} must be used within <PricingTable />`);
|
|
169
|
+
}
|
|
170
|
+
return context;
|
|
171
|
+
};
|
|
172
|
+
var PricingTableContainer = ({
|
|
173
|
+
children,
|
|
174
|
+
products,
|
|
175
|
+
showFeatures = true,
|
|
176
|
+
className,
|
|
177
|
+
isAnnualToggle,
|
|
178
|
+
setIsAnnualToggle,
|
|
179
|
+
multiInterval
|
|
490
180
|
}) => {
|
|
491
181
|
if (!products) {
|
|
492
182
|
throw new Error("products is required in <PricingTable />");
|
|
@@ -638,8 +328,8 @@ var PricingFeatureList = ({
|
|
|
638
328
|
)) })
|
|
639
329
|
] });
|
|
640
330
|
};
|
|
641
|
-
var PricingCardButton =
|
|
642
|
-
const [loading, setLoading] =
|
|
331
|
+
var PricingCardButton = React.forwardRef(({ recommended, children, className, onClick, ...props }, ref) => {
|
|
332
|
+
const [loading, setLoading] = useState(false);
|
|
643
333
|
const handleClick = async (e) => {
|
|
644
334
|
setLoading(true);
|
|
645
335
|
try {
|
|
@@ -697,37 +387,351 @@ var RecommendedBadge = ({ recommended }) => {
|
|
|
697
387
|
return /* @__PURE__ */ jsx2("div", { className: "au-bg-secondary au-absolute au-border au-text-muted-foreground au-text-sm au-font-medium lg:au-rounded-full au-px-3 lg:au-py-0.5 lg:au-top-4 lg:au-right-4 au-top-[-1px] au-right-[-1px] au-rounded-bl-lg", children: recommended });
|
|
698
388
|
};
|
|
699
389
|
|
|
700
|
-
// src/libraries/react/components/
|
|
390
|
+
// src/libraries/react/components/checkout-dialog/checkout-dialog-synced.tsx
|
|
701
391
|
import { Fragment as Fragment3, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
392
|
+
var formatCurrency = ({
|
|
393
|
+
amount,
|
|
394
|
+
currency
|
|
395
|
+
}) => {
|
|
396
|
+
return new Intl.NumberFormat("en-US", {
|
|
397
|
+
style: "currency",
|
|
398
|
+
currency
|
|
399
|
+
}).format(amount);
|
|
400
|
+
};
|
|
401
|
+
function CheckoutDialog(params) {
|
|
402
|
+
const { attach } = useCustomer();
|
|
403
|
+
const [checkoutResult, setCheckoutResult] = useState2(params?.checkoutResult);
|
|
404
|
+
useEffect(() => {
|
|
405
|
+
if (params.checkoutResult) {
|
|
406
|
+
setCheckoutResult(params.checkoutResult);
|
|
407
|
+
}
|
|
408
|
+
}, [params.checkoutResult]);
|
|
409
|
+
const [loading, setLoading] = useState2(false);
|
|
410
|
+
if (!checkoutResult) {
|
|
708
411
|
return /* @__PURE__ */ jsx3(Fragment3, {});
|
|
709
412
|
}
|
|
710
413
|
const { open, setOpen } = params;
|
|
711
|
-
const { title, message } =
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
/* @__PURE__ */ jsx3(
|
|
414
|
+
const { title, message } = getCheckoutContent(checkoutResult);
|
|
415
|
+
const isFree = checkoutResult?.product.properties?.is_free;
|
|
416
|
+
const isPaid = isFree === false;
|
|
417
|
+
return /* @__PURE__ */ jsx3(Dialog, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs3(DialogContent, { className: "au-p-0 au-pt-4 au-gap-0 au-text-foreground au-text-sm", children: [
|
|
418
|
+
/* @__PURE__ */ jsx3(DialogTitle, { className: "au-px-6 au-mb-1", children: title }),
|
|
419
|
+
/* @__PURE__ */ jsx3("div", { className: "au-px-6 au-mt-1 au-mb-4 au-text-muted-foreground", children: message }),
|
|
420
|
+
isPaid && checkoutResult && /* @__PURE__ */ jsx3(
|
|
421
|
+
PriceInformation,
|
|
422
|
+
{
|
|
423
|
+
checkoutResult,
|
|
424
|
+
setCheckoutResult
|
|
425
|
+
}
|
|
426
|
+
),
|
|
427
|
+
/* @__PURE__ */ jsx3(DialogFooter, { className: "au-flex au-flex-col sm:au-flex-row au-justify-between au-gap-x-4 au-py-2 au-pl-6 au-pr-3 au-bg-secondary au-border-t au-shadow-inner", children: /* @__PURE__ */ jsx3(
|
|
716
428
|
Button,
|
|
717
429
|
{
|
|
718
430
|
size: "sm",
|
|
719
|
-
className: "au-font-medium au-shadow au-transition au-min-w-20",
|
|
720
431
|
onClick: async () => {
|
|
432
|
+
setLoading(true);
|
|
433
|
+
const options = checkoutResult.options.map((option) => {
|
|
434
|
+
return {
|
|
435
|
+
featureId: option.feature_id,
|
|
436
|
+
quantity: option.quantity
|
|
437
|
+
};
|
|
438
|
+
});
|
|
439
|
+
await attach({
|
|
440
|
+
productId: checkoutResult.product.id,
|
|
441
|
+
...params.checkoutParams || {},
|
|
442
|
+
options
|
|
443
|
+
});
|
|
721
444
|
setOpen(false);
|
|
445
|
+
setLoading(false);
|
|
722
446
|
},
|
|
723
|
-
|
|
447
|
+
disabled: loading,
|
|
448
|
+
className: "au-min-w-16 au-flex au-items-center au-gap-2",
|
|
449
|
+
children: loading ? /* @__PURE__ */ jsx3(LoaderCircle, { className: "au-w-4 au-h-4 au-animate-spin" }) : /* @__PURE__ */ jsx3(Fragment3, { children: /* @__PURE__ */ jsx3("span", { className: "au-whitespace-nowrap au-flex au-gap-1", children: "Confirm" }) })
|
|
724
450
|
}
|
|
725
451
|
) })
|
|
726
452
|
] }) });
|
|
727
453
|
}
|
|
454
|
+
function PriceInformation({
|
|
455
|
+
checkoutResult,
|
|
456
|
+
setCheckoutResult
|
|
457
|
+
}) {
|
|
458
|
+
return /* @__PURE__ */ jsxs3("div", { className: "au-px-6 au-mb-4 au-flex au-flex-col au-gap-4", children: [
|
|
459
|
+
/* @__PURE__ */ jsx3(
|
|
460
|
+
ProductItems,
|
|
461
|
+
{
|
|
462
|
+
checkoutResult,
|
|
463
|
+
setCheckoutResult
|
|
464
|
+
}
|
|
465
|
+
),
|
|
466
|
+
/* @__PURE__ */ jsxs3("div", { className: "au-flex au-flex-col au-gap-2", children: [
|
|
467
|
+
checkoutResult?.has_prorations && checkoutResult.lines.length > 0 && /* @__PURE__ */ jsx3(CheckoutLines, { checkoutResult }),
|
|
468
|
+
/* @__PURE__ */ jsx3(DueAmounts, { checkoutResult })
|
|
469
|
+
] })
|
|
470
|
+
] });
|
|
471
|
+
}
|
|
472
|
+
function DueAmounts({ checkoutResult }) {
|
|
473
|
+
const { next_cycle, product } = checkoutResult;
|
|
474
|
+
const nextCycleAtStr = next_cycle ? new Date(next_cycle.starts_at).toLocaleDateString() : void 0;
|
|
475
|
+
const hasUsagePrice = product.items.some(
|
|
476
|
+
(item) => item.usage_model === "pay_per_use"
|
|
477
|
+
);
|
|
478
|
+
const showNextCycle = next_cycle && next_cycle.total !== checkoutResult.total;
|
|
479
|
+
return /* @__PURE__ */ jsxs3("div", { className: "au-flex au-flex-col au-gap-1", children: [
|
|
480
|
+
/* @__PURE__ */ jsxs3("div", { className: "au-flex au-justify-between", children: [
|
|
481
|
+
/* @__PURE__ */ jsx3("div", { children: /* @__PURE__ */ jsx3("p", { className: "au-font-medium au-text-md", children: "Total due today" }) }),
|
|
482
|
+
/* @__PURE__ */ jsx3("p", { className: "au-font-medium au-text-md", children: formatCurrency({
|
|
483
|
+
amount: checkoutResult?.total,
|
|
484
|
+
currency: checkoutResult?.currency
|
|
485
|
+
}) })
|
|
486
|
+
] }),
|
|
487
|
+
showNextCycle && /* @__PURE__ */ jsxs3("div", { className: "au-flex au-justify-between au-text-muted-foreground", children: [
|
|
488
|
+
/* @__PURE__ */ jsx3("div", { children: /* @__PURE__ */ jsxs3("p", { className: "au-text-md", children: [
|
|
489
|
+
"Due next cycle (",
|
|
490
|
+
nextCycleAtStr,
|
|
491
|
+
")"
|
|
492
|
+
] }) }),
|
|
493
|
+
/* @__PURE__ */ jsxs3("p", { className: "au-text-md", children: [
|
|
494
|
+
formatCurrency({
|
|
495
|
+
amount: next_cycle.total,
|
|
496
|
+
currency: checkoutResult?.currency
|
|
497
|
+
}),
|
|
498
|
+
hasUsagePrice && /* @__PURE__ */ jsx3("span", { children: " + usage prices" })
|
|
499
|
+
] })
|
|
500
|
+
] })
|
|
501
|
+
] });
|
|
502
|
+
}
|
|
503
|
+
function ProductItems({
|
|
504
|
+
checkoutResult,
|
|
505
|
+
setCheckoutResult
|
|
506
|
+
}) {
|
|
507
|
+
const isUpdateQuantity = checkoutResult?.product.scenario === "active" && checkoutResult.product.properties.updateable;
|
|
508
|
+
const isOneOff = checkoutResult?.product.properties.is_one_off;
|
|
509
|
+
return /* @__PURE__ */ jsxs3("div", { className: "au-flex au-flex-col au-gap-2", children: [
|
|
510
|
+
/* @__PURE__ */ jsx3("p", { className: "au-text-sm au-font-medium", children: "Price" }),
|
|
511
|
+
checkoutResult?.product.items.filter((item) => item.type !== "feature").map((item, index) => {
|
|
512
|
+
if (item.usage_model == "prepaid") {
|
|
513
|
+
return /* @__PURE__ */ jsx3(
|
|
514
|
+
PrepaidItem,
|
|
515
|
+
{
|
|
516
|
+
item,
|
|
517
|
+
checkoutResult,
|
|
518
|
+
setCheckoutResult
|
|
519
|
+
},
|
|
520
|
+
index
|
|
521
|
+
);
|
|
522
|
+
}
|
|
523
|
+
if (isUpdateQuantity) {
|
|
524
|
+
return null;
|
|
525
|
+
}
|
|
526
|
+
return /* @__PURE__ */ jsxs3("div", { className: "au-flex au-justify-between", children: [
|
|
527
|
+
/* @__PURE__ */ jsx3("p", { className: "au-text-muted-foreground", children: item.feature ? item.feature.name : isOneOff ? "Price" : "Subscription" }),
|
|
528
|
+
/* @__PURE__ */ jsxs3("p", { children: [
|
|
529
|
+
item.display?.primary_text,
|
|
530
|
+
" ",
|
|
531
|
+
item.display?.secondary_text
|
|
532
|
+
] })
|
|
533
|
+
] }, index);
|
|
534
|
+
})
|
|
535
|
+
] });
|
|
536
|
+
}
|
|
537
|
+
function CheckoutLines({ checkoutResult }) {
|
|
538
|
+
return /* @__PURE__ */ jsx3(Accordion, { type: "single", collapsible: true, children: /* @__PURE__ */ jsxs3(AccordionItem, { value: "total", className: "au-border-b-0", children: [
|
|
539
|
+
/* @__PURE__ */ jsx3(CustomAccordionTrigger, { className: "au-justify-between au-w-full au-my-0 au-py-0 au-border-none", children: /* @__PURE__ */ jsxs3("div", { className: "au-cursor-pointer au-flex au-items-center au-gap-1 au-w-full au-justify-end", children: [
|
|
540
|
+
/* @__PURE__ */ jsx3("p", { className: "au-font-light au-text-muted-foreground", children: "View details" }),
|
|
541
|
+
/* @__PURE__ */ jsx3(
|
|
542
|
+
ChevronDown,
|
|
543
|
+
{
|
|
544
|
+
className: "au-text-muted-foreground au-mt-0.5 au-rotate-90 au-transition-transform au-duration-200 au-ease-in-out",
|
|
545
|
+
size: 14
|
|
546
|
+
}
|
|
547
|
+
)
|
|
548
|
+
] }) }),
|
|
549
|
+
/* @__PURE__ */ jsx3(AccordionContent, { className: "au-mt-2 au-mb-0 au-pb-2 au-flex au-flex-col au-gap-2", children: checkoutResult?.lines.filter((line) => line.amount != 0).map((line, index) => {
|
|
550
|
+
return /* @__PURE__ */ jsxs3("div", { className: "au-flex au-justify-between", children: [
|
|
551
|
+
/* @__PURE__ */ jsx3("p", { className: "au-text-muted-foreground", children: line.description }),
|
|
552
|
+
/* @__PURE__ */ jsx3("p", { className: "au-text-muted-foreground", children: new Intl.NumberFormat("en-US", {
|
|
553
|
+
style: "currency",
|
|
554
|
+
currency: checkoutResult?.currency
|
|
555
|
+
}).format(line.amount) })
|
|
556
|
+
] }, index);
|
|
557
|
+
}) })
|
|
558
|
+
] }) });
|
|
559
|
+
}
|
|
560
|
+
function CustomAccordionTrigger({
|
|
561
|
+
className,
|
|
562
|
+
children,
|
|
563
|
+
...props
|
|
564
|
+
}) {
|
|
565
|
+
return /* @__PURE__ */ jsx3(Header, { className: "au-flex", children: /* @__PURE__ */ jsx3(
|
|
566
|
+
Trigger2,
|
|
567
|
+
{
|
|
568
|
+
"data-slot": "accordion-trigger",
|
|
569
|
+
className: cn(
|
|
570
|
+
"focus-visible:au-border-ring focus-visible:au-ring-ring/50 au-flex au-flex-1 au-items-start au-justify-between au-gap-4 au-rounded-md au-py-4 au-text-left au-text-sm au-font-medium au-transition-all au-outline-none focus-visible:au-ring-[3px] disabled:au-pointer-events-none disabled:au-opacity-50 [&[data-state=open]_svg]:au-rotate-0",
|
|
571
|
+
className
|
|
572
|
+
),
|
|
573
|
+
...props,
|
|
574
|
+
children
|
|
575
|
+
}
|
|
576
|
+
) });
|
|
577
|
+
}
|
|
578
|
+
var PrepaidItem = ({
|
|
579
|
+
item,
|
|
580
|
+
checkoutResult,
|
|
581
|
+
setCheckoutResult
|
|
582
|
+
}) => {
|
|
583
|
+
const { quantity = 0, billing_units: billingUnits = 1 } = item;
|
|
584
|
+
const [quantityInput, setQuantityInput] = useState2(
|
|
585
|
+
(quantity / billingUnits).toString()
|
|
586
|
+
);
|
|
587
|
+
const { checkout } = useCustomer();
|
|
588
|
+
const [loading, setLoading] = useState2(false);
|
|
589
|
+
const [open, setOpen] = useState2(false);
|
|
590
|
+
const scenario = checkoutResult.product.scenario;
|
|
591
|
+
const handleSave = async () => {
|
|
592
|
+
setLoading(true);
|
|
593
|
+
try {
|
|
594
|
+
const newOptions = checkoutResult.options.filter((option) => option.feature_id !== item.feature_id).map((option) => {
|
|
595
|
+
return {
|
|
596
|
+
featureId: option.feature_id,
|
|
597
|
+
quantity: option.quantity
|
|
598
|
+
};
|
|
599
|
+
});
|
|
600
|
+
newOptions.push({
|
|
601
|
+
featureId: item.feature_id,
|
|
602
|
+
quantity: Number(quantityInput) * billingUnits
|
|
603
|
+
});
|
|
604
|
+
const { data, error } = await checkout({
|
|
605
|
+
productId: checkoutResult.product.id,
|
|
606
|
+
options: newOptions,
|
|
607
|
+
dialog: CheckoutDialog
|
|
608
|
+
});
|
|
609
|
+
if (error) {
|
|
610
|
+
console.error(error);
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
setCheckoutResult(data);
|
|
614
|
+
} catch (error) {
|
|
615
|
+
console.error(error);
|
|
616
|
+
} finally {
|
|
617
|
+
setLoading(false);
|
|
618
|
+
setOpen(false);
|
|
619
|
+
}
|
|
620
|
+
};
|
|
621
|
+
const disableSelection = scenario === "renew";
|
|
622
|
+
return /* @__PURE__ */ jsxs3("div", { className: "au-flex au-justify-between au-gap-2", children: [
|
|
623
|
+
/* @__PURE__ */ jsxs3("div", { className: "au-flex au-gap-2 au-items-start", children: [
|
|
624
|
+
/* @__PURE__ */ jsx3("p", { className: "au-text-muted-foreground au-whitespace-nowrap", children: item.feature?.name }),
|
|
625
|
+
/* @__PURE__ */ jsxs3(Popover, { open, onOpenChange: setOpen, children: [
|
|
626
|
+
/* @__PURE__ */ jsxs3(
|
|
627
|
+
PopoverTrigger,
|
|
628
|
+
{
|
|
629
|
+
className: cn(
|
|
630
|
+
"au-text-muted-foreground au-text-xs au-px-1 au-py-0.5 au-rounded-md au-flex au-items-center au-gap-1 au-bg-accent/80 au-shrink-0",
|
|
631
|
+
disableSelection !== true && "hover:au-bg-accent hover:au-text-foreground"
|
|
632
|
+
),
|
|
633
|
+
disabled: disableSelection,
|
|
634
|
+
children: [
|
|
635
|
+
"Qty: ",
|
|
636
|
+
quantity,
|
|
637
|
+
/* @__PURE__ */ jsx3(ChevronDown, { size: 12 })
|
|
638
|
+
]
|
|
639
|
+
}
|
|
640
|
+
),
|
|
641
|
+
/* @__PURE__ */ jsxs3(
|
|
642
|
+
PopoverContent,
|
|
643
|
+
{
|
|
644
|
+
align: "start",
|
|
645
|
+
className: "au-w-80 au-text-sm au-p-4 au-pt-3 au-flex au-flex-col au-gap-4",
|
|
646
|
+
children: [
|
|
647
|
+
/* @__PURE__ */ jsxs3("div", { className: "au-flex au-flex-col au-gap-1", children: [
|
|
648
|
+
/* @__PURE__ */ jsx3("p", { className: "au-text-sm au-font-medium", children: item.feature?.name }),
|
|
649
|
+
/* @__PURE__ */ jsxs3("p", { className: "au-text-muted-foreground", children: [
|
|
650
|
+
item.display?.primary_text,
|
|
651
|
+
" ",
|
|
652
|
+
item.display?.secondary_text
|
|
653
|
+
] })
|
|
654
|
+
] }),
|
|
655
|
+
/* @__PURE__ */ jsxs3("div", { className: "au-flex au-justify-between au-items-end", children: [
|
|
656
|
+
/* @__PURE__ */ jsxs3("div", { className: "au-flex au-gap-2 au-items-center", children: [
|
|
657
|
+
/* @__PURE__ */ jsx3(
|
|
658
|
+
Input,
|
|
659
|
+
{
|
|
660
|
+
className: "au-h-7 au-w-16 focus:!au-ring-2",
|
|
661
|
+
value: quantityInput,
|
|
662
|
+
onChange: (e) => setQuantityInput(e.target.value)
|
|
663
|
+
}
|
|
664
|
+
),
|
|
665
|
+
/* @__PURE__ */ jsxs3("p", { className: "au-text-muted-foreground", children: [
|
|
666
|
+
billingUnits > 1 && `x ${billingUnits} `,
|
|
667
|
+
item.feature?.name
|
|
668
|
+
] })
|
|
669
|
+
] }),
|
|
670
|
+
/* @__PURE__ */ jsx3(
|
|
671
|
+
Button,
|
|
672
|
+
{
|
|
673
|
+
onClick: handleSave,
|
|
674
|
+
className: "au-w-14 !au-h-7 au-text-sm au-items-center au-bg-white au-text-foreground au-shadow-sm au-border au-border-zinc-200 hover:au-bg-zinc-100",
|
|
675
|
+
disabled: loading,
|
|
676
|
+
children: loading ? /* @__PURE__ */ jsx3(LoaderCircle, { className: "au-text-muted-foreground au-animate-spin !au-w-4 !au-h-4" }) : "Save"
|
|
677
|
+
}
|
|
678
|
+
)
|
|
679
|
+
] })
|
|
680
|
+
]
|
|
681
|
+
}
|
|
682
|
+
)
|
|
683
|
+
] })
|
|
684
|
+
] }),
|
|
685
|
+
/* @__PURE__ */ jsxs3("p", { className: "au-text-end", children: [
|
|
686
|
+
item.display?.primary_text,
|
|
687
|
+
" ",
|
|
688
|
+
item.display?.secondary_text
|
|
689
|
+
] })
|
|
690
|
+
] });
|
|
691
|
+
};
|
|
692
|
+
var PriceItem = ({
|
|
693
|
+
children,
|
|
694
|
+
className,
|
|
695
|
+
...props
|
|
696
|
+
}) => {
|
|
697
|
+
return /* @__PURE__ */ jsx3(
|
|
698
|
+
"div",
|
|
699
|
+
{
|
|
700
|
+
className: cn(
|
|
701
|
+
"au-flex au-flex-col au-pb-4 sm:au-pb-0 au-gap-1 sm:au-flex-row au-justify-between sm:au-h-7 sm:au-gap-2 sm:au-items-center",
|
|
702
|
+
className
|
|
703
|
+
),
|
|
704
|
+
...props,
|
|
705
|
+
children
|
|
706
|
+
}
|
|
707
|
+
);
|
|
708
|
+
};
|
|
709
|
+
var PricingDialogButton = ({
|
|
710
|
+
children,
|
|
711
|
+
size,
|
|
712
|
+
onClick,
|
|
713
|
+
disabled,
|
|
714
|
+
className
|
|
715
|
+
}) => {
|
|
716
|
+
return /* @__PURE__ */ jsxs3(
|
|
717
|
+
Button,
|
|
718
|
+
{
|
|
719
|
+
onClick,
|
|
720
|
+
disabled,
|
|
721
|
+
size,
|
|
722
|
+
className: cn(className, "au-shadow-sm au-shadow-stone-400"),
|
|
723
|
+
children: [
|
|
724
|
+
children,
|
|
725
|
+
/* @__PURE__ */ jsx3(ArrowRight, { className: "!au-h-3" })
|
|
726
|
+
]
|
|
727
|
+
}
|
|
728
|
+
);
|
|
729
|
+
};
|
|
728
730
|
|
|
729
731
|
export {
|
|
730
|
-
|
|
732
|
+
CheckoutDialog,
|
|
733
|
+
PriceItem,
|
|
734
|
+
PricingDialogButton,
|
|
731
735
|
PricingTable,
|
|
732
736
|
usePricingTableContext,
|
|
733
737
|
PricingTableContainer,
|
|
@@ -736,7 +740,5 @@ export {
|
|
|
736
740
|
PricingCardButton,
|
|
737
741
|
AnnualSwitch,
|
|
738
742
|
RecommendedBadge,
|
|
739
|
-
|
|
740
|
-
PriceItem,
|
|
741
|
-
PricingDialogButton
|
|
743
|
+
PaywallDialog
|
|
742
744
|
};
|