autumn-js 0.0.80 → 0.0.81
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/backend/express.d.mts +1 -1
- package/dist/libraries/backend/express.d.ts +1 -1
- package/dist/libraries/backend/{referralTypes-3L_pJkT7.d.ts → referralTypes-BZ4WOVK5.d.ts} +2 -0
- package/dist/libraries/backend/{referralTypes-BOtccenE.d.mts → referralTypes-C6ao6j-_.d.mts} +2 -0
- package/dist/libraries/backend/utils/withAuth.d.mts +1 -1
- package/dist/libraries/backend/utils/withAuth.d.ts +1 -1
- package/dist/libraries/react/AutumnContext.d.mts +4 -4
- package/dist/libraries/react/AutumnContext.d.ts +4 -4
- package/dist/libraries/react/AutumnContext.mjs +4 -4
- package/dist/libraries/react/BaseAutumnProvider.d.mts +4 -4
- package/dist/libraries/react/BaseAutumnProvider.d.ts +4 -4
- package/dist/libraries/react/BaseAutumnProvider.js +169 -5690
- package/dist/libraries/react/BaseAutumnProvider.mjs +9 -19
- package/dist/libraries/react/{ReactAutumnClient-BUIEn-KV.d.ts → ReactAutumnClient-CD6wjJoS.d.ts} +3 -3
- package/dist/libraries/react/{ReactAutumnClient-B-g4zQsF.d.mts → ReactAutumnClient-DglSetDZ.d.mts} +3 -3
- package/dist/libraries/react/ReactAutumnProvider.d.mts +1 -1
- package/dist/libraries/react/ReactAutumnProvider.d.ts +1 -1
- package/dist/libraries/react/ReactAutumnProvider.js +173 -5690
- package/dist/libraries/react/ReactAutumnProvider.mjs +10 -19
- package/dist/libraries/react/chunk-4DZUJMZF.mjs +170 -0
- package/dist/libraries/react/chunk-6XKT4CR3.mjs +20 -0
- package/dist/libraries/react/{chunk-WYADGMAH.mjs → chunk-DFKCNRXM.mjs} +1 -1
- package/dist/libraries/react/chunk-DSHLYZWS.mjs +83 -0
- package/dist/libraries/react/chunk-EI2TXOE2.mjs +569 -0
- package/dist/libraries/react/chunk-ELPGPLUJ.mjs +77 -0
- package/dist/libraries/react/chunk-I2TAKPWB.mjs +53 -0
- package/dist/libraries/react/chunk-KOX2RKIK.mjs +17 -0
- package/dist/libraries/react/{chunk-3OBQBUE2.mjs → chunk-LLOLCHBX.mjs} +2 -2
- package/dist/libraries/react/chunk-QEYI3IGZ.mjs +17 -0
- package/dist/libraries/react/{chunk-JYOLY75Q.mjs → chunk-XNJDRLWX.mjs} +1 -1
- package/dist/libraries/react/chunk-ZLYUPJN5.mjs +85 -0
- package/dist/libraries/react/client/ReactAutumnClient.d.mts +4 -4
- package/dist/libraries/react/client/ReactAutumnClient.d.ts +4 -4
- package/dist/libraries/react/client/ReactAutumnClient.mjs +3 -3
- package/dist/libraries/react/client/clientCompMethods.d.mts +4 -4
- package/dist/libraries/react/client/clientCompMethods.d.ts +4 -4
- package/dist/libraries/react/client/clientCusMethods.d.mts +4 -4
- package/dist/libraries/react/client/clientCusMethods.d.ts +4 -4
- package/dist/libraries/react/client/clientEntityMethods.d.mts +4 -4
- package/dist/libraries/react/client/clientEntityMethods.d.ts +4 -4
- package/dist/libraries/react/client/clientGenMethods.d.mts +4 -4
- package/dist/libraries/react/client/clientGenMethods.d.ts +4 -4
- package/dist/libraries/react/client/clientProdMethods.d.mts +4 -4
- package/dist/libraries/react/client/clientProdMethods.d.ts +4 -4
- package/dist/libraries/react/client/clientReferralMethods.d.mts +4 -4
- package/dist/libraries/react/client/clientReferralMethods.d.ts +4 -4
- package/dist/libraries/react/components/attach-dialog/attach-dialog-synced.d.mts +1 -1
- package/dist/libraries/react/components/attach-dialog/attach-dialog-synced.d.ts +1 -1
- package/dist/libraries/react/components/attach-dialog/attach-dialog-synced.js +1 -1
- package/dist/libraries/react/components/attach-dialog/attach-dialog-synced.mjs +18 -10
- package/dist/libraries/react/components/attach-dialog/lib/attach-content.d.mts +1 -1
- package/dist/libraries/react/components/attach-dialog/lib/attach-content.d.ts +1 -1
- package/dist/libraries/react/components/check-dialog/check-dialog-synced.d.mts +1 -1
- package/dist/libraries/react/components/check-dialog/check-dialog-synced.d.ts +1 -1
- package/dist/libraries/react/components/check-dialog/lib/check-content.d.mts +1 -1
- package/dist/libraries/react/components/check-dialog/lib/check-content.d.ts +1 -1
- package/dist/libraries/react/components/pricing-table/pricing-table-synced.d.mts +1 -1
- package/dist/libraries/react/components/pricing-table/pricing-table-synced.d.ts +1 -1
- package/dist/libraries/react/components/pricing-table/pricing-table-synced.js +2897 -2897
- package/dist/libraries/react/components/pricing-table/pricing-table-synced.mjs +18 -10
- 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/{cusTypes-DSlkhuov.d.mts → cusTypes-JFEvVZLp.d.mts} +3 -1
- package/dist/libraries/react/{cusTypes-DSlkhuov.d.ts → cusTypes-JFEvVZLp.d.ts} +3 -1
- package/dist/libraries/react/{entTypes-Rpnetevb.d.mts → entTypes-CIemXnyX.d.mts} +1 -1
- package/dist/libraries/react/{entTypes-CcB_hEh5.d.ts → entTypes-CJ3jqOWR.d.ts} +1 -1
- package/dist/libraries/react/hooks/handleAllowed.d.mts +2 -2
- package/dist/libraries/react/hooks/handleAllowed.d.ts +2 -2
- package/dist/libraries/react/hooks/useAutumn.d.mts +2 -2
- package/dist/libraries/react/hooks/useAutumn.d.ts +2 -2
- package/dist/libraries/react/hooks/useAutumn.js +1 -5639
- package/dist/libraries/react/hooks/useAutumn.mjs +7 -20
- package/dist/libraries/react/hooks/useAutumnBase.d.mts +4 -4
- package/dist/libraries/react/hooks/useAutumnBase.d.ts +4 -4
- package/dist/libraries/react/hooks/useAutumnBase.js +1 -5639
- package/dist/libraries/react/hooks/useAutumnBase.mjs +6 -20
- package/dist/libraries/react/hooks/useCustomer.d.mts +4 -4
- package/dist/libraries/react/hooks/useCustomer.d.ts +4 -4
- package/dist/libraries/react/hooks/useCustomer.js +208 -5730
- package/dist/libraries/react/hooks/useCustomer.mjs +9 -20
- package/dist/libraries/react/hooks/useCustomerBase.d.mts +4 -4
- package/dist/libraries/react/hooks/useCustomerBase.d.ts +4 -4
- package/dist/libraries/react/hooks/useCustomerBase.js +163 -5693
- package/dist/libraries/react/hooks/useCustomerBase.mjs +8 -20
- package/dist/libraries/react/hooks/useEntity.d.mts +3 -3
- package/dist/libraries/react/hooks/useEntity.d.ts +3 -3
- package/dist/libraries/react/hooks/useEntity.js +199 -5787
- package/dist/libraries/react/hooks/useEntity.mjs +9 -20
- package/dist/libraries/react/hooks/useEntityBase.d.mts +4 -4
- package/dist/libraries/react/hooks/useEntityBase.d.ts +4 -4
- package/dist/libraries/react/hooks/useEntityBase.js +160 -5748
- package/dist/libraries/react/hooks/useEntityBase.mjs +8 -20
- package/dist/libraries/react/hooks/usePricingTable.d.mts +1 -1
- package/dist/libraries/react/hooks/usePricingTable.d.ts +1 -1
- package/dist/libraries/react/hooks/usePricingTable.mjs +6 -6
- package/dist/libraries/react/hooks/usePricingTableBase.d.mts +4 -4
- package/dist/libraries/react/hooks/usePricingTableBase.d.ts +4 -4
- package/dist/libraries/react/hooks/usePricingTableBase.mjs +5 -5
- package/dist/libraries/react/hooks/useProductsBase.mjs +4 -4
- package/dist/libraries/react/index.d.ts +2 -0
- package/dist/libraries/react/index.js +5442 -5442
- package/dist/libraries/react/index.mjs +5448 -5448
- package/dist/libraries/react/{response-BKKi_PDD.d.ts → response-BIBRaj58.d.ts} +1 -1
- package/dist/libraries/react/{response-CTqlSAVK.d.mts → response-CCcWrbaE.d.mts} +1 -1
- package/dist/next/{AutumnProvider-CGdXoZNQ.d.mts → AutumnProvider-DPcEuE_Q.d.mts} +2 -0
- package/dist/next/{AutumnProvider-CGdXoZNQ.d.ts → AutumnProvider-DPcEuE_Q.d.ts} +2 -0
- package/dist/next/AutumnProvider.d.mts +1 -1
- package/dist/next/AutumnProvider.d.ts +1 -1
- package/dist/next/client/NextAutumnClient.d.mts +3 -3
- package/dist/next/client/NextAutumnClient.d.ts +3 -3
- package/dist/next/client/NextAutumnProvider.d.mts +1 -1
- package/dist/next/client/NextAutumnProvider.d.ts +1 -1
- package/dist/next/client/{clientGenTypes-HDbUC8f6.d.ts → clientGenTypes-CAv4hwb4.d.ts} +1 -1
- package/dist/next/client/{clientGenTypes-BHrxzZi_.d.mts → clientGenTypes-Dlpw9wy_.d.mts} +1 -1
- package/dist/next/client/clientUtils.d.mts +2 -2
- package/dist/next/client/clientUtils.d.ts +2 -2
- package/dist/next/client/{cusTypes-CSbB7Wu9.d.mts → cusTypes-CJI8rdlY.d.mts} +2 -0
- package/dist/next/client/{cusTypes-CSbB7Wu9.d.ts → cusTypes-CJI8rdlY.d.ts} +2 -0
- package/dist/next/client/{entTypes-B3R2yjLW.d.ts → entTypes-CqHWTcCX.d.ts} +1 -1
- package/dist/next/client/{entTypes-6xEkbn32.d.mts → entTypes-okM0aeOM.d.mts} +1 -1
- package/dist/next/client/hooks/useAutumn.d.mts +3 -3
- package/dist/next/client/hooks/useAutumn.d.ts +3 -3
- package/dist/next/client/hooks/useCustomer.d.mts +3 -3
- package/dist/next/client/hooks/useCustomer.d.ts +3 -3
- package/dist/next/client/hooks/useEntity.d.mts +4 -4
- package/dist/next/client/hooks/useEntity.d.ts +4 -4
- package/dist/next/client/hooks/usePricingTable.d.mts +1 -1
- package/dist/next/client/hooks/usePricingTable.d.ts +1 -1
- package/dist/next/client/types.d.mts +2 -2
- package/dist/next/client/types.d.ts +2 -2
- package/dist/next/index.d.mts +2 -2
- package/dist/next/index.d.ts +2 -2
- package/dist/next/server/auth/withNextAuth.d.mts +1 -1
- package/dist/next/server/auth/withNextAuth.d.ts +1 -1
- package/dist/next/server/componentActions.d.mts +1 -1
- package/dist/next/server/componentActions.d.ts +1 -1
- package/dist/next/server/cusActions.d.mts +1 -1
- package/dist/next/server/cusActions.d.ts +1 -1
- package/dist/next/server/{cusTypes-ASrCF4fa.d.mts → cusTypes-DuSwXVmp.d.mts} +2 -0
- package/dist/next/server/{cusTypes-ASrCF4fa.d.ts → cusTypes-DuSwXVmp.d.ts} +2 -0
- package/dist/next/server/genActions.d.mts +1 -1
- package/dist/next/server/genActions.d.ts +1 -1
- package/dist/sdk/index.d.mts +2 -0
- package/dist/sdk/index.d.ts +2 -0
- package/package.json +1 -1
- package/dist/libraries/react/BaseAutumnProvider.css +0 -1264
- package/dist/libraries/react/ReactAutumnProvider.css +0 -1264
- package/dist/libraries/react/chunk-XPGX7SQG.mjs +0 -1014
- package/dist/libraries/react/hooks/useAutumn.css +0 -1264
- package/dist/libraries/react/hooks/useAutumnBase.css +0 -1264
- package/dist/libraries/react/hooks/useCustomer.css +0 -1264
- package/dist/libraries/react/hooks/useCustomerBase.css +0 -1264
- package/dist/libraries/react/hooks/useEntity.css +0 -1264
- package/dist/libraries/react/hooks/useEntityBase.css +0 -1264
- package/dist/libraries/react/{chunk-Y6UVL46W.mjs → chunk-ET534E5H.mjs} +6 -6
|
@@ -1,1014 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
getAttachContent
|
|
5
|
-
} from "./chunk-BCMBFJ7E.mjs";
|
|
6
|
-
import {
|
|
7
|
-
getPricingTableContent
|
|
8
|
-
} from "./chunk-QBBE72EF.mjs";
|
|
9
|
-
import {
|
|
10
|
-
Switch
|
|
11
|
-
} from "./chunk-CMO5LYYU.mjs";
|
|
12
|
-
import {
|
|
13
|
-
loadingStyles,
|
|
14
|
-
spinnerStyles
|
|
15
|
-
} from "./chunk-OWFX3JFF.mjs";
|
|
16
|
-
import {
|
|
17
|
-
Button
|
|
18
|
-
} from "./chunk-P2O4LZFD.mjs";
|
|
19
|
-
import {
|
|
20
|
-
ArrowRight,
|
|
21
|
-
Check,
|
|
22
|
-
Dialog,
|
|
23
|
-
DialogContent,
|
|
24
|
-
DialogFooter,
|
|
25
|
-
DialogTitle,
|
|
26
|
-
LoaderCircle
|
|
27
|
-
} from "./chunk-5FZ7IV6P.mjs";
|
|
28
|
-
import {
|
|
29
|
-
cn
|
|
30
|
-
} from "./chunk-4J6OC4ZQ.mjs";
|
|
31
|
-
import {
|
|
32
|
-
useDialog
|
|
33
|
-
} from "./chunk-4QPHNIQ7.mjs";
|
|
34
|
-
import {
|
|
35
|
-
usePricingTable
|
|
36
|
-
} from "./chunk-3OBQBUE2.mjs";
|
|
37
|
-
import {
|
|
38
|
-
usePricingTableBase
|
|
39
|
-
} from "./chunk-JYOLY75Q.mjs";
|
|
40
|
-
import {
|
|
41
|
-
AutumnContext,
|
|
42
|
-
useAutumnContext
|
|
43
|
-
} from "./chunk-WYADGMAH.mjs";
|
|
44
|
-
import {
|
|
45
|
-
AutumnClient
|
|
46
|
-
} from "./chunk-Y6UVL46W.mjs";
|
|
47
|
-
import {
|
|
48
|
-
handleAllowed
|
|
49
|
-
} from "./chunk-JFXBUWKA.mjs";
|
|
50
|
-
|
|
51
|
-
// src/libraries/react/BaseAutumnProvider.tsx
|
|
52
|
-
import { useState as useState3 } from "react";
|
|
53
|
-
|
|
54
|
-
// src/libraries/react/hooks/useCustomerBase.tsx
|
|
55
|
-
import useSWR2 from "swr";
|
|
56
|
-
|
|
57
|
-
// src/libraries/react/components/attach-dialog/attach-dialog-synced.tsx
|
|
58
|
-
import { useEffect, useState as useState2 } from "react";
|
|
59
|
-
|
|
60
|
-
// src/libraries/react/hooks/useCustomer.tsx
|
|
61
|
-
var useCustomer = (params) => {
|
|
62
|
-
return useCustomerBase({
|
|
63
|
-
params,
|
|
64
|
-
AutumnContext
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
// src/libraries/react/hooks/useEntityBase.tsx
|
|
69
|
-
import useSWR from "swr";
|
|
70
|
-
import { useContext } from "react";
|
|
71
|
-
var useEntityBase = ({
|
|
72
|
-
entityId,
|
|
73
|
-
params,
|
|
74
|
-
AutumnContext: AutumnContext2
|
|
75
|
-
}) => {
|
|
76
|
-
const { client } = useContext(AutumnContext2);
|
|
77
|
-
const queryKey = ["entity", entityId, params?.expand];
|
|
78
|
-
const fetchEntity = async () => {
|
|
79
|
-
if (!entityId) {
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
const { data: data2, error: error2 } = await client.entities.get(entityId, params);
|
|
83
|
-
if (error2) {
|
|
84
|
-
throw error2;
|
|
85
|
-
}
|
|
86
|
-
if (!data2) {
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
89
|
-
return data2;
|
|
90
|
-
};
|
|
91
|
-
const { data, error, isLoading, mutate } = useSWR(queryKey, fetchEntity, {
|
|
92
|
-
fallbackData: null,
|
|
93
|
-
onErrorRetry: (error2, key, config) => {
|
|
94
|
-
if (error2.code == "entity_not_found") {
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
const {
|
|
101
|
-
check: checkAutumn,
|
|
102
|
-
attach: attachAutumn,
|
|
103
|
-
cancel: cancelAutumn,
|
|
104
|
-
track: trackAutumn
|
|
105
|
-
} = useAutumnBase({
|
|
106
|
-
AutumnContext: AutumnContext2
|
|
107
|
-
});
|
|
108
|
-
const allowed = (params2) => handleAllowed({ customer: data, params: params2 });
|
|
109
|
-
const check = (params2) => checkAutumn({ ...params2, entityId: entityId || void 0 });
|
|
110
|
-
const attach = (params2) => attachAutumn({ ...params2, entityId: entityId || void 0 });
|
|
111
|
-
const cancel = (params2) => cancelAutumn({ ...params2, entityId: entityId || void 0 });
|
|
112
|
-
const track = (params2) => trackAutumn({ ...params2, entityId: entityId || void 0 });
|
|
113
|
-
if (!entityId) {
|
|
114
|
-
return {
|
|
115
|
-
entity: null,
|
|
116
|
-
isLoading: false,
|
|
117
|
-
error: null,
|
|
118
|
-
refetch: mutate,
|
|
119
|
-
allowed,
|
|
120
|
-
check,
|
|
121
|
-
attach,
|
|
122
|
-
cancel,
|
|
123
|
-
track
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
return {
|
|
127
|
-
entity: error ? null : data,
|
|
128
|
-
isLoading,
|
|
129
|
-
error,
|
|
130
|
-
refetch: mutate,
|
|
131
|
-
allowed,
|
|
132
|
-
check,
|
|
133
|
-
attach,
|
|
134
|
-
cancel,
|
|
135
|
-
track
|
|
136
|
-
};
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
// src/libraries/react/hooks/useEntity.tsx
|
|
140
|
-
var useEntity = (entityId, params) => {
|
|
141
|
-
return useEntityBase({ AutumnContext, entityId, params });
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
// src/libraries/react/hooks/useAutumn.tsx
|
|
145
|
-
var useAutumn = () => {
|
|
146
|
-
return useAutumnBase({ AutumnContext });
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
// src/libraries/react/components/pricing-table/pricing-table-synced.tsx
|
|
150
|
-
import React from "react";
|
|
151
|
-
import { createContext, useContext as useContext2, useState } from "react";
|
|
152
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
153
|
-
function PricingTable({
|
|
154
|
-
productDetails
|
|
155
|
-
}) {
|
|
156
|
-
const { attach } = useCustomer();
|
|
157
|
-
const [isAnnual, setIsAnnual] = useState(false);
|
|
158
|
-
const { products, isLoading, error } = usePricingTable({ productDetails });
|
|
159
|
-
if (isLoading) {
|
|
160
|
-
return /* @__PURE__ */ jsx("div", { style: loadingStyles, children: /* @__PURE__ */ jsx(LoaderCircle, { style: spinnerStyles }) });
|
|
161
|
-
}
|
|
162
|
-
if (error) {
|
|
163
|
-
return /* @__PURE__ */ jsx("div", { children: " Something went wrong..." });
|
|
164
|
-
}
|
|
165
|
-
const intervals = Array.from(
|
|
166
|
-
new Set(
|
|
167
|
-
products?.map((p) => p.properties?.interval_group).filter((i) => !!i)
|
|
168
|
-
)
|
|
169
|
-
);
|
|
170
|
-
const multiInterval = intervals.length > 1;
|
|
171
|
-
const intervalFilter = (product) => {
|
|
172
|
-
if (!product.properties?.interval_group) {
|
|
173
|
-
return true;
|
|
174
|
-
}
|
|
175
|
-
if (multiInterval) {
|
|
176
|
-
if (isAnnual) {
|
|
177
|
-
return product.properties?.interval_group === "year";
|
|
178
|
-
} else {
|
|
179
|
-
return product.properties?.interval_group === "month";
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return true;
|
|
183
|
-
};
|
|
184
|
-
return /* @__PURE__ */ jsx("div", { className: cn("au-root"), children: products && /* @__PURE__ */ jsx(
|
|
185
|
-
PricingTableContainer,
|
|
186
|
-
{
|
|
187
|
-
products,
|
|
188
|
-
isAnnualToggle: isAnnual,
|
|
189
|
-
setIsAnnualToggle: setIsAnnual,
|
|
190
|
-
multiInterval,
|
|
191
|
-
children: products.filter(intervalFilter).map((product, index) => /* @__PURE__ */ jsx(
|
|
192
|
-
PricingCard,
|
|
193
|
-
{
|
|
194
|
-
productId: product.id,
|
|
195
|
-
buttonProps: {
|
|
196
|
-
disabled: product.scenario === "active" || product.scenario === "scheduled",
|
|
197
|
-
onClick: async () => {
|
|
198
|
-
if (product.id) {
|
|
199
|
-
await attach({
|
|
200
|
-
productId: product.id,
|
|
201
|
-
dialog: AttachDialog
|
|
202
|
-
});
|
|
203
|
-
} else if (product.display?.button_url) {
|
|
204
|
-
window.open(product.display?.button_url, "_blank");
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
},
|
|
209
|
-
index
|
|
210
|
-
))
|
|
211
|
-
}
|
|
212
|
-
) });
|
|
213
|
-
}
|
|
214
|
-
var PricingTableContext = createContext({
|
|
215
|
-
isAnnualToggle: false,
|
|
216
|
-
setIsAnnualToggle: () => {
|
|
217
|
-
},
|
|
218
|
-
products: [],
|
|
219
|
-
showFeatures: true
|
|
220
|
-
});
|
|
221
|
-
var usePricingTableContext = (componentName) => {
|
|
222
|
-
const context = useContext2(PricingTableContext);
|
|
223
|
-
if (context === void 0) {
|
|
224
|
-
throw new Error(`${componentName} must be used within <PricingTable />`);
|
|
225
|
-
}
|
|
226
|
-
return context;
|
|
227
|
-
};
|
|
228
|
-
var PricingTableContainer = ({
|
|
229
|
-
children,
|
|
230
|
-
products,
|
|
231
|
-
showFeatures = true,
|
|
232
|
-
className,
|
|
233
|
-
isAnnualToggle,
|
|
234
|
-
setIsAnnualToggle,
|
|
235
|
-
multiInterval
|
|
236
|
-
}) => {
|
|
237
|
-
if (!products) {
|
|
238
|
-
throw new Error("products is required in <PricingTable />");
|
|
239
|
-
}
|
|
240
|
-
if (products.length === 0) {
|
|
241
|
-
return /* @__PURE__ */ jsx(Fragment, {});
|
|
242
|
-
}
|
|
243
|
-
const hasRecommended = products?.some((p) => p.display?.recommend_text);
|
|
244
|
-
return /* @__PURE__ */ jsx(
|
|
245
|
-
PricingTableContext.Provider,
|
|
246
|
-
{
|
|
247
|
-
value: { isAnnualToggle, setIsAnnualToggle, products, showFeatures },
|
|
248
|
-
children: /* @__PURE__ */ jsxs(
|
|
249
|
-
"div",
|
|
250
|
-
{
|
|
251
|
-
className: cn(
|
|
252
|
-
"au-flex au-items-center au-flex-col",
|
|
253
|
-
hasRecommended && "!au-py-10"
|
|
254
|
-
),
|
|
255
|
-
children: [
|
|
256
|
-
multiInterval && /* @__PURE__ */ jsx(
|
|
257
|
-
"div",
|
|
258
|
-
{
|
|
259
|
-
className: cn(
|
|
260
|
-
products.some((p) => p.display?.recommend_text) && "au-mb-8"
|
|
261
|
-
),
|
|
262
|
-
children: /* @__PURE__ */ jsx(
|
|
263
|
-
AnnualSwitch,
|
|
264
|
-
{
|
|
265
|
-
isAnnualToggle,
|
|
266
|
-
setIsAnnualToggle
|
|
267
|
-
}
|
|
268
|
-
)
|
|
269
|
-
}
|
|
270
|
-
),
|
|
271
|
-
/* @__PURE__ */ jsx(
|
|
272
|
-
"div",
|
|
273
|
-
{
|
|
274
|
-
className: cn(
|
|
275
|
-
"au-grid au-grid-cols-1 sm:au-grid-cols-2 lg:au-grid-cols-[repeat(auto-fit,minmax(200px,1fr))] au-w-full au-gap-2",
|
|
276
|
-
className
|
|
277
|
-
),
|
|
278
|
-
children
|
|
279
|
-
}
|
|
280
|
-
)
|
|
281
|
-
]
|
|
282
|
-
}
|
|
283
|
-
)
|
|
284
|
-
}
|
|
285
|
-
);
|
|
286
|
-
};
|
|
287
|
-
var PricingCard = ({
|
|
288
|
-
productId,
|
|
289
|
-
className,
|
|
290
|
-
buttonProps
|
|
291
|
-
}) => {
|
|
292
|
-
const { products, showFeatures } = usePricingTableContext("PricingCard");
|
|
293
|
-
const product = products.find((p) => p.id === productId);
|
|
294
|
-
if (!product) {
|
|
295
|
-
throw new Error(`Product with id ${productId} not found`);
|
|
296
|
-
}
|
|
297
|
-
const { name, display: productDisplay, items } = product;
|
|
298
|
-
const { buttonText } = getPricingTableContent(product);
|
|
299
|
-
const isRecommended = productDisplay?.recommend_text ? true : false;
|
|
300
|
-
const mainPriceDisplay = product.properties?.is_free ? {
|
|
301
|
-
primary_text: "Free"
|
|
302
|
-
} : product.items[0].display;
|
|
303
|
-
const featureItems = product.properties?.is_free ? product.items : product.items.slice(1);
|
|
304
|
-
return /* @__PURE__ */ jsxs(
|
|
305
|
-
"div",
|
|
306
|
-
{
|
|
307
|
-
className: cn(
|
|
308
|
-
" au-w-full au-h-full au-py-6 au-text-foreground au-border au-rounded-lg au-shadow-sm au-max-w-xl",
|
|
309
|
-
isRecommended && "lg:au--translate-y-6 lg:au-shadow-lg dark:au-shadow-zinc-800/80 lg:au-h-[calc(100%+48px)] au-bg-secondary/40",
|
|
310
|
-
className
|
|
311
|
-
),
|
|
312
|
-
children: [
|
|
313
|
-
productDisplay?.recommend_text && /* @__PURE__ */ jsx(RecommendedBadge, { recommended: productDisplay?.recommend_text }),
|
|
314
|
-
/* @__PURE__ */ jsxs(
|
|
315
|
-
"div",
|
|
316
|
-
{
|
|
317
|
-
className: cn(
|
|
318
|
-
"au-flex au-flex-col au-h-full au-flex-grow",
|
|
319
|
-
isRecommended && "lg:au-translate-y-6"
|
|
320
|
-
),
|
|
321
|
-
children: [
|
|
322
|
-
/* @__PURE__ */ jsxs("div", { className: "au-h-full", children: [
|
|
323
|
-
/* @__PURE__ */ jsxs("div", { className: "au-flex au-flex-col", children: [
|
|
324
|
-
/* @__PURE__ */ jsxs("div", { className: "au-pb-4", children: [
|
|
325
|
-
/* @__PURE__ */ jsx("h2", { className: "au-text-2xl au-font-semibold au-px-6 au-truncate", children: productDisplay?.name || name }),
|
|
326
|
-
productDisplay?.description && /* @__PURE__ */ jsx("div", { className: "au-text-sm au-text-muted-foreground au-px-6 au-h-8", children: /* @__PURE__ */ jsx("p", { className: "au-line-clamp-2", children: productDisplay?.description }) })
|
|
327
|
-
] }),
|
|
328
|
-
/* @__PURE__ */ jsx("div", { className: "au-mb-2", children: /* @__PURE__ */ jsx("h3", { className: "au-font-semibold au-h-16 au-flex au-px-6 au-items-center au-border-y au-mb-4 au-bg-secondary/40", children: /* @__PURE__ */ jsxs("div", { className: "au-line-clamp-2", children: [
|
|
329
|
-
mainPriceDisplay?.primary_text,
|
|
330
|
-
" ",
|
|
331
|
-
mainPriceDisplay?.secondary_text && /* @__PURE__ */ jsx("span", { className: "au-font-normal au-text-muted-foreground au-mt-1", children: mainPriceDisplay?.secondary_text })
|
|
332
|
-
] }) }) })
|
|
333
|
-
] }),
|
|
334
|
-
showFeatures && featureItems.length > 0 && /* @__PURE__ */ jsx("div", { className: "au-flex-grow au-px-6 au-mb-6", children: /* @__PURE__ */ jsx(
|
|
335
|
-
PricingFeatureList,
|
|
336
|
-
{
|
|
337
|
-
items: featureItems,
|
|
338
|
-
showIcon: true,
|
|
339
|
-
everythingFrom: product.display?.everything_from
|
|
340
|
-
}
|
|
341
|
-
) })
|
|
342
|
-
] }),
|
|
343
|
-
/* @__PURE__ */ jsx(
|
|
344
|
-
"div",
|
|
345
|
-
{
|
|
346
|
-
className: cn(" au-px-6 ", isRecommended && "lg:au--translate-y-12"),
|
|
347
|
-
children: /* @__PURE__ */ jsx(
|
|
348
|
-
PricingCardButton,
|
|
349
|
-
{
|
|
350
|
-
recommended: productDisplay?.recommend_text ? true : false,
|
|
351
|
-
...buttonProps,
|
|
352
|
-
children: buttonText
|
|
353
|
-
}
|
|
354
|
-
)
|
|
355
|
-
}
|
|
356
|
-
)
|
|
357
|
-
]
|
|
358
|
-
}
|
|
359
|
-
)
|
|
360
|
-
]
|
|
361
|
-
}
|
|
362
|
-
);
|
|
363
|
-
};
|
|
364
|
-
var PricingFeatureList = ({
|
|
365
|
-
items,
|
|
366
|
-
showIcon = true,
|
|
367
|
-
everythingFrom,
|
|
368
|
-
className
|
|
369
|
-
}) => {
|
|
370
|
-
return /* @__PURE__ */ jsxs("div", { className: cn("au-flex-grow", className), children: [
|
|
371
|
-
everythingFrom && /* @__PURE__ */ jsxs("p", { className: "au-text-sm au-mb-4", children: [
|
|
372
|
-
"Everything from ",
|
|
373
|
-
everythingFrom,
|
|
374
|
-
", plus:"
|
|
375
|
-
] }),
|
|
376
|
-
/* @__PURE__ */ jsx("div", { className: "au-space-y-3", children: items.map((item, index) => /* @__PURE__ */ jsxs(
|
|
377
|
-
"div",
|
|
378
|
-
{
|
|
379
|
-
className: "au-flex au-items-start au-gap-2 au-text-sm",
|
|
380
|
-
children: [
|
|
381
|
-
showIcon && /* @__PURE__ */ jsx(Check, { className: "au-h-4 au-w-4 au-text-primary au-flex-shrink-0 au-mt-0.5" }),
|
|
382
|
-
/* @__PURE__ */ jsxs("div", { className: "au-flex au-flex-col", children: [
|
|
383
|
-
/* @__PURE__ */ jsx("span", { children: item.display?.primary_text }),
|
|
384
|
-
item.display?.secondary_text && /* @__PURE__ */ jsx("span", { className: "au-text-sm au-text-muted-foreground", children: item.display?.secondary_text })
|
|
385
|
-
] })
|
|
386
|
-
]
|
|
387
|
-
},
|
|
388
|
-
index
|
|
389
|
-
)) })
|
|
390
|
-
] });
|
|
391
|
-
};
|
|
392
|
-
var PricingCardButton = React.forwardRef(({ recommended, children, className, onClick, ...props }, ref) => {
|
|
393
|
-
const [loading, setLoading] = useState(false);
|
|
394
|
-
const handleClick = async (e) => {
|
|
395
|
-
setLoading(true);
|
|
396
|
-
try {
|
|
397
|
-
await onClick?.(e);
|
|
398
|
-
} catch (error) {
|
|
399
|
-
console.error(error);
|
|
400
|
-
} finally {
|
|
401
|
-
setLoading(false);
|
|
402
|
-
}
|
|
403
|
-
};
|
|
404
|
-
return /* @__PURE__ */ jsx(
|
|
405
|
-
Button,
|
|
406
|
-
{
|
|
407
|
-
className: cn(
|
|
408
|
-
"au-w-full au-py-3 au-px-4 au-group au-overflow-hidden au-relative au-transition-all au-duration-300 hover:au-brightness-90 au-border au-rounded-lg",
|
|
409
|
-
className
|
|
410
|
-
),
|
|
411
|
-
...props,
|
|
412
|
-
variant: recommended ? "default" : "secondary",
|
|
413
|
-
ref,
|
|
414
|
-
disabled: loading || props.disabled,
|
|
415
|
-
onClick: handleClick,
|
|
416
|
-
children: loading ? /* @__PURE__ */ jsx(LoaderCircle, { className: "au-h-4 au-w-4 au-animate-spin" }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
417
|
-
/* @__PURE__ */ jsxs("div", { className: "au-flex au-items-center au-justify-between au-w-full au-transition-transform au-duration-300 group-hover:au-translate-y-[-130%]", children: [
|
|
418
|
-
/* @__PURE__ */ jsx("span", { children }),
|
|
419
|
-
/* @__PURE__ */ jsx("span", { className: "au-text-sm", children: "\u2192" })
|
|
420
|
-
] }),
|
|
421
|
-
/* @__PURE__ */ jsxs("div", { className: "au-flex au-items-center au-justify-between au-w-full au-absolute au-px-4 au-translate-y-[130%] au-transition-transform au-duration-300 group-hover:au-translate-y-0 au-mt-2 group-hover:au-mt-0", children: [
|
|
422
|
-
/* @__PURE__ */ jsx("span", { children }),
|
|
423
|
-
/* @__PURE__ */ jsx("span", { className: "au-text-sm", children: "\u2192" })
|
|
424
|
-
] })
|
|
425
|
-
] })
|
|
426
|
-
}
|
|
427
|
-
);
|
|
428
|
-
});
|
|
429
|
-
PricingCardButton.displayName = "PricingCardButton";
|
|
430
|
-
var AnnualSwitch = ({
|
|
431
|
-
isAnnualToggle,
|
|
432
|
-
setIsAnnualToggle
|
|
433
|
-
}) => {
|
|
434
|
-
return /* @__PURE__ */ jsxs("div", { className: "au-flex au-items-center au-space-x-2 au-mb-4", children: [
|
|
435
|
-
/* @__PURE__ */ jsx("span", { className: "au-text-sm au-text-muted-foreground", children: "Monthly" }),
|
|
436
|
-
/* @__PURE__ */ jsx(
|
|
437
|
-
Switch,
|
|
438
|
-
{
|
|
439
|
-
id: "annual-billing",
|
|
440
|
-
checked: isAnnualToggle,
|
|
441
|
-
onCheckedChange: setIsAnnualToggle
|
|
442
|
-
}
|
|
443
|
-
),
|
|
444
|
-
/* @__PURE__ */ jsx("span", { className: "au-text-sm au-text-muted-foreground", children: "Annual" })
|
|
445
|
-
] });
|
|
446
|
-
};
|
|
447
|
-
var RecommendedBadge = ({ recommended }) => {
|
|
448
|
-
return /* @__PURE__ */ jsx("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 });
|
|
449
|
-
};
|
|
450
|
-
|
|
451
|
-
// src/libraries/react/components/attach-dialog/attach-dialog-synced.tsx
|
|
452
|
-
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
453
|
-
function AttachDialog(params) {
|
|
454
|
-
const { attach } = useCustomer();
|
|
455
|
-
const [loading, setLoading] = useState2(false);
|
|
456
|
-
const [optionsInput, setOptionsInput] = useState2(
|
|
457
|
-
params?.preview?.options || []
|
|
458
|
-
);
|
|
459
|
-
const getTotalPrice = () => {
|
|
460
|
-
let sum = due_today?.price || 0;
|
|
461
|
-
optionsInput.forEach((option) => {
|
|
462
|
-
if (option.price && option.quantity) {
|
|
463
|
-
sum += option.price * (option.quantity / option.billing_units);
|
|
464
|
-
}
|
|
465
|
-
});
|
|
466
|
-
return sum;
|
|
467
|
-
};
|
|
468
|
-
useEffect(() => {
|
|
469
|
-
setOptionsInput(params?.preview?.options || []);
|
|
470
|
-
}, [params?.preview?.options]);
|
|
471
|
-
if (!params || !params.preview) {
|
|
472
|
-
return /* @__PURE__ */ jsx2(Fragment2, {});
|
|
473
|
-
}
|
|
474
|
-
const { open, setOpen, preview } = params;
|
|
475
|
-
const { items, due_today } = preview;
|
|
476
|
-
const { title, message } = getAttachContent(preview);
|
|
477
|
-
return /* @__PURE__ */ jsx2(Dialog, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs2(
|
|
478
|
-
DialogContent,
|
|
479
|
-
{
|
|
480
|
-
className: cn(
|
|
481
|
-
"au-p-0 au-pt-4 au-gap-0 au-text-foreground au-overflow-hidden au-text-sm"
|
|
482
|
-
),
|
|
483
|
-
children: [
|
|
484
|
-
/* @__PURE__ */ jsx2(DialogTitle, { className: cn("au-px-6 au-mb-1 "), children: title }),
|
|
485
|
-
/* @__PURE__ */ jsx2("div", { className: cn("au-px-6 au-mt-1 au-mb-4 au-text-muted-foreground"), children: message }),
|
|
486
|
-
(items || optionsInput.length > 0) && /* @__PURE__ */ jsxs2("div", { className: "au-mb-6 au-px-6", children: [
|
|
487
|
-
items?.map((item) => /* @__PURE__ */ jsxs2(PriceItem, { children: [
|
|
488
|
-
/* @__PURE__ */ jsx2("span", { className: "au-truncate au-flex-1", children: item.description }),
|
|
489
|
-
/* @__PURE__ */ jsx2("span", { children: item.price })
|
|
490
|
-
] }, item.description)),
|
|
491
|
-
optionsInput?.map((option, index) => {
|
|
492
|
-
return /* @__PURE__ */ jsx2(
|
|
493
|
-
OptionsInput,
|
|
494
|
-
{
|
|
495
|
-
option,
|
|
496
|
-
optionsInput,
|
|
497
|
-
setOptionsInput,
|
|
498
|
-
index
|
|
499
|
-
},
|
|
500
|
-
option.feature_name
|
|
501
|
-
);
|
|
502
|
-
})
|
|
503
|
-
] }),
|
|
504
|
-
/* @__PURE__ */ jsxs2(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: [
|
|
505
|
-
due_today && /* @__PURE__ */ jsxs2(TotalPrice, { children: [
|
|
506
|
-
/* @__PURE__ */ jsx2("span", { children: "Due Today" }),
|
|
507
|
-
/* @__PURE__ */ jsx2("span", { children: new Intl.NumberFormat("en-US", {
|
|
508
|
-
style: "currency",
|
|
509
|
-
currency: due_today.currency
|
|
510
|
-
}).format(getTotalPrice()) })
|
|
511
|
-
] }),
|
|
512
|
-
/* @__PURE__ */ jsx2(
|
|
513
|
-
Button,
|
|
514
|
-
{
|
|
515
|
-
size: "sm",
|
|
516
|
-
onClick: async () => {
|
|
517
|
-
setLoading(true);
|
|
518
|
-
await attach({
|
|
519
|
-
productId: preview.product_id,
|
|
520
|
-
options: optionsInput.map((option) => ({
|
|
521
|
-
featureId: option.feature_id,
|
|
522
|
-
quantity: option.quantity || 0
|
|
523
|
-
}))
|
|
524
|
-
});
|
|
525
|
-
setOpen(false);
|
|
526
|
-
setLoading(false);
|
|
527
|
-
},
|
|
528
|
-
disabled: loading,
|
|
529
|
-
className: "au-min-w-16 au-flex au-items-center au-gap-2",
|
|
530
|
-
children: loading ? /* @__PURE__ */ jsx2(LoaderCircle, { className: "au-w-4 au-h-4 au-animate-spin" }) : /* @__PURE__ */ jsx2(Fragment2, { children: /* @__PURE__ */ jsx2("span", { className: "au-whitespace-nowrap au-flex au-gap-1", children: "Confirm" }) })
|
|
531
|
-
}
|
|
532
|
-
)
|
|
533
|
-
] })
|
|
534
|
-
]
|
|
535
|
-
}
|
|
536
|
-
) });
|
|
537
|
-
}
|
|
538
|
-
var PriceItem = ({
|
|
539
|
-
children,
|
|
540
|
-
className,
|
|
541
|
-
...props
|
|
542
|
-
}) => {
|
|
543
|
-
return /* @__PURE__ */ jsx2(
|
|
544
|
-
"div",
|
|
545
|
-
{
|
|
546
|
-
className: cn(
|
|
547
|
-
"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",
|
|
548
|
-
className
|
|
549
|
-
),
|
|
550
|
-
...props,
|
|
551
|
-
children
|
|
552
|
-
}
|
|
553
|
-
);
|
|
554
|
-
};
|
|
555
|
-
var OptionsInput = ({
|
|
556
|
-
className,
|
|
557
|
-
option,
|
|
558
|
-
optionsInput,
|
|
559
|
-
setOptionsInput,
|
|
560
|
-
index,
|
|
561
|
-
...props
|
|
562
|
-
}) => {
|
|
563
|
-
const { feature_name, billing_units, quantity, price } = option;
|
|
564
|
-
return /* @__PURE__ */ jsxs2(PriceItem, { children: [
|
|
565
|
-
/* @__PURE__ */ jsx2("span", { children: feature_name }),
|
|
566
|
-
/* @__PURE__ */ jsx2(
|
|
567
|
-
QuantityInput,
|
|
568
|
-
{
|
|
569
|
-
value: quantity ? quantity / billing_units : "",
|
|
570
|
-
onChange: (e) => {
|
|
571
|
-
const newOptions = [...optionsInput];
|
|
572
|
-
newOptions[index].quantity = parseInt(e.target.value) * billing_units;
|
|
573
|
-
setOptionsInput(newOptions);
|
|
574
|
-
},
|
|
575
|
-
children: /* @__PURE__ */ jsxs2("span", { className: "", children: [
|
|
576
|
-
"\xD7 $",
|
|
577
|
-
price,
|
|
578
|
-
" per ",
|
|
579
|
-
billing_units === 1 ? " " : billing_units,
|
|
580
|
-
" ",
|
|
581
|
-
feature_name
|
|
582
|
-
] })
|
|
583
|
-
},
|
|
584
|
-
feature_name
|
|
585
|
-
)
|
|
586
|
-
] }, feature_name);
|
|
587
|
-
};
|
|
588
|
-
var QuantityInput = ({
|
|
589
|
-
children,
|
|
590
|
-
onChange,
|
|
591
|
-
value,
|
|
592
|
-
className,
|
|
593
|
-
...props
|
|
594
|
-
}) => {
|
|
595
|
-
const currentValue = Number(value) || 0;
|
|
596
|
-
const handleValueChange = (newValue) => {
|
|
597
|
-
const syntheticEvent = {
|
|
598
|
-
target: { value: String(newValue) }
|
|
599
|
-
};
|
|
600
|
-
onChange(syntheticEvent);
|
|
601
|
-
};
|
|
602
|
-
return /* @__PURE__ */ jsxs2(
|
|
603
|
-
"div",
|
|
604
|
-
{
|
|
605
|
-
className: cn(className, "au-flex au-flex-row au-items-center au-gap-4"),
|
|
606
|
-
...props,
|
|
607
|
-
children: [
|
|
608
|
-
/* @__PURE__ */ jsxs2("div", { className: "au-flex au-items-center au-gap-1", children: [
|
|
609
|
-
/* @__PURE__ */ jsx2(
|
|
610
|
-
Button,
|
|
611
|
-
{
|
|
612
|
-
variant: "outline",
|
|
613
|
-
size: "icon",
|
|
614
|
-
onClick: () => currentValue > 0 && handleValueChange(currentValue - 1),
|
|
615
|
-
disabled: currentValue <= 0,
|
|
616
|
-
className: "au-h-6 au-w-6 au-pb-0.5",
|
|
617
|
-
children: "-"
|
|
618
|
-
}
|
|
619
|
-
),
|
|
620
|
-
/* @__PURE__ */ jsx2("span", { className: "au-w-8 au-text-center au-text-foreground", children: currentValue }),
|
|
621
|
-
/* @__PURE__ */ jsx2(
|
|
622
|
-
Button,
|
|
623
|
-
{
|
|
624
|
-
variant: "outline",
|
|
625
|
-
size: "icon",
|
|
626
|
-
onClick: () => handleValueChange(currentValue + 1),
|
|
627
|
-
className: "au-h-6 au-w-6 au-pb-0.5",
|
|
628
|
-
children: "+"
|
|
629
|
-
}
|
|
630
|
-
)
|
|
631
|
-
] }),
|
|
632
|
-
children
|
|
633
|
-
]
|
|
634
|
-
}
|
|
635
|
-
);
|
|
636
|
-
};
|
|
637
|
-
var TotalPrice = ({ children }) => {
|
|
638
|
-
return /* @__PURE__ */ jsx2("div", { className: "au-w-full au-font-semibold au-flex au-justify-between au-items-center", children });
|
|
639
|
-
};
|
|
640
|
-
var PricingDialogButton = ({
|
|
641
|
-
children,
|
|
642
|
-
size,
|
|
643
|
-
onClick,
|
|
644
|
-
disabled,
|
|
645
|
-
className
|
|
646
|
-
}) => {
|
|
647
|
-
return /* @__PURE__ */ jsxs2(
|
|
648
|
-
Button,
|
|
649
|
-
{
|
|
650
|
-
onClick,
|
|
651
|
-
disabled,
|
|
652
|
-
size,
|
|
653
|
-
className: cn(className, "au-shadow-sm au-shadow-stone-400"),
|
|
654
|
-
children: [
|
|
655
|
-
children,
|
|
656
|
-
/* @__PURE__ */ jsx2(ArrowRight, { className: "!au-h-3" })
|
|
657
|
-
]
|
|
658
|
-
}
|
|
659
|
-
);
|
|
660
|
-
};
|
|
661
|
-
|
|
662
|
-
// src/libraries/react/hooks/useAutumnBase.tsx
|
|
663
|
-
var useAutumnBase = ({
|
|
664
|
-
AutumnContext: AutumnContext2
|
|
665
|
-
}) => {
|
|
666
|
-
const context = useAutumnContext({ AutumnContext: AutumnContext2, name: "useAutumn" });
|
|
667
|
-
const { attachDialog, paywallDialog } = context;
|
|
668
|
-
const client = context.client;
|
|
669
|
-
const { refetch: refetchPricingTable } = usePricingTableBase({
|
|
670
|
-
AutumnContext: AutumnContext2
|
|
671
|
-
});
|
|
672
|
-
let {
|
|
673
|
-
open: attachOpen,
|
|
674
|
-
setProps: setAttachProps,
|
|
675
|
-
setOpen: setAttachOpen,
|
|
676
|
-
setComponent: setAttachComponent
|
|
677
|
-
} = attachDialog;
|
|
678
|
-
let {
|
|
679
|
-
setProps: setCheckProps,
|
|
680
|
-
setOpen: setCheckOpen,
|
|
681
|
-
setComponent: setPaywallComponent
|
|
682
|
-
} = paywallDialog;
|
|
683
|
-
const attachWithoutDialog = async (params) => {
|
|
684
|
-
const result = await client.attach(params);
|
|
685
|
-
if (result.error) {
|
|
686
|
-
return result;
|
|
687
|
-
}
|
|
688
|
-
let data = result.data;
|
|
689
|
-
if (data?.checkout_url && typeof window !== "undefined") {
|
|
690
|
-
if (params.openInNewTab) {
|
|
691
|
-
window.open(data.checkout_url, "_blank");
|
|
692
|
-
} else {
|
|
693
|
-
window.location.href = data.checkout_url;
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
await refetchPricingTable();
|
|
697
|
-
if (setAttachOpen) {
|
|
698
|
-
setAttachOpen(false);
|
|
699
|
-
}
|
|
700
|
-
return result;
|
|
701
|
-
};
|
|
702
|
-
const attachWithDialog = async (params) => {
|
|
703
|
-
let { dialog, ...rest } = params;
|
|
704
|
-
const { productId, entityId, entityData } = params;
|
|
705
|
-
const checkRes = await client.check({
|
|
706
|
-
productId,
|
|
707
|
-
entityId,
|
|
708
|
-
entityData,
|
|
709
|
-
withPreview: true
|
|
710
|
-
});
|
|
711
|
-
if (checkRes.error) {
|
|
712
|
-
return checkRes;
|
|
713
|
-
}
|
|
714
|
-
let preview = checkRes.data.preview;
|
|
715
|
-
if (!preview) {
|
|
716
|
-
return await attachWithoutDialog(rest);
|
|
717
|
-
} else {
|
|
718
|
-
setAttachProps({ preview, attachParams: rest });
|
|
719
|
-
setAttachOpen(true);
|
|
720
|
-
}
|
|
721
|
-
return checkRes;
|
|
722
|
-
};
|
|
723
|
-
const attach = async (params) => {
|
|
724
|
-
const { dialog, openInNewTab } = params;
|
|
725
|
-
let finalDialog = dialog ? dialog : context.disableDialogs ? void 0 : AttachDialog;
|
|
726
|
-
if (finalDialog && !attachOpen) {
|
|
727
|
-
setAttachComponent(finalDialog);
|
|
728
|
-
return await attachWithDialog(params);
|
|
729
|
-
}
|
|
730
|
-
return await attachWithoutDialog(params);
|
|
731
|
-
};
|
|
732
|
-
const cancel = async (params) => {
|
|
733
|
-
const res = await client.cancel(params);
|
|
734
|
-
if (res.error) {
|
|
735
|
-
return res;
|
|
736
|
-
}
|
|
737
|
-
return res;
|
|
738
|
-
};
|
|
739
|
-
const check = async (params) => {
|
|
740
|
-
let { dialog, withPreview } = params;
|
|
741
|
-
if (dialog) {
|
|
742
|
-
setPaywallComponent(dialog);
|
|
743
|
-
}
|
|
744
|
-
const res = await client.check({
|
|
745
|
-
...params,
|
|
746
|
-
withPreview: withPreview || dialog ? true : false
|
|
747
|
-
});
|
|
748
|
-
if (res.error) {
|
|
749
|
-
return res;
|
|
750
|
-
}
|
|
751
|
-
let data = res.data;
|
|
752
|
-
if (data && data.preview && dialog) {
|
|
753
|
-
let preview = data.preview;
|
|
754
|
-
setCheckProps({ preview });
|
|
755
|
-
setCheckOpen(true);
|
|
756
|
-
}
|
|
757
|
-
return res;
|
|
758
|
-
};
|
|
759
|
-
const track = async (params) => {
|
|
760
|
-
const res = await client.track(params);
|
|
761
|
-
if (res.error) {
|
|
762
|
-
return res;
|
|
763
|
-
}
|
|
764
|
-
return res;
|
|
765
|
-
};
|
|
766
|
-
const openBillingPortal = async (params) => {
|
|
767
|
-
let defaultParams = {
|
|
768
|
-
openInNewTab: false
|
|
769
|
-
};
|
|
770
|
-
let finalParams = {
|
|
771
|
-
...defaultParams,
|
|
772
|
-
...params
|
|
773
|
-
};
|
|
774
|
-
const res = await client.openBillingPortal(finalParams);
|
|
775
|
-
if (res.error) {
|
|
776
|
-
return res;
|
|
777
|
-
}
|
|
778
|
-
let data = res.data;
|
|
779
|
-
if (data?.url && typeof window !== "undefined") {
|
|
780
|
-
if (finalParams.openInNewTab) {
|
|
781
|
-
window.open(data.url, "_blank");
|
|
782
|
-
} else {
|
|
783
|
-
window.open(data.url, "_self");
|
|
784
|
-
}
|
|
785
|
-
return res;
|
|
786
|
-
} else {
|
|
787
|
-
return res;
|
|
788
|
-
}
|
|
789
|
-
};
|
|
790
|
-
const setupPayment = async (params) => {
|
|
791
|
-
let defaultParams = {
|
|
792
|
-
openInNewTab: false
|
|
793
|
-
};
|
|
794
|
-
let finalParams = {
|
|
795
|
-
...defaultParams,
|
|
796
|
-
...params || {}
|
|
797
|
-
};
|
|
798
|
-
const res = await client.setupPayment(finalParams);
|
|
799
|
-
if (res.data?.url && typeof window !== "undefined") {
|
|
800
|
-
if (finalParams.openInNewTab) {
|
|
801
|
-
window.open(res.data.url, "_blank");
|
|
802
|
-
} else {
|
|
803
|
-
window.open(res.data.url, "_self");
|
|
804
|
-
}
|
|
805
|
-
return res;
|
|
806
|
-
} else {
|
|
807
|
-
return res;
|
|
808
|
-
}
|
|
809
|
-
};
|
|
810
|
-
return {
|
|
811
|
-
attach,
|
|
812
|
-
check,
|
|
813
|
-
track,
|
|
814
|
-
cancel,
|
|
815
|
-
openBillingPortal,
|
|
816
|
-
setupPayment
|
|
817
|
-
};
|
|
818
|
-
};
|
|
819
|
-
|
|
820
|
-
// src/libraries/react/hooks/useCustomerBase.tsx
|
|
821
|
-
var emptyDefaultFunctions = {
|
|
822
|
-
attach: "",
|
|
823
|
-
check: "",
|
|
824
|
-
track: "",
|
|
825
|
-
cancel: "",
|
|
826
|
-
openBillingPortal: "",
|
|
827
|
-
setupPayment: ""
|
|
828
|
-
};
|
|
829
|
-
var useCustomerBase = ({
|
|
830
|
-
params,
|
|
831
|
-
AutumnContext: AutumnContext2,
|
|
832
|
-
client
|
|
833
|
-
}) => {
|
|
834
|
-
const queryKey = ["customer", params?.expand];
|
|
835
|
-
let context;
|
|
836
|
-
if (AutumnContext2) {
|
|
837
|
-
context = useAutumnContext({ AutumnContext: AutumnContext2, name: "useCustomer" });
|
|
838
|
-
}
|
|
839
|
-
if (!client) {
|
|
840
|
-
client = context.client;
|
|
841
|
-
}
|
|
842
|
-
const fetchCustomer = async () => {
|
|
843
|
-
const { data, error: error2 } = await client.createCustomer({
|
|
844
|
-
errorOnNotFound: params?.errorOnNotFound,
|
|
845
|
-
expand: params?.expand
|
|
846
|
-
});
|
|
847
|
-
if (error2) {
|
|
848
|
-
throw error2;
|
|
849
|
-
}
|
|
850
|
-
if (!data) {
|
|
851
|
-
return null;
|
|
852
|
-
}
|
|
853
|
-
return data;
|
|
854
|
-
};
|
|
855
|
-
const { data: customer, error, isLoading, mutate } = useSWR2(queryKey, fetchCustomer, {
|
|
856
|
-
fallbackData: null,
|
|
857
|
-
onErrorRetry: (error2, key, config) => {
|
|
858
|
-
if (error2.code == "entity_not_found") {
|
|
859
|
-
return false;
|
|
860
|
-
}
|
|
861
|
-
return true;
|
|
862
|
-
}
|
|
863
|
-
});
|
|
864
|
-
let autumnFunctions = emptyDefaultFunctions;
|
|
865
|
-
if (AutumnContext2) {
|
|
866
|
-
autumnFunctions = useAutumnBase({ AutumnContext: AutumnContext2 });
|
|
867
|
-
}
|
|
868
|
-
return {
|
|
869
|
-
customer: error ? null : customer,
|
|
870
|
-
isLoading,
|
|
871
|
-
error,
|
|
872
|
-
refetch: mutate,
|
|
873
|
-
...autumnFunctions,
|
|
874
|
-
createEntity: client.entities.create,
|
|
875
|
-
createReferralCode: client.referrals.createCode,
|
|
876
|
-
redeemReferralCode: client.referrals.redeemCode,
|
|
877
|
-
allowed: (params2) => handleAllowed({ customer, params: params2 })
|
|
878
|
-
};
|
|
879
|
-
};
|
|
880
|
-
|
|
881
|
-
// src/libraries/react/BaseAutumnProvider.tsx
|
|
882
|
-
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
883
|
-
function BaseAutumnProvider({
|
|
884
|
-
client,
|
|
885
|
-
children,
|
|
886
|
-
AutumnContext: AutumnContext2,
|
|
887
|
-
disableDialogs = false
|
|
888
|
-
}) {
|
|
889
|
-
const [components, setComponents] = useState3({});
|
|
890
|
-
const [paywallProps, setPaywallProps, paywallOpen, setPaywallOpen] = useDialog(components.paywallDialog);
|
|
891
|
-
const [
|
|
892
|
-
productChangeProps,
|
|
893
|
-
setProductChangeProps,
|
|
894
|
-
productChangeOpen,
|
|
895
|
-
setProductChangeOpen
|
|
896
|
-
] = useDialog(components.productChangeDialog);
|
|
897
|
-
useCustomerBase({ client, params: { errorOnNotFound: false } });
|
|
898
|
-
return /* @__PURE__ */ jsxs3(
|
|
899
|
-
AutumnContext2.Provider,
|
|
900
|
-
{
|
|
901
|
-
value: {
|
|
902
|
-
initialized: true,
|
|
903
|
-
client,
|
|
904
|
-
disableDialogs,
|
|
905
|
-
paywallDialog: {
|
|
906
|
-
props: paywallProps,
|
|
907
|
-
setProps: setPaywallProps,
|
|
908
|
-
open: paywallOpen,
|
|
909
|
-
setOpen: setPaywallOpen,
|
|
910
|
-
setComponent: (component) => {
|
|
911
|
-
setComponents({
|
|
912
|
-
...components,
|
|
913
|
-
paywallDialog: component
|
|
914
|
-
});
|
|
915
|
-
}
|
|
916
|
-
},
|
|
917
|
-
attachDialog: {
|
|
918
|
-
props: productChangeProps,
|
|
919
|
-
setProps: setProductChangeProps,
|
|
920
|
-
open: productChangeOpen,
|
|
921
|
-
setOpen: setProductChangeOpen,
|
|
922
|
-
setComponent: (component) => {
|
|
923
|
-
setComponents({
|
|
924
|
-
...components,
|
|
925
|
-
productChangeDialog: component
|
|
926
|
-
});
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
},
|
|
930
|
-
children: [
|
|
931
|
-
components.paywallDialog && /* @__PURE__ */ jsx3(
|
|
932
|
-
components.paywallDialog,
|
|
933
|
-
{
|
|
934
|
-
open: paywallOpen,
|
|
935
|
-
setOpen: setPaywallOpen,
|
|
936
|
-
...paywallProps
|
|
937
|
-
}
|
|
938
|
-
),
|
|
939
|
-
components.productChangeDialog && /* @__PURE__ */ jsx3(
|
|
940
|
-
components.productChangeDialog,
|
|
941
|
-
{
|
|
942
|
-
open: productChangeOpen,
|
|
943
|
-
setOpen: setProductChangeOpen,
|
|
944
|
-
...productChangeProps
|
|
945
|
-
}
|
|
946
|
-
),
|
|
947
|
-
children
|
|
948
|
-
]
|
|
949
|
-
}
|
|
950
|
-
);
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
// src/libraries/react/ReactAutumnProvider.tsx
|
|
954
|
-
import { useEffect as useEffect3 } from "react";
|
|
955
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
956
|
-
var ReactAutumnProvider = ({
|
|
957
|
-
children,
|
|
958
|
-
getBearerToken,
|
|
959
|
-
backendUrl,
|
|
960
|
-
customerData,
|
|
961
|
-
includeCredentials = true,
|
|
962
|
-
disableDialogs = false,
|
|
963
|
-
authClient
|
|
964
|
-
}) => {
|
|
965
|
-
if (backendUrl && !backendUrl.startsWith("http")) {
|
|
966
|
-
console.warn(`backendUrl is not a valid URL: ${backendUrl}`);
|
|
967
|
-
}
|
|
968
|
-
let client = new AutumnClient({
|
|
969
|
-
backendUrl: backendUrl || "",
|
|
970
|
-
getBearerToken,
|
|
971
|
-
customerData,
|
|
972
|
-
includeCredentials
|
|
973
|
-
});
|
|
974
|
-
const analyseAuthClient = async () => {
|
|
975
|
-
console.log("Auth client:", authClient);
|
|
976
|
-
};
|
|
977
|
-
useEffect3(() => {
|
|
978
|
-
analyseAuthClient();
|
|
979
|
-
}, [authClient]);
|
|
980
|
-
return /* @__PURE__ */ jsx4(
|
|
981
|
-
BaseAutumnProvider,
|
|
982
|
-
{
|
|
983
|
-
client,
|
|
984
|
-
AutumnContext,
|
|
985
|
-
disableDialogs,
|
|
986
|
-
children
|
|
987
|
-
}
|
|
988
|
-
);
|
|
989
|
-
};
|
|
990
|
-
|
|
991
|
-
export {
|
|
992
|
-
ReactAutumnProvider,
|
|
993
|
-
useCustomer,
|
|
994
|
-
useEntityBase,
|
|
995
|
-
useEntity,
|
|
996
|
-
useAutumn,
|
|
997
|
-
PricingTable,
|
|
998
|
-
usePricingTableContext,
|
|
999
|
-
PricingTableContainer,
|
|
1000
|
-
PricingCard,
|
|
1001
|
-
PricingFeatureList,
|
|
1002
|
-
PricingCardButton,
|
|
1003
|
-
AnnualSwitch,
|
|
1004
|
-
RecommendedBadge,
|
|
1005
|
-
AttachDialog,
|
|
1006
|
-
PriceItem,
|
|
1007
|
-
OptionsInput,
|
|
1008
|
-
QuantityInput,
|
|
1009
|
-
TotalPrice,
|
|
1010
|
-
PricingDialogButton,
|
|
1011
|
-
useAutumnBase,
|
|
1012
|
-
useCustomerBase,
|
|
1013
|
-
BaseAutumnProvider
|
|
1014
|
-
};
|