@bunnyapp/components 1.3.0-beta.1 → 1.3.0-beta.4
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/cjs/index.js +521 -598
- package/dist/cjs/src/components/BillingDetails/BillingDetails.d.ts +1 -1
- package/dist/cjs/src/components/PaymentForm/DemoPay/demoPayUtils.d.ts +2 -2
- package/dist/cjs/src/components/PaymentForm/PaymentForm.d.ts +3 -2
- package/dist/cjs/src/components/PaymentForm/PaymentMethodDetails.d.ts +1 -1
- package/dist/cjs/src/components/Subscriptions/PlanManager/PlanPicker/priceListCard/priceListCardUtils.d.ts +2 -1
- package/dist/cjs/src/components/Subscriptions/SubscriptionRequests.d.ts +1 -0
- package/dist/cjs/src/components/Subscriptions/subscriptionsList/subscriptionUtils.d.ts +0 -1
- package/dist/cjs/src/components/TaxationForm.d.ts +2 -2
- package/dist/cjs/src/components/UpgradeFromTrial.d.ts +6 -0
- package/dist/cjs/src/graphql/QuoteRequests.d.ts +0 -1
- package/dist/cjs/src/graphql/queries/getFeatureUsage.d.ts +4 -1
- package/dist/cjs/src/graphql/queries/getFormattedQuote.d.ts +4 -2
- package/dist/cjs/src/graphql/queries/getPriceListChangeOptions.d.ts +1 -2
- package/dist/cjs/src/hooks/useCurrentUserData.d.ts +1 -10
- package/dist/cjs/src/hooks/usePaymentPlugins.d.ts +2 -2
- package/dist/cjs/src/mocks/handlers.d.ts +1 -1
- package/dist/esm/index.js +522 -599
- package/dist/esm/src/components/BillingDetails/BillingDetails.d.ts +1 -1
- package/dist/esm/src/components/PaymentForm/DemoPay/demoPayUtils.d.ts +2 -2
- package/dist/esm/src/components/PaymentForm/PaymentForm.d.ts +3 -2
- package/dist/esm/src/components/PaymentForm/PaymentMethodDetails.d.ts +1 -1
- package/dist/esm/src/components/Subscriptions/PlanManager/PlanPicker/priceListCard/priceListCardUtils.d.ts +2 -1
- package/dist/esm/src/components/Subscriptions/SubscriptionRequests.d.ts +1 -0
- package/dist/esm/src/components/Subscriptions/subscriptionsList/subscriptionUtils.d.ts +0 -1
- package/dist/esm/src/components/TaxationForm.d.ts +2 -2
- package/dist/esm/src/components/UpgradeFromTrial.d.ts +6 -0
- package/dist/esm/src/graphql/QuoteRequests.d.ts +0 -1
- package/dist/esm/src/graphql/queries/getFeatureUsage.d.ts +4 -1
- package/dist/esm/src/graphql/queries/getFormattedQuote.d.ts +4 -2
- package/dist/esm/src/graphql/queries/getPriceListChangeOptions.d.ts +1 -2
- package/dist/esm/src/hooks/useCurrentUserData.d.ts +1 -10
- package/dist/esm/src/hooks/usePaymentPlugins.d.ts +2 -2
- package/dist/esm/src/mocks/handlers.d.ts +1 -1
- package/dist/index.d.ts +4 -3
- package/package.json +1 -1
- package/dist/cjs/src/graphql/mutations/subscriptionTrialConvert.d.ts +0 -7
- package/dist/cjs/src/graphql/queries/getCurrentUserData.d.ts +0 -13
- package/dist/cjs/src/utils/couponUtils.d.ts +0 -2
- package/dist/esm/src/graphql/mutations/subscriptionTrialConvert.d.ts +0 -7
- package/dist/esm/src/graphql/queries/getCurrentUserData.d.ts +0 -13
- package/dist/esm/src/utils/couponUtils.d.ts +0 -2
- /package/dist/cjs/src/components/icons/{IDeal.d.ts → iDeal.d.ts} +0 -0
- /package/dist/esm/src/components/icons/{IDeal.d.ts → iDeal.d.ts} +0 -0
package/dist/cjs/index.js
CHANGED
|
@@ -154,7 +154,7 @@ var BrandContext = react.createContext({
|
|
|
154
154
|
});
|
|
155
155
|
|
|
156
156
|
// This will be replaced at build time by rollup-plugin-replace
|
|
157
|
-
var PACKAGE_VERSION = '1.
|
|
157
|
+
var PACKAGE_VERSION = '1.0.76-beta.15';
|
|
158
158
|
var createRequestHeaders = function (token) {
|
|
159
159
|
var headers = common.createClientDevHeaders(token);
|
|
160
160
|
// Add the components version header
|
|
@@ -430,7 +430,6 @@ var DocumentTemplatePreview = function (_a) {
|
|
|
430
430
|
URL.revokeObjectURL(url_1);
|
|
431
431
|
};
|
|
432
432
|
}
|
|
433
|
-
return undefined;
|
|
434
433
|
}, [data]);
|
|
435
434
|
if (isLoading) {
|
|
436
435
|
return (jsxRuntime.jsx("div", __assign({ className: "flex items-center justify-center h-96" }, { children: jsxRuntime.jsx(antd.Spin, {}) })));
|
|
@@ -502,7 +501,6 @@ function LegacyDocument(_a) {
|
|
|
502
501
|
setPdfUrl(url_1);
|
|
503
502
|
return function () { return URL.revokeObjectURL(url_1); };
|
|
504
503
|
}
|
|
505
|
-
return undefined;
|
|
506
504
|
}, [pdfBlob]);
|
|
507
505
|
if (isLoading || !pdfUrl)
|
|
508
506
|
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
@@ -549,7 +547,7 @@ var checkout = function (_a) {
|
|
|
549
547
|
});
|
|
550
548
|
};
|
|
551
549
|
|
|
552
|
-
var paymentMethodsQuery = function () { return "query
|
|
550
|
+
var paymentMethodsQuery = function (filter) { return "query paymentMethods {\n paymentMethods ".concat(filter ? "(".concat(filter, ")") : '', " {\n nodes {\n id\n pluginId\n accountId\n expirationDate\n plugin {\n guid\n id\n }\n state\n metadata {\n issuer\n identifier\n kind\n description\n icon\n type\n }\n isDefault\n }\n }\n}"); };
|
|
553
551
|
var getPaymentMethods = function (_a) {
|
|
554
552
|
var apiHost = _a.apiHost, token = _a.token, accountId = _a.accountId;
|
|
555
553
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -558,10 +556,9 @@ var getPaymentMethods = function (_a) {
|
|
|
558
556
|
return __generator(this, function (_c) {
|
|
559
557
|
switch (_c.label) {
|
|
560
558
|
case 0: return [4 /*yield*/, gqlRequest({
|
|
561
|
-
query: paymentMethodsQuery(),
|
|
559
|
+
query: paymentMethodsQuery(accountId ? "filter: \"accountId is ".concat(accountId, "\"") : ''),
|
|
562
560
|
token: token,
|
|
563
561
|
apiHost: apiHost,
|
|
564
|
-
vars: { accountId: accountId },
|
|
565
562
|
})];
|
|
566
563
|
case 1:
|
|
567
564
|
response = _c.sent();
|
|
@@ -589,11 +586,20 @@ var usePaymentMethod = function (_a) {
|
|
|
589
586
|
};
|
|
590
587
|
|
|
591
588
|
var filterPaymentPlugins = function (plugins) {
|
|
592
|
-
return plugins === null || plugins === void 0 ? void 0 : plugins.filter(function (plugin) { var _a, _b; return ((_a = plugin.type) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'payment' && ((_b = plugin.status) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'valid'; });
|
|
589
|
+
return plugins === null || plugins === void 0 ? void 0 : plugins.filter(function (plugin) { var _a, _b; return ((_a = plugin.type) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'payment' && ((_b = plugin.status) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'valid'; }).filter(function (plugin) { return plugin.name !== 'Manual Payment'; });
|
|
590
|
+
};
|
|
591
|
+
var filterPaymentPluginsByEntity = function (plugins, selectedEntityId) {
|
|
592
|
+
return plugins === null || plugins === void 0 ? void 0 : plugins.filter(function (plugin) {
|
|
593
|
+
var _a, _b;
|
|
594
|
+
return selectedEntityId === undefined ||
|
|
595
|
+
selectedEntityId === null ||
|
|
596
|
+
((_a = plugin.entities) === null || _a === void 0 ? void 0 : _a.includes(selectedEntityId)) ||
|
|
597
|
+
((_b = plugin.entities) === null || _b === void 0 ? void 0 : _b.length) === 0;
|
|
598
|
+
});
|
|
593
599
|
};
|
|
594
|
-
var MUTATION$9 = "
|
|
600
|
+
var MUTATION$9 = "{\n paymentPlugins {\n enabled\n entities\n guid\n hidden\n id\n name\n status\n type\n webhookEnabled\n components\n }\n}";
|
|
595
601
|
var getPaymentPlugins = function (_a) {
|
|
596
|
-
var apiHost = _a.apiHost, token = _a.token
|
|
602
|
+
var apiHost = _a.apiHost, token = _a.token;
|
|
597
603
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
598
604
|
var response;
|
|
599
605
|
return __generator(this, function (_b) {
|
|
@@ -604,7 +610,6 @@ var getPaymentPlugins = function (_a) {
|
|
|
604
610
|
query: MUTATION$9,
|
|
605
611
|
token: token,
|
|
606
612
|
apiHost: apiHost,
|
|
607
|
-
vars: { accountId: accountId },
|
|
608
613
|
})];
|
|
609
614
|
case 1:
|
|
610
615
|
response = _b.sent();
|
|
@@ -618,15 +623,18 @@ var getPaymentPlugins = function (_a) {
|
|
|
618
623
|
});
|
|
619
624
|
};
|
|
620
625
|
var usePaymentPlugins = function (_a) {
|
|
621
|
-
var apiHost = _a.apiHost, token = _a.token,
|
|
626
|
+
var apiHost = _a.apiHost, token = _a.token, selectedEntityId = _a.selectedEntityId;
|
|
622
627
|
var _b = reactQuery.useQuery({
|
|
623
628
|
queryKey: ['paymentPlugins', token],
|
|
624
|
-
queryFn: function () { return getPaymentPlugins({ apiHost: apiHost, token: token
|
|
629
|
+
queryFn: function () { return getPaymentPlugins({ apiHost: apiHost, token: token }); },
|
|
625
630
|
staleTime: 5 * 60 * 1000, // Consider data fresh for 5 minutes
|
|
626
631
|
}), paymentPlugins = _b.data, isFetched = _b.isFetched;
|
|
627
632
|
var filteredPaymentPlugins = filterPaymentPlugins(paymentPlugins);
|
|
633
|
+
var filteredPaymentPluginsByEntity = selectedEntityId
|
|
634
|
+
? filterPaymentPluginsByEntity(filteredPaymentPlugins, selectedEntityId)
|
|
635
|
+
: filteredPaymentPlugins;
|
|
628
636
|
return {
|
|
629
|
-
paymentPlugins:
|
|
637
|
+
paymentPlugins: filteredPaymentPluginsByEntity,
|
|
630
638
|
isFetched: isFetched,
|
|
631
639
|
};
|
|
632
640
|
};
|
|
@@ -18605,13 +18613,13 @@ var isCardExpired = function (expiry) {
|
|
|
18605
18613
|
var formatCardExpiry = function (cardExpiry) {
|
|
18606
18614
|
if (cardExpiry.length <= 2)
|
|
18607
18615
|
return cardExpiry;
|
|
18608
|
-
return cardExpiry.substring(0, 2) +
|
|
18616
|
+
return cardExpiry.substring(0, 2) + "/" + cardExpiry.substring(2);
|
|
18609
18617
|
};
|
|
18610
18618
|
// removes spaces from a credit card number
|
|
18611
18619
|
var unformatCardNumber = function (cardNumber) {
|
|
18612
|
-
var cardNumberArray = cardNumber.split(
|
|
18613
|
-
var unformattedCardNumberArray = cardNumberArray.filter(function (character) { return character !==
|
|
18614
|
-
return unformattedCardNumberArray.join(
|
|
18620
|
+
var cardNumberArray = cardNumber.split("");
|
|
18621
|
+
var unformattedCardNumberArray = cardNumberArray.filter(function (character) { return character !== " "; });
|
|
18622
|
+
return unformattedCardNumberArray.join("");
|
|
18615
18623
|
};
|
|
18616
18624
|
var storePayment = function (options, plugin, apiHost, accountId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
18617
18625
|
var testCreditCardNumber, testCreditCardCvc, testCreditCardExpirationDate, token, response;
|
|
@@ -18620,7 +18628,7 @@ var storePayment = function (options, plugin, apiHost, accountId) { return __awa
|
|
|
18620
18628
|
case 0:
|
|
18621
18629
|
testCreditCardNumber = options.testCreditCardNumber, testCreditCardCvc = options.testCreditCardCvc, testCreditCardExpirationDate = options.testCreditCardExpirationDate, token = options.token;
|
|
18622
18630
|
return [4 /*yield*/, common.invokePlugin({
|
|
18623
|
-
method:
|
|
18631
|
+
method: "store_payment_method",
|
|
18624
18632
|
plugin: plugin,
|
|
18625
18633
|
payload: {
|
|
18626
18634
|
test_credit_card_number: testCreditCardNumber,
|
|
@@ -18633,7 +18641,7 @@ var storePayment = function (options, plugin, apiHost, accountId) { return __awa
|
|
|
18633
18641
|
})];
|
|
18634
18642
|
case 1:
|
|
18635
18643
|
response = _a.sent();
|
|
18636
|
-
if ((response === null || response === void 0 ? void 0 : response.status) !==
|
|
18644
|
+
if ((response === null || response === void 0 ? void 0 : response.status) !== "success")
|
|
18637
18645
|
throw new Error(response === null || response === void 0 ? void 0 : response.message);
|
|
18638
18646
|
return [2 /*return*/, response];
|
|
18639
18647
|
}
|
|
@@ -18950,7 +18958,7 @@ var PaymentMethodDetails = function (_a) {
|
|
|
18950
18958
|
case 'StripePayment':
|
|
18951
18959
|
return (jsxRuntime.jsx(StripeForm, { onFail: onFail, onSavePaymentMethod: onSavePaymentMethod, plugin: plugin }));
|
|
18952
18960
|
case 'DemoPayPayment':
|
|
18953
|
-
return (jsxRuntime.jsx(DemoPayForm, { onFail: onFail, onSavePaymentMethod:
|
|
18961
|
+
return (jsxRuntime.jsx(DemoPayForm, { onFail: onFail, onSavePaymentMethod: onSavePaymentMethod, plugin: plugin }));
|
|
18954
18962
|
default:
|
|
18955
18963
|
console.warn('Can not find form for plugin', plugin);
|
|
18956
18964
|
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
@@ -19096,7 +19104,7 @@ function useSetDefaultPaymentMethod(paymentPlugins, apiHost, token, accountId, o
|
|
|
19096
19104
|
var showErrorNotification$2 = common.useErrorNotification();
|
|
19097
19105
|
var PaymentForm = function (_a) {
|
|
19098
19106
|
var _b;
|
|
19099
|
-
var invoice = _a.invoice, onFail = _a.onFail, onPaymentSuccess = _a.onPaymentSuccess, onPaymentHoldSuccess = _a.onPaymentHoldSuccess, quote = _a.quote, accountId = _a.accountId, onSavePaymentMethod = _a.onSavePaymentMethod, onRemovePaymentMethod = _a.onRemovePaymentMethod, onSetDefaultPaymentMethod = _a.onSetDefaultPaymentMethod, overrideToken = _a.overrideToken, customCheckoutFunction = _a.customCheckoutFunction, currencyIdFromProps = _a.currencyId, paymentHoldOptions = _a.paymentHoldOptions;
|
|
19107
|
+
var invoice = _a.invoice, onFail = _a.onFail, onPaymentSuccess = _a.onPaymentSuccess, onPaymentHoldSuccess = _a.onPaymentHoldSuccess, quote = _a.quote, accountId = _a.accountId, onSavePaymentMethod = _a.onSavePaymentMethod, onRemovePaymentMethod = _a.onRemovePaymentMethod, onSetDefaultPaymentMethod = _a.onSetDefaultPaymentMethod, entityId = _a.entityId, overrideToken = _a.overrideToken, customCheckoutFunction = _a.customCheckoutFunction, currencyIdFromProps = _a.currencyId, paymentHoldOptions = _a.paymentHoldOptions;
|
|
19100
19108
|
// Local state
|
|
19101
19109
|
var _c = react.useState(false), showPaymentMethodForm = _c[0], setShowPaymentMethodForm = _c[1];
|
|
19102
19110
|
// Simple hooks
|
|
@@ -19110,7 +19118,7 @@ var PaymentForm = function (_a) {
|
|
|
19110
19118
|
apiHost: apiHost,
|
|
19111
19119
|
}), storedPaymentMethods = _d.paymentMethods, defaultPaymentMethod = _d.defaultPaymentMethod, isPaymentMethodLoading = _d.isLoading;
|
|
19112
19120
|
// Complex hooks
|
|
19113
|
-
var paymentPlugins = usePaymentPlugins({ apiHost: apiHost,
|
|
19121
|
+
var paymentPlugins = usePaymentPlugins({ apiHost: apiHost, selectedEntityId: entityId, token: token }).paymentPlugins;
|
|
19114
19122
|
var selectedPaymentMethodPlugin = react.useMemo(function () {
|
|
19115
19123
|
// TODO: consolate PluginData and PaymentPlugin into one type. Needs to be done on API side.
|
|
19116
19124
|
return paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.find(function (plugin) { var _a, _b, _c; return ((_a = plugin.id) === null || _a === void 0 ? void 0 : _a.toString()) === ((_c = (_b = defaultPaymentMethod === null || defaultPaymentMethod === void 0 ? void 0 : defaultPaymentMethod.plugin) === null || _b === void 0 ? void 0 : _b.id) === null || _c === void 0 ? void 0 : _c.toString()); });
|
|
@@ -19168,14 +19176,14 @@ var PaymentForm = function (_a) {
|
|
|
19168
19176
|
setShowPaymentMethodForm(false);
|
|
19169
19177
|
onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess();
|
|
19170
19178
|
};
|
|
19171
|
-
var handleSavePaymentMethod = function (
|
|
19179
|
+
var handleSavePaymentMethod = function () {
|
|
19172
19180
|
queryClient.invalidateQueries({
|
|
19173
19181
|
queryKey: common.QueryKeyFactory.default.accountPaymentMethodKey({
|
|
19174
19182
|
accountId: accountId,
|
|
19175
19183
|
token: token,
|
|
19176
19184
|
}),
|
|
19177
19185
|
});
|
|
19178
|
-
onSavePaymentMethod === null || onSavePaymentMethod === void 0 ? void 0 : onSavePaymentMethod(
|
|
19186
|
+
onSavePaymentMethod === null || onSavePaymentMethod === void 0 ? void 0 : onSavePaymentMethod();
|
|
19179
19187
|
setShowPaymentMethodForm(false);
|
|
19180
19188
|
};
|
|
19181
19189
|
function handleClickAddPaymentMethod() {
|
|
@@ -19217,6 +19225,15 @@ function StripeWrapper(_a) {
|
|
|
19217
19225
|
return (jsxRuntime.jsx(reactStripeJs.Elements, __assign({ options: options, stripe: stripe }, { children: children })));
|
|
19218
19226
|
}
|
|
19219
19227
|
|
|
19228
|
+
var useCurrentUserData = function () {
|
|
19229
|
+
var queryClient = reactQuery.useQueryClient();
|
|
19230
|
+
var token = useToken();
|
|
19231
|
+
var currentUser = queryClient.getQueryData(common.QueryKeyFactory.default.currentUserKey(token));
|
|
19232
|
+
if (!currentUser)
|
|
19233
|
+
return {};
|
|
19234
|
+
return currentUser;
|
|
19235
|
+
};
|
|
19236
|
+
|
|
19220
19237
|
function Invoice(_a) {
|
|
19221
19238
|
var id = _a.id, invoiceQuoteViewComponent = _a.invoiceQuoteViewComponent, backButtonName = _a.backButtonName, onBackButtonClick = _a.onBackButtonClick, onInvoiceDownloadError = _a.onInvoiceDownloadError, onPaymentSuccess = _a.onPaymentSuccess, _b = _a.shadow, shadow = _b === void 0 ? 'shadow-md' : _b, className = _a.className, _c = _a.hideDownloadButton, hideDownloadButton = _c === void 0 ? false : _c, onInvoiceLoaded = _a.onInvoiceLoaded;
|
|
19222
19239
|
return (jsxRuntime.jsx(InvoiceQuoteContext.Provider, __assign({ value: {
|
|
@@ -19239,6 +19256,7 @@ function ActualInvoice() {
|
|
|
19239
19256
|
var _b = react.useContext(BunnyContext), apiHost = _b.apiHost, onTokenExpired = _b.onTokenExpired;
|
|
19240
19257
|
var _c = react.useContext(InvoiceQuoteContext), hideDownloadButton = _c.hideDownloadButton, onInvoiceLoaded = _c.onInvoiceLoaded;
|
|
19241
19258
|
var token = useToken();
|
|
19259
|
+
var entityId = useCurrentUserData().entityId;
|
|
19242
19260
|
// Hooks
|
|
19243
19261
|
var showSuccessNotification = common.useSuccessNotification();
|
|
19244
19262
|
var handleAllErrorFormats = common.useAllErrorFormats(onTokenExpired);
|
|
@@ -19274,12 +19292,12 @@ function ActualInvoice() {
|
|
|
19274
19292
|
}, [formattedInvoice]);
|
|
19275
19293
|
if (!formattedInvoice)
|
|
19276
19294
|
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
19277
|
-
return (jsxRuntime.jsx("div", __assign({ className: "bunny-invoice-container" }, { children: jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-gap-6 ".concat(isMobile ? 'bunny-flex-col bunny-w-full' : '', " ").concat(className) }, { children: [formattedInvoice.isLegacy ? (jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-justify-center bunny-w-full" }, { children: jsxRuntime.jsx(LegacyDocument, { documentUuid: formattedInvoice.uuid, documentType: "invoice" }) }))) : (invoiceQuoteViewComponent || (jsxRuntime.jsx(InvoiceQuoteView, { html: formattedInvoice.html, formattedInvoice: formattedInvoice, backButtonName: backButtonName, onBackButtonClick: onBackButtonClick }))), isInvoicePayable && (jsxRuntime.jsx("div", __assign({ className: "bunny-w-full ".concat(hideDownloadButton || formattedInvoice.isLegacy ? '' : 'pt-12') }, { children: jsxRuntime.jsx(PaymentForm, { onPaymentSuccess: onSuccess, onFail: onFail, invoice: formattedInvoice }) })))] })) })));
|
|
19295
|
+
return (jsxRuntime.jsx("div", __assign({ className: "bunny-invoice-container" }, { children: jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-gap-6 ".concat(isMobile ? 'bunny-flex-col bunny-w-full' : '', " ").concat(className) }, { children: [formattedInvoice.isLegacy ? (jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-justify-center bunny-w-full" }, { children: jsxRuntime.jsx(LegacyDocument, { documentUuid: formattedInvoice.uuid, documentType: "invoice" }) }))) : (invoiceQuoteViewComponent || (jsxRuntime.jsx(InvoiceQuoteView, { html: formattedInvoice.html, formattedInvoice: formattedInvoice, backButtonName: backButtonName, onBackButtonClick: onBackButtonClick }))), isInvoicePayable && (jsxRuntime.jsx("div", __assign({ className: "bunny-w-full ".concat(hideDownloadButton || formattedInvoice.isLegacy ? '' : 'pt-12') }, { children: jsxRuntime.jsx(PaymentForm, { entityId: entityId, onPaymentSuccess: onSuccess, onFail: onFail, invoice: formattedInvoice }) })))] })) })));
|
|
19278
19296
|
}
|
|
19279
19297
|
|
|
19280
|
-
var MUTATION$8 = function () { return "\n query formattedQuote ($id: ID) {\n formattedQuote (id: $id) {\n quote {\n documentTemplateId\n documents { id filename size date url }\n firstInvoice {\n id\n state\n }\n payableId\n id\n payToAccept\n currentPaymentHold {\n createdAt\n expiresAt\n id\n updatedAt\n paymentMethod {\n accountId\n createdAt\n expirationDate\n failureCode\n id\n isDefault\n lastSuccess\n paymentType\n pluginId\n state\n updatedAt\n metadata {\n description\n expiration\n icon\n identifier\n issuer\n kind\n }\n }\n }\n }\n payableId\n acceptedAt\n acceptedByName\n amount\n amountDue\n amountsByPeriod {\n id\n name\n amount\n }\n billingCity\n billingCountry\n billingState\n billingStreet\n billingZip\n contactName\n currency\n customerBillingCity\n customerBillingCountry\n customerBillingState\n customerBillingStreet\n customerBillingZip\n customerName\n discount\n discountValue\n duration\n endDate\n expiresAt\n html\n formattedLines {\n amount\n amountsByPeriod {\n quantity\n id\n name\n startDate\n endDate\n amount\n amountsByTier {\n id\n tier {\n starts\n ends\n price\n }\n quantity\n amount\n }\n prorationRate\n }\n billingPeriodEnd\n billingPeriodStart\n chargeType\n discount\n frequency\n isRamp\n periods\n planName\n position\n price\n priceDecimals\n priceListChargeId\n priceListChargeName\n priceListId\n priceListName\n priceTiers {\n price\n starts\n }\n pricingModel\n productName\n prorationRate\n quantity\n showProductNameOnLineItem\n taxCode\n trialEndDate\n trialStartDate\n unitOfMeasure\n vatCode\n }\n netPaymentDays\n notes\n number\n poNumberRequired\n salesContactEmail\n sharedAt\n startDate\n state\n subtotal\n taxAmount\n taxNumberLabel\n taxNumberRequired\n vendorName\n }\n }"; };
|
|
19298
|
+
var MUTATION$8 = function (id) { return "\n query formattedQuote ($id: ID) {\n formattedQuote (id: $id) {\n quote {\n documentTemplateId\n documents { id filename size date url }\n firstInvoice {\n id\n state\n }\n payableId\n id\n payToAccept\n currentPaymentHold {\n createdAt\n expiresAt\n id\n updatedAt\n paymentMethod {\n accountId\n createdAt\n expirationDate\n failureCode\n id\n isDefault\n lastSuccess\n paymentType\n pluginId\n state\n updatedAt\n metadata {\n description\n expiration\n icon\n identifier\n issuer\n kind\n }\n }\n }\n }\n payableId\n acceptedAt\n acceptedByName\n amount\n amountDue\n amountsByPeriod {\n id\n name\n amount\n }\n billingCity\n billingCountry\n billingState\n billingStreet\n billingZip\n contactName\n currency\n customerBillingCity\n customerBillingCountry\n customerBillingState\n customerBillingStreet\n customerBillingZip\n customerName\n discount\n discountValue\n duration\n endDate\n expiresAt\n html\n formattedLines {\n amount\n amountsByPeriod {\n quantity\n id\n name\n startDate\n endDate\n amount\n amountsByTier {\n id\n tier {\n starts\n ends\n price\n }\n quantity\n amount\n }\n prorationRate\n }\n billingPeriodEnd\n billingPeriodStart\n chargeType\n discount\n frequency\n isRamp\n periods\n planName\n position\n price\n priceDecimals\n priceListChargeId\n priceListChargeName\n priceListId\n priceListName\n priceTiers {\n price\n starts\n }\n pricingModel\n productName\n prorationRate\n quantity\n showProductNameOnLineItem\n taxCode\n trialEndDate\n trialStartDate\n unitOfMeasure\n vatCode\n }\n netPaymentDays\n notes\n number\n poNumberRequired\n salesContactEmail\n sharedAt\n startDate\n state\n subtotal\n taxAmount\n taxNumberLabel\n taxNumberRequired\n vendorName\n }\n }"; };
|
|
19281
19299
|
var getFormattedQuote = function (_a) {
|
|
19282
|
-
var token = _a.token, apiHost = _a.apiHost;
|
|
19300
|
+
var id = _a.id, token = _a.token, apiHost = _a.apiHost;
|
|
19283
19301
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
19284
19302
|
var response;
|
|
19285
19303
|
return __generator(this, function (_b) {
|
|
@@ -19288,11 +19306,12 @@ var getFormattedQuote = function (_a) {
|
|
|
19288
19306
|
query: MUTATION$8(),
|
|
19289
19307
|
token: token,
|
|
19290
19308
|
apiHost: apiHost,
|
|
19309
|
+
vars: { id: id },
|
|
19291
19310
|
})];
|
|
19292
19311
|
case 1:
|
|
19293
19312
|
response = _b.sent();
|
|
19294
|
-
if (response
|
|
19295
|
-
throw new Error(response
|
|
19313
|
+
if (response === null || response === void 0 ? void 0 : response.formattedQuote.error) {
|
|
19314
|
+
throw new Error(response === null || response === void 0 ? void 0 : response.formattedQuote.error);
|
|
19296
19315
|
}
|
|
19297
19316
|
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.formattedQuote];
|
|
19298
19317
|
}
|
|
@@ -19587,9 +19606,10 @@ var PaymentHoldModal = function (_a) {
|
|
|
19587
19606
|
var visible = _a.visible, setVisible = _a.setVisible, quote = _a.quote;
|
|
19588
19607
|
var queryClient = reactQuery.useQueryClient();
|
|
19589
19608
|
var token = useToken();
|
|
19609
|
+
var entityId = useCurrentUserData().entityId;
|
|
19590
19610
|
return (jsxRuntime.jsxs(StyledModal$1, __assign({ centered: true, onCancel: function () {
|
|
19591
19611
|
setVisible(false);
|
|
19592
|
-
}, footer: null, open: visible, width: 600 }, { children: [jsxRuntime.jsx(Title$2, __assign({ className: "mt-4 pb-4 mx-4", level: 5 }, { children: "Pay to accept" })), jsxRuntime.jsx("div", __assign({ className: "mb-4" }, { children: jsxRuntime.jsx(PaymentForm, { quote: {
|
|
19612
|
+
}, footer: null, open: visible, width: 600 }, { children: [jsxRuntime.jsx(Title$2, __assign({ className: "mt-4 pb-4 mx-4", level: 5 }, { children: "Pay to accept" })), jsxRuntime.jsx("div", __assign({ className: "mb-4" }, { children: jsxRuntime.jsx(PaymentForm, { entityId: entityId, quote: {
|
|
19593
19613
|
amount: quote.amount,
|
|
19594
19614
|
currencyId: quote.currency,
|
|
19595
19615
|
id: quote.quote.id,
|
|
@@ -19652,10 +19672,18 @@ function ActualQuote() {
|
|
|
19652
19672
|
var _f = reactQuery.useQuery({
|
|
19653
19673
|
queryKey: common.QueryKeyFactory.default.createQuoteKey({ id: id, token: token }),
|
|
19654
19674
|
queryFn: function () { return __awaiter(_this, void 0, void 0, function () {
|
|
19675
|
+
var error_1;
|
|
19655
19676
|
return __generator(this, function (_a) {
|
|
19656
19677
|
switch (_a.label) {
|
|
19657
|
-
case 0:
|
|
19678
|
+
case 0:
|
|
19679
|
+
_a.trys.push([0, 2, , 3]);
|
|
19680
|
+
return [4 /*yield*/, getFormattedQuote({ token: token, apiHost: apiHost, id: id })];
|
|
19658
19681
|
case 1: return [2 /*return*/, _a.sent()];
|
|
19682
|
+
case 2:
|
|
19683
|
+
error_1 = _a.sent();
|
|
19684
|
+
showErrorNotification(error_1.message);
|
|
19685
|
+
return [3 /*break*/, 3];
|
|
19686
|
+
case 3: return [2 /*return*/];
|
|
19659
19687
|
}
|
|
19660
19688
|
});
|
|
19661
19689
|
}); },
|
|
@@ -19670,6 +19698,7 @@ function ActualQuote() {
|
|
|
19670
19698
|
}), acceptBoxVisible = _g.acceptBoxVisible, isAccepting = _g.isAccepting, sendAccept = _g.sendAccept, setAcceptBoxVisible = _g.setAcceptBoxVisible, setIsAccepting = _g.setIsAccepting, startAcceptance = _g.startAcceptance, pandadocPollingModalVisible = _g.pandadocPollingModalVisible, setPandadocPollingModalVisible = _g.setPandadocPollingModalVisible, isSendAcceptPending = _g.isSendAcceptPending;
|
|
19671
19699
|
useSigningComplete({ data: formattedQuote, token: token });
|
|
19672
19700
|
var isMobile = common.useIsMobile();
|
|
19701
|
+
var showErrorNotification = common.useErrorNotification();
|
|
19673
19702
|
react.useEffect(function () {
|
|
19674
19703
|
if (formattedQuote) {
|
|
19675
19704
|
onQuoteLoaded === null || onQuoteLoaded === void 0 ? void 0 : onQuoteLoaded(formattedQuote);
|
|
@@ -19989,7 +20018,7 @@ function Transactions(_a) {
|
|
|
19989
20018
|
function TransactionsDisplay(_a) {
|
|
19990
20019
|
var _b, _c;
|
|
19991
20020
|
var transactions = _a.transactions, onSearchValueChanged = _a.onSearchValueChanged, search = _a.search;
|
|
19992
|
-
var _d = react.useContext(TransactionsListContext), showSearchBar = _d.showSearchBar, showTitle = _d.showTitle, title = _d.title, transactionComponent = _d.transactionComponent, useModal = _d.useModal, suppressTransactionDisplay = _d.suppressTransactionDisplay, className = _d.className, shadow = _d.shadow, searchBarClassName = _d.searchBarClassName, style = _d.style, onTransactionClick = _d.onTransactionClick, onTransactionDisplayClose = _d.onTransactionDisplayClose, kindsToShow = _d.kindsToShow, filterTransactions = _d.filterTransactions, sortTransactions = _d.sortTransactions;
|
|
20021
|
+
var _d = react.useContext(TransactionsListContext), showSearchBar = _d.showSearchBar, showTitle = _d.showTitle, title = _d.title, transactionComponent = _d.transactionComponent, useModal = _d.useModal, suppressTransactionDisplay = _d.suppressTransactionDisplay, className = _d.className, shadow = _d.shadow, searchBarClassName = _d.searchBarClassName, style = _d.style, onTransactionClick = _d.onTransactionClick, onTransactionDisplayClose = _d.onTransactionDisplayClose, kindsToShow = _d.kindsToShow, filterTransactions = _d.filterTransactions, sortTransactions = _d.sortTransactions; _d.transactionDateType;
|
|
19993
20022
|
var columns = react.useContext(TransactionsListContext).columns;
|
|
19994
20023
|
var darkMode = react.useContext(BunnyContext).darkMode;
|
|
19995
20024
|
var secondaryColor = react.useContext(BrandContext).secondaryColor;
|
|
@@ -20283,7 +20312,7 @@ var getPriceList = function (_a) {
|
|
|
20283
20312
|
});
|
|
20284
20313
|
};
|
|
20285
20314
|
|
|
20286
|
-
var QUOTE_QUERY = function (id) { return "\n query quote {\n quote ".concat(id ? "(id: ".concat(id, ")") : '', " {\n accountId\n amount\n amountDue\n smallUnitAmountDue\n currencyId\n formattedQuote {\n html\n }\n id\n payableId\n periodAmount\n subtotal\n taxAmount\n startDate\n amountsByPeriod {\n amount\n startDate\n }\n
|
|
20315
|
+
var QUOTE_QUERY = function (id) { return "\n query quote {\n quote ".concat(id ? "(id: ".concat(id, ")") : '', " {\n accountId\n amount\n amountDue\n smallUnitAmountDue\n currencyId\n formattedQuote {\n html\n }\n id\n payableId\n periodAmount\n subtotal\n taxAmount\n startDate\n amountsByPeriod {\n amount\n startDate\n }\n quoteChanges {\n currencyId\n id\n kind\n charges {\n subtotal\n amountsByPeriod {\n amount\n startDate\n }\n amount\n billingPeriod\n currencyId\n feature {\n unitName\n }\n id\n name\n priceListCharge {\n id\n }\n priceList {\n id\n }\n coupon {\n couponCode\n }\n quantity\n kind\n }\n priceList {\n id\n plan {\n name\n }\n product {\n name\n }\n }\n\n }\n }\n }"); };
|
|
20287
20316
|
var getQuote = function (_a) {
|
|
20288
20317
|
var id = _a.id, token = _a.token, apiHost = _a.apiHost;
|
|
20289
20318
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -20438,44 +20467,6 @@ var useUpdateCoupons = function (_a) {
|
|
|
20438
20467
|
};
|
|
20439
20468
|
};
|
|
20440
20469
|
|
|
20441
|
-
var CURRENT_USER_DATA_QUERY = "{\n company {\n name\n }\n currentUser {\n account {\n billingCountry\n currencyId\n }\n authObjectName\n payload {\n returnUrl\n }\n privacyUrl\n termsUrl\n entityId\n }\n }";
|
|
20442
|
-
var getCurrentUserData = function (_a) {
|
|
20443
|
-
var token = _a.token, apiHost = _a.apiHost;
|
|
20444
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
20445
|
-
var response;
|
|
20446
|
-
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
20447
|
-
return __generator(this, function (_k) {
|
|
20448
|
-
switch (_k.label) {
|
|
20449
|
-
case 0: return [4 /*yield*/, common.gqlRequest({
|
|
20450
|
-
query: CURRENT_USER_DATA_QUERY,
|
|
20451
|
-
token: token,
|
|
20452
|
-
apiHost: apiHost,
|
|
20453
|
-
})];
|
|
20454
|
-
case 1:
|
|
20455
|
-
response = _k.sent();
|
|
20456
|
-
return [2 /*return*/, {
|
|
20457
|
-
authObjectName: (_b = response === null || response === void 0 ? void 0 : response.currentUser) === null || _b === void 0 ? void 0 : _b.authObjectName,
|
|
20458
|
-
account: (_c = response === null || response === void 0 ? void 0 : response.currentUser) === null || _c === void 0 ? void 0 : _c.account,
|
|
20459
|
-
companyName: (_d = response === null || response === void 0 ? void 0 : response.company) === null || _d === void 0 ? void 0 : _d.name,
|
|
20460
|
-
returnUrl: (_f = (_e = response === null || response === void 0 ? void 0 : response.currentUser) === null || _e === void 0 ? void 0 : _e.payload) === null || _f === void 0 ? void 0 : _f.returnUrl,
|
|
20461
|
-
privacyUrl: (_g = response === null || response === void 0 ? void 0 : response.currentUser) === null || _g === void 0 ? void 0 : _g.privacyUrl,
|
|
20462
|
-
termsUrl: (_h = response === null || response === void 0 ? void 0 : response.currentUser) === null || _h === void 0 ? void 0 : _h.termsUrl,
|
|
20463
|
-
entityId: (_j = response === null || response === void 0 ? void 0 : response.currentUser) === null || _j === void 0 ? void 0 : _j.entityId,
|
|
20464
|
-
}];
|
|
20465
|
-
}
|
|
20466
|
-
});
|
|
20467
|
-
});
|
|
20468
|
-
};
|
|
20469
|
-
|
|
20470
|
-
var useCurrentUserData = function (token) {
|
|
20471
|
-
var apiHost = react.useContext(BunnyContext).apiHost;
|
|
20472
|
-
var currentUserData = reactQuery.useQuery({
|
|
20473
|
-
queryKey: common.QueryKeyFactory.default.currentUserKey(token),
|
|
20474
|
-
queryFn: function () { return getCurrentUserData({ token: token, apiHost: apiHost }); },
|
|
20475
|
-
}).data;
|
|
20476
|
-
return currentUserData || {};
|
|
20477
|
-
};
|
|
20478
|
-
|
|
20479
20470
|
var BunnyFooterIcon = function (_a) {
|
|
20480
20471
|
var color = _a.color;
|
|
20481
20472
|
return (jsxRuntime.jsxs("svg", __assign({ width: "45", height: "15", viewBox: "0 0 39 13", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [jsxRuntime.jsxs("g", __assign({ clipPath: "url(#clip0_6_851)" }, { children: [jsxRuntime.jsx("path", { className: "bunny-icon-path", d: "M14.5898 7.19708C14.5898 9.35053 13.0926 10.325 11.2495 10.325C9.39955 10.325 7.90234 9.35001 7.90234 7.18967V3.26221H10.1125V7.00052C10.1125 7.87719 10.5855 8.27725 11.2495 8.27725C11.9061 8.27725 12.3865 7.87719 12.3865 7.00052V3.26221H14.5898V7.19708Z", fill: color }), jsxRuntime.jsx("path", { className: "bunny-icon-path", d: "M31.8943 12.9625H29.4793L31.8523 8.62816L28.9355 3.26221H31.4708L33.0457 6.35524L34.5924 3.26221H37.0075L31.8943 12.9625Z", fill: color }), jsxRuntime.jsx("path", { className: "bunny-icon-path", d: "M15.1602 5.96827C15.1602 3.8148 16.6574 2.84033 18.5005 2.84033C20.3504 2.84033 21.8476 3.81533 21.8476 5.97568V10.1473H19.6374V6.16483C19.6374 5.28815 19.1645 4.8881 18.5005 4.8881C17.8439 4.8881 17.3634 5.28815 17.3634 6.16483V10.1473H15.1602V5.96827Z", fill: color }), jsxRuntime.jsx("path", { className: "bunny-icon-path", d: "M22.4316 5.96827C22.4316 3.8148 23.9289 2.84033 25.7719 2.84033C27.6219 2.84033 29.1191 3.81533 29.1191 5.97568V10.1473H26.9089V6.16483C26.9089 5.28815 26.4359 4.8881 25.7719 4.8881C25.1154 4.8881 24.6349 5.28815 24.6349 6.16483V10.1473H22.4316V5.96827Z", fill: color }), jsxRuntime.jsx("path", { className: "bunny-icon-path", d: "M7.40511 6.68957C7.40511 8.7236 6.02815 10.3227 4.17816 10.3227C3.23907 10.3227 2.61071 9.94378 2.19358 9.40371V10.1404H0.0605469V0.0405273H2.26381V3.91939C2.68041 3.42158 3.28802 3.07069 4.17763 3.07069C6.02759 3.07069 7.40511 4.66981 7.40511 6.68957ZM2.17229 6.69642C2.17229 7.60802 2.77937 8.2744 3.64823 8.2744C4.53783 8.2744 5.13107 7.59372 5.13107 6.69642C5.13107 5.79912 4.53783 5.11844 3.64823 5.11844C2.77937 5.11844 2.17229 5.78482 2.17229 6.69642Z", fill: color }), jsxRuntime.jsx("path", { className: "bunny-icon-path", d: "M38.966 8.94801C38.966 9.76181 38.2668 10.4631 37.4618 10.4631C36.6499 10.4631 35.9434 9.76181 35.9434 8.94801C35.9434 8.14846 36.6494 7.46094 37.4618 7.46094C38.2668 7.46094 38.966 8.14846 38.966 8.94801Z", fill: color })] })), jsxRuntime.jsx("defs", { children: jsxRuntime.jsx("clipPath", __assign({ id: "clip0_6_851" }, { children: jsxRuntime.jsx("rect", { width: "39", height: "13", fill: "white" }) })) })] })));
|
|
@@ -20497,22 +20488,6 @@ var StyedLink = styled__default["default"].a(templateObject_1$5 || (templateObje
|
|
|
20497
20488
|
var StyledBunnyLink = styled__default["default"](StyedLink)(templateObject_2$1 || (templateObject_2$1 = __makeTemplateObject(["\n &:hover {\n color: ", " !important;\n }\n"], ["\n &:hover {\n color: ", " !important;\n }\n"])), common.PRIMARY_COLOR);
|
|
20498
20489
|
var templateObject_1$5, templateObject_2$1;
|
|
20499
20490
|
|
|
20500
|
-
function shouldShowCouponEditor(quote, activeCouponsExist, upgradingSubscription) {
|
|
20501
|
-
var _a;
|
|
20502
|
-
var upgradingFromTrial = ((_a = upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.TRIAL;
|
|
20503
|
-
function upgradingFromFree() {
|
|
20504
|
-
var totalPrice = upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.charges.reduce(function (acc, charge) { return acc + Number((charge === null || charge === void 0 ? void 0 : charge.discountedPrice) || 0); }, 0);
|
|
20505
|
-
return totalPrice === 0;
|
|
20506
|
-
}
|
|
20507
|
-
if (quote.kind === common.QuoteChangeKind.SUBSCRIBE) {
|
|
20508
|
-
return activeCouponsExist;
|
|
20509
|
-
}
|
|
20510
|
-
else if (quote.kind === common.QuoteChangeKind.ADJUSTMENT) {
|
|
20511
|
-
return activeCouponsExist && (upgradingFromTrial || upgradingFromFree());
|
|
20512
|
-
}
|
|
20513
|
-
return false;
|
|
20514
|
-
}
|
|
20515
|
-
|
|
20516
20491
|
function CouponEditor(_a) {
|
|
20517
20492
|
var className = _a.className, onAddCoupon = _a.onAddCoupon, isAddingCoupon = _a.isAddingCoupon, couponCode = _a.couponCode, setCouponCode = _a.setCouponCode;
|
|
20518
20493
|
function handleAddCoupon() {
|
|
@@ -20526,12 +20501,9 @@ function CouponEditor(_a) {
|
|
|
20526
20501
|
return (jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-2 ".concat(className) }, { children: jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-row bunny-gap-2" }, { children: [jsxRuntime.jsx(antd.Input, { value: couponCode, onChange: function (e) { return setCouponCode(e.target.value); }, placeholder: "Coupon code", disabled: isAddingCoupon, size: "small" }), jsxRuntime.jsx(antd.Button, __assign({ loading: isAddingCoupon, type: "primary", onClick: handleAddCoupon, disabled: couponCode.length === 0 }, { children: "Apply" }))] })) })));
|
|
20527
20502
|
}
|
|
20528
20503
|
|
|
20529
|
-
var SubscriptionsContext = react.createContext({});
|
|
20530
|
-
|
|
20531
20504
|
var Text$f = antd.Typography.Text;
|
|
20532
20505
|
function CheckoutSummary(_a) {
|
|
20533
20506
|
var quote = _a.quote, className = _a.className, onAddCoupon = _a.onAddCoupon, onRemoveCoupon = _a.onRemoveCoupon, isRemovingCoupon = _a.isRemovingCoupon, priceListData = _a.priceListData, isAddingCoupon = _a.isAddingCoupon, couponCode = _a.couponCode, setCouponCode = _a.setCouponCode, activeCouponsExist = _a.activeCouponsExist;
|
|
20534
|
-
var upgradingSubscription = react.useContext(SubscriptionsContext).upgradingSubscription;
|
|
20535
20507
|
return (jsxRuntime.jsxs("div", __assign({ className: "".concat(className, " bunny-space-y-4") }, { children: [jsxRuntime.jsxs(Text$f, { children: [jsxRuntime.jsxs("div", __assign({ className: "bunny-text-lg bunny-font-medium bunny-mb-4" }, { children: ["Checkout summary - ", priceListData === null || priceListData === void 0 ? void 0 : priceListData.product.name, " ", priceListData === null || priceListData === void 0 ? void 0 : priceListData.name] })), jsxRuntime.jsx("div", __assign({ className: "bunny-space-y-4" }, { children: quote === null || quote === void 0 ? void 0 : quote.quoteChanges.map(function (quoteChange) {
|
|
20536
20508
|
return quoteChange === null || quoteChange === void 0 ? void 0 : quoteChange.charges.map(function (charge) {
|
|
20537
20509
|
var _a;
|
|
@@ -20547,8 +20519,7 @@ function CheckoutSummary(_a) {
|
|
|
20547
20519
|
onRemoveCoupon((_b = charge.coupon) === null || _b === void 0 ? void 0 : _b.couponCode);
|
|
20548
20520
|
}, className: "bunny-text-orange-500 hover:bunny-text-orange-400 bunny-cursor-pointer" }, { children: "Remove" }))) : (jsxRuntime.jsx("div", { children: charge.quantity })) })), jsxRuntime.jsx("div", __assign({ className: "bunny-col-span-1 bunny-text-right" }, { children: common.formatCurrency(multiplier * (charge.subtotal || 0), charge.currencyId) }))] }), charge.id));
|
|
20549
20521
|
});
|
|
20550
|
-
}) })), jsxRuntime.jsx(CheckoutSummaryDivider, {}), jsxRuntime.jsxs("div", __assign({ className: "bunny-space-y-4" }, { children: [jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-justify-between" }, { children: [jsxRuntime.jsx("div", { children: "Subtotal" }), jsxRuntime.jsx("div", { children: common.formatCurrency(quote.subtotal, quote.currencyId) })] })), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-justify-between" }, { children: [jsxRuntime.jsx("div", { children: "Taxes" }), jsxRuntime.jsx("div", { children: common.formatCurrency(quote.taxAmount, quote.currencyId) })] }))] })), jsxRuntime.jsx(CheckoutSummaryDivider, {}), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-justify-between" }, { children: [jsxRuntime.jsx("div", { children: "Total" }), jsxRuntime.jsx("div", { children: common.formatCurrency(quote.amountDue, quote.currencyId) })] }))] }),
|
|
20551
|
-
shouldShowCouponEditor(quote, activeCouponsExist, upgradingSubscription) && (jsxRuntime.jsx(CouponEditor, { className: "bunny-w-full", quote: quote, onAddCoupon: onAddCoupon, isAddingCoupon: isAddingCoupon, couponCode: couponCode, setCouponCode: setCouponCode }))] })));
|
|
20522
|
+
}) })), jsxRuntime.jsx(CheckoutSummaryDivider, {}), jsxRuntime.jsxs("div", __assign({ className: "bunny-space-y-4" }, { children: [jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-justify-between" }, { children: [jsxRuntime.jsx("div", { children: "Subtotal" }), jsxRuntime.jsx("div", { children: common.formatCurrency(quote.subtotal, quote.currencyId) })] })), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-justify-between" }, { children: [jsxRuntime.jsx("div", { children: "Taxes" }), jsxRuntime.jsx("div", { children: common.formatCurrency(quote.taxAmount, quote.currencyId) })] }))] })), jsxRuntime.jsx(CheckoutSummaryDivider, {}), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-justify-between" }, { children: [jsxRuntime.jsx("div", { children: "Total" }), jsxRuntime.jsx("div", { children: common.formatCurrency(quote.amountDue, quote.currencyId) })] }))] }), activeCouponsExist && (jsxRuntime.jsx(CouponEditor, { className: "bunny-w-full", quote: quote, onAddCoupon: onAddCoupon, isAddingCoupon: isAddingCoupon, couponCode: couponCode, setCouponCode: setCouponCode }))] })));
|
|
20552
20523
|
}
|
|
20553
20524
|
var CheckoutSummaryDivider = function () {
|
|
20554
20525
|
return (jsxRuntime.jsx("div", __assign({ className: "bunny-my-2" }, { children: jsxRuntime.jsx(antd.Divider, { className: "m-0" }) })));
|
|
@@ -20557,7 +20528,8 @@ var CheckoutSummaryDivider = function () {
|
|
|
20557
20528
|
var Title$1 = antd.Typography.Title;
|
|
20558
20529
|
function PaymentForms(_a) {
|
|
20559
20530
|
var quote = _a.quote, handlePaymentSuccess = _a.handlePaymentSuccess, handlePaymentFail = _a.handlePaymentFail, handleSubmit = _a.handleSubmit, proceedingToPayment = _a.proceedingToPayment, accountId = _a.accountId, overrideToken = _a.overrideToken, customCheckoutFunction = _a.customCheckoutFunction, defaultValues = _a.defaultValues;
|
|
20560
|
-
|
|
20531
|
+
var entityId = useCurrentUserData().entityId;
|
|
20532
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: quote ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: overrideToken ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Title$1, __assign({ className: "bunny-px-4 bunny-m-0", level: 2 }, { children: "Payment" })), jsxRuntime.jsx("div", __assign({ className: "bunny-overflow-y-auto bunny-max-h-[calc(100vh-10rem)]" }, { children: jsxRuntime.jsx(PaymentForm, { entityId: entityId, onFail: handlePaymentFail, onPaymentSuccess: handlePaymentSuccess, accountId: accountId, quote: quote, overrideToken: overrideToken, customCheckoutFunction: customCheckoutFunction }) }))] })) : null })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Title$1, __assign({ className: "bunny-px-4 bunny-m-0", level: 2 }, { children: "Signup" })), jsxRuntime.jsx(InitialSignupForm, { className: "bunny-px-4", onSubmit: handleSubmit, submitting: proceedingToPayment, defaultValues: defaultValues })] })) }));
|
|
20561
20533
|
}
|
|
20562
20534
|
function InitialSignupForm(_a) {
|
|
20563
20535
|
var className = _a.className, onSubmit = _a.onSubmit, submitting = _a.submitting, defaultValues = _a.defaultValues;
|
|
@@ -20868,22 +20840,8 @@ var useQuoteDelete = function () {
|
|
|
20868
20840
|
});
|
|
20869
20841
|
}); };
|
|
20870
20842
|
};
|
|
20871
|
-
var useQuoteSubscriptionActivate = function () {
|
|
20872
|
-
var graphQLRequest = useGraphQLRequest();
|
|
20873
|
-
return function (subscriptionId, apiHost, token) { return __awaiter(void 0, void 0, void 0, function () {
|
|
20874
|
-
var response;
|
|
20875
|
-
return __generator(this, function (_a) {
|
|
20876
|
-
switch (_a.label) {
|
|
20877
|
-
case 0: return [4 /*yield*/, graphQLRequest("mutation QuoteSubscriptionActivate($subscriptionId: ID!) {\n quoteSubscriptionActivate(subscriptionId: $subscriptionId) {\n quote {\n id\n }\n }\n }", apiHost, token, { subscriptionId: subscriptionId })];
|
|
20878
|
-
case 1:
|
|
20879
|
-
response = _a.sent();
|
|
20880
|
-
return [2 /*return*/, response];
|
|
20881
|
-
}
|
|
20882
|
-
});
|
|
20883
|
-
}); };
|
|
20884
|
-
};
|
|
20885
20843
|
|
|
20886
|
-
var SUBSCRIPTIONS_QUERY = "\nquery subscriptions {\n subscriptions {\n nodes {\n cancellationDate\n currencyId\n endDate\n evergreen\n id\n period\n plan { id name selfServiceBuy selfServiceCancel selfServiceRenew }\n priceList { id periodMonths }\n product { id name showProductNameOnLineItem }\n startDate\n state\n trialEndDate\n trialPeriod\n trialStartDate\n daysLeftInTrial\n
|
|
20844
|
+
var SUBSCRIPTIONS_QUERY = "\nquery subscriptions {\n subscriptions {\n nodes {\n cancellationDate\n currencyId\n endDate\n evergreen\n id\n period\n plan { id name selfServiceBuy selfServiceCancel selfServiceRenew }\n priceList { id periodMonths }\n product { id name showProductNameOnLineItem }\n startDate\n state\n trialEndDate\n trialPeriod\n trialStartDate\n daysLeftInTrial\n charges {\n priceListCharge {\n priceListChargeTiers {\n price\n starts\n }\n featureAddon\n id\n }\n amount\n billingPeriod\n chargeType\n discount\n discountedPrice\n endDate\n expired\n feature { name }\n id\n isAmendment\n isRamp\n kind\n name\n periodPrice\n price\n priceDecimals\n priceListChargeId\n priceTiers { starts price }\n pricingModel\n quantity\n selfServiceQuantity\n startDate\n trial\n }\n }\n }\n }";
|
|
20887
20845
|
var getSubscriptions = function (_a) {
|
|
20888
20846
|
var apiHost = _a.apiHost, isInPreviewMode = _a.isInPreviewMode, token = _a.token;
|
|
20889
20847
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -20969,7 +20927,7 @@ var accountUpdate = function (_a) {
|
|
|
20969
20927
|
});
|
|
20970
20928
|
};
|
|
20971
20929
|
|
|
20972
|
-
var COUNTRIES_REQUIRING_STATE = [
|
|
20930
|
+
var COUNTRIES_REQUIRING_STATE = ["US", "CA"];
|
|
20973
20931
|
var TaxationForm = function (_a) {
|
|
20974
20932
|
var account = _a.account, quote = _a.quote;
|
|
20975
20933
|
// Hooks
|
|
@@ -20997,18 +20955,19 @@ var TaxationForm = function (_a) {
|
|
|
20997
20955
|
}); },
|
|
20998
20956
|
onSuccess: function () {
|
|
20999
20957
|
queryClient.invalidateQueries({
|
|
21000
|
-
queryKey: [
|
|
20958
|
+
queryKey: ["getTaxationRequiredAccountFields", token],
|
|
21001
20959
|
});
|
|
21002
20960
|
},
|
|
21003
20961
|
}), updateAccount = _b.mutate, isUpdatingAccount = _b.isPending;
|
|
21004
|
-
return (jsxRuntime.jsxs(antd.Form, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4", form: form, initialValues: account, layout: "vertical", onFinish: updateAccount }, { children: [jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Billing street", name: "billingStreet" }, { children: jsxRuntime.jsx(antd.Input, { placeholder: "Street" }) })), jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Billing city", name: "billingCity" }, { children: jsxRuntime.jsx(antd.Input, { placeholder: "City" }) })), jsxRuntime.jsx(FormBillingState, {}), jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Billing country", name: "billingCountry", rules: [{ required: true }] }, { children: jsxRuntime.jsx(antd.Select, { options: common.Lists.COUNTRY_LIST, placeholder: "Select a country", showSearch: true, filterOption: function (input, option) {
|
|
20962
|
+
return (jsxRuntime.jsxs(antd.Form, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4", form: form, initialValues: account, layout: "vertical", onFinish: updateAccount }, { children: [jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Billing street", name: "billingStreet" }, { children: jsxRuntime.jsx(antd.Input, { placeholder: "Street" }) })), jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Billing city", name: "billingCity" }, { children: jsxRuntime.jsx(antd.Input, { placeholder: "City" }) })), jsxRuntime.jsx(FormBillingState, { form: form }), jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Billing country", name: "billingCountry", rules: [{ required: true }] }, { children: jsxRuntime.jsx(antd.Select, { options: common.Lists.COUNTRY_LIST, placeholder: "Select a country", showSearch: true, filterOption: function (input, option) {
|
|
21005
20963
|
var _a, _b;
|
|
21006
|
-
return ((_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a :
|
|
21007
|
-
((_b = option === null || option === void 0 ? void 0 : option.value) !== null && _b !== void 0 ? _b :
|
|
20964
|
+
return ((_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a : "").toLowerCase().includes(input.toLowerCase()) ||
|
|
20965
|
+
((_b = option === null || option === void 0 ? void 0 : option.value) !== null && _b !== void 0 ? _b : "").toLowerCase().includes(input.toLowerCase());
|
|
21008
20966
|
} }) })), jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Billing zip", name: "billingZip" }, { children: jsxRuntime.jsx(antd.Input, { placeholder: "Zip" }) })), jsxRuntime.jsx(antd.Form.Item, { children: jsxRuntime.jsx(antd.Button, __assign({ className: "bunny-w-full", disabled: isUpdatingAccount, htmlType: "submit", type: "primary" }, { children: "Submit" })) })] })));
|
|
21009
20967
|
};
|
|
21010
|
-
var FormBillingState = function () {
|
|
21011
|
-
|
|
20968
|
+
var FormBillingState = function (_a) {
|
|
20969
|
+
_a.form;
|
|
20970
|
+
var billingCountry = antd.Form.useWatch("billingCountry");
|
|
21012
20971
|
var billingStateRequired = COUNTRIES_REQUIRING_STATE.includes(billingCountry);
|
|
21013
20972
|
return (jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Billing state", name: "billingState", rules: [{ required: billingStateRequired }] }, { children: jsxRuntime.jsx(antd.Input, { placeholder: "State" }) })));
|
|
21014
20973
|
};
|
|
@@ -21018,11 +20977,11 @@ var QuoteCheckout = function (_a) {
|
|
|
21018
20977
|
var _b, _c;
|
|
21019
20978
|
var account = _a.account, onSuccess = _a.onSuccess, onFail = _a.onFail, quote = _a.quote, taxationRequiredAccountFields = _a.taxationRequiredAccountFields, onRecalculateTaxes = _a.onRecalculateTaxes;
|
|
21020
20979
|
var apiHost = react.useContext(BunnyContext).apiHost;
|
|
21021
|
-
var upgradingSubscription = react.useContext(SubscriptionsContext).upgradingSubscription;
|
|
21022
20980
|
var token = useToken();
|
|
21023
20981
|
var isMobile = common.useIsMobile();
|
|
21024
20982
|
var _d = react.useState(false), isSaving = _d[0], setIsSaving = _d[1];
|
|
21025
20983
|
var paymentRequired = getQuoteAmountDue(quote) > 0;
|
|
20984
|
+
var entityId = useCurrentUserData().entityId;
|
|
21026
20985
|
var queryClient = reactQuery.useQueryClient();
|
|
21027
20986
|
var _e = react.useState(''), couponCode = _e[0], setCouponCode = _e[1];
|
|
21028
20987
|
var _f = useUpdateCoupons({
|
|
@@ -21083,8 +21042,7 @@ var QuoteCheckout = function (_a) {
|
|
|
21083
21042
|
}
|
|
21084
21043
|
if (taxationRequiredAccountFields)
|
|
21085
21044
|
return (jsxRuntime.jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsxRuntime.jsx(TaxationForm, { account: account, quote: quote }) })));
|
|
21086
|
-
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: paymentRequired ? (jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-2 bunny-w-full" }, { children: [jsxRuntime.jsx(PaymentForm, { onFail: onFail, onPaymentSuccess: onSuccess, quote: quote }), (couponsOnQuote === null || couponsOnQuote === void 0 ? void 0 : couponsOnQuote.length) === 0 ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children:
|
|
21087
|
-
shouldShowCouponEditor(quote, activeCouponsExist, upgradingSubscription) && (jsxRuntime.jsx(CouponEditor, { className: "bunny-px-4 bunny-pt-1", quote: quote, onAddCoupon: addCoupon, isAddingCoupon: isAddingCoupon, couponCode: couponCode, setCouponCode: setCouponCode })) })) : (jsxRuntime.jsx(antd.Button, __assign({ type: "link", loading: isRemovingCoupon, onClick: function () {
|
|
21045
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: paymentRequired ? (jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-2 bunny-w-full" }, { children: [jsxRuntime.jsx(PaymentForm, { entityId: entityId, onFail: onFail, onPaymentSuccess: onSuccess, quote: quote }), (couponsOnQuote === null || couponsOnQuote === void 0 ? void 0 : couponsOnQuote.length) === 0 ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: activeCouponsExist && (jsxRuntime.jsx(CouponEditor, { className: "bunny-px-4 bunny-pt-1", quote: quote, onAddCoupon: addCoupon, isAddingCoupon: isAddingCoupon, couponCode: couponCode, setCouponCode: setCouponCode })) })) : (jsxRuntime.jsx(antd.Button, __assign({ type: "link", loading: isRemovingCoupon, onClick: function () {
|
|
21088
21046
|
couponsOnQuote === null || couponsOnQuote === void 0 ? void 0 : couponsOnQuote.forEach(function (couponCharge) {
|
|
21089
21047
|
var _a;
|
|
21090
21048
|
var couponCode = (_a = couponCharge === null || couponCharge === void 0 ? void 0 : couponCharge.coupon) === null || _a === void 0 ? void 0 : _a.couponCode;
|
|
@@ -21233,6 +21191,8 @@ var PageTitle = function (_a) {
|
|
|
21233
21191
|
} })), title] })));
|
|
21234
21192
|
};
|
|
21235
21193
|
|
|
21194
|
+
var SubscriptionsContext = react.createContext({});
|
|
21195
|
+
|
|
21236
21196
|
var QUOTE_CHARGE_UPDATE = "\n mutation QuoteChargeUpdate (\n $discount: Float,\n $endDate: ISO8601Date,\n $name: String,\n $price: Float,\n $quantity: Int,\n $quoteChargeId: ID!\n $startDate: ISO8601Date\n $subtotal: Float,\n ) {\n quoteChargeUpdate(\n discount: $discount\n endDate: $endDate\n name: $name\n price: $price\n quantity: $quantity\n quoteChargeId: $quoteChargeId\n startDate: $startDate\n subtotal: $subtotal\n ) {\n quoteCharge {\n id\n }\n }\n }\n";
|
|
21237
21197
|
var quoteChargeUpdate = function (_a) {
|
|
21238
21198
|
var discount = _a.discount, name = _a.name, price = _a.price, quantity = _a.quantity, quoteChargeId = _a.quoteChargeId, startDate = _a.startDate, subtotal = _a.subtotal, apiHost = _a.apiHost, token = _a.token;
|
|
@@ -21324,112 +21284,10 @@ var billingPeriodConverter = function (period) {
|
|
|
21324
21284
|
return 12;
|
|
21325
21285
|
};
|
|
21326
21286
|
|
|
21327
|
-
var canShowQuantitiesInput = function (charge, subscription) {
|
|
21328
|
-
// Check if the subscription is active, pending, or in trial,
|
|
21329
|
-
// the pricing model is not flat,
|
|
21330
|
-
// and if it's not a trial, also check if the current charge is the last one in the subscription.
|
|
21331
|
-
var _a, _b, _c;
|
|
21332
|
-
var isActiveSubscription = ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.ACTIVE;
|
|
21333
|
-
var isPendingSubscription = ((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === common.SubscriptionState.PENDING;
|
|
21334
|
-
var isTrialSubscription = ((_c = subscription.state) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === common.SubscriptionState.TRIAL;
|
|
21335
|
-
var isFlatPricing = charge.pricingModel === 'FLAT';
|
|
21336
|
-
var shouldProcessCharge = (isActiveSubscription || isPendingSubscription || isTrialSubscription) &&
|
|
21337
|
-
!isFlatPricing &&
|
|
21338
|
-
charge.selfServiceQuantity &&
|
|
21339
|
-
!charge.expired;
|
|
21340
|
-
// Now you can use the value of shouldProcessCharge to determine whether to process the charge.
|
|
21341
|
-
return shouldProcessCharge;
|
|
21342
|
-
};
|
|
21343
|
-
var createQuoteParams = function (quote, subscriptionQuantity, editedSubscription) {
|
|
21344
|
-
var quoteChange = quote.quoteChanges.find(function (quoteChange) { return quoteChange.priceList.id === (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription.priceList.id); });
|
|
21345
|
-
var quoteChangeCharge = quoteChange === null || quoteChange === void 0 ? void 0 : quoteChange.charges.find(function (charge) { return charge.priceListCharge.id === editedSubscription.chargeId; });
|
|
21346
|
-
var charges = [
|
|
21347
|
-
{
|
|
21348
|
-
id: quoteChangeCharge.id,
|
|
21349
|
-
quantity: editedSubscription.quantity - subscriptionQuantity,
|
|
21350
|
-
},
|
|
21351
|
-
];
|
|
21352
|
-
return { charges: charges, quoteChange: quoteChange };
|
|
21353
|
-
};
|
|
21354
|
-
var canShowChangeQuantities = function (_a) {
|
|
21355
|
-
var subscriptions = _a.subscriptions;
|
|
21356
|
-
return subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.some(function (subscription) {
|
|
21357
|
-
return subscription.charges.some(function (charge) {
|
|
21358
|
-
return canShowQuantitiesInput(charge, subscription);
|
|
21359
|
-
});
|
|
21360
|
-
});
|
|
21361
|
-
};
|
|
21362
|
-
var canSubscriptionUpgradeFromTrial = function (subscription) {
|
|
21363
|
-
var _a;
|
|
21364
|
-
return (((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.TRIAL &&
|
|
21365
|
-
subscription.plan.selfServiceBuy) ||
|
|
21366
|
-
false;
|
|
21367
|
-
};
|
|
21368
|
-
var isSubscriptionNotActive = function (subscription) {
|
|
21369
|
-
var _a, _b;
|
|
21370
|
-
return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.EXPIRED ||
|
|
21371
|
-
((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === common.SubscriptionState.CANCELED;
|
|
21372
|
-
};
|
|
21373
|
-
var isSubscriptionActiveOrPending = function (subscription) {
|
|
21374
|
-
var _a, _b;
|
|
21375
|
-
return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.ACTIVE ||
|
|
21376
|
-
((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === common.SubscriptionState.PENDING;
|
|
21377
|
-
};
|
|
21378
|
-
var isSubscriptionTrial = function (subscription) { var _a; return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.TRIAL; };
|
|
21379
|
-
// Helper function to check if charge is a discount
|
|
21380
|
-
var isDiscount = function (kind) {
|
|
21381
|
-
return kind === common.QuoteChangeKind.DISCOUNT || kind === common.QuoteChangeKind.FREE_PERIOD_DISCOUNT;
|
|
21382
|
-
};
|
|
21383
|
-
var hasPriceTiers = function (charge) {
|
|
21384
|
-
var _a;
|
|
21385
|
-
return Boolean((_a = charge === null || charge === void 0 ? void 0 : charge.priceTiers) === null || _a === void 0 ? void 0 : _a.length);
|
|
21386
|
-
};
|
|
21387
|
-
var hasMultiplePriceTiers = function (charge) {
|
|
21388
|
-
var _a;
|
|
21389
|
-
return ((_a = charge === null || charge === void 0 ? void 0 : charge.priceTiers) === null || _a === void 0 ? void 0 : _a.length) > 1;
|
|
21390
|
-
};
|
|
21391
|
-
var getApplicablePriceTier = function (charge, currencyId, priceDecimals) {
|
|
21392
|
-
var _a;
|
|
21393
|
-
if (!((_a = charge.priceTiers) === null || _a === void 0 ? void 0 : _a.length))
|
|
21394
|
-
return '';
|
|
21395
|
-
var selectedTier;
|
|
21396
|
-
// For TIERED pricing model: always show the first tier
|
|
21397
|
-
if (charge.pricingModel === common.PricingModel.TIERED) {
|
|
21398
|
-
selectedTier = charge.priceTiers[0];
|
|
21399
|
-
}
|
|
21400
|
-
// For VOLUME and BANDS pricing models: find the tier that contains the current quantity
|
|
21401
|
-
else if (charge.pricingModel === common.PricingModel.VOLUME ||
|
|
21402
|
-
charge.pricingModel === common.PricingModel.BANDS) {
|
|
21403
|
-
// Find the appropriate tier based on quantity
|
|
21404
|
-
selectedTier = charge.priceTiers.find(function (tier, index) {
|
|
21405
|
-
var nextTier = charge.priceTiers[index + 1];
|
|
21406
|
-
var tierStart = tier.starts;
|
|
21407
|
-
var tierEnd = nextTier ? nextTier.starts - 1 : Infinity;
|
|
21408
|
-
return charge.quantity >= tierStart && charge.quantity <= tierEnd;
|
|
21409
|
-
});
|
|
21410
|
-
// Fallback to first tier if no tier found (shouldn't happen with proper data)
|
|
21411
|
-
selectedTier = selectedTier || charge.priceTiers[0];
|
|
21412
|
-
}
|
|
21413
|
-
// Default fallback for any other pricing models
|
|
21414
|
-
else {
|
|
21415
|
-
selectedTier = charge.priceTiers[0];
|
|
21416
|
-
}
|
|
21417
|
-
if (!selectedTier)
|
|
21418
|
-
return '';
|
|
21419
|
-
// Calculate the tier range for display
|
|
21420
|
-
var tierIndex = charge.priceTiers.indexOf(selectedTier);
|
|
21421
|
-
var starts = selectedTier.starts;
|
|
21422
|
-
var nextTier = charge.priceTiers[tierIndex + 1];
|
|
21423
|
-
var ends = nextTier ? nextTier.starts - 1 : '∞';
|
|
21424
|
-
return hasMultiplePriceTiers(charge)
|
|
21425
|
-
? "".concat(starts, "-").concat(ends, ": ").concat(common.formatCurrency(selectedTier.price, currencyId, priceDecimals))
|
|
21426
|
-
: "".concat(common.formatCurrency(selectedTier.price, currencyId, priceDecimals));
|
|
21427
|
-
};
|
|
21428
|
-
|
|
21429
21287
|
var removeHTMLTagsRegex = /<br>(?=(?:\s*<[^>]*>)*$)|(<br>)|<[^>]*>/gi;
|
|
21430
21288
|
// Description is a string that can contain HTML tags. We want to remove all HTML tags except <br> tags.
|
|
21431
21289
|
var createPlanDescription = function (priceList) {
|
|
21432
|
-
return (priceList.plan.description || '').replace(removeHTMLTagsRegex, function (
|
|
21290
|
+
return (priceList.plan.description || '').replace(removeHTMLTagsRegex, function (x, y) {
|
|
21433
21291
|
return y ? ' & ' : '';
|
|
21434
21292
|
});
|
|
21435
21293
|
};
|
|
@@ -21471,17 +21329,25 @@ var getActivePlanPriceData = function (priceList, selectedPriceList) {
|
|
|
21471
21329
|
};
|
|
21472
21330
|
};
|
|
21473
21331
|
var isPriceListDisabled = function (_a) {
|
|
21474
|
-
var priceList = _a.priceList, upgradingSubscription = _a.upgradingSubscription, canPurchaseFeatureAddons = _a.canPurchaseFeatureAddons;
|
|
21475
|
-
|
|
21476
|
-
var
|
|
21477
|
-
|
|
21478
|
-
|
|
21479
|
-
|
|
21480
|
-
|
|
21481
|
-
|
|
21482
|
-
|
|
21483
|
-
|
|
21484
|
-
|
|
21332
|
+
var priceList = _a.priceList, subscriptions = _a.subscriptions, upgradingSubscription = _a.upgradingSubscription, canPurchaseFeatureAddons = _a.canPurchaseFeatureAddons;
|
|
21333
|
+
// Plan already has a subscription
|
|
21334
|
+
var existingSubscription = subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.find(function (subscription) {
|
|
21335
|
+
var _a, _b;
|
|
21336
|
+
var isCurrentUpgradingSubscription = subscription.id === (upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id);
|
|
21337
|
+
var subscriptionAlreadyExists = isCurrentUpgradingSubscription
|
|
21338
|
+
? subscription.priceList.id === priceList.id
|
|
21339
|
+
: subscription.plan.id === priceList.plan.id;
|
|
21340
|
+
return (subscriptionAlreadyExists &&
|
|
21341
|
+
subscription.plan.id === priceList.plan.id &&
|
|
21342
|
+
((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) !== common.SubscriptionState.CANCELED &&
|
|
21343
|
+
((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) !== common.SubscriptionState.EXPIRED);
|
|
21344
|
+
});
|
|
21345
|
+
var isUpgradingPriceList = (upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.priceList.id) === priceList.id;
|
|
21346
|
+
if (existingSubscription) {
|
|
21347
|
+
return true;
|
|
21348
|
+
}
|
|
21349
|
+
if (isUpgradingPriceList && !canPurchaseFeatureAddons) {
|
|
21350
|
+
return true;
|
|
21485
21351
|
}
|
|
21486
21352
|
return false;
|
|
21487
21353
|
};
|
|
@@ -21510,13 +21376,11 @@ var CheckoutBarSummarySection = function (_a) {
|
|
|
21510
21376
|
// Context
|
|
21511
21377
|
var apiHost = react.useContext(BunnyContext).apiHost;
|
|
21512
21378
|
var quotePreviewData = react.useContext(QuotePreviewContext).quotePreviewData;
|
|
21513
|
-
var accountId = react.useContext(PaymentContext).accountId;
|
|
21514
21379
|
// Hooks
|
|
21515
21380
|
var token = useToken();
|
|
21516
21381
|
var paymentPlugins = usePaymentPlugins({
|
|
21517
21382
|
apiHost: apiHost,
|
|
21518
21383
|
token: token,
|
|
21519
|
-
accountId: accountId,
|
|
21520
21384
|
}).paymentPlugins;
|
|
21521
21385
|
var queryClient = reactQuery.useQueryClient();
|
|
21522
21386
|
var isMobile = common.useIsMobile();
|
|
@@ -21569,32 +21433,31 @@ var PlanPickerCheckoutBar = function (_a) {
|
|
|
21569
21433
|
}).defaultPaymentMethod;
|
|
21570
21434
|
var createSubscriptionUpgradeQuote = useQuoteSubscriptionUpgrade();
|
|
21571
21435
|
var createSubscriptionUpdateQuote = useCreateSubscriptionQuote();
|
|
21572
|
-
var quoteSubscriptionActivate = useQuoteSubscriptionActivate();
|
|
21573
21436
|
// Mutations
|
|
21574
21437
|
var createQuote = reactQuery.useMutation({
|
|
21575
21438
|
mutationFn: function (_a) {
|
|
21576
21439
|
var subscriptionId = _a.subscriptionId, priceListId = _a.priceListId;
|
|
21577
21440
|
return createSubscriptionUpgradeQuote(subscriptionId, priceListId, apiHost, token);
|
|
21578
21441
|
},
|
|
21579
|
-
onSuccess: function (
|
|
21442
|
+
onSuccess: function (subscriptionUpdateData) {
|
|
21580
21443
|
var _a;
|
|
21581
|
-
var quote = (_a =
|
|
21444
|
+
var quote = (_a = subscriptionUpdateData === null || subscriptionUpdateData === void 0 ? void 0 : subscriptionUpdateData.quoteSubscriptionUpgrade) === null || _a === void 0 ? void 0 : _a.quote;
|
|
21582
21445
|
setEditingQuoteData === null || setEditingQuoteData === void 0 ? void 0 : setEditingQuoteData(quote.id);
|
|
21583
21446
|
handleSetEditingQuote(quote.id);
|
|
21584
21447
|
},
|
|
21585
|
-
})
|
|
21448
|
+
});
|
|
21586
21449
|
var createEmptyQuote = reactQuery.useMutation({
|
|
21587
21450
|
mutationFn: function (_a) {
|
|
21588
21451
|
var subscriptionId = _a.subscriptionId;
|
|
21589
21452
|
return createSubscriptionUpdateQuote([subscriptionId], apiHost, token);
|
|
21590
21453
|
},
|
|
21591
|
-
onSuccess: function (
|
|
21454
|
+
onSuccess: function (subscriptionUpdateData) {
|
|
21592
21455
|
var _a;
|
|
21593
|
-
var quote = (_a =
|
|
21456
|
+
var quote = (_a = subscriptionUpdateData === null || subscriptionUpdateData === void 0 ? void 0 : subscriptionUpdateData.quoteSubscriptionUpdate) === null || _a === void 0 ? void 0 : _a.quote;
|
|
21594
21457
|
setEditingQuoteData === null || setEditingQuoteData === void 0 ? void 0 : setEditingQuoteData(quote.id);
|
|
21595
21458
|
handleSetEditingQuote(quote.id);
|
|
21596
21459
|
},
|
|
21597
|
-
})
|
|
21460
|
+
});
|
|
21598
21461
|
var updateCharge = reactQuery.useMutation({
|
|
21599
21462
|
mutationFn: quoteChargeUpdate,
|
|
21600
21463
|
onSuccess: function () {
|
|
@@ -21607,32 +21470,6 @@ var PlanPickerCheckoutBar = function (_a) {
|
|
|
21607
21470
|
});
|
|
21608
21471
|
},
|
|
21609
21472
|
}).mutate;
|
|
21610
|
-
var subscriptionActivate = reactQuery.useMutation({
|
|
21611
|
-
mutationFn: function (_a) {
|
|
21612
|
-
var subscriptionId = _a.subscriptionId;
|
|
21613
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
21614
|
-
return __generator(this, function (_b) {
|
|
21615
|
-
switch (_b.label) {
|
|
21616
|
-
case 0: return [4 /*yield*/, quoteSubscriptionActivate(subscriptionId, apiHost, token)];
|
|
21617
|
-
case 1: return [2 /*return*/, _b.sent()];
|
|
21618
|
-
}
|
|
21619
|
-
});
|
|
21620
|
-
});
|
|
21621
|
-
},
|
|
21622
|
-
onSuccess: function (response) {
|
|
21623
|
-
var _a;
|
|
21624
|
-
var quote = (_a = response === null || response === void 0 ? void 0 : response.quoteSubscriptionActivate) === null || _a === void 0 ? void 0 : _a.quote;
|
|
21625
|
-
setEditingQuoteData === null || setEditingQuoteData === void 0 ? void 0 : setEditingQuoteData(quote.id);
|
|
21626
|
-
handleSetEditingQuote(quote.id);
|
|
21627
|
-
queryClient.invalidateQueries({
|
|
21628
|
-
queryKey: common.QueryKeyFactory.default.createObjectKey({
|
|
21629
|
-
objectName: 'editingQuote',
|
|
21630
|
-
id: editingQuote === null || editingQuote === void 0 ? void 0 : editingQuote.id,
|
|
21631
|
-
token: token,
|
|
21632
|
-
}),
|
|
21633
|
-
});
|
|
21634
|
-
},
|
|
21635
|
-
}).mutate;
|
|
21636
21473
|
// Queries
|
|
21637
21474
|
var quote = reactQuery.useQuery({
|
|
21638
21475
|
queryKey: common.QueryKeyFactory.default.createObjectKey({
|
|
@@ -21662,26 +21499,18 @@ var PlanPickerCheckoutBar = function (_a) {
|
|
|
21662
21499
|
enabled: Boolean(editingQuote === null || editingQuote === void 0 ? void 0 : editingQuote.id),
|
|
21663
21500
|
}).data;
|
|
21664
21501
|
react.useEffect(function () {
|
|
21665
|
-
var _a;
|
|
21666
21502
|
if (!(upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id)) {
|
|
21667
21503
|
console.error('upgradingSubscription is undefined');
|
|
21668
21504
|
return;
|
|
21669
21505
|
}
|
|
21670
21506
|
var upgradingCurrentSubscription = (upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.priceList.id) === (selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id);
|
|
21671
21507
|
if (upgradingCurrentSubscription) {
|
|
21672
|
-
|
|
21673
|
-
|
|
21674
|
-
|
|
21675
|
-
});
|
|
21676
|
-
}
|
|
21677
|
-
else {
|
|
21678
|
-
createEmptyQuote({
|
|
21679
|
-
subscriptionId: upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id,
|
|
21680
|
-
});
|
|
21681
|
-
}
|
|
21508
|
+
createEmptyQuote.mutate({
|
|
21509
|
+
subscriptionId: upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id,
|
|
21510
|
+
});
|
|
21682
21511
|
}
|
|
21683
21512
|
else {
|
|
21684
|
-
createQuote({
|
|
21513
|
+
createQuote.mutate({
|
|
21685
21514
|
subscriptionId: upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id,
|
|
21686
21515
|
priceListId: selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id,
|
|
21687
21516
|
});
|
|
@@ -21756,7 +21585,7 @@ var PlanPickerCheckoutBar = function (_a) {
|
|
|
21756
21585
|
// WARNING: There is a preview button on APP that will need to be changed if this query is changed
|
|
21757
21586
|
var PRICE_LIST_CHANGE_OPTIONS_QUERY = "\n query priceListChangeOptions($subscriptionId: ID, $productId: ID) {\n priceListChangeOptions(subscriptionId: $subscriptionId, productId: $productId) {\n products {\n everythingInPlus\n id\n name\n plansToDisplay\n features(sort: \"position asc\") {\n description\n id\n isVisible\n kind\n name\n position\n }\n }\n priceLists {\n showPriceAsMonthly\n basePrice\n currencyId\n id\n monthlyBasePrice\n periodMonths\n plan {\n code\n contactUsLabel\n contactUsUrl\n description\n id\n name\n position\n pricingDescription\n pricingStyle\n planFeatures {\n featureId\n value\n feature {\n name\n }\n }\n }\n product {\n id\n }\n charges {\n featureAddon\n basePrice\n billingPeriod\n chargeType\n id\n name\n priceDecimals\n pricingModel\n quantityMax\n quantityMin\n selfServiceQuantity\n priceList {\n id\n }\n feature {\n name\n unitName\n }\n }\n }\n }\n }";
|
|
21758
21587
|
var getPriceListChangeOptions = function (_a) {
|
|
21759
|
-
var apiHost = _a.apiHost, isInPreviewMode = _a.isInPreviewMode, productId = _a.productId, token = _a.token, upgradingSubscription = _a.upgradingSubscription
|
|
21588
|
+
var apiHost = _a.apiHost, isInPreviewMode = _a.isInPreviewMode, productId = _a.productId, token = _a.token, upgradingSubscription = _a.upgradingSubscription;
|
|
21760
21589
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
21761
21590
|
var response, priceListChangeOptions;
|
|
21762
21591
|
return __generator(this, function (_b) {
|
|
@@ -21777,8 +21606,6 @@ var getPriceListChangeOptions = function (_a) {
|
|
|
21777
21606
|
if (priceListChangeOptions === null || priceListChangeOptions === void 0 ? void 0 : priceListChangeOptions.priceLists) {
|
|
21778
21607
|
priceListChangeOptions.priceLists.sort(function (a, b) { return a.plan.position - b.plan.position; });
|
|
21779
21608
|
}
|
|
21780
|
-
// Filter out price lists that don't have the same currency as the account
|
|
21781
|
-
priceListChangeOptions.priceLists = priceListChangeOptions.priceLists.filter(function (priceList) { return priceList.currencyId === accountCurrencyId; });
|
|
21782
21609
|
return [2 /*return*/, priceListChangeOptions];
|
|
21783
21610
|
}
|
|
21784
21611
|
});
|
|
@@ -21910,10 +21737,7 @@ var PriceListCardButton = function (_a) {
|
|
|
21910
21737
|
subscriptionPlan &&
|
|
21911
21738
|
priceListHasUnpurchasedFeatureAddons(priceList, upgradingSubscription);
|
|
21912
21739
|
var isPriceListNonSubscribedCurrentPlan = (upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.plan.id) === priceList.plan.id && !isPriceListCurrentSubscription;
|
|
21913
|
-
var canUpgradeFromTrial = upgradingSubscription && canSubscriptionUpgradeFromTrial(upgradingSubscription);
|
|
21914
21740
|
var createButtonText = function () {
|
|
21915
|
-
if (isPriceListCurrentSubscription && canUpgradeFromTrial)
|
|
21916
|
-
return 'Upgrade from trial';
|
|
21917
21741
|
if (isPriceListCurrentSubscription)
|
|
21918
21742
|
return 'Current';
|
|
21919
21743
|
if (isSelected)
|
|
@@ -22067,6 +21891,7 @@ var PriceListCard = function (_a) {
|
|
|
22067
21891
|
var canPurchaseFeatureAddons = priceListHasUnpurchasedFeatureAddons(priceList, upgradingSubscription);
|
|
22068
21892
|
var disableOnClick = isPriceListDisabled({
|
|
22069
21893
|
priceList: priceList,
|
|
21894
|
+
subscriptions: subscriptions,
|
|
22070
21895
|
upgradingSubscription: upgradingSubscription,
|
|
22071
21896
|
canPurchaseFeatureAddons: canPurchaseFeatureAddons,
|
|
22072
21897
|
});
|
|
@@ -22363,14 +22188,14 @@ var FeatureTitle = function (_a) {
|
|
|
22363
22188
|
|
|
22364
22189
|
var PriceListGridDesktop = function (_a) {
|
|
22365
22190
|
var availablePriceLists = _a.availablePriceLists, onChangePriceList = _a.onChangePriceList, priceListChangeOptions = _a.priceListChangeOptions, priceListStart = _a.priceListStart, selectedPriceList = _a.selectedPriceList, selectedProduct = _a.selectedProduct, setPriceListStart = _a.setPriceListStart, subscriptions = _a.subscriptions, trialRemainingDays = _a.trialRemainingDays;
|
|
22366
|
-
var
|
|
22191
|
+
var _b = react.useMemo(function () {
|
|
22367
22192
|
return getAvailablePlansAndPriceLists({
|
|
22368
22193
|
availablePriceLists: availablePriceLists,
|
|
22369
22194
|
priceListChangeOptions: priceListChangeOptions,
|
|
22370
22195
|
priceListStart: priceListStart,
|
|
22371
22196
|
plansToDisplay: (selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.plansToDisplay) || 3,
|
|
22372
22197
|
});
|
|
22373
|
-
}, [availablePriceLists, priceListChangeOptions, priceListStart]).displayPriceLists;
|
|
22198
|
+
}, [availablePriceLists, priceListChangeOptions, priceListStart]); _b.availablePriceListsArray; var displayPriceLists = _b.displayPriceLists;
|
|
22374
22199
|
var everythingInPlus = selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.everythingInPlus;
|
|
22375
22200
|
var plansToDisplay = Math.min((selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.plansToDisplay) || 3, availablePriceLists.length);
|
|
22376
22201
|
var hasFeatureAddons = displayPriceLists.some(function (priceList) {
|
|
@@ -22385,7 +22210,7 @@ var PriceListGridDesktop = function (_a) {
|
|
|
22385
22210
|
var doesPrevPriceListExist = displayPriceLists[index - 1];
|
|
22386
22211
|
if (!priceList)
|
|
22387
22212
|
return jsxRuntime.jsx(PlanPickerGridCell, { noBorder: !Boolean(doesPrevPriceListExist) }, index);
|
|
22388
|
-
return (jsxRuntime.jsx(PriceListCard, { isSelected: priceList.id === (selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id), onClick: onChangePriceList, priceList: priceList, subscriptions: subscriptions, trialRemainingDays: trialRemainingDays }, index));
|
|
22213
|
+
return (jsxRuntime.jsx(PriceListCard, { isSelected: priceList.plan.id === (selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.plan.id), onClick: onChangePriceList, priceList: priceList, subscriptions: subscriptions, trialRemainingDays: trialRemainingDays }, index));
|
|
22389
22214
|
}), (selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.everythingInPlus) ? (jsxRuntime.jsx(EverythingPlanFeatures, { displayPriceLists: displayPriceLists, plansToDisplay: plansToDisplay, selectedProduct: selectedProduct })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(PlanFeatures, { displayPriceLists: displayPriceLists, plansToDisplay: plansToDisplay, selectedProduct: selectedProduct }), hasFeatureAddons && (jsxRuntime.jsx(PlanFeatureAddons, { displayPriceLists: displayPriceLists, plansToDisplay: plansToDisplay }))] }))] }))] })));
|
|
22390
22215
|
};
|
|
22391
22216
|
|
|
@@ -22459,6 +22284,7 @@ var PriceListSelector = function (_a) {
|
|
|
22459
22284
|
priceList.plan.id === ((_a = quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.priceList) === null || _a === void 0 ? void 0 : _a.plan.id) &&
|
|
22460
22285
|
!isPriceListDisabled({
|
|
22461
22286
|
priceList: priceList,
|
|
22287
|
+
subscriptions: subscriptions,
|
|
22462
22288
|
upgradingSubscription: upgradingSubscription,
|
|
22463
22289
|
canPurchaseFeatureAddons: priceListHasUnpurchasedFeatureAddons(quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.priceList, upgradingSubscription),
|
|
22464
22290
|
});
|
|
@@ -22476,7 +22302,13 @@ var PriceListSelector = function (_a) {
|
|
|
22476
22302
|
});
|
|
22477
22303
|
}
|
|
22478
22304
|
}
|
|
22479
|
-
}, [
|
|
22305
|
+
}, [
|
|
22306
|
+
quotePreviewData,
|
|
22307
|
+
priceListChangeOptions,
|
|
22308
|
+
subscriptions,
|
|
22309
|
+
upgradingSubscription,
|
|
22310
|
+
setQuotePreviewData,
|
|
22311
|
+
]);
|
|
22480
22312
|
var onChangeProduct = react.useCallback(function (product) {
|
|
22481
22313
|
var newAvailableBillingPeriods = createAvailableBillingPeriods(priceListChangeOptions === null || priceListChangeOptions === void 0 ? void 0 : priceListChangeOptions.priceLists, product);
|
|
22482
22314
|
if (!(newAvailableBillingPeriods === null || newAvailableBillingPeriods === void 0 ? void 0 : newAvailableBillingPeriods.includes(billingPeriodConverter(selectedBillingPeriod)))) {
|
|
@@ -22521,6 +22353,7 @@ var PriceListSelector = function (_a) {
|
|
|
22521
22353
|
!isInPreviewMode &&
|
|
22522
22354
|
!isPriceListDisabled({
|
|
22523
22355
|
priceList: initialPriceList,
|
|
22356
|
+
subscriptions: subscriptions,
|
|
22524
22357
|
upgradingSubscription: upgradingSubscription,
|
|
22525
22358
|
canPurchaseFeatureAddons: priceListHasUnpurchasedFeatureAddons(initialPriceList, upgradingSubscription),
|
|
22526
22359
|
})) {
|
|
@@ -22538,6 +22371,7 @@ var PriceListSelector = function (_a) {
|
|
|
22538
22371
|
selectedPriceList,
|
|
22539
22372
|
selectedProduct,
|
|
22540
22373
|
setQuotePreviewData,
|
|
22374
|
+
subscriptions,
|
|
22541
22375
|
upgradingSubscription,
|
|
22542
22376
|
]);
|
|
22543
22377
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(BillingPeriodSelector, { availableBillingPeriods: availableBillingPeriods, onChangeBillingPeriod: onChangeBillingPeriod, products: priceListChangeOptions === null || priceListChangeOptions === void 0 ? void 0 : priceListChangeOptions.products, selectedBillingPeriod: selectedBillingPeriod, selectedProduct: selectedProduct, onChangeProduct: onChangeProduct }), jsxRuntime.jsx(PriceListGrid, { availablePriceLists: availablePriceLists, onChangePriceList: onChangePriceList, priceListChangeOptions: priceListChangeOptions, priceListStart: priceListStart, selectedPriceList: selectedPriceList, selectedProduct: selectedProduct, setPriceListStart: setPriceListStart, subscriptions: subscriptions, upgradingSubscriptionState: upgradingSubscription })] }));
|
|
@@ -22550,7 +22384,6 @@ var PlanPicker = function () {
|
|
|
22550
22384
|
var apiHost = react.useContext(BunnyContext).apiHost;
|
|
22551
22385
|
var _b = react.useContext(SubscriptionsContext), isInPreviewMode = _b.isInPreviewMode, productId = _b.productId, upgradingSubscription = _b.upgradingSubscription;
|
|
22552
22386
|
var _c = react.useContext(QuotePreviewContext), quotePreviewData = _c.quotePreviewData, setQuotePreviewData = _c.setQuotePreviewData;
|
|
22553
|
-
var account = useCurrentUserData(token).account;
|
|
22554
22387
|
// Hooks
|
|
22555
22388
|
var showInfoNotification = common.useInfoNotification();
|
|
22556
22389
|
// Queries
|
|
@@ -22573,7 +22406,6 @@ var PlanPicker = function () {
|
|
|
22573
22406
|
productId: productId,
|
|
22574
22407
|
token: token,
|
|
22575
22408
|
upgradingSubscription: upgradingSubscription,
|
|
22576
|
-
accountCurrencyId: account === null || account === void 0 ? void 0 : account.currencyId,
|
|
22577
22409
|
});
|
|
22578
22410
|
},
|
|
22579
22411
|
enabled: !areSubscriptionsLoading,
|
|
@@ -22736,7 +22568,7 @@ var SubscriptionState$1 = SubscriptionState;
|
|
|
22736
22568
|
|
|
22737
22569
|
var FEATURE_USAGE_MUTATION = "\nquery GetFeatureUsage($id: ID!) {\n featureUsageHistogram(subscriptionChargeId: $id) {\n subscriptionCharge { \n id\n name\n amount\n currentPeriodPriceByTiers { \n tier { starts price } \n quantity\n amount\n }\n }\n feature { id name }\n periodRange\n dataInterval\n data {\n periodStart\n periodEnd\n intervals {\n intervalStart\n intervalUsage\n }\n intervalsTotal\n }\n }\n}\n";
|
|
22738
22570
|
var getFeatureUsage = function (_a) {
|
|
22739
|
-
var subscriptionChargeId = _a.subscriptionChargeId
|
|
22571
|
+
var subscriptionChargeId = _a.subscriptionChargeId; _a.startDate; _a.endDate; _a.dataInterval; var token = _a.token, apiHost = _a.apiHost;
|
|
22740
22572
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
22741
22573
|
var vars, response;
|
|
22742
22574
|
var _b;
|
|
@@ -22856,51 +22688,387 @@ var FeatureBarChart = function (_a) {
|
|
|
22856
22688
|
var StyledBarChart = defaultStyled(recharts.BarChart)(templateObject_1$2 || (templateObject_1$2 = __makeTemplateObject(["\n .recharts-surface {\n overflow: visible;\n }\n"], ["\n .recharts-surface {\n overflow: visible;\n }\n"])));
|
|
22857
22689
|
var templateObject_1$2;
|
|
22858
22690
|
|
|
22859
|
-
var
|
|
22860
|
-
|
|
22861
|
-
|
|
22862
|
-
|
|
22863
|
-
var
|
|
22864
|
-
var
|
|
22865
|
-
|
|
22866
|
-
|
|
22867
|
-
|
|
22868
|
-
|
|
22869
|
-
|
|
22870
|
-
|
|
22871
|
-
|
|
22872
|
-
|
|
22873
|
-
|
|
22874
|
-
var isActiveOrPending = isSubscriptionActiveOrPending(subscription);
|
|
22875
|
-
if (isPaymentMethodLoading)
|
|
22876
|
-
return null;
|
|
22877
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [isSelfServiceCancelable && (isInTrial || isActiveOrPending) && (jsxRuntime.jsx(antd.Popconfirm, __assign({ icon: null, onConfirm: function () { return onCancelSubscriptionClick === null || onCancelSubscriptionClick === void 0 ? void 0 : onCancelSubscriptionClick(subscription); }, title: "Cancel subscription" }, { children: jsxRuntime.jsx(antd.Button, __assign({ className: "bunny-p-0", type: "link" }, { children: "Cancel subscription" })) }))), arePlansAvailable && (isActiveOrPending || isInTrial) && (jsxRuntime.jsx(antd.Button, __assign({ onClick: function () { return onChangePlanClick(subscription); }, type: 'primary' }, { children: isInTrial ? 'Upgrade from trial' : 'Change plan' }))), !arePlansAvailable && isInTrial && jsxRuntime.jsx(antd.Tag, __assign({ color: "warning" }, { children: "Cannot upgrade" }))] }));
|
|
22691
|
+
var canShowQuantitiesInput = function (charge, subscription) {
|
|
22692
|
+
// Check if the subscription is active, pending, or in trial,
|
|
22693
|
+
// the pricing model is not flat,
|
|
22694
|
+
// and if it's not a trial, also check if the current charge is the last one in the subscription.
|
|
22695
|
+
var _a, _b, _c;
|
|
22696
|
+
var isActiveSubscription = ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.ACTIVE;
|
|
22697
|
+
var isPendingSubscription = ((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === common.SubscriptionState.PENDING;
|
|
22698
|
+
var isTrialSubscription = ((_c = subscription.state) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === common.SubscriptionState.TRIAL;
|
|
22699
|
+
var isFlatPricing = charge.pricingModel === 'FLAT';
|
|
22700
|
+
var shouldProcessCharge = (isActiveSubscription || isPendingSubscription || isTrialSubscription) &&
|
|
22701
|
+
!isFlatPricing &&
|
|
22702
|
+
charge.selfServiceQuantity &&
|
|
22703
|
+
!charge.expired;
|
|
22704
|
+
// Now you can use the value of shouldProcessCharge to determine whether to process the charge.
|
|
22705
|
+
return shouldProcessCharge;
|
|
22878
22706
|
};
|
|
22879
|
-
|
|
22880
|
-
var
|
|
22881
|
-
var
|
|
22882
|
-
var
|
|
22883
|
-
|
|
22884
|
-
|
|
22885
|
-
|
|
22886
|
-
|
|
22887
|
-
|
|
22888
|
-
|
|
22889
|
-
|
|
22890
|
-
|
|
22891
|
-
|
|
22892
|
-
|
|
22893
|
-
|
|
22894
|
-
|
|
22895
|
-
|
|
22896
|
-
|
|
22897
|
-
|
|
22898
|
-
|
|
22899
|
-
|
|
22900
|
-
|
|
22901
|
-
|
|
22902
|
-
|
|
22903
|
-
|
|
22707
|
+
var createQuoteParams = function (quote, subscriptionQuantity, editedSubscription) {
|
|
22708
|
+
var quoteChange = quote.quoteChanges.find(function (quoteChange) { return quoteChange.priceList.id === (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription.priceList.id); });
|
|
22709
|
+
var quoteChangeCharge = quoteChange === null || quoteChange === void 0 ? void 0 : quoteChange.charges.find(function (charge) { return charge.priceListCharge.id === editedSubscription.chargeId; });
|
|
22710
|
+
var charges = [
|
|
22711
|
+
{
|
|
22712
|
+
id: quoteChangeCharge.id,
|
|
22713
|
+
quantity: editedSubscription.quantity - subscriptionQuantity,
|
|
22714
|
+
},
|
|
22715
|
+
];
|
|
22716
|
+
return { charges: charges, quoteChange: quoteChange };
|
|
22717
|
+
};
|
|
22718
|
+
var canShowChangeQuantities = function (_a) {
|
|
22719
|
+
var subscriptions = _a.subscriptions;
|
|
22720
|
+
return subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.some(function (subscription) {
|
|
22721
|
+
return subscription.charges.some(function (charge, chargeIndex) {
|
|
22722
|
+
return canShowQuantitiesInput(charge, subscription);
|
|
22723
|
+
});
|
|
22724
|
+
});
|
|
22725
|
+
};
|
|
22726
|
+
var isSubscriptionNotActive = function (subscription) {
|
|
22727
|
+
var _a, _b;
|
|
22728
|
+
return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.EXPIRED ||
|
|
22729
|
+
((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === common.SubscriptionState.CANCELED;
|
|
22730
|
+
};
|
|
22731
|
+
var isSubscriptionActiveOrPending = function (subscription) {
|
|
22732
|
+
var _a, _b;
|
|
22733
|
+
return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.ACTIVE ||
|
|
22734
|
+
((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === common.SubscriptionState.PENDING;
|
|
22735
|
+
};
|
|
22736
|
+
var isSubscriptionTrial = function (subscription) { var _a; return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.TRIAL; };
|
|
22737
|
+
// Helper function to check if charge is a discount
|
|
22738
|
+
var isDiscount = function (kind) {
|
|
22739
|
+
return kind === common.QuoteChangeKind.DISCOUNT || kind === common.QuoteChangeKind.FREE_PERIOD_DISCOUNT;
|
|
22740
|
+
};
|
|
22741
|
+
var hasPriceTiers = function (charge) {
|
|
22742
|
+
var _a;
|
|
22743
|
+
return Boolean((_a = charge === null || charge === void 0 ? void 0 : charge.priceTiers) === null || _a === void 0 ? void 0 : _a.length);
|
|
22744
|
+
};
|
|
22745
|
+
var hasMultiplePriceTiers = function (charge) {
|
|
22746
|
+
var _a;
|
|
22747
|
+
return ((_a = charge === null || charge === void 0 ? void 0 : charge.priceTiers) === null || _a === void 0 ? void 0 : _a.length) > 1;
|
|
22748
|
+
};
|
|
22749
|
+
var getApplicablePriceTier = function (charge, currencyId, priceDecimals) {
|
|
22750
|
+
var _a;
|
|
22751
|
+
if (!((_a = charge.priceTiers) === null || _a === void 0 ? void 0 : _a.length))
|
|
22752
|
+
return '';
|
|
22753
|
+
var selectedTier;
|
|
22754
|
+
// For TIERED pricing model: always show the first tier
|
|
22755
|
+
if (charge.pricingModel === common.PricingModel.TIERED) {
|
|
22756
|
+
selectedTier = charge.priceTiers[0];
|
|
22757
|
+
}
|
|
22758
|
+
// For VOLUME and BANDS pricing models: find the tier that contains the current quantity
|
|
22759
|
+
else if (charge.pricingModel === common.PricingModel.VOLUME ||
|
|
22760
|
+
charge.pricingModel === common.PricingModel.BANDS) {
|
|
22761
|
+
// Find the appropriate tier based on quantity
|
|
22762
|
+
selectedTier = charge.priceTiers.find(function (tier, index) {
|
|
22763
|
+
var nextTier = charge.priceTiers[index + 1];
|
|
22764
|
+
var tierStart = tier.starts;
|
|
22765
|
+
var tierEnd = nextTier ? nextTier.starts - 1 : Infinity;
|
|
22766
|
+
return charge.quantity >= tierStart && charge.quantity <= tierEnd;
|
|
22767
|
+
});
|
|
22768
|
+
// Fallback to first tier if no tier found (shouldn't happen with proper data)
|
|
22769
|
+
selectedTier = selectedTier || charge.priceTiers[0];
|
|
22770
|
+
}
|
|
22771
|
+
// Default fallback for any other pricing models
|
|
22772
|
+
else {
|
|
22773
|
+
selectedTier = charge.priceTiers[0];
|
|
22774
|
+
}
|
|
22775
|
+
if (!selectedTier)
|
|
22776
|
+
return '';
|
|
22777
|
+
// Calculate the tier range for display
|
|
22778
|
+
var tierIndex = charge.priceTiers.indexOf(selectedTier);
|
|
22779
|
+
var starts = selectedTier.starts;
|
|
22780
|
+
var nextTier = charge.priceTiers[tierIndex + 1];
|
|
22781
|
+
var ends = nextTier ? nextTier.starts - 1 : '∞';
|
|
22782
|
+
return hasMultiplePriceTiers(charge)
|
|
22783
|
+
? "".concat(starts, "-").concat(ends, ": ").concat(common.formatCurrency(selectedTier.price, currencyId, priceDecimals))
|
|
22784
|
+
: "".concat(common.formatCurrency(selectedTier.price, currencyId, priceDecimals));
|
|
22785
|
+
};
|
|
22786
|
+
|
|
22787
|
+
var MUTATION = "\nmutation BillingDetailsUpdate(\n $attributes: BillingDetailsAttributes!) {\n billingDetailsUpdate(\n attributes: $attributes\n ) {\n billingDetails {\n billingCity\n billingContact {\n email\n }\n billingCountry\n billingState\n billingStreet\n billingZip\n name\n taxNumber\n }\n errors\n }\n }\n";
|
|
22788
|
+
var billingDetailsUpdate = function (_a) {
|
|
22789
|
+
var attributes = _a.attributes, token = _a.token, apiHost = _a.apiHost;
|
|
22790
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
22791
|
+
var vars, response, errors;
|
|
22792
|
+
var _b;
|
|
22793
|
+
return __generator(this, function (_c) {
|
|
22794
|
+
switch (_c.label) {
|
|
22795
|
+
case 0:
|
|
22796
|
+
vars = { attributes: attributes };
|
|
22797
|
+
return [4 /*yield*/, gqlRequest({
|
|
22798
|
+
query: MUTATION,
|
|
22799
|
+
token: token,
|
|
22800
|
+
vars: vars,
|
|
22801
|
+
apiHost: apiHost,
|
|
22802
|
+
})];
|
|
22803
|
+
case 1:
|
|
22804
|
+
response = _c.sent();
|
|
22805
|
+
errors = (_b = response === null || response === void 0 ? void 0 : response.billingDetailsUpdate) === null || _b === void 0 ? void 0 : _b.errors;
|
|
22806
|
+
if (errors)
|
|
22807
|
+
throw errors;
|
|
22808
|
+
return [2 /*return*/, response.billingDetailsUpdate];
|
|
22809
|
+
}
|
|
22810
|
+
});
|
|
22811
|
+
});
|
|
22812
|
+
};
|
|
22813
|
+
|
|
22814
|
+
// TODO: move this to common
|
|
22815
|
+
var billingDetailsQuery = function () {
|
|
22816
|
+
return "\nquery BillingDetails {\n billingDetails {\n billingCity\n billingContact {\n email\n }\n billingCountry\n billingState\n billingStreet\n billingZip\n name\n taxNumber\n currency {\n id\n }\n }\n}";
|
|
22817
|
+
};
|
|
22818
|
+
var getBillingDetails = function (_a) {
|
|
22819
|
+
var token = _a.token, apiHost = _a.apiHost;
|
|
22820
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
22821
|
+
var response;
|
|
22822
|
+
var _b;
|
|
22823
|
+
return __generator(this, function (_c) {
|
|
22824
|
+
switch (_c.label) {
|
|
22825
|
+
case 0: return [4 /*yield*/, gqlRequest({
|
|
22826
|
+
query: billingDetailsQuery(),
|
|
22827
|
+
token: token,
|
|
22828
|
+
apiHost: apiHost,
|
|
22829
|
+
})];
|
|
22830
|
+
case 1:
|
|
22831
|
+
response = _c.sent();
|
|
22832
|
+
if (response === null || response === void 0 ? void 0 : response.errors) {
|
|
22833
|
+
throw new Error((_b = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _b === void 0 ? void 0 : _b.message);
|
|
22834
|
+
}
|
|
22835
|
+
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.billingDetails];
|
|
22836
|
+
}
|
|
22837
|
+
});
|
|
22838
|
+
});
|
|
22839
|
+
};
|
|
22840
|
+
|
|
22841
|
+
var Text$7 = antd.Typography.Text;
|
|
22842
|
+
function BillingDetailsSection(_a) {
|
|
22843
|
+
var _this = this;
|
|
22844
|
+
var hidePaymentMethodForm = _a.hidePaymentMethodForm, countryListFilter = _a.countryListFilter;
|
|
22845
|
+
// State
|
|
22846
|
+
var _b = react.useState(false), isFormEdited = _b[0], setIsFormEdited = _b[1];
|
|
22847
|
+
var _c = react.useState(false), formIsValid = _c[0], setFormIsValid = _c[1];
|
|
22848
|
+
var form = antd.Form.useForm()[0];
|
|
22849
|
+
var values = antd.Form.useWatch([], form);
|
|
22850
|
+
// Context
|
|
22851
|
+
var apiHost = react.useContext(BunnyContext).apiHost;
|
|
22852
|
+
var token = useToken();
|
|
22853
|
+
// Hooks
|
|
22854
|
+
var isMobile = common.useIsMobile();
|
|
22855
|
+
var queryClient = reactQuery.useQueryClient();
|
|
22856
|
+
var showErrorNotification = common.useErrorNotification();
|
|
22857
|
+
var showSuccessNotification = common.useSuccessNotification();
|
|
22858
|
+
// Queries
|
|
22859
|
+
var _d = reactQuery.useQuery({
|
|
22860
|
+
queryKey: common.QueryKeyFactory.default.billingDetailsKey({ token: token }),
|
|
22861
|
+
queryFn: function () { return getBillingDetails({ token: token, apiHost: apiHost }); },
|
|
22862
|
+
}), billingDetails = _d.data, isLoadingBillingDetails = _d.isLoading;
|
|
22863
|
+
var _e = reactQuery.useMutation({
|
|
22864
|
+
mutationFn: function (changedFormData) { return __awaiter(_this, void 0, void 0, function () {
|
|
22865
|
+
var updatedBillingDetails;
|
|
22866
|
+
return __generator(this, function (_a) {
|
|
22867
|
+
switch (_a.label) {
|
|
22868
|
+
case 0: return [4 /*yield*/, billingDetailsUpdate({
|
|
22869
|
+
attributes: {
|
|
22870
|
+
name: changedFormData.name,
|
|
22871
|
+
billingStreet: changedFormData.billingStreet,
|
|
22872
|
+
billingCity: changedFormData.billingCity,
|
|
22873
|
+
billingZip: changedFormData.billingZip,
|
|
22874
|
+
billingState: changedFormData.billingState,
|
|
22875
|
+
billingCountry: changedFormData.billingCountry,
|
|
22876
|
+
billingContactEmail: changedFormData.billingContactEmail,
|
|
22877
|
+
taxNumber: changedFormData.taxNumber,
|
|
22878
|
+
},
|
|
22879
|
+
token: token,
|
|
22880
|
+
apiHost: apiHost,
|
|
22881
|
+
})];
|
|
22882
|
+
case 1:
|
|
22883
|
+
updatedBillingDetails = _a.sent();
|
|
22884
|
+
queryClient.setQueryData(common.QueryKeyFactory.default.billingDetailsKey({ token: token }), function (old) {
|
|
22885
|
+
return __assign(__assign({}, old), updatedBillingDetails.billingDetails);
|
|
22886
|
+
});
|
|
22887
|
+
return [2 /*return*/, updatedBillingDetails];
|
|
22888
|
+
}
|
|
22889
|
+
});
|
|
22890
|
+
}); },
|
|
22891
|
+
onSuccess: function () {
|
|
22892
|
+
showSuccessNotification('Your account details have been saved');
|
|
22893
|
+
queryClient.invalidateQueries({
|
|
22894
|
+
queryKey: common.QueryKeyFactory.default.taxationRequiredAccountFieldsKey({
|
|
22895
|
+
token: token,
|
|
22896
|
+
}),
|
|
22897
|
+
});
|
|
22898
|
+
},
|
|
22899
|
+
}), updateBillingDetails = _e.mutate, isUpdatingBillingDetails = _e.isPending;
|
|
22900
|
+
// Set form values when billing details are loaded
|
|
22901
|
+
react.useEffect(function () {
|
|
22902
|
+
var _a;
|
|
22903
|
+
if (billingDetails) {
|
|
22904
|
+
form.setFieldsValue({
|
|
22905
|
+
billingStreet: billingDetails.billingStreet,
|
|
22906
|
+
billingCity: billingDetails.billingCity,
|
|
22907
|
+
billingZip: billingDetails.billingZip,
|
|
22908
|
+
billingState: billingDetails.billingState,
|
|
22909
|
+
billingCountry: billingDetails.billingCountry,
|
|
22910
|
+
billingContactEmail: (_a = billingDetails.billingContact) === null || _a === void 0 ? void 0 : _a.email,
|
|
22911
|
+
taxNumber: billingDetails.taxNumber,
|
|
22912
|
+
});
|
|
22913
|
+
}
|
|
22914
|
+
}, [billingDetails]);
|
|
22915
|
+
react.useEffect(function () {
|
|
22916
|
+
form
|
|
22917
|
+
.validateFields({ validateOnly: true })
|
|
22918
|
+
.then(function () { return setFormIsValid(true); })
|
|
22919
|
+
.catch(function () { return setFormIsValid(false); });
|
|
22920
|
+
var isFormEdited = function () {
|
|
22921
|
+
var _a;
|
|
22922
|
+
if (!billingDetails)
|
|
22923
|
+
return false;
|
|
22924
|
+
var currentValues = form.getFieldsValue();
|
|
22925
|
+
var accountValues = {
|
|
22926
|
+
billingStreet: billingDetails.billingStreet,
|
|
22927
|
+
billingCity: billingDetails.billingCity,
|
|
22928
|
+
billingZip: billingDetails.billingZip,
|
|
22929
|
+
billingState: billingDetails.billingState,
|
|
22930
|
+
billingCountry: billingDetails.billingCountry,
|
|
22931
|
+
billingContactEmail: (_a = billingDetails.billingContact) === null || _a === void 0 ? void 0 : _a.email,
|
|
22932
|
+
taxNumber: billingDetails.taxNumber,
|
|
22933
|
+
};
|
|
22934
|
+
return Object.keys(currentValues).some(function (key) {
|
|
22935
|
+
var value = accountValues[key];
|
|
22936
|
+
return currentValues[key] !== value;
|
|
22937
|
+
});
|
|
22938
|
+
};
|
|
22939
|
+
setIsFormEdited(isFormEdited());
|
|
22940
|
+
}, [form, values, billingDetails]);
|
|
22941
|
+
// Validate form fields when isFormEdited changes
|
|
22942
|
+
react.useEffect(function () {
|
|
22943
|
+
var validateOnly = isFormEdited ? false : true;
|
|
22944
|
+
form.validateFields({ validateOnly: validateOnly });
|
|
22945
|
+
}, [isFormEdited]);
|
|
22946
|
+
var saveBillingDetails = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
22947
|
+
var _this = this;
|
|
22948
|
+
return __generator(this, function (_a) {
|
|
22949
|
+
form.validateFields({ validateOnly: false }).then(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
22950
|
+
var error_1;
|
|
22951
|
+
return __generator(this, function (_a) {
|
|
22952
|
+
switch (_a.label) {
|
|
22953
|
+
case 0:
|
|
22954
|
+
_a.trys.push([0, 2, 3, 4]);
|
|
22955
|
+
return [4 /*yield*/, form.validateFields()];
|
|
22956
|
+
case 1:
|
|
22957
|
+
_a.sent();
|
|
22958
|
+
updateBillingDetails(form.getFieldsValue());
|
|
22959
|
+
return [3 /*break*/, 4];
|
|
22960
|
+
case 2:
|
|
22961
|
+
error_1 = _a.sent();
|
|
22962
|
+
if (error_1 instanceof Error) {
|
|
22963
|
+
showErrorNotification('Failed to update account', error_1.message);
|
|
22964
|
+
}
|
|
22965
|
+
else {
|
|
22966
|
+
showErrorNotification('Please fill out all required fields');
|
|
22967
|
+
}
|
|
22968
|
+
return [3 /*break*/, 4];
|
|
22969
|
+
case 3:
|
|
22970
|
+
setIsFormEdited(false);
|
|
22971
|
+
return [7 /*endfinally*/];
|
|
22972
|
+
case 4: return [2 /*return*/];
|
|
22973
|
+
}
|
|
22974
|
+
});
|
|
22975
|
+
}); });
|
|
22976
|
+
return [2 /*return*/];
|
|
22977
|
+
});
|
|
22978
|
+
}); };
|
|
22979
|
+
var filteredCountryList = react.useMemo(function () {
|
|
22980
|
+
return countryListFilter ? common.Lists.COUNTRY_LIST.filter(countryListFilter) : common.Lists.COUNTRY_LIST;
|
|
22981
|
+
}, [countryListFilter]);
|
|
22982
|
+
return (jsxRuntime.jsx("div", __assign({ className: "".concat(isMobile || hidePaymentMethodForm ? 'bunny-w-full' : 'bunny-w-1/2') }, { children: jsxRuntime.jsxs("div", __assign({ className: "bunny-px-4" }, { children: [jsxRuntime.jsxs(antd.Skeleton, __assign({ loading: isLoadingBillingDetails }, { children: [jsxRuntime.jsx("div", __assign({ className: "bunny-mb-2" }, { children: jsxRuntime.jsx(Text$7, __assign({ className: "bunny-font-medium bunny-text-lg" }, { children: (billingDetails === null || billingDetails === void 0 ? void 0 : billingDetails.name) || 'No company name' })) })), jsxRuntime.jsxs(antd.Form, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-2", form: form, layout: "vertical", disabled: isUpdatingBillingDetails, autoComplete: "off" }, { children: [jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Street address", name: "billingStreet", rules: [{ required: true, message: 'Street address is required' }] }, { children: jsxRuntime.jsx(antd.Input, {}) })), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-gap-4" }, { children: [jsxRuntime.jsx(antd.Form.Item, __assign({ label: "City", name: "billingCity", rules: [{ required: true, message: 'City is required' }], className: "bunny-flex-1" }, { children: jsxRuntime.jsx(antd.Input, {}) })), jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Zipcode", name: "billingZip", rules: [{ required: true, message: 'Zipcode is required' }], className: "bunny-flex-1" }, { children: jsxRuntime.jsx(antd.Input, {}) }))] })), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex ".concat(isMobile ? 'bunny-flex-row bunny-pb-2' : 'bunny-flex-row', " bunny-gap-4") }, { children: [jsxRuntime.jsx("div", __assign({ className: "bunny-flex-1 bunny-w-1/2" }, { children: jsxRuntime.jsx(antd.Form.Item, __assign({ label: "State", name: "billingState", rules: [
|
|
22983
|
+
{
|
|
22984
|
+
required: false,
|
|
22985
|
+
},
|
|
22986
|
+
] }, { children: jsxRuntime.jsx(antd.Input, {}) })) })), jsxRuntime.jsx("div", __assign({ className: "bunny-flex-1 bunny-w-1/2" }, { children: jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Country", name: "billingCountry", rules: [{ required: true, message: 'Country is required' }] }, { children: jsxRuntime.jsx(antd.Select, { className: "bunny-w-full", options: filteredCountryList, placeholder: "Select a country", popupMatchSelectWidth: false, showSearch: true, filterOption: function (input, option) {
|
|
22987
|
+
var _a, _b;
|
|
22988
|
+
return ((_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a : '').toLowerCase().includes(input.toLowerCase()) ||
|
|
22989
|
+
((_b = option === null || option === void 0 ? void 0 : option.value) !== null && _b !== void 0 ? _b : '').toLowerCase().includes(input.toLowerCase());
|
|
22990
|
+
} }) })) }))] })), jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Email", name: "billingContactEmail", rules: [
|
|
22991
|
+
{
|
|
22992
|
+
required: true,
|
|
22993
|
+
message: 'Email is required',
|
|
22994
|
+
type: 'email',
|
|
22995
|
+
},
|
|
22996
|
+
] }, { children: jsxRuntime.jsx(antd.Input, {}) })), jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Tax ID", name: "taxNumber", tooltip: "Tax ID will be printed on quotes and invoices below the account's address", rules: [{ required: false }] }, { children: jsxRuntime.jsx(antd.Input, {}) }))] }))] })), jsxRuntime.jsx(antd.Button, __assign({ disabled: !isFormEdited || isUpdatingBillingDetails || !formIsValid, className: "bunny-w-full bunny-mt-4", type: "primary", onClick: saveBillingDetails }, { children: "Save" }))] })) })));
|
|
22997
|
+
}
|
|
22998
|
+
|
|
22999
|
+
var BillingDetails = function (_a) {
|
|
23000
|
+
var className = _a.className, countryListFilter = _a.countryListFilter, _b = _a.hideBillingDetailsForm, hideBillingDetailsForm = _b === void 0 ? false : _b, _c = _a.hidePaymentMethodForm, hidePaymentMethodForm = _c === void 0 ? false : _c, _d = _a.isCardEnabled, isCardEnabled = _d === void 0 ? true : _d, _e = _a.isUpgradeFromTrial, isUpgradeFromTrial = _e === void 0 ? false : _e, _f = _a.shadow, shadow = _f === void 0 ? 'shadow-md' : _f, onSavePaymentMethod = _a.onSavePaymentMethod;
|
|
23001
|
+
// Hooks
|
|
23002
|
+
var isMobile = common.useIsMobile();
|
|
23003
|
+
return (jsxRuntime.jsx(WrapperComponent, __assign({ isCardEnabled: isCardEnabled, shadow: shadow, className: className }, { children: jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-py-2 bunny-my-2 ".concat(isMobile ? 'bunny-flex-col bunny-space-y-4' : 'bunny-flex-row', " bunny-gap-4") }, { children: [!hideBillingDetailsForm ? (jsxRuntime.jsx(BillingDetailsSection, { hidePaymentMethodForm: hidePaymentMethodForm, countryListFilter: countryListFilter })) : null, !hideBillingDetailsForm && !hidePaymentMethodForm ? jsxRuntime.jsx(ResponsiveDivider, {}) : null, !hidePaymentMethodForm ? (jsxRuntime.jsx(PaymentFormSection, { hideBillingDetailsForm: hideBillingDetailsForm, isUpgradeFromTrial: isUpgradeFromTrial, onSavePaymentMethod: onSavePaymentMethod })) : null] })) })));
|
|
23004
|
+
};
|
|
23005
|
+
var WrapperComponent = function (_a) {
|
|
23006
|
+
var children = _a.children, isCardEnabled = _a.isCardEnabled, shadow = _a.shadow, className = _a.className;
|
|
23007
|
+
return (jsxRuntime.jsx("div", __assign({ className: "".concat(className) }, { children: isCardEnabled ? jsxRuntime.jsx(Card, __assign({ className: "".concat(shadow) }, { children: children })) : jsxRuntime.jsx("div", { children: children }) })));
|
|
23008
|
+
};
|
|
23009
|
+
var ResponsiveDivider = function () {
|
|
23010
|
+
var isMobile = common.useIsMobile();
|
|
23011
|
+
return isMobile ? (jsxRuntime.jsx("div", __assign({ className: "bunny-mx-4" }, { children: jsxRuntime.jsx(antd.Divider, {}) }))) : (jsxRuntime.jsx("div", { children: jsxRuntime.jsx(antd.Divider, { className: "bunny-h-full", type: "vertical" }) }));
|
|
23012
|
+
};
|
|
23013
|
+
var PaymentFormSection = function (_a) {
|
|
23014
|
+
var hideBillingDetailsForm = _a.hideBillingDetailsForm, isUpgradeFromTrial = _a.isUpgradeFromTrial, onSavePaymentMethod = _a.onSavePaymentMethod;
|
|
23015
|
+
var isMobile = common.useIsMobile();
|
|
23016
|
+
var onTokenExpired = react.useContext(BunnyContext).onTokenExpired;
|
|
23017
|
+
var handleAllErrorFormats = common.useAllErrorFormats(onTokenExpired);
|
|
23018
|
+
var showSuccessNotification = common.useSuccessNotification();
|
|
23019
|
+
var entityId = useCurrentUserData().entityId;
|
|
23020
|
+
return (jsxRuntime.jsx("div", __assign({ className: "".concat(isMobile || hideBillingDetailsForm ? 'bunny-w-full' : 'bunny-w-1/2 bunny-pt-4', " bunny-flex bunny-justify-center") }, { children: jsxRuntime.jsx(PaymentForm, { entityId: entityId, onFail: function (error) {
|
|
23021
|
+
handleAllErrorFormats(error);
|
|
23022
|
+
}, onSavePaymentMethod: function () {
|
|
23023
|
+
showSuccessNotification(isUpgradeFromTrial
|
|
23024
|
+
? 'Payment method saved! Your trial will automatically convert to a paid subscription.'
|
|
23025
|
+
: 'Payment method saved successfully!');
|
|
23026
|
+
onSavePaymentMethod === null || onSavePaymentMethod === void 0 ? void 0 : onSavePaymentMethod();
|
|
23027
|
+
} }) })));
|
|
23028
|
+
};
|
|
23029
|
+
|
|
23030
|
+
var UpgradeFromTrial = function (_a) {
|
|
23031
|
+
var onClose = _a.onClose, open = _a.open;
|
|
23032
|
+
return (jsxRuntime.jsx(antd.Modal, __assign({ width: '80vw', open: open, onCancel: onClose, footer: null }, { children: jsxRuntime.jsx(BillingDetails, { isUpgradeFromTrial: true, onSavePaymentMethod: onClose }) })));
|
|
23033
|
+
};
|
|
23034
|
+
|
|
23035
|
+
var SubscriptionCardActions = function (_a) {
|
|
23036
|
+
var _b;
|
|
23037
|
+
var onChangePlanClick = _a.onChangePlanClick, onCancelSubscriptionClick = _a.onCancelSubscriptionClick, priceListChangeOptions = _a.priceListChangeOptions, subscription = _a.subscription;
|
|
23038
|
+
var apiHost = react.useContext(BunnyContext).apiHost;
|
|
23039
|
+
var token = useToken();
|
|
23040
|
+
var _c = usePaymentMethod({
|
|
23041
|
+
accountId: subscription.accountId,
|
|
23042
|
+
token: token,
|
|
23043
|
+
apiHost: apiHost,
|
|
23044
|
+
}), storedPaymentMethods = _c.paymentMethods, isPaymentMethodLoading = _c.isLoading;
|
|
23045
|
+
// Local state
|
|
23046
|
+
var _d = react.useState(false), isUpgradeFromTrialModalOpen = _d[0], setIsUpgradeFromTrialModalOpen = _d[1];
|
|
23047
|
+
// Derived state
|
|
23048
|
+
var isSelfServiceCancelable = subscription.plan.selfServiceCancel;
|
|
23049
|
+
var productPlans = (_b = priceListChangeOptions === null || priceListChangeOptions === void 0 ? void 0 : priceListChangeOptions.priceLists) === null || _b === void 0 ? void 0 : _b.filter(function (priceList) { return priceList.product.id === subscription.product.id; });
|
|
23050
|
+
var arePlansAvailable = ((productPlans === null || productPlans === void 0 ? void 0 : productPlans.length) || 0) > 0;
|
|
23051
|
+
var isInTrial = isSubscriptionTrial(subscription);
|
|
23052
|
+
var isActiveOrPending = isSubscriptionActiveOrPending(subscription);
|
|
23053
|
+
if (isPaymentMethodLoading)
|
|
23054
|
+
return null;
|
|
23055
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [isSelfServiceCancelable && (isInTrial || isActiveOrPending) && (jsxRuntime.jsx(antd.Popconfirm, __assign({ icon: null, onConfirm: function () { return onCancelSubscriptionClick === null || onCancelSubscriptionClick === void 0 ? void 0 : onCancelSubscriptionClick(subscription); }, title: "Cancel subscription" }, { children: jsxRuntime.jsx(antd.Button, __assign({ className: "bunny-p-0", type: "link" }, { children: "Cancel subscription" })) }))), isInTrial && !(storedPaymentMethods === null || storedPaymentMethods === void 0 ? void 0 : storedPaymentMethods.length) && (jsxRuntime.jsx(antd.Button, __assign({ onClick: function () { return setIsUpgradeFromTrialModalOpen(true); }, type: "primary" }, { children: "Upgrade from trial" }))), arePlansAvailable && (isInTrial || isActiveOrPending) && (jsxRuntime.jsx(antd.Button, __assign({ onClick: function () { return onChangePlanClick(subscription); }, type: isInTrial ? 'default' : 'primary' }, { children: "Change plan" }))), jsxRuntime.jsx(UpgradeFromTrial, { onClose: function () { return setIsUpgradeFromTrialModalOpen(false); }, open: isUpgradeFromTrialModalOpen })] }));
|
|
23056
|
+
};
|
|
23057
|
+
|
|
23058
|
+
var Text$6 = antd.Typography.Text;
|
|
23059
|
+
var getSubscriptionStatusText = function (subscription) {
|
|
23060
|
+
var cancellationDate = subscription.cancellationDate, state = subscription.state, evergreen = subscription.evergreen, endDate = subscription.endDate;
|
|
23061
|
+
if (cancellationDate &&
|
|
23062
|
+
(state === null || state === void 0 ? void 0 : state.toUpperCase()) !== common.SubscriptionState.CANCELED &&
|
|
23063
|
+
(state === null || state === void 0 ? void 0 : state.toUpperCase()) !== common.SubscriptionState.EXPIRED) {
|
|
23064
|
+
return (jsxRuntime.jsxs(CustomizedTag, __assign({ color: "red" }, { children: ["Canceled - ends on ", common.formatDate(cancellationDate)] })));
|
|
23065
|
+
}
|
|
23066
|
+
if (evergreen) {
|
|
23067
|
+
return "Renews on ".concat(common.formatDate(endDate));
|
|
23068
|
+
}
|
|
23069
|
+
if ((state === null || state === void 0 ? void 0 : state.toUpperCase()) === common.SubscriptionState.CANCELED ||
|
|
23070
|
+
(state === null || state === void 0 ? void 0 : state.toUpperCase()) === common.SubscriptionState.EXPIRED) {
|
|
23071
|
+
return "Ended on ".concat(common.formatDate(endDate));
|
|
22904
23072
|
}
|
|
22905
23073
|
return "Ends on ".concat(common.formatDate(endDate));
|
|
22906
23074
|
};
|
|
@@ -22916,7 +23084,7 @@ var SubscriptionCardHeader = function (_a) {
|
|
|
22916
23084
|
var isTrial = ((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === common.SubscriptionState.TRIAL;
|
|
22917
23085
|
return (jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-items-center bunny-justify-between", style: {
|
|
22918
23086
|
backgroundColor: darkMode ? 'var(--row-background-dark)' : '',
|
|
22919
|
-
} }, { children: [jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-2" }, { children: [((_c = subscription === null || subscription === void 0 ? void 0 : subscription.product) === null || _c === void 0 ? void 0 : _c.name) && (jsxRuntime.jsx(Text$
|
|
23087
|
+
} }, { children: [jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-2" }, { children: [((_c = subscription === null || subscription === void 0 ? void 0 : subscription.product) === null || _c === void 0 ? void 0 : _c.name) && (jsxRuntime.jsx(Text$6, __assign({ style: __assign({ fontSize: '11px', fontWeight: 500, color: brandColor }, subscriptionProductNameStyle) }, { children: (_d = subscription.product.name) === null || _d === void 0 ? void 0 : _d.toUpperCase() }))), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-grow bunny-items-center bunny-gap-2" }, { children: [((_e = subscription === null || subscription === void 0 ? void 0 : subscription.plan) === null || _e === void 0 ? void 0 : _e.name) && (jsxRuntime.jsx(Text$6, __assign({ className: "bunny-text-lg" }, { children: subscription.plan.name }))), jsxRuntime.jsxs(CustomizedTag, __assign({ color: common.TAG_COLORS[(_f = subscription.state) === null || _f === void 0 ? void 0 : _f.toUpperCase()] }, { children: [lodashExports.capitalize(subscription.state.toLowerCase()), isTrial ? " (".concat(trialDaysLeft || 'N/A', " days left)") : ''] }))] }))] })), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-items-center bunny-gap-6" }, { children: [jsxRuntime.jsx(Text$6, __assign({ className: "bunny-grow bunny-text-xs" }, { children: getSubscriptionStatusText(subscription) })), !isMobile && priceListChangeOptions && onChangePlanClick && onCancelSubscriptionClick && (jsxRuntime.jsx(SubscriptionCardActions, { onChangePlanClick: onChangePlanClick, onCancelSubscriptionClick: onCancelSubscriptionClick, priceListChangeOptions: priceListChangeOptions, subscription: subscription }))] }))] })));
|
|
22920
23088
|
};
|
|
22921
23089
|
|
|
22922
23090
|
var SubscriptionChargeTotal = function (_a) {
|
|
@@ -22993,16 +23161,16 @@ var SubscriptionChargeUnitPrice = function (_a) {
|
|
|
22993
23161
|
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: hasPriceTiers(charge) ? (jsxRuntime.jsx(TieredDisplayDropdown, { charge: charge, currencyId: currencyId, truncatedText: "".concat(charge.kind === common.QuoteChangeKind.PRICE_UPDATE ? 'new ' : '').concat(getApplicablePriceTier(charge, currencyId, charge.priceDecimals)) })) : isChargeDiscount ? ("-".concat(price)) : (price) }));
|
|
22994
23162
|
};
|
|
22995
23163
|
|
|
22996
|
-
var Text$
|
|
23164
|
+
var Text$5 = antd.Typography.Text;
|
|
22997
23165
|
var SubscriptionCardColumnHeaders = function (_a) {
|
|
22998
23166
|
var columns = _a.columns;
|
|
22999
|
-
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: columns.map(function (subscriptionColumn, index) { return (jsxRuntime.jsx(Text$
|
|
23167
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: columns.map(function (subscriptionColumn, index) { return (jsxRuntime.jsx(Text$5, __assign({ className: "bunny-text-slate-400 ".concat(subscriptionColumn.className), style: { fontSize: "11px" } }, { children: subscriptionColumn.title }), index)); }) }));
|
|
23000
23168
|
};
|
|
23001
23169
|
|
|
23002
|
-
var Text$
|
|
23170
|
+
var Text$4 = antd.Typography.Text;
|
|
23003
23171
|
var SubscriptionsListCell = function (_a) {
|
|
23004
23172
|
var children = _a.children, className = _a.className, gridColumn = _a.gridColumn, right = _a.right, style = _a.style;
|
|
23005
|
-
return (jsxRuntime.jsx(Text$
|
|
23173
|
+
return (jsxRuntime.jsx(Text$4, __assign({ className: "bunny-flex bunny-items-center bunny-text-sm bunny-whitespace-nowrap ".concat(className), style: __assign({ gridColumn: gridColumn, textAlign: right ? "right" : "left", justifyContent: right ? "flex-end" : "flex-start" }, style) }, { children: children })));
|
|
23006
23174
|
};
|
|
23007
23175
|
|
|
23008
23176
|
var CARD_COLUMNS = [
|
|
@@ -23062,9 +23230,11 @@ var SubscriptionCardDesktopRow = function (_a) {
|
|
|
23062
23230
|
var chargePeriod = "".concat(common.formatDate(charge.startDate), " - ").concat(common.formatDate(charge.endDate));
|
|
23063
23231
|
// Queries
|
|
23064
23232
|
var data = reactQuery.useQuery({
|
|
23065
|
-
queryKey: ['getFeatureUsage', charge.id],
|
|
23233
|
+
queryKey: ['getFeatureUsage', charge.id, charge.startDate, charge.endDate],
|
|
23066
23234
|
queryFn: function () {
|
|
23067
23235
|
return getFeatureUsage({
|
|
23236
|
+
endDate: charge.endDate,
|
|
23237
|
+
startDate: charge.startDate,
|
|
23068
23238
|
subscriptionChargeId: charge.id,
|
|
23069
23239
|
token: token,
|
|
23070
23240
|
apiHost: apiHost,
|
|
@@ -23088,10 +23258,10 @@ var SubscriptionCardDesktopRow = function (_a) {
|
|
|
23088
23258
|
: (_c = charge.quantity) === null || _c === void 0 ? void 0 : _c.toLocaleString() })), jsxRuntime.jsx(SubscriptionsListCell, __assign({ right: true }, { children: jsxRuntime.jsx(SubscriptionChargeUnitPrice, { charge: charge, currencyId: subscription.currencyId }) })), jsxRuntime.jsx(SubscriptionsListCell, __assign({ right: true }, { children: jsxRuntime.jsx(SubscriptionChargeTotal, { charge: charge, subscription: subscription }) }))] })));
|
|
23089
23259
|
};
|
|
23090
23260
|
|
|
23091
|
-
var Text$
|
|
23261
|
+
var Text$3 = antd.Typography.Text;
|
|
23092
23262
|
var SubscriptionCardCellMobile = function (_a) {
|
|
23093
23263
|
var children = _a.children, className = _a.className, style = _a.style;
|
|
23094
|
-
return (jsxRuntime.jsx(Text$
|
|
23264
|
+
return (jsxRuntime.jsx(Text$3, __assign({ className: className, style: style }, { children: children })));
|
|
23095
23265
|
};
|
|
23096
23266
|
|
|
23097
23267
|
var CHARGE_COLUMNS = [
|
|
@@ -23157,13 +23327,10 @@ var SubscriptionsListContainer = function (_a) {
|
|
|
23157
23327
|
var apiHost = react.useContext(BunnyContext).apiHost;
|
|
23158
23328
|
var gap = react.useContext(SubscriptionsContext).gap;
|
|
23159
23329
|
var token = useToken();
|
|
23160
|
-
var account = useCurrentUserData(token).account;
|
|
23161
23330
|
// Queries
|
|
23162
23331
|
var _c = reactQuery.useQuery({
|
|
23163
23332
|
queryKey: common.QueryKeyFactory.default.planChangeOptionsKey({ token: token }),
|
|
23164
|
-
queryFn: function () {
|
|
23165
|
-
return getPriceListChangeOptions({ apiHost: apiHost, token: token, accountCurrencyId: account === null || account === void 0 ? void 0 : account.currencyId });
|
|
23166
|
-
},
|
|
23333
|
+
queryFn: function () { return getPriceListChangeOptions({ apiHost: apiHost, token: token }); },
|
|
23167
23334
|
enabled: Boolean(onChangePlanClick),
|
|
23168
23335
|
}), priceListChangeOptions = _c.data, arePriceListChangeOptionsLoading = _c.isLoading;
|
|
23169
23336
|
if (subscriptionsAreLoading ||
|
|
@@ -23172,10 +23339,10 @@ var SubscriptionsListContainer = function (_a) {
|
|
|
23172
23339
|
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: (subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.length) > 0 ? (jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-".concat(gap, " bunny-shrink bunny-overflow-auto") }, { children: jsxRuntime.jsx(SubscriptionsList, { hideExpired: hideExpired, onChangePlanClick: onChangePlanClick, onCancelSubscriptionClick: onCancelSubscriptionClick, priceListChangeOptions: priceListChangeOptions, subscriptions: subscriptions }) }))) : (noSubscriptionsComponent || (jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-flex-col bunny-items-center bunny-w-full" }, { children: jsxRuntime.jsx(ErrorView, { message: "You have no subscriptions with ".concat(companyName, " yet") }) })))) }));
|
|
23173
23340
|
};
|
|
23174
23341
|
|
|
23175
|
-
var Text$
|
|
23342
|
+
var Text$2 = antd.Typography.Text;
|
|
23176
23343
|
var DrawerHeader = function (_a) {
|
|
23177
23344
|
var description = _a.description, onClose = _a.onClose, title = _a.title, closeButtonClassName = _a.closeButtonClassName;
|
|
23178
|
-
return (jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4" }, { children: [jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-items-center bunny-justify-between bunny-gap-2" }, { children: [jsxRuntime.jsx(Text$
|
|
23345
|
+
return (jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4" }, { children: [jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-items-center bunny-justify-between bunny-gap-2" }, { children: [jsxRuntime.jsx(Text$2, __assign({ className: "bunny-text-xl", style: { fontWeight: 400 } }, { children: title })), onClose ? (jsxRuntime.jsx("button", __assign({ id: "closePayment", onClick: onClose, className: closeButtonClassName }, { children: jsxRuntime.jsx(icons.CloseOutlined, {}) }))) : null] })), description && jsxRuntime.jsx("div", __assign({ className: "bunny-text-xs" }, { children: description }))] })));
|
|
23179
23346
|
};
|
|
23180
23347
|
|
|
23181
23348
|
var formatDateForApi = function (date) {
|
|
@@ -23358,13 +23525,13 @@ var QuantityInput = function (_a) {
|
|
|
23358
23525
|
}, status: isQuantityLowerThanOriginal(charge.quantity) ? 'error' : '', style: { width: '96px' }, value: value }) }));
|
|
23359
23526
|
};
|
|
23360
23527
|
|
|
23361
|
-
var Text$
|
|
23528
|
+
var Text$1 = antd.Typography.Text;
|
|
23362
23529
|
var QuantityChangeGridRow = function (_a) {
|
|
23363
23530
|
var _b;
|
|
23364
23531
|
var chargeIndex = _a.chargeIndex, editingQuote = _a.editingQuote, subscriptions = _a.subscriptions, subscriptionIndex = _a.subscriptionIndex, setEditingQuoteData = _a.setEditingQuoteData, subscription = _a.subscription, subscriptionCharge = _a.subscriptionCharge;
|
|
23365
23532
|
if (!canShowQuantitiesInput(subscriptionCharge, subscription))
|
|
23366
23533
|
return null;
|
|
23367
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Text$
|
|
23534
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Text$1, __assign({ className: "bunny-font-medium bunny-text-orange-600 bunny-col-span-full", style: { fontSize: "11px" } }, { children: subscription.plan.name })), jsxRuntime.jsx(Text$1, __assign({ className: "bunny-font-medium bunny-text-base bunny-text-gray-900" }, { children: (_b = subscriptionCharge.name) === null || _b === void 0 ? void 0 : _b.toUpperCase() })), jsxRuntime.jsx(Text$1, __assign({ className: "bunny-flex bunny-items-center bunny-justify-end bunny-font-medium bunny-text-base bunny-text-gray-900" }, { children: subscriptionCharge.quantity })), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-items-end" }, { children: [jsxRuntime.jsx(QuantityInput, { charge: subscriptionCharge, chargeIndex: chargeIndex, editingQuote: editingQuote, setEditingQuoteData: setEditingQuoteData, subscription: subscription, subscriptionIndex: subscriptionIndex, subscriptions: subscriptions }), jsxRuntime.jsx("div", {})] })), jsxRuntime.jsx(antd.Divider, { className: "bunny-col-span-full bunny-my-2" })] }));
|
|
23368
23535
|
};
|
|
23369
23536
|
|
|
23370
23537
|
var QuantityChangeGridTitle = function (_a) {
|
|
@@ -23475,7 +23642,7 @@ var SubscriptionsNavigation = function (_a) {
|
|
|
23475
23642
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!isMobile && expiredSwitchVisible && (jsxRuntime.jsx(HideExpiredToggle, { hideExpired: hideExpired, setHideExpired: setHideExpired })), jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-grow bunny-gap-2 ".concat(isMobile ? 'bunny-flex-col' : 'bunny-justify-end') }, { children: canShowChangeQuantitiesButton && (jsxRuntime.jsx(ChangeQuantitiesButton, { canShowChangeQuantitiesButton: canShowChangeQuantitiesButton, setQuantityDrawerOpen: setQuantityDrawerOpen })) }))] }));
|
|
23476
23643
|
};
|
|
23477
23644
|
|
|
23478
|
-
var Text
|
|
23645
|
+
var Text = antd.Typography.Text;
|
|
23479
23646
|
var SubscriptionsWrapper = function (_a) {
|
|
23480
23647
|
var handlePortalErrors = _a.handlePortalErrors, companyName = _a.companyName, _b = _a.isInPreviewMode, isInPreviewMode = _b === void 0 ? false : _b, productId = _a.productId, className = _a.className, _c = _a.styles, userStyles = _c === void 0 ? {} : _c, noSubscriptionsComponent = _a.noSubscriptionsComponent, _d = _a.hideTitle, hideTitle = _d === void 0 ? false : _d, hideExpired = _a.hideExpired, _e = _a.hideExpiredToggle, hideExpiredToggle = _e === void 0 ? false : _e;
|
|
23481
23648
|
var defaultStyles = {
|
|
@@ -23634,7 +23801,7 @@ var Subscriptions = function (_a) {
|
|
|
23634
23801
|
setIsChangingPlan(false);
|
|
23635
23802
|
}, handlePortalErrors: handlePortalErrors }));
|
|
23636
23803
|
}
|
|
23637
|
-
return (jsxRuntime.jsxs("div", __assign({ className: className }, { children: [!hideTitle ? jsxRuntime.jsx(PageTitle, { title: 'Subscriptions' }) : null, jsxRuntime.jsx(PageHeaderWithActions, __assign({ title: jsxRuntime.jsx(jsxRuntime.Fragment, { children: !hideExpiredToggle && (jsxRuntime.jsxs(Text
|
|
23804
|
+
return (jsxRuntime.jsxs("div", __assign({ className: className }, { children: [!hideTitle ? jsxRuntime.jsx(PageTitle, { title: 'Subscriptions' }) : null, jsxRuntime.jsx(PageHeaderWithActions, __assign({ title: jsxRuntime.jsx(jsxRuntime.Fragment, { children: !hideExpiredToggle && (jsxRuntime.jsxs(Text, __assign({ className: "bunny-flex bunny-items-center bunny-justify-between", style: { minWidth: '120px' } }, { children: [hideExpired ? 'Active subscriptions' : 'All subscriptions', isMobile && expiredSwitchVisible && (jsxRuntime.jsx(HideExpiredToggle, { hideExpired: hideExpired, setHideExpired: setHideExpiredState }))] }))) }) }, { children: !isMobile && (jsxRuntime.jsx(SubscriptionsNavigation, { expiredSwitchVisible: !hideExpiredToggle && expiredSwitchVisible, hideExpired: hideExpired, setHideExpired: setHideExpiredState, setQuantityDrawerOpen: setQuantityDrawerOpen, subscriptions: subscriptions })) })), jsxRuntime.jsx(SubscriptionsListContainer, { companyName: companyName, hideExpired: hideExpired, onCancelSubscriptionClick: onCancelSubscriptionClick, onChangePlanClick: onChangePlanClick, subscriptions: subscriptions, subscriptionsAreLoading: subscriptionsAreLoading, noSubscriptionsComponent: noSubscriptionsComponent }), isMobile && (jsxRuntime.jsx("div", __assign({ className: "bunny-pt-4 bunny-pb-2" }, { children: jsxRuntime.jsx(SubscriptionsNavigation, { expiredSwitchVisible: expiredSwitchVisible, hideExpired: hideExpired, setHideExpired: setHideExpiredState, setQuantityDrawerOpen: setQuantityDrawerOpen, subscriptions: subscriptions }) }))), jsxRuntime.jsx(QuantityChangeDrawerDesktop, { editingQuote: quote, editingQuoteData: editingQuoteData, onClose: onClose, open: quantityDrawerOpen, openCheckout: function () { return setPayModalVisible(true); }, setEditingQuoteData: setEditingQuoteData, subscriptions: subscriptions }), jsxRuntime.jsx(Checkout, { onCancel: onCancel, onSuccess: onSuccess, onFail: onFail, open: payModalVisible, quote: quote, token: token, storedPaymentMethod: defaultPaymentMethod })] })));
|
|
23638
23805
|
};
|
|
23639
23806
|
var PageHeaderWithActions = function (_a) {
|
|
23640
23807
|
var children = _a.children, title = _a.title;
|
|
@@ -23649,250 +23816,6 @@ var PageSubTitle = function (_a) {
|
|
|
23649
23816
|
return (jsxRuntime.jsx("div", __assign({ className: "bunny-shrink-0 bunny-font-medium", style: { color: secondaryColor } }, { children: title })));
|
|
23650
23817
|
};
|
|
23651
23818
|
|
|
23652
|
-
var MUTATION = "\nmutation BillingDetailsUpdate(\n $attributes: BillingDetailsAttributes!) {\n billingDetailsUpdate(\n attributes: $attributes\n ) {\n billingDetails {\n billingCity\n billingContact {\n email\n }\n billingCountry\n billingState\n billingStreet\n billingZip\n name\n taxNumber\n }\n errors\n }\n }\n";
|
|
23653
|
-
var billingDetailsUpdate = function (_a) {
|
|
23654
|
-
var attributes = _a.attributes, token = _a.token, apiHost = _a.apiHost;
|
|
23655
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
23656
|
-
var vars, response, errors;
|
|
23657
|
-
var _b;
|
|
23658
|
-
return __generator(this, function (_c) {
|
|
23659
|
-
switch (_c.label) {
|
|
23660
|
-
case 0:
|
|
23661
|
-
vars = { attributes: attributes };
|
|
23662
|
-
return [4 /*yield*/, gqlRequest({
|
|
23663
|
-
query: MUTATION,
|
|
23664
|
-
token: token,
|
|
23665
|
-
vars: vars,
|
|
23666
|
-
apiHost: apiHost,
|
|
23667
|
-
})];
|
|
23668
|
-
case 1:
|
|
23669
|
-
response = _c.sent();
|
|
23670
|
-
errors = (_b = response === null || response === void 0 ? void 0 : response.billingDetailsUpdate) === null || _b === void 0 ? void 0 : _b.errors;
|
|
23671
|
-
if (errors)
|
|
23672
|
-
throw errors;
|
|
23673
|
-
return [2 /*return*/, response.billingDetailsUpdate];
|
|
23674
|
-
}
|
|
23675
|
-
});
|
|
23676
|
-
});
|
|
23677
|
-
};
|
|
23678
|
-
|
|
23679
|
-
// TODO: move this to common
|
|
23680
|
-
var billingDetailsQuery = function () {
|
|
23681
|
-
return "\nquery BillingDetails {\n billingDetails {\n billingCity\n billingContact {\n email\n }\n billingCountry\n billingState\n billingStreet\n billingZip\n name\n taxNumber\n currency {\n id\n }\n }\n}";
|
|
23682
|
-
};
|
|
23683
|
-
var getBillingDetails = function (_a) {
|
|
23684
|
-
var token = _a.token, apiHost = _a.apiHost;
|
|
23685
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
23686
|
-
var response;
|
|
23687
|
-
var _b;
|
|
23688
|
-
return __generator(this, function (_c) {
|
|
23689
|
-
switch (_c.label) {
|
|
23690
|
-
case 0: return [4 /*yield*/, gqlRequest({
|
|
23691
|
-
query: billingDetailsQuery(),
|
|
23692
|
-
token: token,
|
|
23693
|
-
apiHost: apiHost,
|
|
23694
|
-
})];
|
|
23695
|
-
case 1:
|
|
23696
|
-
response = _c.sent();
|
|
23697
|
-
if (response === null || response === void 0 ? void 0 : response.errors) {
|
|
23698
|
-
throw new Error((_b = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _b === void 0 ? void 0 : _b.message);
|
|
23699
|
-
}
|
|
23700
|
-
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.billingDetails];
|
|
23701
|
-
}
|
|
23702
|
-
});
|
|
23703
|
-
});
|
|
23704
|
-
};
|
|
23705
|
-
|
|
23706
|
-
var Text = antd.Typography.Text;
|
|
23707
|
-
function BillingDetailsSection(_a) {
|
|
23708
|
-
var _this = this;
|
|
23709
|
-
var hidePaymentMethodForm = _a.hidePaymentMethodForm, countryListFilter = _a.countryListFilter;
|
|
23710
|
-
// State
|
|
23711
|
-
var _b = react.useState(false), isFormEdited = _b[0], setIsFormEdited = _b[1];
|
|
23712
|
-
var _c = react.useState(false), formIsValid = _c[0], setFormIsValid = _c[1];
|
|
23713
|
-
var form = antd.Form.useForm()[0];
|
|
23714
|
-
var values = antd.Form.useWatch([], form);
|
|
23715
|
-
// Context
|
|
23716
|
-
var apiHost = react.useContext(BunnyContext).apiHost;
|
|
23717
|
-
var token = useToken();
|
|
23718
|
-
// Hooks
|
|
23719
|
-
var isMobile = common.useIsMobile();
|
|
23720
|
-
var queryClient = reactQuery.useQueryClient();
|
|
23721
|
-
var showErrorNotification = common.useErrorNotification();
|
|
23722
|
-
var showSuccessNotification = common.useSuccessNotification();
|
|
23723
|
-
// Queries
|
|
23724
|
-
var _d = reactQuery.useQuery({
|
|
23725
|
-
queryKey: common.QueryKeyFactory.default.billingDetailsKey({ token: token }),
|
|
23726
|
-
queryFn: function () { return getBillingDetails({ token: token, apiHost: apiHost }); },
|
|
23727
|
-
}), billingDetails = _d.data, isLoadingBillingDetails = _d.isLoading;
|
|
23728
|
-
var _e = reactQuery.useMutation({
|
|
23729
|
-
mutationFn: function (changedFormData) { return __awaiter(_this, void 0, void 0, function () {
|
|
23730
|
-
var updatedBillingDetails;
|
|
23731
|
-
return __generator(this, function (_a) {
|
|
23732
|
-
switch (_a.label) {
|
|
23733
|
-
case 0: return [4 /*yield*/, billingDetailsUpdate({
|
|
23734
|
-
attributes: {
|
|
23735
|
-
name: changedFormData.name,
|
|
23736
|
-
billingStreet: changedFormData.billingStreet,
|
|
23737
|
-
billingCity: changedFormData.billingCity,
|
|
23738
|
-
billingZip: changedFormData.billingZip,
|
|
23739
|
-
billingState: changedFormData.billingState,
|
|
23740
|
-
billingCountry: changedFormData.billingCountry,
|
|
23741
|
-
billingContactEmail: changedFormData.billingContactEmail,
|
|
23742
|
-
taxNumber: changedFormData.taxNumber,
|
|
23743
|
-
},
|
|
23744
|
-
token: token,
|
|
23745
|
-
apiHost: apiHost,
|
|
23746
|
-
})];
|
|
23747
|
-
case 1:
|
|
23748
|
-
updatedBillingDetails = _a.sent();
|
|
23749
|
-
queryClient.setQueryData(common.QueryKeyFactory.default.billingDetailsKey({ token: token }), function (old) {
|
|
23750
|
-
return __assign(__assign({}, old), updatedBillingDetails.billingDetails);
|
|
23751
|
-
});
|
|
23752
|
-
return [2 /*return*/, updatedBillingDetails];
|
|
23753
|
-
}
|
|
23754
|
-
});
|
|
23755
|
-
}); },
|
|
23756
|
-
onSuccess: function () {
|
|
23757
|
-
showSuccessNotification('Your account details have been saved');
|
|
23758
|
-
queryClient.invalidateQueries({
|
|
23759
|
-
queryKey: common.QueryKeyFactory.default.taxationRequiredAccountFieldsKey({
|
|
23760
|
-
token: token,
|
|
23761
|
-
}),
|
|
23762
|
-
});
|
|
23763
|
-
},
|
|
23764
|
-
}), updateBillingDetails = _e.mutate, isUpdatingBillingDetails = _e.isPending;
|
|
23765
|
-
// Set form values when billing details are loaded
|
|
23766
|
-
react.useEffect(function () {
|
|
23767
|
-
var _a;
|
|
23768
|
-
if (billingDetails) {
|
|
23769
|
-
form.setFieldsValue({
|
|
23770
|
-
billingStreet: billingDetails.billingStreet,
|
|
23771
|
-
billingCity: billingDetails.billingCity,
|
|
23772
|
-
billingZip: billingDetails.billingZip,
|
|
23773
|
-
billingState: billingDetails.billingState,
|
|
23774
|
-
billingCountry: billingDetails.billingCountry,
|
|
23775
|
-
billingContactEmail: (_a = billingDetails.billingContact) === null || _a === void 0 ? void 0 : _a.email,
|
|
23776
|
-
taxNumber: billingDetails.taxNumber,
|
|
23777
|
-
});
|
|
23778
|
-
}
|
|
23779
|
-
}, [billingDetails]);
|
|
23780
|
-
react.useEffect(function () {
|
|
23781
|
-
form
|
|
23782
|
-
.validateFields({ validateOnly: true })
|
|
23783
|
-
.then(function () { return setFormIsValid(true); })
|
|
23784
|
-
.catch(function () { return setFormIsValid(false); });
|
|
23785
|
-
var isFormEdited = function () {
|
|
23786
|
-
var _a;
|
|
23787
|
-
if (!billingDetails)
|
|
23788
|
-
return false;
|
|
23789
|
-
var currentValues = form.getFieldsValue();
|
|
23790
|
-
var accountValues = {
|
|
23791
|
-
billingStreet: billingDetails.billingStreet,
|
|
23792
|
-
billingCity: billingDetails.billingCity,
|
|
23793
|
-
billingZip: billingDetails.billingZip,
|
|
23794
|
-
billingState: billingDetails.billingState,
|
|
23795
|
-
billingCountry: billingDetails.billingCountry,
|
|
23796
|
-
billingContactEmail: (_a = billingDetails.billingContact) === null || _a === void 0 ? void 0 : _a.email,
|
|
23797
|
-
taxNumber: billingDetails.taxNumber,
|
|
23798
|
-
};
|
|
23799
|
-
return Object.keys(currentValues).some(function (key) {
|
|
23800
|
-
var value = accountValues[key];
|
|
23801
|
-
return currentValues[key] !== value;
|
|
23802
|
-
});
|
|
23803
|
-
};
|
|
23804
|
-
setIsFormEdited(isFormEdited());
|
|
23805
|
-
}, [form, values, billingDetails]);
|
|
23806
|
-
// Validate form fields when isFormEdited changes
|
|
23807
|
-
react.useEffect(function () {
|
|
23808
|
-
var validateOnly = isFormEdited ? false : true;
|
|
23809
|
-
form.validateFields({ validateOnly: validateOnly });
|
|
23810
|
-
}, [isFormEdited]);
|
|
23811
|
-
var saveBillingDetails = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
23812
|
-
var _this = this;
|
|
23813
|
-
return __generator(this, function (_a) {
|
|
23814
|
-
form.validateFields({ validateOnly: false }).then(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
23815
|
-
var error_1;
|
|
23816
|
-
return __generator(this, function (_a) {
|
|
23817
|
-
switch (_a.label) {
|
|
23818
|
-
case 0:
|
|
23819
|
-
_a.trys.push([0, 2, 3, 4]);
|
|
23820
|
-
return [4 /*yield*/, form.validateFields()];
|
|
23821
|
-
case 1:
|
|
23822
|
-
_a.sent();
|
|
23823
|
-
updateBillingDetails(form.getFieldsValue());
|
|
23824
|
-
return [3 /*break*/, 4];
|
|
23825
|
-
case 2:
|
|
23826
|
-
error_1 = _a.sent();
|
|
23827
|
-
if (error_1 instanceof Error) {
|
|
23828
|
-
showErrorNotification('Failed to update account', error_1.message);
|
|
23829
|
-
}
|
|
23830
|
-
else {
|
|
23831
|
-
showErrorNotification('Please fill out all required fields');
|
|
23832
|
-
}
|
|
23833
|
-
return [3 /*break*/, 4];
|
|
23834
|
-
case 3:
|
|
23835
|
-
setIsFormEdited(false);
|
|
23836
|
-
return [7 /*endfinally*/];
|
|
23837
|
-
case 4: return [2 /*return*/];
|
|
23838
|
-
}
|
|
23839
|
-
});
|
|
23840
|
-
}); });
|
|
23841
|
-
return [2 /*return*/];
|
|
23842
|
-
});
|
|
23843
|
-
}); };
|
|
23844
|
-
var filteredCountryList = react.useMemo(function () {
|
|
23845
|
-
return countryListFilter ? common.Lists.COUNTRY_LIST.filter(countryListFilter) : common.Lists.COUNTRY_LIST;
|
|
23846
|
-
}, [countryListFilter]);
|
|
23847
|
-
return (jsxRuntime.jsx("div", __assign({ className: "".concat(isMobile || hidePaymentMethodForm ? 'bunny-w-full' : 'bunny-w-1/2') }, { children: jsxRuntime.jsxs("div", __assign({ className: "bunny-px-4" }, { children: [jsxRuntime.jsxs(antd.Skeleton, __assign({ loading: isLoadingBillingDetails }, { children: [jsxRuntime.jsx("div", __assign({ className: "bunny-mb-2" }, { children: jsxRuntime.jsx(Text, __assign({ className: "bunny-font-medium bunny-text-lg" }, { children: (billingDetails === null || billingDetails === void 0 ? void 0 : billingDetails.name) || 'No company name' })) })), jsxRuntime.jsxs(antd.Form, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-2", form: form, layout: "vertical", disabled: isUpdatingBillingDetails, autoComplete: "off" }, { children: [jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Street address", name: "billingStreet", rules: [{ required: true, message: 'Street address is required' }] }, { children: jsxRuntime.jsx(antd.Input, {}) })), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-gap-4" }, { children: [jsxRuntime.jsx(antd.Form.Item, __assign({ label: "City", name: "billingCity", rules: [{ required: true, message: 'City is required' }], className: "bunny-flex-1" }, { children: jsxRuntime.jsx(antd.Input, {}) })), jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Zipcode", name: "billingZip", rules: [{ required: true, message: 'Zipcode is required' }], className: "bunny-flex-1" }, { children: jsxRuntime.jsx(antd.Input, {}) }))] })), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex ".concat(isMobile ? 'bunny-flex-row bunny-pb-2' : 'bunny-flex-row', " bunny-gap-4") }, { children: [jsxRuntime.jsx("div", __assign({ className: "bunny-flex-1 bunny-w-1/2" }, { children: jsxRuntime.jsx(antd.Form.Item, __assign({ label: "State", name: "billingState", rules: [
|
|
23848
|
-
{
|
|
23849
|
-
required: false,
|
|
23850
|
-
},
|
|
23851
|
-
] }, { children: jsxRuntime.jsx(antd.Input, {}) })) })), jsxRuntime.jsx("div", __assign({ className: "bunny-flex-1 bunny-w-1/2" }, { children: jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Country", name: "billingCountry", rules: [{ required: true, message: 'Country is required' }] }, { children: jsxRuntime.jsx(antd.Select, { className: "bunny-w-full", options: filteredCountryList, placeholder: "Select a country", popupMatchSelectWidth: false, showSearch: true, filterOption: function (input, option) {
|
|
23852
|
-
var _a, _b;
|
|
23853
|
-
return ((_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a : '').toLowerCase().includes(input.toLowerCase()) ||
|
|
23854
|
-
((_b = option === null || option === void 0 ? void 0 : option.value) !== null && _b !== void 0 ? _b : '').toLowerCase().includes(input.toLowerCase());
|
|
23855
|
-
} }) })) }))] })), jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Email", name: "billingContactEmail", rules: [
|
|
23856
|
-
{
|
|
23857
|
-
required: true,
|
|
23858
|
-
message: 'Email is required',
|
|
23859
|
-
type: 'email',
|
|
23860
|
-
},
|
|
23861
|
-
] }, { children: jsxRuntime.jsx(antd.Input, {}) })), jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Tax ID", name: "taxNumber", tooltip: "Tax ID will be printed on quotes and invoices below the account's address", rules: [{ required: false }] }, { children: jsxRuntime.jsx(antd.Input, {}) }))] }))] })), jsxRuntime.jsx(antd.Button, __assign({ disabled: !isFormEdited || isUpdatingBillingDetails || !formIsValid, className: "bunny-w-full bunny-mt-4", type: "primary", onClick: saveBillingDetails }, { children: "Save" }))] })) })));
|
|
23862
|
-
}
|
|
23863
|
-
|
|
23864
|
-
var BillingDetails = function (_a) {
|
|
23865
|
-
var className = _a.className, countryListFilter = _a.countryListFilter, _b = _a.hideBillingDetailsForm, hideBillingDetailsForm = _b === void 0 ? false : _b, _c = _a.hidePaymentMethodForm, hidePaymentMethodForm = _c === void 0 ? false : _c, _d = _a.isCardEnabled, isCardEnabled = _d === void 0 ? true : _d, _e = _a.isUpgradeFromTrial, isUpgradeFromTrial = _e === void 0 ? false : _e, _f = _a.shadow, shadow = _f === void 0 ? 'shadow-md' : _f, onSavePaymentMethod = _a.onSavePaymentMethod;
|
|
23866
|
-
// Hooks
|
|
23867
|
-
var isMobile = common.useIsMobile();
|
|
23868
|
-
return (jsxRuntime.jsx(WrapperComponent, __assign({ isCardEnabled: isCardEnabled, shadow: shadow, className: className }, { children: jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-py-2 bunny-my-2 ".concat(isMobile ? 'bunny-flex-col bunny-space-y-4' : 'bunny-flex-row', " bunny-gap-4") }, { children: [!hideBillingDetailsForm ? (jsxRuntime.jsx(BillingDetailsSection, { hidePaymentMethodForm: hidePaymentMethodForm, countryListFilter: countryListFilter })) : null, !hideBillingDetailsForm && !hidePaymentMethodForm ? jsxRuntime.jsx(ResponsiveDivider, {}) : null, !hidePaymentMethodForm ? (jsxRuntime.jsx(PaymentFormSection, { hideBillingDetailsForm: hideBillingDetailsForm, isUpgradeFromTrial: isUpgradeFromTrial, onSavePaymentMethod: onSavePaymentMethod })) : null] })) })));
|
|
23869
|
-
};
|
|
23870
|
-
var WrapperComponent = function (_a) {
|
|
23871
|
-
var children = _a.children, isCardEnabled = _a.isCardEnabled, shadow = _a.shadow, className = _a.className;
|
|
23872
|
-
return (jsxRuntime.jsx("div", __assign({ className: "".concat(className) }, { children: isCardEnabled ? jsxRuntime.jsx(Card, __assign({ className: "".concat(shadow) }, { children: children })) : jsxRuntime.jsx("div", { children: children }) })));
|
|
23873
|
-
};
|
|
23874
|
-
var ResponsiveDivider = function () {
|
|
23875
|
-
var isMobile = common.useIsMobile();
|
|
23876
|
-
return isMobile ? (jsxRuntime.jsx("div", __assign({ className: "bunny-mx-4" }, { children: jsxRuntime.jsx(antd.Divider, {}) }))) : (jsxRuntime.jsx("div", { children: jsxRuntime.jsx(antd.Divider, { className: "bunny-h-full", type: "vertical" }) }));
|
|
23877
|
-
};
|
|
23878
|
-
var PaymentFormSection = function (_a) {
|
|
23879
|
-
var hideBillingDetailsForm = _a.hideBillingDetailsForm, isUpgradeFromTrial = _a.isUpgradeFromTrial, onSavePaymentMethod = _a.onSavePaymentMethod;
|
|
23880
|
-
var isMobile = common.useIsMobile();
|
|
23881
|
-
var onTokenExpired = react.useContext(BunnyContext).onTokenExpired;
|
|
23882
|
-
var handleAllErrorFormats = common.useAllErrorFormats(onTokenExpired);
|
|
23883
|
-
var showSuccessNotification = common.useSuccessNotification();
|
|
23884
|
-
return (jsxRuntime.jsx("div", __assign({ className: "".concat(isMobile || hideBillingDetailsForm ? 'bunny-w-full' : 'bunny-w-1/2 bunny-pt-4', " bunny-flex bunny-justify-center") }, { children: jsxRuntime.jsx(PaymentForm, { onFail: function (error) {
|
|
23885
|
-
handleAllErrorFormats(error);
|
|
23886
|
-
}, onSavePaymentMethod: function (response) {
|
|
23887
|
-
showSuccessNotification(isUpgradeFromTrial
|
|
23888
|
-
? 'Payment method saved! Your trial will automatically convert to a paid subscription.'
|
|
23889
|
-
: 'Payment method saved successfully!');
|
|
23890
|
-
// TODO: onSavePaymentMethod(response: any) should be cleaned up to have a response type (not any)
|
|
23891
|
-
// and work with both stripe and demo pay requests
|
|
23892
|
-
onSavePaymentMethod === null || onSavePaymentMethod === void 0 ? void 0 : onSavePaymentMethod(response);
|
|
23893
|
-
} }) })));
|
|
23894
|
-
};
|
|
23895
|
-
|
|
23896
23819
|
exports.BillingDetails = BillingDetails;
|
|
23897
23820
|
exports.BunnyProvider = BunnyProvider;
|
|
23898
23821
|
exports.Footer = Footer;
|