@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/esm/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Markup } from 'interweave';
|
|
|
4
4
|
import { ConfigProvider, Spin, Button, Tag, Typography, Dropdown, Input, Modal, Checkbox, Skeleton, Collapse, Form, Tooltip, Drawer, Card as Card$1, Divider, Select, Image, Radio, Space, Switch, Popconfirm, Table } from 'antd';
|
|
5
5
|
import { DownloadOutlined, CreditCardOutlined, EllipsisOutlined, BankOutlined, SearchOutlined, CheckCircleFilled, CloseOutlined, ArrowLeftOutlined, InfoCircleOutlined } from '@ant-design/icons';
|
|
6
6
|
import styled from 'styled-components';
|
|
7
|
-
import { DEFAULT_ACCENT_COLOR, DEFAULT_BRAND_COLOR, DEFAULT_SECONDARY_COLOR, DEFAULT_TOP_NAV_IMAGE_URL, gqlRequest as gqlRequest$1, createClientDevHeaders, X_BUNNY_COMPONENTS_VERSION_HEADER_NAME, QueryKeyFactory, useIsMobile, isColorTooDark, INPUT_BORDER_COLOR, SLATE_50, SLATE_400, SLATE_200, request as request$1, useErrorNotification, invokePlugin, useAllErrorFormats, formatCurrency, GRAY_500, GRAY_200, useSuccessNotification, getFormattedInvoice, PAYABLE_INVOICE_STATES, BreakpointNumbers, useGraphQLmutation, useInfoNotification, formatDate, TransactionState, SLATE_600, WHITE, TransactionKind, SLATE_500, PRIMARY_COLOR,
|
|
7
|
+
import { DEFAULT_ACCENT_COLOR, DEFAULT_BRAND_COLOR, DEFAULT_SECONDARY_COLOR, DEFAULT_TOP_NAV_IMAGE_URL, gqlRequest as gqlRequest$1, createClientDevHeaders, X_BUNNY_COMPONENTS_VERSION_HEADER_NAME, QueryKeyFactory, useIsMobile, isColorTooDark, INPUT_BORDER_COLOR, SLATE_50, SLATE_400, SLATE_200, request as request$1, useErrorNotification, invokePlugin, useAllErrorFormats, formatCurrency, GRAY_500, GRAY_200, useSuccessNotification, getFormattedInvoice, PAYABLE_INVOICE_STATES, BreakpointNumbers, useGraphQLmutation, useInfoNotification, formatDate, TransactionState, SLATE_600, WHITE, TransactionKind, SLATE_500, PRIMARY_COLOR, Lists, sortSubscriptionCharges, getAccount, StringUtils, BillingPeriod, ChargeType, SubscriptionState as SubscriptionState$2, PERIOD_LABELS, PricingStyle, PricingModel, SLATE_100, MODAL_MAX_HEIGHT, DataInterval, QuoteChangeKind, TAG_COLORS } from '@bunnyapp/common';
|
|
8
8
|
import { QueryClient, QueryClientProvider, useQuery, useQueryClient, useMutation, keepPreviousData } from '@tanstack/react-query';
|
|
9
9
|
import theme from 'antd/lib/theme/index.js';
|
|
10
10
|
import { RecoilRoot } from 'recoil';
|
|
@@ -143,7 +143,7 @@ var BrandContext = createContext({
|
|
|
143
143
|
});
|
|
144
144
|
|
|
145
145
|
// This will be replaced at build time by rollup-plugin-replace
|
|
146
|
-
var PACKAGE_VERSION = '1.
|
|
146
|
+
var PACKAGE_VERSION = '1.0.76-beta.15';
|
|
147
147
|
var createRequestHeaders = function (token) {
|
|
148
148
|
var headers = createClientDevHeaders(token);
|
|
149
149
|
// Add the components version header
|
|
@@ -419,7 +419,6 @@ var DocumentTemplatePreview = function (_a) {
|
|
|
419
419
|
URL.revokeObjectURL(url_1);
|
|
420
420
|
};
|
|
421
421
|
}
|
|
422
|
-
return undefined;
|
|
423
422
|
}, [data]);
|
|
424
423
|
if (isLoading) {
|
|
425
424
|
return (jsx("div", __assign({ className: "flex items-center justify-center h-96" }, { children: jsx(Spin, {}) })));
|
|
@@ -491,7 +490,6 @@ function LegacyDocument(_a) {
|
|
|
491
490
|
setPdfUrl(url_1);
|
|
492
491
|
return function () { return URL.revokeObjectURL(url_1); };
|
|
493
492
|
}
|
|
494
|
-
return undefined;
|
|
495
493
|
}, [pdfBlob]);
|
|
496
494
|
if (isLoading || !pdfUrl)
|
|
497
495
|
return jsx(Fragment, {});
|
|
@@ -538,7 +536,7 @@ var checkout = function (_a) {
|
|
|
538
536
|
});
|
|
539
537
|
};
|
|
540
538
|
|
|
541
|
-
var paymentMethodsQuery = function () { return "query
|
|
539
|
+
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}"); };
|
|
542
540
|
var getPaymentMethods = function (_a) {
|
|
543
541
|
var apiHost = _a.apiHost, token = _a.token, accountId = _a.accountId;
|
|
544
542
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -547,10 +545,9 @@ var getPaymentMethods = function (_a) {
|
|
|
547
545
|
return __generator(this, function (_c) {
|
|
548
546
|
switch (_c.label) {
|
|
549
547
|
case 0: return [4 /*yield*/, gqlRequest({
|
|
550
|
-
query: paymentMethodsQuery(),
|
|
548
|
+
query: paymentMethodsQuery(accountId ? "filter: \"accountId is ".concat(accountId, "\"") : ''),
|
|
551
549
|
token: token,
|
|
552
550
|
apiHost: apiHost,
|
|
553
|
-
vars: { accountId: accountId },
|
|
554
551
|
})];
|
|
555
552
|
case 1:
|
|
556
553
|
response = _c.sent();
|
|
@@ -578,11 +575,20 @@ var usePaymentMethod = function (_a) {
|
|
|
578
575
|
};
|
|
579
576
|
|
|
580
577
|
var filterPaymentPlugins = function (plugins) {
|
|
581
|
-
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'; });
|
|
578
|
+
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'; });
|
|
579
|
+
};
|
|
580
|
+
var filterPaymentPluginsByEntity = function (plugins, selectedEntityId) {
|
|
581
|
+
return plugins === null || plugins === void 0 ? void 0 : plugins.filter(function (plugin) {
|
|
582
|
+
var _a, _b;
|
|
583
|
+
return selectedEntityId === undefined ||
|
|
584
|
+
selectedEntityId === null ||
|
|
585
|
+
((_a = plugin.entities) === null || _a === void 0 ? void 0 : _a.includes(selectedEntityId)) ||
|
|
586
|
+
((_b = plugin.entities) === null || _b === void 0 ? void 0 : _b.length) === 0;
|
|
587
|
+
});
|
|
582
588
|
};
|
|
583
|
-
var MUTATION$9 = "
|
|
589
|
+
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}";
|
|
584
590
|
var getPaymentPlugins = function (_a) {
|
|
585
|
-
var apiHost = _a.apiHost, token = _a.token
|
|
591
|
+
var apiHost = _a.apiHost, token = _a.token;
|
|
586
592
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
587
593
|
var response;
|
|
588
594
|
return __generator(this, function (_b) {
|
|
@@ -593,7 +599,6 @@ var getPaymentPlugins = function (_a) {
|
|
|
593
599
|
query: MUTATION$9,
|
|
594
600
|
token: token,
|
|
595
601
|
apiHost: apiHost,
|
|
596
|
-
vars: { accountId: accountId },
|
|
597
602
|
})];
|
|
598
603
|
case 1:
|
|
599
604
|
response = _b.sent();
|
|
@@ -607,15 +612,18 @@ var getPaymentPlugins = function (_a) {
|
|
|
607
612
|
});
|
|
608
613
|
};
|
|
609
614
|
var usePaymentPlugins = function (_a) {
|
|
610
|
-
var apiHost = _a.apiHost, token = _a.token,
|
|
615
|
+
var apiHost = _a.apiHost, token = _a.token, selectedEntityId = _a.selectedEntityId;
|
|
611
616
|
var _b = useQuery({
|
|
612
617
|
queryKey: ['paymentPlugins', token],
|
|
613
|
-
queryFn: function () { return getPaymentPlugins({ apiHost: apiHost, token: token
|
|
618
|
+
queryFn: function () { return getPaymentPlugins({ apiHost: apiHost, token: token }); },
|
|
614
619
|
staleTime: 5 * 60 * 1000, // Consider data fresh for 5 minutes
|
|
615
620
|
}), paymentPlugins = _b.data, isFetched = _b.isFetched;
|
|
616
621
|
var filteredPaymentPlugins = filterPaymentPlugins(paymentPlugins);
|
|
622
|
+
var filteredPaymentPluginsByEntity = selectedEntityId
|
|
623
|
+
? filterPaymentPluginsByEntity(filteredPaymentPlugins, selectedEntityId)
|
|
624
|
+
: filteredPaymentPlugins;
|
|
617
625
|
return {
|
|
618
|
-
paymentPlugins:
|
|
626
|
+
paymentPlugins: filteredPaymentPluginsByEntity,
|
|
619
627
|
isFetched: isFetched,
|
|
620
628
|
};
|
|
621
629
|
};
|
|
@@ -18594,13 +18602,13 @@ var isCardExpired = function (expiry) {
|
|
|
18594
18602
|
var formatCardExpiry = function (cardExpiry) {
|
|
18595
18603
|
if (cardExpiry.length <= 2)
|
|
18596
18604
|
return cardExpiry;
|
|
18597
|
-
return cardExpiry.substring(0, 2) +
|
|
18605
|
+
return cardExpiry.substring(0, 2) + "/" + cardExpiry.substring(2);
|
|
18598
18606
|
};
|
|
18599
18607
|
// removes spaces from a credit card number
|
|
18600
18608
|
var unformatCardNumber = function (cardNumber) {
|
|
18601
|
-
var cardNumberArray = cardNumber.split(
|
|
18602
|
-
var unformattedCardNumberArray = cardNumberArray.filter(function (character) { return character !==
|
|
18603
|
-
return unformattedCardNumberArray.join(
|
|
18609
|
+
var cardNumberArray = cardNumber.split("");
|
|
18610
|
+
var unformattedCardNumberArray = cardNumberArray.filter(function (character) { return character !== " "; });
|
|
18611
|
+
return unformattedCardNumberArray.join("");
|
|
18604
18612
|
};
|
|
18605
18613
|
var storePayment = function (options, plugin, apiHost, accountId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
18606
18614
|
var testCreditCardNumber, testCreditCardCvc, testCreditCardExpirationDate, token, response;
|
|
@@ -18609,7 +18617,7 @@ var storePayment = function (options, plugin, apiHost, accountId) { return __awa
|
|
|
18609
18617
|
case 0:
|
|
18610
18618
|
testCreditCardNumber = options.testCreditCardNumber, testCreditCardCvc = options.testCreditCardCvc, testCreditCardExpirationDate = options.testCreditCardExpirationDate, token = options.token;
|
|
18611
18619
|
return [4 /*yield*/, invokePlugin({
|
|
18612
|
-
method:
|
|
18620
|
+
method: "store_payment_method",
|
|
18613
18621
|
plugin: plugin,
|
|
18614
18622
|
payload: {
|
|
18615
18623
|
test_credit_card_number: testCreditCardNumber,
|
|
@@ -18622,7 +18630,7 @@ var storePayment = function (options, plugin, apiHost, accountId) { return __awa
|
|
|
18622
18630
|
})];
|
|
18623
18631
|
case 1:
|
|
18624
18632
|
response = _a.sent();
|
|
18625
|
-
if ((response === null || response === void 0 ? void 0 : response.status) !==
|
|
18633
|
+
if ((response === null || response === void 0 ? void 0 : response.status) !== "success")
|
|
18626
18634
|
throw new Error(response === null || response === void 0 ? void 0 : response.message);
|
|
18627
18635
|
return [2 /*return*/, response];
|
|
18628
18636
|
}
|
|
@@ -18939,7 +18947,7 @@ var PaymentMethodDetails = function (_a) {
|
|
|
18939
18947
|
case 'StripePayment':
|
|
18940
18948
|
return (jsx(StripeForm, { onFail: onFail, onSavePaymentMethod: onSavePaymentMethod, plugin: plugin }));
|
|
18941
18949
|
case 'DemoPayPayment':
|
|
18942
|
-
return (jsx(DemoPayForm, { onFail: onFail, onSavePaymentMethod:
|
|
18950
|
+
return (jsx(DemoPayForm, { onFail: onFail, onSavePaymentMethod: onSavePaymentMethod, plugin: plugin }));
|
|
18943
18951
|
default:
|
|
18944
18952
|
console.warn('Can not find form for plugin', plugin);
|
|
18945
18953
|
return jsx(Fragment, {});
|
|
@@ -19085,7 +19093,7 @@ function useSetDefaultPaymentMethod(paymentPlugins, apiHost, token, accountId, o
|
|
|
19085
19093
|
var showErrorNotification$2 = useErrorNotification();
|
|
19086
19094
|
var PaymentForm = function (_a) {
|
|
19087
19095
|
var _b;
|
|
19088
|
-
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;
|
|
19096
|
+
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;
|
|
19089
19097
|
// Local state
|
|
19090
19098
|
var _c = useState(false), showPaymentMethodForm = _c[0], setShowPaymentMethodForm = _c[1];
|
|
19091
19099
|
// Simple hooks
|
|
@@ -19099,7 +19107,7 @@ var PaymentForm = function (_a) {
|
|
|
19099
19107
|
apiHost: apiHost,
|
|
19100
19108
|
}), storedPaymentMethods = _d.paymentMethods, defaultPaymentMethod = _d.defaultPaymentMethod, isPaymentMethodLoading = _d.isLoading;
|
|
19101
19109
|
// Complex hooks
|
|
19102
|
-
var paymentPlugins = usePaymentPlugins({ apiHost: apiHost,
|
|
19110
|
+
var paymentPlugins = usePaymentPlugins({ apiHost: apiHost, selectedEntityId: entityId, token: token }).paymentPlugins;
|
|
19103
19111
|
var selectedPaymentMethodPlugin = useMemo(function () {
|
|
19104
19112
|
// TODO: consolate PluginData and PaymentPlugin into one type. Needs to be done on API side.
|
|
19105
19113
|
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()); });
|
|
@@ -19157,14 +19165,14 @@ var PaymentForm = function (_a) {
|
|
|
19157
19165
|
setShowPaymentMethodForm(false);
|
|
19158
19166
|
onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess();
|
|
19159
19167
|
};
|
|
19160
|
-
var handleSavePaymentMethod = function (
|
|
19168
|
+
var handleSavePaymentMethod = function () {
|
|
19161
19169
|
queryClient.invalidateQueries({
|
|
19162
19170
|
queryKey: QueryKeyFactory.default.accountPaymentMethodKey({
|
|
19163
19171
|
accountId: accountId,
|
|
19164
19172
|
token: token,
|
|
19165
19173
|
}),
|
|
19166
19174
|
});
|
|
19167
|
-
onSavePaymentMethod === null || onSavePaymentMethod === void 0 ? void 0 : onSavePaymentMethod(
|
|
19175
|
+
onSavePaymentMethod === null || onSavePaymentMethod === void 0 ? void 0 : onSavePaymentMethod();
|
|
19168
19176
|
setShowPaymentMethodForm(false);
|
|
19169
19177
|
};
|
|
19170
19178
|
function handleClickAddPaymentMethod() {
|
|
@@ -19206,6 +19214,15 @@ function StripeWrapper(_a) {
|
|
|
19206
19214
|
return (jsx(Elements, __assign({ options: options, stripe: stripe }, { children: children })));
|
|
19207
19215
|
}
|
|
19208
19216
|
|
|
19217
|
+
var useCurrentUserData = function () {
|
|
19218
|
+
var queryClient = useQueryClient();
|
|
19219
|
+
var token = useToken();
|
|
19220
|
+
var currentUser = queryClient.getQueryData(QueryKeyFactory.default.currentUserKey(token));
|
|
19221
|
+
if (!currentUser)
|
|
19222
|
+
return {};
|
|
19223
|
+
return currentUser;
|
|
19224
|
+
};
|
|
19225
|
+
|
|
19209
19226
|
function Invoice(_a) {
|
|
19210
19227
|
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;
|
|
19211
19228
|
return (jsx(InvoiceQuoteContext.Provider, __assign({ value: {
|
|
@@ -19228,6 +19245,7 @@ function ActualInvoice() {
|
|
|
19228
19245
|
var _b = useContext(BunnyContext), apiHost = _b.apiHost, onTokenExpired = _b.onTokenExpired;
|
|
19229
19246
|
var _c = useContext(InvoiceQuoteContext), hideDownloadButton = _c.hideDownloadButton, onInvoiceLoaded = _c.onInvoiceLoaded;
|
|
19230
19247
|
var token = useToken();
|
|
19248
|
+
var entityId = useCurrentUserData().entityId;
|
|
19231
19249
|
// Hooks
|
|
19232
19250
|
var showSuccessNotification = useSuccessNotification();
|
|
19233
19251
|
var handleAllErrorFormats = useAllErrorFormats(onTokenExpired);
|
|
@@ -19263,12 +19281,12 @@ function ActualInvoice() {
|
|
|
19263
19281
|
}, [formattedInvoice]);
|
|
19264
19282
|
if (!formattedInvoice)
|
|
19265
19283
|
return jsx(Fragment, {});
|
|
19266
|
-
return (jsx("div", __assign({ className: "bunny-invoice-container" }, { children: jsxs("div", __assign({ className: "bunny-flex bunny-gap-6 ".concat(isMobile ? 'bunny-flex-col bunny-w-full' : '', " ").concat(className) }, { children: [formattedInvoice.isLegacy ? (jsx("div", __assign({ className: "bunny-flex bunny-justify-center bunny-w-full" }, { children: jsx(LegacyDocument, { documentUuid: formattedInvoice.uuid, documentType: "invoice" }) }))) : (invoiceQuoteViewComponent || (jsx(InvoiceQuoteView, { html: formattedInvoice.html, formattedInvoice: formattedInvoice, backButtonName: backButtonName, onBackButtonClick: onBackButtonClick }))), isInvoicePayable && (jsx("div", __assign({ className: "bunny-w-full ".concat(hideDownloadButton || formattedInvoice.isLegacy ? '' : 'pt-12') }, { children: jsx(PaymentForm, { onPaymentSuccess: onSuccess, onFail: onFail, invoice: formattedInvoice }) })))] })) })));
|
|
19284
|
+
return (jsx("div", __assign({ className: "bunny-invoice-container" }, { children: jsxs("div", __assign({ className: "bunny-flex bunny-gap-6 ".concat(isMobile ? 'bunny-flex-col bunny-w-full' : '', " ").concat(className) }, { children: [formattedInvoice.isLegacy ? (jsx("div", __assign({ className: "bunny-flex bunny-justify-center bunny-w-full" }, { children: jsx(LegacyDocument, { documentUuid: formattedInvoice.uuid, documentType: "invoice" }) }))) : (invoiceQuoteViewComponent || (jsx(InvoiceQuoteView, { html: formattedInvoice.html, formattedInvoice: formattedInvoice, backButtonName: backButtonName, onBackButtonClick: onBackButtonClick }))), isInvoicePayable && (jsx("div", __assign({ className: "bunny-w-full ".concat(hideDownloadButton || formattedInvoice.isLegacy ? '' : 'pt-12') }, { children: jsx(PaymentForm, { entityId: entityId, onPaymentSuccess: onSuccess, onFail: onFail, invoice: formattedInvoice }) })))] })) })));
|
|
19267
19285
|
}
|
|
19268
19286
|
|
|
19269
|
-
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 }"; };
|
|
19287
|
+
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 }"; };
|
|
19270
19288
|
var getFormattedQuote = function (_a) {
|
|
19271
|
-
var token = _a.token, apiHost = _a.apiHost;
|
|
19289
|
+
var id = _a.id, token = _a.token, apiHost = _a.apiHost;
|
|
19272
19290
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
19273
19291
|
var response;
|
|
19274
19292
|
return __generator(this, function (_b) {
|
|
@@ -19277,11 +19295,12 @@ var getFormattedQuote = function (_a) {
|
|
|
19277
19295
|
query: MUTATION$8(),
|
|
19278
19296
|
token: token,
|
|
19279
19297
|
apiHost: apiHost,
|
|
19298
|
+
vars: { id: id },
|
|
19280
19299
|
})];
|
|
19281
19300
|
case 1:
|
|
19282
19301
|
response = _b.sent();
|
|
19283
|
-
if (response
|
|
19284
|
-
throw new Error(response
|
|
19302
|
+
if (response === null || response === void 0 ? void 0 : response.formattedQuote.error) {
|
|
19303
|
+
throw new Error(response === null || response === void 0 ? void 0 : response.formattedQuote.error);
|
|
19285
19304
|
}
|
|
19286
19305
|
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.formattedQuote];
|
|
19287
19306
|
}
|
|
@@ -19576,9 +19595,10 @@ var PaymentHoldModal = function (_a) {
|
|
|
19576
19595
|
var visible = _a.visible, setVisible = _a.setVisible, quote = _a.quote;
|
|
19577
19596
|
var queryClient = useQueryClient();
|
|
19578
19597
|
var token = useToken();
|
|
19598
|
+
var entityId = useCurrentUserData().entityId;
|
|
19579
19599
|
return (jsxs(StyledModal$1, __assign({ centered: true, onCancel: function () {
|
|
19580
19600
|
setVisible(false);
|
|
19581
|
-
}, footer: null, open: visible, width: 600 }, { children: [jsx(Title$2, __assign({ className: "mt-4 pb-4 mx-4", level: 5 }, { children: "Pay to accept" })), jsx("div", __assign({ className: "mb-4" }, { children: jsx(PaymentForm, { quote: {
|
|
19601
|
+
}, footer: null, open: visible, width: 600 }, { children: [jsx(Title$2, __assign({ className: "mt-4 pb-4 mx-4", level: 5 }, { children: "Pay to accept" })), jsx("div", __assign({ className: "mb-4" }, { children: jsx(PaymentForm, { entityId: entityId, quote: {
|
|
19582
19602
|
amount: quote.amount,
|
|
19583
19603
|
currencyId: quote.currency,
|
|
19584
19604
|
id: quote.quote.id,
|
|
@@ -19641,10 +19661,18 @@ function ActualQuote() {
|
|
|
19641
19661
|
var _f = useQuery({
|
|
19642
19662
|
queryKey: QueryKeyFactory.default.createQuoteKey({ id: id, token: token }),
|
|
19643
19663
|
queryFn: function () { return __awaiter(_this, void 0, void 0, function () {
|
|
19664
|
+
var error_1;
|
|
19644
19665
|
return __generator(this, function (_a) {
|
|
19645
19666
|
switch (_a.label) {
|
|
19646
|
-
case 0:
|
|
19667
|
+
case 0:
|
|
19668
|
+
_a.trys.push([0, 2, , 3]);
|
|
19669
|
+
return [4 /*yield*/, getFormattedQuote({ token: token, apiHost: apiHost, id: id })];
|
|
19647
19670
|
case 1: return [2 /*return*/, _a.sent()];
|
|
19671
|
+
case 2:
|
|
19672
|
+
error_1 = _a.sent();
|
|
19673
|
+
showErrorNotification(error_1.message);
|
|
19674
|
+
return [3 /*break*/, 3];
|
|
19675
|
+
case 3: return [2 /*return*/];
|
|
19648
19676
|
}
|
|
19649
19677
|
});
|
|
19650
19678
|
}); },
|
|
@@ -19659,6 +19687,7 @@ function ActualQuote() {
|
|
|
19659
19687
|
}), 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;
|
|
19660
19688
|
useSigningComplete({ data: formattedQuote, token: token });
|
|
19661
19689
|
var isMobile = useIsMobile();
|
|
19690
|
+
var showErrorNotification = useErrorNotification();
|
|
19662
19691
|
useEffect(function () {
|
|
19663
19692
|
if (formattedQuote) {
|
|
19664
19693
|
onQuoteLoaded === null || onQuoteLoaded === void 0 ? void 0 : onQuoteLoaded(formattedQuote);
|
|
@@ -19978,7 +20007,7 @@ function Transactions(_a) {
|
|
|
19978
20007
|
function TransactionsDisplay(_a) {
|
|
19979
20008
|
var _b, _c;
|
|
19980
20009
|
var transactions = _a.transactions, onSearchValueChanged = _a.onSearchValueChanged, search = _a.search;
|
|
19981
|
-
var _d = 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;
|
|
20010
|
+
var _d = 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;
|
|
19982
20011
|
var columns = useContext(TransactionsListContext).columns;
|
|
19983
20012
|
var darkMode = useContext(BunnyContext).darkMode;
|
|
19984
20013
|
var secondaryColor = useContext(BrandContext).secondaryColor;
|
|
@@ -20272,7 +20301,7 @@ var getPriceList = function (_a) {
|
|
|
20272
20301
|
});
|
|
20273
20302
|
};
|
|
20274
20303
|
|
|
20275
|
-
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
|
|
20304
|
+
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 }"); };
|
|
20276
20305
|
var getQuote = function (_a) {
|
|
20277
20306
|
var id = _a.id, token = _a.token, apiHost = _a.apiHost;
|
|
20278
20307
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -20427,44 +20456,6 @@ var useUpdateCoupons = function (_a) {
|
|
|
20427
20456
|
};
|
|
20428
20457
|
};
|
|
20429
20458
|
|
|
20430
|
-
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 }";
|
|
20431
|
-
var getCurrentUserData = function (_a) {
|
|
20432
|
-
var token = _a.token, apiHost = _a.apiHost;
|
|
20433
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
20434
|
-
var response;
|
|
20435
|
-
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
20436
|
-
return __generator(this, function (_k) {
|
|
20437
|
-
switch (_k.label) {
|
|
20438
|
-
case 0: return [4 /*yield*/, gqlRequest$1({
|
|
20439
|
-
query: CURRENT_USER_DATA_QUERY,
|
|
20440
|
-
token: token,
|
|
20441
|
-
apiHost: apiHost,
|
|
20442
|
-
})];
|
|
20443
|
-
case 1:
|
|
20444
|
-
response = _k.sent();
|
|
20445
|
-
return [2 /*return*/, {
|
|
20446
|
-
authObjectName: (_b = response === null || response === void 0 ? void 0 : response.currentUser) === null || _b === void 0 ? void 0 : _b.authObjectName,
|
|
20447
|
-
account: (_c = response === null || response === void 0 ? void 0 : response.currentUser) === null || _c === void 0 ? void 0 : _c.account,
|
|
20448
|
-
companyName: (_d = response === null || response === void 0 ? void 0 : response.company) === null || _d === void 0 ? void 0 : _d.name,
|
|
20449
|
-
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,
|
|
20450
|
-
privacyUrl: (_g = response === null || response === void 0 ? void 0 : response.currentUser) === null || _g === void 0 ? void 0 : _g.privacyUrl,
|
|
20451
|
-
termsUrl: (_h = response === null || response === void 0 ? void 0 : response.currentUser) === null || _h === void 0 ? void 0 : _h.termsUrl,
|
|
20452
|
-
entityId: (_j = response === null || response === void 0 ? void 0 : response.currentUser) === null || _j === void 0 ? void 0 : _j.entityId,
|
|
20453
|
-
}];
|
|
20454
|
-
}
|
|
20455
|
-
});
|
|
20456
|
-
});
|
|
20457
|
-
};
|
|
20458
|
-
|
|
20459
|
-
var useCurrentUserData = function (token) {
|
|
20460
|
-
var apiHost = useContext(BunnyContext).apiHost;
|
|
20461
|
-
var currentUserData = useQuery({
|
|
20462
|
-
queryKey: QueryKeyFactory.default.currentUserKey(token),
|
|
20463
|
-
queryFn: function () { return getCurrentUserData({ token: token, apiHost: apiHost }); },
|
|
20464
|
-
}).data;
|
|
20465
|
-
return currentUserData || {};
|
|
20466
|
-
};
|
|
20467
|
-
|
|
20468
20459
|
var BunnyFooterIcon = function (_a) {
|
|
20469
20460
|
var color = _a.color;
|
|
20470
20461
|
return (jsxs("svg", __assign({ width: "45", height: "15", viewBox: "0 0 39 13", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [jsxs("g", __assign({ clipPath: "url(#clip0_6_851)" }, { children: [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 }), 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 }), 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 }), 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 }), 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 }), 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 })] })), jsx("defs", { children: jsx("clipPath", __assign({ id: "clip0_6_851" }, { children: jsx("rect", { width: "39", height: "13", fill: "white" }) })) })] })));
|
|
@@ -20486,22 +20477,6 @@ var StyedLink = styled.a(templateObject_1$5 || (templateObject_1$5 = __makeTempl
|
|
|
20486
20477
|
var StyledBunnyLink = styled(StyedLink)(templateObject_2$1 || (templateObject_2$1 = __makeTemplateObject(["\n &:hover {\n color: ", " !important;\n }\n"], ["\n &:hover {\n color: ", " !important;\n }\n"])), PRIMARY_COLOR);
|
|
20487
20478
|
var templateObject_1$5, templateObject_2$1;
|
|
20488
20479
|
|
|
20489
|
-
function shouldShowCouponEditor(quote, activeCouponsExist, upgradingSubscription) {
|
|
20490
|
-
var _a;
|
|
20491
|
-
var upgradingFromTrial = ((_a = upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === SubscriptionState$2.TRIAL;
|
|
20492
|
-
function upgradingFromFree() {
|
|
20493
|
-
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);
|
|
20494
|
-
return totalPrice === 0;
|
|
20495
|
-
}
|
|
20496
|
-
if (quote.kind === QuoteChangeKind.SUBSCRIBE) {
|
|
20497
|
-
return activeCouponsExist;
|
|
20498
|
-
}
|
|
20499
|
-
else if (quote.kind === QuoteChangeKind.ADJUSTMENT) {
|
|
20500
|
-
return activeCouponsExist && (upgradingFromTrial || upgradingFromFree());
|
|
20501
|
-
}
|
|
20502
|
-
return false;
|
|
20503
|
-
}
|
|
20504
|
-
|
|
20505
20480
|
function CouponEditor(_a) {
|
|
20506
20481
|
var className = _a.className, onAddCoupon = _a.onAddCoupon, isAddingCoupon = _a.isAddingCoupon, couponCode = _a.couponCode, setCouponCode = _a.setCouponCode;
|
|
20507
20482
|
function handleAddCoupon() {
|
|
@@ -20515,12 +20490,9 @@ function CouponEditor(_a) {
|
|
|
20515
20490
|
return (jsx("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-2 ".concat(className) }, { children: jsxs("div", __assign({ className: "bunny-flex bunny-flex-row bunny-gap-2" }, { children: [jsx(Input, { value: couponCode, onChange: function (e) { return setCouponCode(e.target.value); }, placeholder: "Coupon code", disabled: isAddingCoupon, size: "small" }), jsx(Button, __assign({ loading: isAddingCoupon, type: "primary", onClick: handleAddCoupon, disabled: couponCode.length === 0 }, { children: "Apply" }))] })) })));
|
|
20516
20491
|
}
|
|
20517
20492
|
|
|
20518
|
-
var SubscriptionsContext = createContext({});
|
|
20519
|
-
|
|
20520
20493
|
var Text$f = Typography.Text;
|
|
20521
20494
|
function CheckoutSummary(_a) {
|
|
20522
20495
|
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;
|
|
20523
|
-
var upgradingSubscription = useContext(SubscriptionsContext).upgradingSubscription;
|
|
20524
20496
|
return (jsxs("div", __assign({ className: "".concat(className, " bunny-space-y-4") }, { children: [jsxs(Text$f, { children: [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] })), jsx("div", __assign({ className: "bunny-space-y-4" }, { children: quote === null || quote === void 0 ? void 0 : quote.quoteChanges.map(function (quoteChange) {
|
|
20525
20497
|
return quoteChange === null || quoteChange === void 0 ? void 0 : quoteChange.charges.map(function (charge) {
|
|
20526
20498
|
var _a;
|
|
@@ -20536,8 +20508,7 @@ function CheckoutSummary(_a) {
|
|
|
20536
20508
|
onRemoveCoupon((_b = charge.coupon) === null || _b === void 0 ? void 0 : _b.couponCode);
|
|
20537
20509
|
}, className: "bunny-text-orange-500 hover:bunny-text-orange-400 bunny-cursor-pointer" }, { children: "Remove" }))) : (jsx("div", { children: charge.quantity })) })), jsx("div", __assign({ className: "bunny-col-span-1 bunny-text-right" }, { children: formatCurrency(multiplier * (charge.subtotal || 0), charge.currencyId) }))] }), charge.id));
|
|
20538
20510
|
});
|
|
20539
|
-
}) })), jsx(CheckoutSummaryDivider, {}), jsxs("div", __assign({ className: "bunny-space-y-4" }, { children: [jsxs("div", __assign({ className: "bunny-flex bunny-justify-between" }, { children: [jsx("div", { children: "Subtotal" }), jsx("div", { children: formatCurrency(quote.subtotal, quote.currencyId) })] })), jsxs("div", __assign({ className: "bunny-flex bunny-justify-between" }, { children: [jsx("div", { children: "Taxes" }), jsx("div", { children: formatCurrency(quote.taxAmount, quote.currencyId) })] }))] })), jsx(CheckoutSummaryDivider, {}), jsxs("div", __assign({ className: "bunny-flex bunny-justify-between" }, { children: [jsx("div", { children: "Total" }), jsx("div", { children: formatCurrency(quote.amountDue, quote.currencyId) })] }))] }),
|
|
20540
|
-
shouldShowCouponEditor(quote, activeCouponsExist, upgradingSubscription) && (jsx(CouponEditor, { className: "bunny-w-full", quote: quote, onAddCoupon: onAddCoupon, isAddingCoupon: isAddingCoupon, couponCode: couponCode, setCouponCode: setCouponCode }))] })));
|
|
20511
|
+
}) })), jsx(CheckoutSummaryDivider, {}), jsxs("div", __assign({ className: "bunny-space-y-4" }, { children: [jsxs("div", __assign({ className: "bunny-flex bunny-justify-between" }, { children: [jsx("div", { children: "Subtotal" }), jsx("div", { children: formatCurrency(quote.subtotal, quote.currencyId) })] })), jsxs("div", __assign({ className: "bunny-flex bunny-justify-between" }, { children: [jsx("div", { children: "Taxes" }), jsx("div", { children: formatCurrency(quote.taxAmount, quote.currencyId) })] }))] })), jsx(CheckoutSummaryDivider, {}), jsxs("div", __assign({ className: "bunny-flex bunny-justify-between" }, { children: [jsx("div", { children: "Total" }), jsx("div", { children: formatCurrency(quote.amountDue, quote.currencyId) })] }))] }), activeCouponsExist && (jsx(CouponEditor, { className: "bunny-w-full", quote: quote, onAddCoupon: onAddCoupon, isAddingCoupon: isAddingCoupon, couponCode: couponCode, setCouponCode: setCouponCode }))] })));
|
|
20541
20512
|
}
|
|
20542
20513
|
var CheckoutSummaryDivider = function () {
|
|
20543
20514
|
return (jsx("div", __assign({ className: "bunny-my-2" }, { children: jsx(Divider, { className: "m-0" }) })));
|
|
@@ -20546,7 +20517,8 @@ var CheckoutSummaryDivider = function () {
|
|
|
20546
20517
|
var Title$1 = Typography.Title;
|
|
20547
20518
|
function PaymentForms(_a) {
|
|
20548
20519
|
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;
|
|
20549
|
-
|
|
20520
|
+
var entityId = useCurrentUserData().entityId;
|
|
20521
|
+
return (jsx(Fragment, { children: quote ? (jsx(Fragment, { children: overrideToken ? (jsxs(Fragment, { children: [jsx(Title$1, __assign({ className: "bunny-px-4 bunny-m-0", level: 2 }, { children: "Payment" })), jsx("div", __assign({ className: "bunny-overflow-y-auto bunny-max-h-[calc(100vh-10rem)]" }, { children: jsx(PaymentForm, { entityId: entityId, onFail: handlePaymentFail, onPaymentSuccess: handlePaymentSuccess, accountId: accountId, quote: quote, overrideToken: overrideToken, customCheckoutFunction: customCheckoutFunction }) }))] })) : null })) : (jsxs(Fragment, { children: [jsx(Title$1, __assign({ className: "bunny-px-4 bunny-m-0", level: 2 }, { children: "Signup" })), jsx(InitialSignupForm, { className: "bunny-px-4", onSubmit: handleSubmit, submitting: proceedingToPayment, defaultValues: defaultValues })] })) }));
|
|
20550
20522
|
}
|
|
20551
20523
|
function InitialSignupForm(_a) {
|
|
20552
20524
|
var className = _a.className, onSubmit = _a.onSubmit, submitting = _a.submitting, defaultValues = _a.defaultValues;
|
|
@@ -20857,22 +20829,8 @@ var useQuoteDelete = function () {
|
|
|
20857
20829
|
});
|
|
20858
20830
|
}); };
|
|
20859
20831
|
};
|
|
20860
|
-
var useQuoteSubscriptionActivate = function () {
|
|
20861
|
-
var graphQLRequest = useGraphQLRequest();
|
|
20862
|
-
return function (subscriptionId, apiHost, token) { return __awaiter(void 0, void 0, void 0, function () {
|
|
20863
|
-
var response;
|
|
20864
|
-
return __generator(this, function (_a) {
|
|
20865
|
-
switch (_a.label) {
|
|
20866
|
-
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 })];
|
|
20867
|
-
case 1:
|
|
20868
|
-
response = _a.sent();
|
|
20869
|
-
return [2 /*return*/, response];
|
|
20870
|
-
}
|
|
20871
|
-
});
|
|
20872
|
-
}); };
|
|
20873
|
-
};
|
|
20874
20832
|
|
|
20875
|
-
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
|
|
20833
|
+
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 }";
|
|
20876
20834
|
var getSubscriptions = function (_a) {
|
|
20877
20835
|
var apiHost = _a.apiHost, isInPreviewMode = _a.isInPreviewMode, token = _a.token;
|
|
20878
20836
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -20958,7 +20916,7 @@ var accountUpdate = function (_a) {
|
|
|
20958
20916
|
});
|
|
20959
20917
|
};
|
|
20960
20918
|
|
|
20961
|
-
var COUNTRIES_REQUIRING_STATE = [
|
|
20919
|
+
var COUNTRIES_REQUIRING_STATE = ["US", "CA"];
|
|
20962
20920
|
var TaxationForm = function (_a) {
|
|
20963
20921
|
var account = _a.account, quote = _a.quote;
|
|
20964
20922
|
// Hooks
|
|
@@ -20986,18 +20944,19 @@ var TaxationForm = function (_a) {
|
|
|
20986
20944
|
}); },
|
|
20987
20945
|
onSuccess: function () {
|
|
20988
20946
|
queryClient.invalidateQueries({
|
|
20989
|
-
queryKey: [
|
|
20947
|
+
queryKey: ["getTaxationRequiredAccountFields", token],
|
|
20990
20948
|
});
|
|
20991
20949
|
},
|
|
20992
20950
|
}), updateAccount = _b.mutate, isUpdatingAccount = _b.isPending;
|
|
20993
|
-
return (jsxs(Form, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4", form: form, initialValues: account, layout: "vertical", onFinish: updateAccount }, { children: [jsx(Form.Item, __assign({ label: "Billing street", name: "billingStreet" }, { children: jsx(Input, { placeholder: "Street" }) })), jsx(Form.Item, __assign({ label: "Billing city", name: "billingCity" }, { children: jsx(Input, { placeholder: "City" }) })), jsx(FormBillingState, {}), jsx(Form.Item, __assign({ label: "Billing country", name: "billingCountry", rules: [{ required: true }] }, { children: jsx(Select, { options: Lists.COUNTRY_LIST, placeholder: "Select a country", showSearch: true, filterOption: function (input, option) {
|
|
20951
|
+
return (jsxs(Form, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4", form: form, initialValues: account, layout: "vertical", onFinish: updateAccount }, { children: [jsx(Form.Item, __assign({ label: "Billing street", name: "billingStreet" }, { children: jsx(Input, { placeholder: "Street" }) })), jsx(Form.Item, __assign({ label: "Billing city", name: "billingCity" }, { children: jsx(Input, { placeholder: "City" }) })), jsx(FormBillingState, { form: form }), jsx(Form.Item, __assign({ label: "Billing country", name: "billingCountry", rules: [{ required: true }] }, { children: jsx(Select, { options: Lists.COUNTRY_LIST, placeholder: "Select a country", showSearch: true, filterOption: function (input, option) {
|
|
20994
20952
|
var _a, _b;
|
|
20995
|
-
return ((_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a :
|
|
20996
|
-
((_b = option === null || option === void 0 ? void 0 : option.value) !== null && _b !== void 0 ? _b :
|
|
20953
|
+
return ((_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a : "").toLowerCase().includes(input.toLowerCase()) ||
|
|
20954
|
+
((_b = option === null || option === void 0 ? void 0 : option.value) !== null && _b !== void 0 ? _b : "").toLowerCase().includes(input.toLowerCase());
|
|
20997
20955
|
} }) })), jsx(Form.Item, __assign({ label: "Billing zip", name: "billingZip" }, { children: jsx(Input, { placeholder: "Zip" }) })), jsx(Form.Item, { children: jsx(Button, __assign({ className: "bunny-w-full", disabled: isUpdatingAccount, htmlType: "submit", type: "primary" }, { children: "Submit" })) })] })));
|
|
20998
20956
|
};
|
|
20999
|
-
var FormBillingState = function () {
|
|
21000
|
-
|
|
20957
|
+
var FormBillingState = function (_a) {
|
|
20958
|
+
_a.form;
|
|
20959
|
+
var billingCountry = Form.useWatch("billingCountry");
|
|
21001
20960
|
var billingStateRequired = COUNTRIES_REQUIRING_STATE.includes(billingCountry);
|
|
21002
20961
|
return (jsx(Form.Item, __assign({ label: "Billing state", name: "billingState", rules: [{ required: billingStateRequired }] }, { children: jsx(Input, { placeholder: "State" }) })));
|
|
21003
20962
|
};
|
|
@@ -21007,11 +20966,11 @@ var QuoteCheckout = function (_a) {
|
|
|
21007
20966
|
var _b, _c;
|
|
21008
20967
|
var account = _a.account, onSuccess = _a.onSuccess, onFail = _a.onFail, quote = _a.quote, taxationRequiredAccountFields = _a.taxationRequiredAccountFields, onRecalculateTaxes = _a.onRecalculateTaxes;
|
|
21009
20968
|
var apiHost = useContext(BunnyContext).apiHost;
|
|
21010
|
-
var upgradingSubscription = useContext(SubscriptionsContext).upgradingSubscription;
|
|
21011
20969
|
var token = useToken();
|
|
21012
20970
|
var isMobile = useIsMobile();
|
|
21013
20971
|
var _d = useState(false), isSaving = _d[0], setIsSaving = _d[1];
|
|
21014
20972
|
var paymentRequired = getQuoteAmountDue(quote) > 0;
|
|
20973
|
+
var entityId = useCurrentUserData().entityId;
|
|
21015
20974
|
var queryClient = useQueryClient();
|
|
21016
20975
|
var _e = useState(''), couponCode = _e[0], setCouponCode = _e[1];
|
|
21017
20976
|
var _f = useUpdateCoupons({
|
|
@@ -21072,8 +21031,7 @@ var QuoteCheckout = function (_a) {
|
|
|
21072
21031
|
}
|
|
21073
21032
|
if (taxationRequiredAccountFields)
|
|
21074
21033
|
return (jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsx(TaxationForm, { account: account, quote: quote }) })));
|
|
21075
|
-
return (jsx(Fragment, { children: paymentRequired ? (jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-2 bunny-w-full" }, { children: [jsx(PaymentForm, { onFail: onFail, onPaymentSuccess: onSuccess, quote: quote }), (couponsOnQuote === null || couponsOnQuote === void 0 ? void 0 : couponsOnQuote.length) === 0 ? (jsx(Fragment, { children:
|
|
21076
|
-
shouldShowCouponEditor(quote, activeCouponsExist, upgradingSubscription) && (jsx(CouponEditor, { className: "bunny-px-4 bunny-pt-1", quote: quote, onAddCoupon: addCoupon, isAddingCoupon: isAddingCoupon, couponCode: couponCode, setCouponCode: setCouponCode })) })) : (jsx(Button, __assign({ type: "link", loading: isRemovingCoupon, onClick: function () {
|
|
21034
|
+
return (jsx(Fragment, { children: paymentRequired ? (jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-2 bunny-w-full" }, { children: [jsx(PaymentForm, { entityId: entityId, onFail: onFail, onPaymentSuccess: onSuccess, quote: quote }), (couponsOnQuote === null || couponsOnQuote === void 0 ? void 0 : couponsOnQuote.length) === 0 ? (jsx(Fragment, { children: activeCouponsExist && (jsx(CouponEditor, { className: "bunny-px-4 bunny-pt-1", quote: quote, onAddCoupon: addCoupon, isAddingCoupon: isAddingCoupon, couponCode: couponCode, setCouponCode: setCouponCode })) })) : (jsx(Button, __assign({ type: "link", loading: isRemovingCoupon, onClick: function () {
|
|
21077
21035
|
couponsOnQuote === null || couponsOnQuote === void 0 ? void 0 : couponsOnQuote.forEach(function (couponCharge) {
|
|
21078
21036
|
var _a;
|
|
21079
21037
|
var couponCode = (_a = couponCharge === null || couponCharge === void 0 ? void 0 : couponCharge.coupon) === null || _a === void 0 ? void 0 : _a.couponCode;
|
|
@@ -21222,6 +21180,8 @@ var PageTitle = function (_a) {
|
|
|
21222
21180
|
} })), title] })));
|
|
21223
21181
|
};
|
|
21224
21182
|
|
|
21183
|
+
var SubscriptionsContext = createContext({});
|
|
21184
|
+
|
|
21225
21185
|
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";
|
|
21226
21186
|
var quoteChargeUpdate = function (_a) {
|
|
21227
21187
|
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;
|
|
@@ -21313,112 +21273,10 @@ var billingPeriodConverter = function (period) {
|
|
|
21313
21273
|
return 12;
|
|
21314
21274
|
};
|
|
21315
21275
|
|
|
21316
|
-
var canShowQuantitiesInput = function (charge, subscription) {
|
|
21317
|
-
// Check if the subscription is active, pending, or in trial,
|
|
21318
|
-
// the pricing model is not flat,
|
|
21319
|
-
// and if it's not a trial, also check if the current charge is the last one in the subscription.
|
|
21320
|
-
var _a, _b, _c;
|
|
21321
|
-
var isActiveSubscription = ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === SubscriptionState$2.ACTIVE;
|
|
21322
|
-
var isPendingSubscription = ((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === SubscriptionState$2.PENDING;
|
|
21323
|
-
var isTrialSubscription = ((_c = subscription.state) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === SubscriptionState$2.TRIAL;
|
|
21324
|
-
var isFlatPricing = charge.pricingModel === 'FLAT';
|
|
21325
|
-
var shouldProcessCharge = (isActiveSubscription || isPendingSubscription || isTrialSubscription) &&
|
|
21326
|
-
!isFlatPricing &&
|
|
21327
|
-
charge.selfServiceQuantity &&
|
|
21328
|
-
!charge.expired;
|
|
21329
|
-
// Now you can use the value of shouldProcessCharge to determine whether to process the charge.
|
|
21330
|
-
return shouldProcessCharge;
|
|
21331
|
-
};
|
|
21332
|
-
var createQuoteParams = function (quote, subscriptionQuantity, editedSubscription) {
|
|
21333
|
-
var quoteChange = quote.quoteChanges.find(function (quoteChange) { return quoteChange.priceList.id === (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription.priceList.id); });
|
|
21334
|
-
var quoteChangeCharge = quoteChange === null || quoteChange === void 0 ? void 0 : quoteChange.charges.find(function (charge) { return charge.priceListCharge.id === editedSubscription.chargeId; });
|
|
21335
|
-
var charges = [
|
|
21336
|
-
{
|
|
21337
|
-
id: quoteChangeCharge.id,
|
|
21338
|
-
quantity: editedSubscription.quantity - subscriptionQuantity,
|
|
21339
|
-
},
|
|
21340
|
-
];
|
|
21341
|
-
return { charges: charges, quoteChange: quoteChange };
|
|
21342
|
-
};
|
|
21343
|
-
var canShowChangeQuantities = function (_a) {
|
|
21344
|
-
var subscriptions = _a.subscriptions;
|
|
21345
|
-
return subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.some(function (subscription) {
|
|
21346
|
-
return subscription.charges.some(function (charge) {
|
|
21347
|
-
return canShowQuantitiesInput(charge, subscription);
|
|
21348
|
-
});
|
|
21349
|
-
});
|
|
21350
|
-
};
|
|
21351
|
-
var canSubscriptionUpgradeFromTrial = function (subscription) {
|
|
21352
|
-
var _a;
|
|
21353
|
-
return (((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === SubscriptionState$2.TRIAL &&
|
|
21354
|
-
subscription.plan.selfServiceBuy) ||
|
|
21355
|
-
false;
|
|
21356
|
-
};
|
|
21357
|
-
var isSubscriptionNotActive = function (subscription) {
|
|
21358
|
-
var _a, _b;
|
|
21359
|
-
return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === SubscriptionState$2.EXPIRED ||
|
|
21360
|
-
((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === SubscriptionState$2.CANCELED;
|
|
21361
|
-
};
|
|
21362
|
-
var isSubscriptionActiveOrPending = function (subscription) {
|
|
21363
|
-
var _a, _b;
|
|
21364
|
-
return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === SubscriptionState$2.ACTIVE ||
|
|
21365
|
-
((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === SubscriptionState$2.PENDING;
|
|
21366
|
-
};
|
|
21367
|
-
var isSubscriptionTrial = function (subscription) { var _a; return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === SubscriptionState$2.TRIAL; };
|
|
21368
|
-
// Helper function to check if charge is a discount
|
|
21369
|
-
var isDiscount = function (kind) {
|
|
21370
|
-
return kind === QuoteChangeKind.DISCOUNT || kind === QuoteChangeKind.FREE_PERIOD_DISCOUNT;
|
|
21371
|
-
};
|
|
21372
|
-
var hasPriceTiers = function (charge) {
|
|
21373
|
-
var _a;
|
|
21374
|
-
return Boolean((_a = charge === null || charge === void 0 ? void 0 : charge.priceTiers) === null || _a === void 0 ? void 0 : _a.length);
|
|
21375
|
-
};
|
|
21376
|
-
var hasMultiplePriceTiers = function (charge) {
|
|
21377
|
-
var _a;
|
|
21378
|
-
return ((_a = charge === null || charge === void 0 ? void 0 : charge.priceTiers) === null || _a === void 0 ? void 0 : _a.length) > 1;
|
|
21379
|
-
};
|
|
21380
|
-
var getApplicablePriceTier = function (charge, currencyId, priceDecimals) {
|
|
21381
|
-
var _a;
|
|
21382
|
-
if (!((_a = charge.priceTiers) === null || _a === void 0 ? void 0 : _a.length))
|
|
21383
|
-
return '';
|
|
21384
|
-
var selectedTier;
|
|
21385
|
-
// For TIERED pricing model: always show the first tier
|
|
21386
|
-
if (charge.pricingModel === PricingModel.TIERED) {
|
|
21387
|
-
selectedTier = charge.priceTiers[0];
|
|
21388
|
-
}
|
|
21389
|
-
// For VOLUME and BANDS pricing models: find the tier that contains the current quantity
|
|
21390
|
-
else if (charge.pricingModel === PricingModel.VOLUME ||
|
|
21391
|
-
charge.pricingModel === PricingModel.BANDS) {
|
|
21392
|
-
// Find the appropriate tier based on quantity
|
|
21393
|
-
selectedTier = charge.priceTiers.find(function (tier, index) {
|
|
21394
|
-
var nextTier = charge.priceTiers[index + 1];
|
|
21395
|
-
var tierStart = tier.starts;
|
|
21396
|
-
var tierEnd = nextTier ? nextTier.starts - 1 : Infinity;
|
|
21397
|
-
return charge.quantity >= tierStart && charge.quantity <= tierEnd;
|
|
21398
|
-
});
|
|
21399
|
-
// Fallback to first tier if no tier found (shouldn't happen with proper data)
|
|
21400
|
-
selectedTier = selectedTier || charge.priceTiers[0];
|
|
21401
|
-
}
|
|
21402
|
-
// Default fallback for any other pricing models
|
|
21403
|
-
else {
|
|
21404
|
-
selectedTier = charge.priceTiers[0];
|
|
21405
|
-
}
|
|
21406
|
-
if (!selectedTier)
|
|
21407
|
-
return '';
|
|
21408
|
-
// Calculate the tier range for display
|
|
21409
|
-
var tierIndex = charge.priceTiers.indexOf(selectedTier);
|
|
21410
|
-
var starts = selectedTier.starts;
|
|
21411
|
-
var nextTier = charge.priceTiers[tierIndex + 1];
|
|
21412
|
-
var ends = nextTier ? nextTier.starts - 1 : '∞';
|
|
21413
|
-
return hasMultiplePriceTiers(charge)
|
|
21414
|
-
? "".concat(starts, "-").concat(ends, ": ").concat(formatCurrency(selectedTier.price, currencyId, priceDecimals))
|
|
21415
|
-
: "".concat(formatCurrency(selectedTier.price, currencyId, priceDecimals));
|
|
21416
|
-
};
|
|
21417
|
-
|
|
21418
21276
|
var removeHTMLTagsRegex = /<br>(?=(?:\s*<[^>]*>)*$)|(<br>)|<[^>]*>/gi;
|
|
21419
21277
|
// Description is a string that can contain HTML tags. We want to remove all HTML tags except <br> tags.
|
|
21420
21278
|
var createPlanDescription = function (priceList) {
|
|
21421
|
-
return (priceList.plan.description || '').replace(removeHTMLTagsRegex, function (
|
|
21279
|
+
return (priceList.plan.description || '').replace(removeHTMLTagsRegex, function (x, y) {
|
|
21422
21280
|
return y ? ' & ' : '';
|
|
21423
21281
|
});
|
|
21424
21282
|
};
|
|
@@ -21460,17 +21318,25 @@ var getActivePlanPriceData = function (priceList, selectedPriceList) {
|
|
|
21460
21318
|
};
|
|
21461
21319
|
};
|
|
21462
21320
|
var isPriceListDisabled = function (_a) {
|
|
21463
|
-
var priceList = _a.priceList, upgradingSubscription = _a.upgradingSubscription, canPurchaseFeatureAddons = _a.canPurchaseFeatureAddons;
|
|
21464
|
-
|
|
21465
|
-
var
|
|
21466
|
-
|
|
21467
|
-
|
|
21468
|
-
|
|
21469
|
-
|
|
21470
|
-
|
|
21471
|
-
|
|
21472
|
-
|
|
21473
|
-
|
|
21321
|
+
var priceList = _a.priceList, subscriptions = _a.subscriptions, upgradingSubscription = _a.upgradingSubscription, canPurchaseFeatureAddons = _a.canPurchaseFeatureAddons;
|
|
21322
|
+
// Plan already has a subscription
|
|
21323
|
+
var existingSubscription = subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.find(function (subscription) {
|
|
21324
|
+
var _a, _b;
|
|
21325
|
+
var isCurrentUpgradingSubscription = subscription.id === (upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id);
|
|
21326
|
+
var subscriptionAlreadyExists = isCurrentUpgradingSubscription
|
|
21327
|
+
? subscription.priceList.id === priceList.id
|
|
21328
|
+
: subscription.plan.id === priceList.plan.id;
|
|
21329
|
+
return (subscriptionAlreadyExists &&
|
|
21330
|
+
subscription.plan.id === priceList.plan.id &&
|
|
21331
|
+
((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) !== SubscriptionState$2.CANCELED &&
|
|
21332
|
+
((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) !== SubscriptionState$2.EXPIRED);
|
|
21333
|
+
});
|
|
21334
|
+
var isUpgradingPriceList = (upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.priceList.id) === priceList.id;
|
|
21335
|
+
if (existingSubscription) {
|
|
21336
|
+
return true;
|
|
21337
|
+
}
|
|
21338
|
+
if (isUpgradingPriceList && !canPurchaseFeatureAddons) {
|
|
21339
|
+
return true;
|
|
21474
21340
|
}
|
|
21475
21341
|
return false;
|
|
21476
21342
|
};
|
|
@@ -21499,13 +21365,11 @@ var CheckoutBarSummarySection = function (_a) {
|
|
|
21499
21365
|
// Context
|
|
21500
21366
|
var apiHost = useContext(BunnyContext).apiHost;
|
|
21501
21367
|
var quotePreviewData = useContext(QuotePreviewContext).quotePreviewData;
|
|
21502
|
-
var accountId = useContext(PaymentContext).accountId;
|
|
21503
21368
|
// Hooks
|
|
21504
21369
|
var token = useToken();
|
|
21505
21370
|
var paymentPlugins = usePaymentPlugins({
|
|
21506
21371
|
apiHost: apiHost,
|
|
21507
21372
|
token: token,
|
|
21508
|
-
accountId: accountId,
|
|
21509
21373
|
}).paymentPlugins;
|
|
21510
21374
|
var queryClient = useQueryClient();
|
|
21511
21375
|
var isMobile = useIsMobile();
|
|
@@ -21558,32 +21422,31 @@ var PlanPickerCheckoutBar = function (_a) {
|
|
|
21558
21422
|
}).defaultPaymentMethod;
|
|
21559
21423
|
var createSubscriptionUpgradeQuote = useQuoteSubscriptionUpgrade();
|
|
21560
21424
|
var createSubscriptionUpdateQuote = useCreateSubscriptionQuote();
|
|
21561
|
-
var quoteSubscriptionActivate = useQuoteSubscriptionActivate();
|
|
21562
21425
|
// Mutations
|
|
21563
21426
|
var createQuote = useMutation({
|
|
21564
21427
|
mutationFn: function (_a) {
|
|
21565
21428
|
var subscriptionId = _a.subscriptionId, priceListId = _a.priceListId;
|
|
21566
21429
|
return createSubscriptionUpgradeQuote(subscriptionId, priceListId, apiHost, token);
|
|
21567
21430
|
},
|
|
21568
|
-
onSuccess: function (
|
|
21431
|
+
onSuccess: function (subscriptionUpdateData) {
|
|
21569
21432
|
var _a;
|
|
21570
|
-
var quote = (_a =
|
|
21433
|
+
var quote = (_a = subscriptionUpdateData === null || subscriptionUpdateData === void 0 ? void 0 : subscriptionUpdateData.quoteSubscriptionUpgrade) === null || _a === void 0 ? void 0 : _a.quote;
|
|
21571
21434
|
setEditingQuoteData === null || setEditingQuoteData === void 0 ? void 0 : setEditingQuoteData(quote.id);
|
|
21572
21435
|
handleSetEditingQuote(quote.id);
|
|
21573
21436
|
},
|
|
21574
|
-
})
|
|
21437
|
+
});
|
|
21575
21438
|
var createEmptyQuote = useMutation({
|
|
21576
21439
|
mutationFn: function (_a) {
|
|
21577
21440
|
var subscriptionId = _a.subscriptionId;
|
|
21578
21441
|
return createSubscriptionUpdateQuote([subscriptionId], apiHost, token);
|
|
21579
21442
|
},
|
|
21580
|
-
onSuccess: function (
|
|
21443
|
+
onSuccess: function (subscriptionUpdateData) {
|
|
21581
21444
|
var _a;
|
|
21582
|
-
var quote = (_a =
|
|
21445
|
+
var quote = (_a = subscriptionUpdateData === null || subscriptionUpdateData === void 0 ? void 0 : subscriptionUpdateData.quoteSubscriptionUpdate) === null || _a === void 0 ? void 0 : _a.quote;
|
|
21583
21446
|
setEditingQuoteData === null || setEditingQuoteData === void 0 ? void 0 : setEditingQuoteData(quote.id);
|
|
21584
21447
|
handleSetEditingQuote(quote.id);
|
|
21585
21448
|
},
|
|
21586
|
-
})
|
|
21449
|
+
});
|
|
21587
21450
|
var updateCharge = useMutation({
|
|
21588
21451
|
mutationFn: quoteChargeUpdate,
|
|
21589
21452
|
onSuccess: function () {
|
|
@@ -21596,32 +21459,6 @@ var PlanPickerCheckoutBar = function (_a) {
|
|
|
21596
21459
|
});
|
|
21597
21460
|
},
|
|
21598
21461
|
}).mutate;
|
|
21599
|
-
var subscriptionActivate = useMutation({
|
|
21600
|
-
mutationFn: function (_a) {
|
|
21601
|
-
var subscriptionId = _a.subscriptionId;
|
|
21602
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
21603
|
-
return __generator(this, function (_b) {
|
|
21604
|
-
switch (_b.label) {
|
|
21605
|
-
case 0: return [4 /*yield*/, quoteSubscriptionActivate(subscriptionId, apiHost, token)];
|
|
21606
|
-
case 1: return [2 /*return*/, _b.sent()];
|
|
21607
|
-
}
|
|
21608
|
-
});
|
|
21609
|
-
});
|
|
21610
|
-
},
|
|
21611
|
-
onSuccess: function (response) {
|
|
21612
|
-
var _a;
|
|
21613
|
-
var quote = (_a = response === null || response === void 0 ? void 0 : response.quoteSubscriptionActivate) === null || _a === void 0 ? void 0 : _a.quote;
|
|
21614
|
-
setEditingQuoteData === null || setEditingQuoteData === void 0 ? void 0 : setEditingQuoteData(quote.id);
|
|
21615
|
-
handleSetEditingQuote(quote.id);
|
|
21616
|
-
queryClient.invalidateQueries({
|
|
21617
|
-
queryKey: QueryKeyFactory.default.createObjectKey({
|
|
21618
|
-
objectName: 'editingQuote',
|
|
21619
|
-
id: editingQuote === null || editingQuote === void 0 ? void 0 : editingQuote.id,
|
|
21620
|
-
token: token,
|
|
21621
|
-
}),
|
|
21622
|
-
});
|
|
21623
|
-
},
|
|
21624
|
-
}).mutate;
|
|
21625
21462
|
// Queries
|
|
21626
21463
|
var quote = useQuery({
|
|
21627
21464
|
queryKey: QueryKeyFactory.default.createObjectKey({
|
|
@@ -21651,26 +21488,18 @@ var PlanPickerCheckoutBar = function (_a) {
|
|
|
21651
21488
|
enabled: Boolean(editingQuote === null || editingQuote === void 0 ? void 0 : editingQuote.id),
|
|
21652
21489
|
}).data;
|
|
21653
21490
|
useEffect(function () {
|
|
21654
|
-
var _a;
|
|
21655
21491
|
if (!(upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id)) {
|
|
21656
21492
|
console.error('upgradingSubscription is undefined');
|
|
21657
21493
|
return;
|
|
21658
21494
|
}
|
|
21659
21495
|
var upgradingCurrentSubscription = (upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.priceList.id) === (selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id);
|
|
21660
21496
|
if (upgradingCurrentSubscription) {
|
|
21661
|
-
|
|
21662
|
-
|
|
21663
|
-
|
|
21664
|
-
});
|
|
21665
|
-
}
|
|
21666
|
-
else {
|
|
21667
|
-
createEmptyQuote({
|
|
21668
|
-
subscriptionId: upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id,
|
|
21669
|
-
});
|
|
21670
|
-
}
|
|
21497
|
+
createEmptyQuote.mutate({
|
|
21498
|
+
subscriptionId: upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id,
|
|
21499
|
+
});
|
|
21671
21500
|
}
|
|
21672
21501
|
else {
|
|
21673
|
-
createQuote({
|
|
21502
|
+
createQuote.mutate({
|
|
21674
21503
|
subscriptionId: upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id,
|
|
21675
21504
|
priceListId: selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id,
|
|
21676
21505
|
});
|
|
@@ -21745,7 +21574,7 @@ var PlanPickerCheckoutBar = function (_a) {
|
|
|
21745
21574
|
// WARNING: There is a preview button on APP that will need to be changed if this query is changed
|
|
21746
21575
|
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 }";
|
|
21747
21576
|
var getPriceListChangeOptions = function (_a) {
|
|
21748
|
-
var apiHost = _a.apiHost, isInPreviewMode = _a.isInPreviewMode, productId = _a.productId, token = _a.token, upgradingSubscription = _a.upgradingSubscription
|
|
21577
|
+
var apiHost = _a.apiHost, isInPreviewMode = _a.isInPreviewMode, productId = _a.productId, token = _a.token, upgradingSubscription = _a.upgradingSubscription;
|
|
21749
21578
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
21750
21579
|
var response, priceListChangeOptions;
|
|
21751
21580
|
return __generator(this, function (_b) {
|
|
@@ -21766,8 +21595,6 @@ var getPriceListChangeOptions = function (_a) {
|
|
|
21766
21595
|
if (priceListChangeOptions === null || priceListChangeOptions === void 0 ? void 0 : priceListChangeOptions.priceLists) {
|
|
21767
21596
|
priceListChangeOptions.priceLists.sort(function (a, b) { return a.plan.position - b.plan.position; });
|
|
21768
21597
|
}
|
|
21769
|
-
// Filter out price lists that don't have the same currency as the account
|
|
21770
|
-
priceListChangeOptions.priceLists = priceListChangeOptions.priceLists.filter(function (priceList) { return priceList.currencyId === accountCurrencyId; });
|
|
21771
21598
|
return [2 /*return*/, priceListChangeOptions];
|
|
21772
21599
|
}
|
|
21773
21600
|
});
|
|
@@ -21899,10 +21726,7 @@ var PriceListCardButton = function (_a) {
|
|
|
21899
21726
|
subscriptionPlan &&
|
|
21900
21727
|
priceListHasUnpurchasedFeatureAddons(priceList, upgradingSubscription);
|
|
21901
21728
|
var isPriceListNonSubscribedCurrentPlan = (upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.plan.id) === priceList.plan.id && !isPriceListCurrentSubscription;
|
|
21902
|
-
var canUpgradeFromTrial = upgradingSubscription && canSubscriptionUpgradeFromTrial(upgradingSubscription);
|
|
21903
21729
|
var createButtonText = function () {
|
|
21904
|
-
if (isPriceListCurrentSubscription && canUpgradeFromTrial)
|
|
21905
|
-
return 'Upgrade from trial';
|
|
21906
21730
|
if (isPriceListCurrentSubscription)
|
|
21907
21731
|
return 'Current';
|
|
21908
21732
|
if (isSelected)
|
|
@@ -22056,6 +21880,7 @@ var PriceListCard = function (_a) {
|
|
|
22056
21880
|
var canPurchaseFeatureAddons = priceListHasUnpurchasedFeatureAddons(priceList, upgradingSubscription);
|
|
22057
21881
|
var disableOnClick = isPriceListDisabled({
|
|
22058
21882
|
priceList: priceList,
|
|
21883
|
+
subscriptions: subscriptions,
|
|
22059
21884
|
upgradingSubscription: upgradingSubscription,
|
|
22060
21885
|
canPurchaseFeatureAddons: canPurchaseFeatureAddons,
|
|
22061
21886
|
});
|
|
@@ -22352,14 +22177,14 @@ var FeatureTitle = function (_a) {
|
|
|
22352
22177
|
|
|
22353
22178
|
var PriceListGridDesktop = function (_a) {
|
|
22354
22179
|
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;
|
|
22355
|
-
var
|
|
22180
|
+
var _b = useMemo(function () {
|
|
22356
22181
|
return getAvailablePlansAndPriceLists({
|
|
22357
22182
|
availablePriceLists: availablePriceLists,
|
|
22358
22183
|
priceListChangeOptions: priceListChangeOptions,
|
|
22359
22184
|
priceListStart: priceListStart,
|
|
22360
22185
|
plansToDisplay: (selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.plansToDisplay) || 3,
|
|
22361
22186
|
});
|
|
22362
|
-
}, [availablePriceLists, priceListChangeOptions, priceListStart]).displayPriceLists;
|
|
22187
|
+
}, [availablePriceLists, priceListChangeOptions, priceListStart]); _b.availablePriceListsArray; var displayPriceLists = _b.displayPriceLists;
|
|
22363
22188
|
var everythingInPlus = selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.everythingInPlus;
|
|
22364
22189
|
var plansToDisplay = Math.min((selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.plansToDisplay) || 3, availablePriceLists.length);
|
|
22365
22190
|
var hasFeatureAddons = displayPriceLists.some(function (priceList) {
|
|
@@ -22374,7 +22199,7 @@ var PriceListGridDesktop = function (_a) {
|
|
|
22374
22199
|
var doesPrevPriceListExist = displayPriceLists[index - 1];
|
|
22375
22200
|
if (!priceList)
|
|
22376
22201
|
return jsx(PlanPickerGridCell, { noBorder: !Boolean(doesPrevPriceListExist) }, index);
|
|
22377
|
-
return (jsx(PriceListCard, { isSelected: priceList.id === (selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id), onClick: onChangePriceList, priceList: priceList, subscriptions: subscriptions, trialRemainingDays: trialRemainingDays }, index));
|
|
22202
|
+
return (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));
|
|
22378
22203
|
}), (selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.everythingInPlus) ? (jsx(EverythingPlanFeatures, { displayPriceLists: displayPriceLists, plansToDisplay: plansToDisplay, selectedProduct: selectedProduct })) : (jsxs(Fragment, { children: [jsx(PlanFeatures, { displayPriceLists: displayPriceLists, plansToDisplay: plansToDisplay, selectedProduct: selectedProduct }), hasFeatureAddons && (jsx(PlanFeatureAddons, { displayPriceLists: displayPriceLists, plansToDisplay: plansToDisplay }))] }))] }))] })));
|
|
22379
22204
|
};
|
|
22380
22205
|
|
|
@@ -22448,6 +22273,7 @@ var PriceListSelector = function (_a) {
|
|
|
22448
22273
|
priceList.plan.id === ((_a = quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.priceList) === null || _a === void 0 ? void 0 : _a.plan.id) &&
|
|
22449
22274
|
!isPriceListDisabled({
|
|
22450
22275
|
priceList: priceList,
|
|
22276
|
+
subscriptions: subscriptions,
|
|
22451
22277
|
upgradingSubscription: upgradingSubscription,
|
|
22452
22278
|
canPurchaseFeatureAddons: priceListHasUnpurchasedFeatureAddons(quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.priceList, upgradingSubscription),
|
|
22453
22279
|
});
|
|
@@ -22465,7 +22291,13 @@ var PriceListSelector = function (_a) {
|
|
|
22465
22291
|
});
|
|
22466
22292
|
}
|
|
22467
22293
|
}
|
|
22468
|
-
}, [
|
|
22294
|
+
}, [
|
|
22295
|
+
quotePreviewData,
|
|
22296
|
+
priceListChangeOptions,
|
|
22297
|
+
subscriptions,
|
|
22298
|
+
upgradingSubscription,
|
|
22299
|
+
setQuotePreviewData,
|
|
22300
|
+
]);
|
|
22469
22301
|
var onChangeProduct = useCallback(function (product) {
|
|
22470
22302
|
var newAvailableBillingPeriods = createAvailableBillingPeriods(priceListChangeOptions === null || priceListChangeOptions === void 0 ? void 0 : priceListChangeOptions.priceLists, product);
|
|
22471
22303
|
if (!(newAvailableBillingPeriods === null || newAvailableBillingPeriods === void 0 ? void 0 : newAvailableBillingPeriods.includes(billingPeriodConverter(selectedBillingPeriod)))) {
|
|
@@ -22510,6 +22342,7 @@ var PriceListSelector = function (_a) {
|
|
|
22510
22342
|
!isInPreviewMode &&
|
|
22511
22343
|
!isPriceListDisabled({
|
|
22512
22344
|
priceList: initialPriceList,
|
|
22345
|
+
subscriptions: subscriptions,
|
|
22513
22346
|
upgradingSubscription: upgradingSubscription,
|
|
22514
22347
|
canPurchaseFeatureAddons: priceListHasUnpurchasedFeatureAddons(initialPriceList, upgradingSubscription),
|
|
22515
22348
|
})) {
|
|
@@ -22527,6 +22360,7 @@ var PriceListSelector = function (_a) {
|
|
|
22527
22360
|
selectedPriceList,
|
|
22528
22361
|
selectedProduct,
|
|
22529
22362
|
setQuotePreviewData,
|
|
22363
|
+
subscriptions,
|
|
22530
22364
|
upgradingSubscription,
|
|
22531
22365
|
]);
|
|
22532
22366
|
return (jsxs(Fragment, { children: [jsx(BillingPeriodSelector, { availableBillingPeriods: availableBillingPeriods, onChangeBillingPeriod: onChangeBillingPeriod, products: priceListChangeOptions === null || priceListChangeOptions === void 0 ? void 0 : priceListChangeOptions.products, selectedBillingPeriod: selectedBillingPeriod, selectedProduct: selectedProduct, onChangeProduct: onChangeProduct }), jsx(PriceListGrid, { availablePriceLists: availablePriceLists, onChangePriceList: onChangePriceList, priceListChangeOptions: priceListChangeOptions, priceListStart: priceListStart, selectedPriceList: selectedPriceList, selectedProduct: selectedProduct, setPriceListStart: setPriceListStart, subscriptions: subscriptions, upgradingSubscriptionState: upgradingSubscription })] }));
|
|
@@ -22539,7 +22373,6 @@ var PlanPicker = function () {
|
|
|
22539
22373
|
var apiHost = useContext(BunnyContext).apiHost;
|
|
22540
22374
|
var _b = useContext(SubscriptionsContext), isInPreviewMode = _b.isInPreviewMode, productId = _b.productId, upgradingSubscription = _b.upgradingSubscription;
|
|
22541
22375
|
var _c = useContext(QuotePreviewContext), quotePreviewData = _c.quotePreviewData, setQuotePreviewData = _c.setQuotePreviewData;
|
|
22542
|
-
var account = useCurrentUserData(token).account;
|
|
22543
22376
|
// Hooks
|
|
22544
22377
|
var showInfoNotification = useInfoNotification();
|
|
22545
22378
|
// Queries
|
|
@@ -22562,7 +22395,6 @@ var PlanPicker = function () {
|
|
|
22562
22395
|
productId: productId,
|
|
22563
22396
|
token: token,
|
|
22564
22397
|
upgradingSubscription: upgradingSubscription,
|
|
22565
|
-
accountCurrencyId: account === null || account === void 0 ? void 0 : account.currencyId,
|
|
22566
22398
|
});
|
|
22567
22399
|
},
|
|
22568
22400
|
enabled: !areSubscriptionsLoading,
|
|
@@ -22725,7 +22557,7 @@ var SubscriptionState$1 = SubscriptionState;
|
|
|
22725
22557
|
|
|
22726
22558
|
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";
|
|
22727
22559
|
var getFeatureUsage = function (_a) {
|
|
22728
|
-
var subscriptionChargeId = _a.subscriptionChargeId
|
|
22560
|
+
var subscriptionChargeId = _a.subscriptionChargeId; _a.startDate; _a.endDate; _a.dataInterval; var token = _a.token, apiHost = _a.apiHost;
|
|
22729
22561
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
22730
22562
|
var vars, response;
|
|
22731
22563
|
var _b;
|
|
@@ -22845,51 +22677,387 @@ var FeatureBarChart = function (_a) {
|
|
|
22845
22677
|
var StyledBarChart = defaultStyled(BarChart)(templateObject_1$2 || (templateObject_1$2 = __makeTemplateObject(["\n .recharts-surface {\n overflow: visible;\n }\n"], ["\n .recharts-surface {\n overflow: visible;\n }\n"])));
|
|
22846
22678
|
var templateObject_1$2;
|
|
22847
22679
|
|
|
22848
|
-
var
|
|
22849
|
-
|
|
22850
|
-
|
|
22851
|
-
|
|
22852
|
-
var
|
|
22853
|
-
var
|
|
22854
|
-
|
|
22855
|
-
|
|
22856
|
-
|
|
22857
|
-
|
|
22858
|
-
|
|
22859
|
-
|
|
22860
|
-
|
|
22861
|
-
|
|
22862
|
-
|
|
22863
|
-
var isActiveOrPending = isSubscriptionActiveOrPending(subscription);
|
|
22864
|
-
if (isPaymentMethodLoading)
|
|
22865
|
-
return null;
|
|
22866
|
-
return (jsxs(Fragment, { children: [isSelfServiceCancelable && (isInTrial || isActiveOrPending) && (jsx(Popconfirm, __assign({ icon: null, onConfirm: function () { return onCancelSubscriptionClick === null || onCancelSubscriptionClick === void 0 ? void 0 : onCancelSubscriptionClick(subscription); }, title: "Cancel subscription" }, { children: jsx(Button, __assign({ className: "bunny-p-0", type: "link" }, { children: "Cancel subscription" })) }))), arePlansAvailable && (isActiveOrPending || isInTrial) && (jsx(Button, __assign({ onClick: function () { return onChangePlanClick(subscription); }, type: 'primary' }, { children: isInTrial ? 'Upgrade from trial' : 'Change plan' }))), !arePlansAvailable && isInTrial && jsx(Tag, __assign({ color: "warning" }, { children: "Cannot upgrade" }))] }));
|
|
22680
|
+
var canShowQuantitiesInput = function (charge, subscription) {
|
|
22681
|
+
// Check if the subscription is active, pending, or in trial,
|
|
22682
|
+
// the pricing model is not flat,
|
|
22683
|
+
// and if it's not a trial, also check if the current charge is the last one in the subscription.
|
|
22684
|
+
var _a, _b, _c;
|
|
22685
|
+
var isActiveSubscription = ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === SubscriptionState$2.ACTIVE;
|
|
22686
|
+
var isPendingSubscription = ((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === SubscriptionState$2.PENDING;
|
|
22687
|
+
var isTrialSubscription = ((_c = subscription.state) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === SubscriptionState$2.TRIAL;
|
|
22688
|
+
var isFlatPricing = charge.pricingModel === 'FLAT';
|
|
22689
|
+
var shouldProcessCharge = (isActiveSubscription || isPendingSubscription || isTrialSubscription) &&
|
|
22690
|
+
!isFlatPricing &&
|
|
22691
|
+
charge.selfServiceQuantity &&
|
|
22692
|
+
!charge.expired;
|
|
22693
|
+
// Now you can use the value of shouldProcessCharge to determine whether to process the charge.
|
|
22694
|
+
return shouldProcessCharge;
|
|
22867
22695
|
};
|
|
22868
|
-
|
|
22869
|
-
var
|
|
22870
|
-
var
|
|
22871
|
-
var
|
|
22872
|
-
|
|
22873
|
-
|
|
22874
|
-
|
|
22875
|
-
|
|
22876
|
-
|
|
22877
|
-
|
|
22878
|
-
|
|
22879
|
-
|
|
22880
|
-
|
|
22881
|
-
|
|
22882
|
-
|
|
22883
|
-
|
|
22884
|
-
|
|
22885
|
-
|
|
22886
|
-
|
|
22887
|
-
|
|
22888
|
-
|
|
22889
|
-
|
|
22890
|
-
|
|
22891
|
-
|
|
22892
|
-
|
|
22696
|
+
var createQuoteParams = function (quote, subscriptionQuantity, editedSubscription) {
|
|
22697
|
+
var quoteChange = quote.quoteChanges.find(function (quoteChange) { return quoteChange.priceList.id === (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription.priceList.id); });
|
|
22698
|
+
var quoteChangeCharge = quoteChange === null || quoteChange === void 0 ? void 0 : quoteChange.charges.find(function (charge) { return charge.priceListCharge.id === editedSubscription.chargeId; });
|
|
22699
|
+
var charges = [
|
|
22700
|
+
{
|
|
22701
|
+
id: quoteChangeCharge.id,
|
|
22702
|
+
quantity: editedSubscription.quantity - subscriptionQuantity,
|
|
22703
|
+
},
|
|
22704
|
+
];
|
|
22705
|
+
return { charges: charges, quoteChange: quoteChange };
|
|
22706
|
+
};
|
|
22707
|
+
var canShowChangeQuantities = function (_a) {
|
|
22708
|
+
var subscriptions = _a.subscriptions;
|
|
22709
|
+
return subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.some(function (subscription) {
|
|
22710
|
+
return subscription.charges.some(function (charge, chargeIndex) {
|
|
22711
|
+
return canShowQuantitiesInput(charge, subscription);
|
|
22712
|
+
});
|
|
22713
|
+
});
|
|
22714
|
+
};
|
|
22715
|
+
var isSubscriptionNotActive = function (subscription) {
|
|
22716
|
+
var _a, _b;
|
|
22717
|
+
return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === SubscriptionState$2.EXPIRED ||
|
|
22718
|
+
((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === SubscriptionState$2.CANCELED;
|
|
22719
|
+
};
|
|
22720
|
+
var isSubscriptionActiveOrPending = function (subscription) {
|
|
22721
|
+
var _a, _b;
|
|
22722
|
+
return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === SubscriptionState$2.ACTIVE ||
|
|
22723
|
+
((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === SubscriptionState$2.PENDING;
|
|
22724
|
+
};
|
|
22725
|
+
var isSubscriptionTrial = function (subscription) { var _a; return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === SubscriptionState$2.TRIAL; };
|
|
22726
|
+
// Helper function to check if charge is a discount
|
|
22727
|
+
var isDiscount = function (kind) {
|
|
22728
|
+
return kind === QuoteChangeKind.DISCOUNT || kind === QuoteChangeKind.FREE_PERIOD_DISCOUNT;
|
|
22729
|
+
};
|
|
22730
|
+
var hasPriceTiers = function (charge) {
|
|
22731
|
+
var _a;
|
|
22732
|
+
return Boolean((_a = charge === null || charge === void 0 ? void 0 : charge.priceTiers) === null || _a === void 0 ? void 0 : _a.length);
|
|
22733
|
+
};
|
|
22734
|
+
var hasMultiplePriceTiers = function (charge) {
|
|
22735
|
+
var _a;
|
|
22736
|
+
return ((_a = charge === null || charge === void 0 ? void 0 : charge.priceTiers) === null || _a === void 0 ? void 0 : _a.length) > 1;
|
|
22737
|
+
};
|
|
22738
|
+
var getApplicablePriceTier = function (charge, currencyId, priceDecimals) {
|
|
22739
|
+
var _a;
|
|
22740
|
+
if (!((_a = charge.priceTiers) === null || _a === void 0 ? void 0 : _a.length))
|
|
22741
|
+
return '';
|
|
22742
|
+
var selectedTier;
|
|
22743
|
+
// For TIERED pricing model: always show the first tier
|
|
22744
|
+
if (charge.pricingModel === PricingModel.TIERED) {
|
|
22745
|
+
selectedTier = charge.priceTiers[0];
|
|
22746
|
+
}
|
|
22747
|
+
// For VOLUME and BANDS pricing models: find the tier that contains the current quantity
|
|
22748
|
+
else if (charge.pricingModel === PricingModel.VOLUME ||
|
|
22749
|
+
charge.pricingModel === PricingModel.BANDS) {
|
|
22750
|
+
// Find the appropriate tier based on quantity
|
|
22751
|
+
selectedTier = charge.priceTiers.find(function (tier, index) {
|
|
22752
|
+
var nextTier = charge.priceTiers[index + 1];
|
|
22753
|
+
var tierStart = tier.starts;
|
|
22754
|
+
var tierEnd = nextTier ? nextTier.starts - 1 : Infinity;
|
|
22755
|
+
return charge.quantity >= tierStart && charge.quantity <= tierEnd;
|
|
22756
|
+
});
|
|
22757
|
+
// Fallback to first tier if no tier found (shouldn't happen with proper data)
|
|
22758
|
+
selectedTier = selectedTier || charge.priceTiers[0];
|
|
22759
|
+
}
|
|
22760
|
+
// Default fallback for any other pricing models
|
|
22761
|
+
else {
|
|
22762
|
+
selectedTier = charge.priceTiers[0];
|
|
22763
|
+
}
|
|
22764
|
+
if (!selectedTier)
|
|
22765
|
+
return '';
|
|
22766
|
+
// Calculate the tier range for display
|
|
22767
|
+
var tierIndex = charge.priceTiers.indexOf(selectedTier);
|
|
22768
|
+
var starts = selectedTier.starts;
|
|
22769
|
+
var nextTier = charge.priceTiers[tierIndex + 1];
|
|
22770
|
+
var ends = nextTier ? nextTier.starts - 1 : '∞';
|
|
22771
|
+
return hasMultiplePriceTiers(charge)
|
|
22772
|
+
? "".concat(starts, "-").concat(ends, ": ").concat(formatCurrency(selectedTier.price, currencyId, priceDecimals))
|
|
22773
|
+
: "".concat(formatCurrency(selectedTier.price, currencyId, priceDecimals));
|
|
22774
|
+
};
|
|
22775
|
+
|
|
22776
|
+
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";
|
|
22777
|
+
var billingDetailsUpdate = function (_a) {
|
|
22778
|
+
var attributes = _a.attributes, token = _a.token, apiHost = _a.apiHost;
|
|
22779
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
22780
|
+
var vars, response, errors;
|
|
22781
|
+
var _b;
|
|
22782
|
+
return __generator(this, function (_c) {
|
|
22783
|
+
switch (_c.label) {
|
|
22784
|
+
case 0:
|
|
22785
|
+
vars = { attributes: attributes };
|
|
22786
|
+
return [4 /*yield*/, gqlRequest({
|
|
22787
|
+
query: MUTATION,
|
|
22788
|
+
token: token,
|
|
22789
|
+
vars: vars,
|
|
22790
|
+
apiHost: apiHost,
|
|
22791
|
+
})];
|
|
22792
|
+
case 1:
|
|
22793
|
+
response = _c.sent();
|
|
22794
|
+
errors = (_b = response === null || response === void 0 ? void 0 : response.billingDetailsUpdate) === null || _b === void 0 ? void 0 : _b.errors;
|
|
22795
|
+
if (errors)
|
|
22796
|
+
throw errors;
|
|
22797
|
+
return [2 /*return*/, response.billingDetailsUpdate];
|
|
22798
|
+
}
|
|
22799
|
+
});
|
|
22800
|
+
});
|
|
22801
|
+
};
|
|
22802
|
+
|
|
22803
|
+
// TODO: move this to common
|
|
22804
|
+
var billingDetailsQuery = function () {
|
|
22805
|
+
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}";
|
|
22806
|
+
};
|
|
22807
|
+
var getBillingDetails = function (_a) {
|
|
22808
|
+
var token = _a.token, apiHost = _a.apiHost;
|
|
22809
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
22810
|
+
var response;
|
|
22811
|
+
var _b;
|
|
22812
|
+
return __generator(this, function (_c) {
|
|
22813
|
+
switch (_c.label) {
|
|
22814
|
+
case 0: return [4 /*yield*/, gqlRequest({
|
|
22815
|
+
query: billingDetailsQuery(),
|
|
22816
|
+
token: token,
|
|
22817
|
+
apiHost: apiHost,
|
|
22818
|
+
})];
|
|
22819
|
+
case 1:
|
|
22820
|
+
response = _c.sent();
|
|
22821
|
+
if (response === null || response === void 0 ? void 0 : response.errors) {
|
|
22822
|
+
throw new Error((_b = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _b === void 0 ? void 0 : _b.message);
|
|
22823
|
+
}
|
|
22824
|
+
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.billingDetails];
|
|
22825
|
+
}
|
|
22826
|
+
});
|
|
22827
|
+
});
|
|
22828
|
+
};
|
|
22829
|
+
|
|
22830
|
+
var Text$7 = Typography.Text;
|
|
22831
|
+
function BillingDetailsSection(_a) {
|
|
22832
|
+
var _this = this;
|
|
22833
|
+
var hidePaymentMethodForm = _a.hidePaymentMethodForm, countryListFilter = _a.countryListFilter;
|
|
22834
|
+
// State
|
|
22835
|
+
var _b = useState(false), isFormEdited = _b[0], setIsFormEdited = _b[1];
|
|
22836
|
+
var _c = useState(false), formIsValid = _c[0], setFormIsValid = _c[1];
|
|
22837
|
+
var form = Form.useForm()[0];
|
|
22838
|
+
var values = Form.useWatch([], form);
|
|
22839
|
+
// Context
|
|
22840
|
+
var apiHost = useContext(BunnyContext).apiHost;
|
|
22841
|
+
var token = useToken();
|
|
22842
|
+
// Hooks
|
|
22843
|
+
var isMobile = useIsMobile();
|
|
22844
|
+
var queryClient = useQueryClient();
|
|
22845
|
+
var showErrorNotification = useErrorNotification();
|
|
22846
|
+
var showSuccessNotification = useSuccessNotification();
|
|
22847
|
+
// Queries
|
|
22848
|
+
var _d = useQuery({
|
|
22849
|
+
queryKey: QueryKeyFactory.default.billingDetailsKey({ token: token }),
|
|
22850
|
+
queryFn: function () { return getBillingDetails({ token: token, apiHost: apiHost }); },
|
|
22851
|
+
}), billingDetails = _d.data, isLoadingBillingDetails = _d.isLoading;
|
|
22852
|
+
var _e = useMutation({
|
|
22853
|
+
mutationFn: function (changedFormData) { return __awaiter(_this, void 0, void 0, function () {
|
|
22854
|
+
var updatedBillingDetails;
|
|
22855
|
+
return __generator(this, function (_a) {
|
|
22856
|
+
switch (_a.label) {
|
|
22857
|
+
case 0: return [4 /*yield*/, billingDetailsUpdate({
|
|
22858
|
+
attributes: {
|
|
22859
|
+
name: changedFormData.name,
|
|
22860
|
+
billingStreet: changedFormData.billingStreet,
|
|
22861
|
+
billingCity: changedFormData.billingCity,
|
|
22862
|
+
billingZip: changedFormData.billingZip,
|
|
22863
|
+
billingState: changedFormData.billingState,
|
|
22864
|
+
billingCountry: changedFormData.billingCountry,
|
|
22865
|
+
billingContactEmail: changedFormData.billingContactEmail,
|
|
22866
|
+
taxNumber: changedFormData.taxNumber,
|
|
22867
|
+
},
|
|
22868
|
+
token: token,
|
|
22869
|
+
apiHost: apiHost,
|
|
22870
|
+
})];
|
|
22871
|
+
case 1:
|
|
22872
|
+
updatedBillingDetails = _a.sent();
|
|
22873
|
+
queryClient.setQueryData(QueryKeyFactory.default.billingDetailsKey({ token: token }), function (old) {
|
|
22874
|
+
return __assign(__assign({}, old), updatedBillingDetails.billingDetails);
|
|
22875
|
+
});
|
|
22876
|
+
return [2 /*return*/, updatedBillingDetails];
|
|
22877
|
+
}
|
|
22878
|
+
});
|
|
22879
|
+
}); },
|
|
22880
|
+
onSuccess: function () {
|
|
22881
|
+
showSuccessNotification('Your account details have been saved');
|
|
22882
|
+
queryClient.invalidateQueries({
|
|
22883
|
+
queryKey: QueryKeyFactory.default.taxationRequiredAccountFieldsKey({
|
|
22884
|
+
token: token,
|
|
22885
|
+
}),
|
|
22886
|
+
});
|
|
22887
|
+
},
|
|
22888
|
+
}), updateBillingDetails = _e.mutate, isUpdatingBillingDetails = _e.isPending;
|
|
22889
|
+
// Set form values when billing details are loaded
|
|
22890
|
+
useEffect(function () {
|
|
22891
|
+
var _a;
|
|
22892
|
+
if (billingDetails) {
|
|
22893
|
+
form.setFieldsValue({
|
|
22894
|
+
billingStreet: billingDetails.billingStreet,
|
|
22895
|
+
billingCity: billingDetails.billingCity,
|
|
22896
|
+
billingZip: billingDetails.billingZip,
|
|
22897
|
+
billingState: billingDetails.billingState,
|
|
22898
|
+
billingCountry: billingDetails.billingCountry,
|
|
22899
|
+
billingContactEmail: (_a = billingDetails.billingContact) === null || _a === void 0 ? void 0 : _a.email,
|
|
22900
|
+
taxNumber: billingDetails.taxNumber,
|
|
22901
|
+
});
|
|
22902
|
+
}
|
|
22903
|
+
}, [billingDetails]);
|
|
22904
|
+
useEffect(function () {
|
|
22905
|
+
form
|
|
22906
|
+
.validateFields({ validateOnly: true })
|
|
22907
|
+
.then(function () { return setFormIsValid(true); })
|
|
22908
|
+
.catch(function () { return setFormIsValid(false); });
|
|
22909
|
+
var isFormEdited = function () {
|
|
22910
|
+
var _a;
|
|
22911
|
+
if (!billingDetails)
|
|
22912
|
+
return false;
|
|
22913
|
+
var currentValues = form.getFieldsValue();
|
|
22914
|
+
var accountValues = {
|
|
22915
|
+
billingStreet: billingDetails.billingStreet,
|
|
22916
|
+
billingCity: billingDetails.billingCity,
|
|
22917
|
+
billingZip: billingDetails.billingZip,
|
|
22918
|
+
billingState: billingDetails.billingState,
|
|
22919
|
+
billingCountry: billingDetails.billingCountry,
|
|
22920
|
+
billingContactEmail: (_a = billingDetails.billingContact) === null || _a === void 0 ? void 0 : _a.email,
|
|
22921
|
+
taxNumber: billingDetails.taxNumber,
|
|
22922
|
+
};
|
|
22923
|
+
return Object.keys(currentValues).some(function (key) {
|
|
22924
|
+
var value = accountValues[key];
|
|
22925
|
+
return currentValues[key] !== value;
|
|
22926
|
+
});
|
|
22927
|
+
};
|
|
22928
|
+
setIsFormEdited(isFormEdited());
|
|
22929
|
+
}, [form, values, billingDetails]);
|
|
22930
|
+
// Validate form fields when isFormEdited changes
|
|
22931
|
+
useEffect(function () {
|
|
22932
|
+
var validateOnly = isFormEdited ? false : true;
|
|
22933
|
+
form.validateFields({ validateOnly: validateOnly });
|
|
22934
|
+
}, [isFormEdited]);
|
|
22935
|
+
var saveBillingDetails = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
22936
|
+
var _this = this;
|
|
22937
|
+
return __generator(this, function (_a) {
|
|
22938
|
+
form.validateFields({ validateOnly: false }).then(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
22939
|
+
var error_1;
|
|
22940
|
+
return __generator(this, function (_a) {
|
|
22941
|
+
switch (_a.label) {
|
|
22942
|
+
case 0:
|
|
22943
|
+
_a.trys.push([0, 2, 3, 4]);
|
|
22944
|
+
return [4 /*yield*/, form.validateFields()];
|
|
22945
|
+
case 1:
|
|
22946
|
+
_a.sent();
|
|
22947
|
+
updateBillingDetails(form.getFieldsValue());
|
|
22948
|
+
return [3 /*break*/, 4];
|
|
22949
|
+
case 2:
|
|
22950
|
+
error_1 = _a.sent();
|
|
22951
|
+
if (error_1 instanceof Error) {
|
|
22952
|
+
showErrorNotification('Failed to update account', error_1.message);
|
|
22953
|
+
}
|
|
22954
|
+
else {
|
|
22955
|
+
showErrorNotification('Please fill out all required fields');
|
|
22956
|
+
}
|
|
22957
|
+
return [3 /*break*/, 4];
|
|
22958
|
+
case 3:
|
|
22959
|
+
setIsFormEdited(false);
|
|
22960
|
+
return [7 /*endfinally*/];
|
|
22961
|
+
case 4: return [2 /*return*/];
|
|
22962
|
+
}
|
|
22963
|
+
});
|
|
22964
|
+
}); });
|
|
22965
|
+
return [2 /*return*/];
|
|
22966
|
+
});
|
|
22967
|
+
}); };
|
|
22968
|
+
var filteredCountryList = useMemo(function () {
|
|
22969
|
+
return countryListFilter ? Lists.COUNTRY_LIST.filter(countryListFilter) : Lists.COUNTRY_LIST;
|
|
22970
|
+
}, [countryListFilter]);
|
|
22971
|
+
return (jsx("div", __assign({ className: "".concat(isMobile || hidePaymentMethodForm ? 'bunny-w-full' : 'bunny-w-1/2') }, { children: jsxs("div", __assign({ className: "bunny-px-4" }, { children: [jsxs(Skeleton, __assign({ loading: isLoadingBillingDetails }, { children: [jsx("div", __assign({ className: "bunny-mb-2" }, { children: jsx(Text$7, __assign({ className: "bunny-font-medium bunny-text-lg" }, { children: (billingDetails === null || billingDetails === void 0 ? void 0 : billingDetails.name) || 'No company name' })) })), jsxs(Form, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-2", form: form, layout: "vertical", disabled: isUpdatingBillingDetails, autoComplete: "off" }, { children: [jsx(Form.Item, __assign({ label: "Street address", name: "billingStreet", rules: [{ required: true, message: 'Street address is required' }] }, { children: jsx(Input, {}) })), jsxs("div", __assign({ className: "bunny-flex bunny-gap-4" }, { children: [jsx(Form.Item, __assign({ label: "City", name: "billingCity", rules: [{ required: true, message: 'City is required' }], className: "bunny-flex-1" }, { children: jsx(Input, {}) })), jsx(Form.Item, __assign({ label: "Zipcode", name: "billingZip", rules: [{ required: true, message: 'Zipcode is required' }], className: "bunny-flex-1" }, { children: jsx(Input, {}) }))] })), jsxs("div", __assign({ className: "bunny-flex ".concat(isMobile ? 'bunny-flex-row bunny-pb-2' : 'bunny-flex-row', " bunny-gap-4") }, { children: [jsx("div", __assign({ className: "bunny-flex-1 bunny-w-1/2" }, { children: jsx(Form.Item, __assign({ label: "State", name: "billingState", rules: [
|
|
22972
|
+
{
|
|
22973
|
+
required: false,
|
|
22974
|
+
},
|
|
22975
|
+
] }, { children: jsx(Input, {}) })) })), jsx("div", __assign({ className: "bunny-flex-1 bunny-w-1/2" }, { children: jsx(Form.Item, __assign({ label: "Country", name: "billingCountry", rules: [{ required: true, message: 'Country is required' }] }, { children: jsx(Select, { className: "bunny-w-full", options: filteredCountryList, placeholder: "Select a country", popupMatchSelectWidth: false, showSearch: true, filterOption: function (input, option) {
|
|
22976
|
+
var _a, _b;
|
|
22977
|
+
return ((_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a : '').toLowerCase().includes(input.toLowerCase()) ||
|
|
22978
|
+
((_b = option === null || option === void 0 ? void 0 : option.value) !== null && _b !== void 0 ? _b : '').toLowerCase().includes(input.toLowerCase());
|
|
22979
|
+
} }) })) }))] })), jsx(Form.Item, __assign({ label: "Email", name: "billingContactEmail", rules: [
|
|
22980
|
+
{
|
|
22981
|
+
required: true,
|
|
22982
|
+
message: 'Email is required',
|
|
22983
|
+
type: 'email',
|
|
22984
|
+
},
|
|
22985
|
+
] }, { children: jsx(Input, {}) })), jsx(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: jsx(Input, {}) }))] }))] })), jsx(Button, __assign({ disabled: !isFormEdited || isUpdatingBillingDetails || !formIsValid, className: "bunny-w-full bunny-mt-4", type: "primary", onClick: saveBillingDetails }, { children: "Save" }))] })) })));
|
|
22986
|
+
}
|
|
22987
|
+
|
|
22988
|
+
var BillingDetails = function (_a) {
|
|
22989
|
+
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;
|
|
22990
|
+
// Hooks
|
|
22991
|
+
var isMobile = useIsMobile();
|
|
22992
|
+
return (jsx(WrapperComponent, __assign({ isCardEnabled: isCardEnabled, shadow: shadow, className: className }, { children: 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 ? (jsx(BillingDetailsSection, { hidePaymentMethodForm: hidePaymentMethodForm, countryListFilter: countryListFilter })) : null, !hideBillingDetailsForm && !hidePaymentMethodForm ? jsx(ResponsiveDivider, {}) : null, !hidePaymentMethodForm ? (jsx(PaymentFormSection, { hideBillingDetailsForm: hideBillingDetailsForm, isUpgradeFromTrial: isUpgradeFromTrial, onSavePaymentMethod: onSavePaymentMethod })) : null] })) })));
|
|
22993
|
+
};
|
|
22994
|
+
var WrapperComponent = function (_a) {
|
|
22995
|
+
var children = _a.children, isCardEnabled = _a.isCardEnabled, shadow = _a.shadow, className = _a.className;
|
|
22996
|
+
return (jsx("div", __assign({ className: "".concat(className) }, { children: isCardEnabled ? jsx(Card, __assign({ className: "".concat(shadow) }, { children: children })) : jsx("div", { children: children }) })));
|
|
22997
|
+
};
|
|
22998
|
+
var ResponsiveDivider = function () {
|
|
22999
|
+
var isMobile = useIsMobile();
|
|
23000
|
+
return isMobile ? (jsx("div", __assign({ className: "bunny-mx-4" }, { children: jsx(Divider, {}) }))) : (jsx("div", { children: jsx(Divider, { className: "bunny-h-full", type: "vertical" }) }));
|
|
23001
|
+
};
|
|
23002
|
+
var PaymentFormSection = function (_a) {
|
|
23003
|
+
var hideBillingDetailsForm = _a.hideBillingDetailsForm, isUpgradeFromTrial = _a.isUpgradeFromTrial, onSavePaymentMethod = _a.onSavePaymentMethod;
|
|
23004
|
+
var isMobile = useIsMobile();
|
|
23005
|
+
var onTokenExpired = useContext(BunnyContext).onTokenExpired;
|
|
23006
|
+
var handleAllErrorFormats = useAllErrorFormats(onTokenExpired);
|
|
23007
|
+
var showSuccessNotification = useSuccessNotification();
|
|
23008
|
+
var entityId = useCurrentUserData().entityId;
|
|
23009
|
+
return (jsx("div", __assign({ className: "".concat(isMobile || hideBillingDetailsForm ? 'bunny-w-full' : 'bunny-w-1/2 bunny-pt-4', " bunny-flex bunny-justify-center") }, { children: jsx(PaymentForm, { entityId: entityId, onFail: function (error) {
|
|
23010
|
+
handleAllErrorFormats(error);
|
|
23011
|
+
}, onSavePaymentMethod: function () {
|
|
23012
|
+
showSuccessNotification(isUpgradeFromTrial
|
|
23013
|
+
? 'Payment method saved! Your trial will automatically convert to a paid subscription.'
|
|
23014
|
+
: 'Payment method saved successfully!');
|
|
23015
|
+
onSavePaymentMethod === null || onSavePaymentMethod === void 0 ? void 0 : onSavePaymentMethod();
|
|
23016
|
+
} }) })));
|
|
23017
|
+
};
|
|
23018
|
+
|
|
23019
|
+
var UpgradeFromTrial = function (_a) {
|
|
23020
|
+
var onClose = _a.onClose, open = _a.open;
|
|
23021
|
+
return (jsx(Modal, __assign({ width: '80vw', open: open, onCancel: onClose, footer: null }, { children: jsx(BillingDetails, { isUpgradeFromTrial: true, onSavePaymentMethod: onClose }) })));
|
|
23022
|
+
};
|
|
23023
|
+
|
|
23024
|
+
var SubscriptionCardActions = function (_a) {
|
|
23025
|
+
var _b;
|
|
23026
|
+
var onChangePlanClick = _a.onChangePlanClick, onCancelSubscriptionClick = _a.onCancelSubscriptionClick, priceListChangeOptions = _a.priceListChangeOptions, subscription = _a.subscription;
|
|
23027
|
+
var apiHost = useContext(BunnyContext).apiHost;
|
|
23028
|
+
var token = useToken();
|
|
23029
|
+
var _c = usePaymentMethod({
|
|
23030
|
+
accountId: subscription.accountId,
|
|
23031
|
+
token: token,
|
|
23032
|
+
apiHost: apiHost,
|
|
23033
|
+
}), storedPaymentMethods = _c.paymentMethods, isPaymentMethodLoading = _c.isLoading;
|
|
23034
|
+
// Local state
|
|
23035
|
+
var _d = useState(false), isUpgradeFromTrialModalOpen = _d[0], setIsUpgradeFromTrialModalOpen = _d[1];
|
|
23036
|
+
// Derived state
|
|
23037
|
+
var isSelfServiceCancelable = subscription.plan.selfServiceCancel;
|
|
23038
|
+
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; });
|
|
23039
|
+
var arePlansAvailable = ((productPlans === null || productPlans === void 0 ? void 0 : productPlans.length) || 0) > 0;
|
|
23040
|
+
var isInTrial = isSubscriptionTrial(subscription);
|
|
23041
|
+
var isActiveOrPending = isSubscriptionActiveOrPending(subscription);
|
|
23042
|
+
if (isPaymentMethodLoading)
|
|
23043
|
+
return null;
|
|
23044
|
+
return (jsxs(Fragment, { children: [isSelfServiceCancelable && (isInTrial || isActiveOrPending) && (jsx(Popconfirm, __assign({ icon: null, onConfirm: function () { return onCancelSubscriptionClick === null || onCancelSubscriptionClick === void 0 ? void 0 : onCancelSubscriptionClick(subscription); }, title: "Cancel subscription" }, { children: jsx(Button, __assign({ className: "bunny-p-0", type: "link" }, { children: "Cancel subscription" })) }))), isInTrial && !(storedPaymentMethods === null || storedPaymentMethods === void 0 ? void 0 : storedPaymentMethods.length) && (jsx(Button, __assign({ onClick: function () { return setIsUpgradeFromTrialModalOpen(true); }, type: "primary" }, { children: "Upgrade from trial" }))), arePlansAvailable && (isInTrial || isActiveOrPending) && (jsx(Button, __assign({ onClick: function () { return onChangePlanClick(subscription); }, type: isInTrial ? 'default' : 'primary' }, { children: "Change plan" }))), jsx(UpgradeFromTrial, { onClose: function () { return setIsUpgradeFromTrialModalOpen(false); }, open: isUpgradeFromTrialModalOpen })] }));
|
|
23045
|
+
};
|
|
23046
|
+
|
|
23047
|
+
var Text$6 = Typography.Text;
|
|
23048
|
+
var getSubscriptionStatusText = function (subscription) {
|
|
23049
|
+
var cancellationDate = subscription.cancellationDate, state = subscription.state, evergreen = subscription.evergreen, endDate = subscription.endDate;
|
|
23050
|
+
if (cancellationDate &&
|
|
23051
|
+
(state === null || state === void 0 ? void 0 : state.toUpperCase()) !== SubscriptionState$2.CANCELED &&
|
|
23052
|
+
(state === null || state === void 0 ? void 0 : state.toUpperCase()) !== SubscriptionState$2.EXPIRED) {
|
|
23053
|
+
return (jsxs(CustomizedTag, __assign({ color: "red" }, { children: ["Canceled - ends on ", formatDate(cancellationDate)] })));
|
|
23054
|
+
}
|
|
23055
|
+
if (evergreen) {
|
|
23056
|
+
return "Renews on ".concat(formatDate(endDate));
|
|
23057
|
+
}
|
|
23058
|
+
if ((state === null || state === void 0 ? void 0 : state.toUpperCase()) === SubscriptionState$2.CANCELED ||
|
|
23059
|
+
(state === null || state === void 0 ? void 0 : state.toUpperCase()) === SubscriptionState$2.EXPIRED) {
|
|
23060
|
+
return "Ended on ".concat(formatDate(endDate));
|
|
22893
23061
|
}
|
|
22894
23062
|
return "Ends on ".concat(formatDate(endDate));
|
|
22895
23063
|
};
|
|
@@ -22905,7 +23073,7 @@ var SubscriptionCardHeader = function (_a) {
|
|
|
22905
23073
|
var isTrial = ((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === SubscriptionState$2.TRIAL;
|
|
22906
23074
|
return (jsxs("div", __assign({ className: "bunny-flex bunny-items-center bunny-justify-between", style: {
|
|
22907
23075
|
backgroundColor: darkMode ? 'var(--row-background-dark)' : '',
|
|
22908
|
-
} }, { children: [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) && (jsx(Text$
|
|
23076
|
+
} }, { children: [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) && (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() }))), 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) && (jsx(Text$6, __assign({ className: "bunny-text-lg" }, { children: subscription.plan.name }))), jsxs(CustomizedTag, __assign({ color: 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)") : ''] }))] }))] })), jsxs("div", __assign({ className: "bunny-flex bunny-items-center bunny-gap-6" }, { children: [jsx(Text$6, __assign({ className: "bunny-grow bunny-text-xs" }, { children: getSubscriptionStatusText(subscription) })), !isMobile && priceListChangeOptions && onChangePlanClick && onCancelSubscriptionClick && (jsx(SubscriptionCardActions, { onChangePlanClick: onChangePlanClick, onCancelSubscriptionClick: onCancelSubscriptionClick, priceListChangeOptions: priceListChangeOptions, subscription: subscription }))] }))] })));
|
|
22909
23077
|
};
|
|
22910
23078
|
|
|
22911
23079
|
var SubscriptionChargeTotal = function (_a) {
|
|
@@ -22982,16 +23150,16 @@ var SubscriptionChargeUnitPrice = function (_a) {
|
|
|
22982
23150
|
return (jsx(Fragment, { children: hasPriceTiers(charge) ? (jsx(TieredDisplayDropdown, { charge: charge, currencyId: currencyId, truncatedText: "".concat(charge.kind === QuoteChangeKind.PRICE_UPDATE ? 'new ' : '').concat(getApplicablePriceTier(charge, currencyId, charge.priceDecimals)) })) : isChargeDiscount ? ("-".concat(price)) : (price) }));
|
|
22983
23151
|
};
|
|
22984
23152
|
|
|
22985
|
-
var Text$
|
|
23153
|
+
var Text$5 = Typography.Text;
|
|
22986
23154
|
var SubscriptionCardColumnHeaders = function (_a) {
|
|
22987
23155
|
var columns = _a.columns;
|
|
22988
|
-
return (jsx(Fragment, { children: columns.map(function (subscriptionColumn, index) { return (jsx(Text$
|
|
23156
|
+
return (jsx(Fragment, { children: columns.map(function (subscriptionColumn, index) { return (jsx(Text$5, __assign({ className: "bunny-text-slate-400 ".concat(subscriptionColumn.className), style: { fontSize: "11px" } }, { children: subscriptionColumn.title }), index)); }) }));
|
|
22989
23157
|
};
|
|
22990
23158
|
|
|
22991
|
-
var Text$
|
|
23159
|
+
var Text$4 = Typography.Text;
|
|
22992
23160
|
var SubscriptionsListCell = function (_a) {
|
|
22993
23161
|
var children = _a.children, className = _a.className, gridColumn = _a.gridColumn, right = _a.right, style = _a.style;
|
|
22994
|
-
return (jsx(Text$
|
|
23162
|
+
return (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 })));
|
|
22995
23163
|
};
|
|
22996
23164
|
|
|
22997
23165
|
var CARD_COLUMNS = [
|
|
@@ -23051,9 +23219,11 @@ var SubscriptionCardDesktopRow = function (_a) {
|
|
|
23051
23219
|
var chargePeriod = "".concat(formatDate(charge.startDate), " - ").concat(formatDate(charge.endDate));
|
|
23052
23220
|
// Queries
|
|
23053
23221
|
var data = useQuery({
|
|
23054
|
-
queryKey: ['getFeatureUsage', charge.id],
|
|
23222
|
+
queryKey: ['getFeatureUsage', charge.id, charge.startDate, charge.endDate],
|
|
23055
23223
|
queryFn: function () {
|
|
23056
23224
|
return getFeatureUsage({
|
|
23225
|
+
endDate: charge.endDate,
|
|
23226
|
+
startDate: charge.startDate,
|
|
23057
23227
|
subscriptionChargeId: charge.id,
|
|
23058
23228
|
token: token,
|
|
23059
23229
|
apiHost: apiHost,
|
|
@@ -23077,10 +23247,10 @@ var SubscriptionCardDesktopRow = function (_a) {
|
|
|
23077
23247
|
: (_c = charge.quantity) === null || _c === void 0 ? void 0 : _c.toLocaleString() })), jsx(SubscriptionsListCell, __assign({ right: true }, { children: jsx(SubscriptionChargeUnitPrice, { charge: charge, currencyId: subscription.currencyId }) })), jsx(SubscriptionsListCell, __assign({ right: true }, { children: jsx(SubscriptionChargeTotal, { charge: charge, subscription: subscription }) }))] })));
|
|
23078
23248
|
};
|
|
23079
23249
|
|
|
23080
|
-
var Text$
|
|
23250
|
+
var Text$3 = Typography.Text;
|
|
23081
23251
|
var SubscriptionCardCellMobile = function (_a) {
|
|
23082
23252
|
var children = _a.children, className = _a.className, style = _a.style;
|
|
23083
|
-
return (jsx(Text$
|
|
23253
|
+
return (jsx(Text$3, __assign({ className: className, style: style }, { children: children })));
|
|
23084
23254
|
};
|
|
23085
23255
|
|
|
23086
23256
|
var CHARGE_COLUMNS = [
|
|
@@ -23146,13 +23316,10 @@ var SubscriptionsListContainer = function (_a) {
|
|
|
23146
23316
|
var apiHost = useContext(BunnyContext).apiHost;
|
|
23147
23317
|
var gap = useContext(SubscriptionsContext).gap;
|
|
23148
23318
|
var token = useToken();
|
|
23149
|
-
var account = useCurrentUserData(token).account;
|
|
23150
23319
|
// Queries
|
|
23151
23320
|
var _c = useQuery({
|
|
23152
23321
|
queryKey: QueryKeyFactory.default.planChangeOptionsKey({ token: token }),
|
|
23153
|
-
queryFn: function () {
|
|
23154
|
-
return getPriceListChangeOptions({ apiHost: apiHost, token: token, accountCurrencyId: account === null || account === void 0 ? void 0 : account.currencyId });
|
|
23155
|
-
},
|
|
23322
|
+
queryFn: function () { return getPriceListChangeOptions({ apiHost: apiHost, token: token }); },
|
|
23156
23323
|
enabled: Boolean(onChangePlanClick),
|
|
23157
23324
|
}), priceListChangeOptions = _c.data, arePriceListChangeOptionsLoading = _c.isLoading;
|
|
23158
23325
|
if (subscriptionsAreLoading ||
|
|
@@ -23161,10 +23328,10 @@ var SubscriptionsListContainer = function (_a) {
|
|
|
23161
23328
|
return (jsx(Fragment, { children: (subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.length) > 0 ? (jsx("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-".concat(gap, " bunny-shrink bunny-overflow-auto") }, { children: jsx(SubscriptionsList, { hideExpired: hideExpired, onChangePlanClick: onChangePlanClick, onCancelSubscriptionClick: onCancelSubscriptionClick, priceListChangeOptions: priceListChangeOptions, subscriptions: subscriptions }) }))) : (noSubscriptionsComponent || (jsx("div", __assign({ className: "bunny-flex bunny-flex-col bunny-items-center bunny-w-full" }, { children: jsx(ErrorView, { message: "You have no subscriptions with ".concat(companyName, " yet") }) })))) }));
|
|
23162
23329
|
};
|
|
23163
23330
|
|
|
23164
|
-
var Text$
|
|
23331
|
+
var Text$2 = Typography.Text;
|
|
23165
23332
|
var DrawerHeader = function (_a) {
|
|
23166
23333
|
var description = _a.description, onClose = _a.onClose, title = _a.title, closeButtonClassName = _a.closeButtonClassName;
|
|
23167
|
-
return (jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4" }, { children: [jsxs("div", __assign({ className: "bunny-flex bunny-items-center bunny-justify-between bunny-gap-2" }, { children: [jsx(Text$
|
|
23334
|
+
return (jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4" }, { children: [jsxs("div", __assign({ className: "bunny-flex bunny-items-center bunny-justify-between bunny-gap-2" }, { children: [jsx(Text$2, __assign({ className: "bunny-text-xl", style: { fontWeight: 400 } }, { children: title })), onClose ? (jsx("button", __assign({ id: "closePayment", onClick: onClose, className: closeButtonClassName }, { children: jsx(CloseOutlined, {}) }))) : null] })), description && jsx("div", __assign({ className: "bunny-text-xs" }, { children: description }))] })));
|
|
23168
23335
|
};
|
|
23169
23336
|
|
|
23170
23337
|
var formatDateForApi = function (date) {
|
|
@@ -23347,13 +23514,13 @@ var QuantityInput = function (_a) {
|
|
|
23347
23514
|
}, status: isQuantityLowerThanOriginal(charge.quantity) ? 'error' : '', style: { width: '96px' }, value: value }) }));
|
|
23348
23515
|
};
|
|
23349
23516
|
|
|
23350
|
-
var Text$
|
|
23517
|
+
var Text$1 = Typography.Text;
|
|
23351
23518
|
var QuantityChangeGridRow = function (_a) {
|
|
23352
23519
|
var _b;
|
|
23353
23520
|
var chargeIndex = _a.chargeIndex, editingQuote = _a.editingQuote, subscriptions = _a.subscriptions, subscriptionIndex = _a.subscriptionIndex, setEditingQuoteData = _a.setEditingQuoteData, subscription = _a.subscription, subscriptionCharge = _a.subscriptionCharge;
|
|
23354
23521
|
if (!canShowQuantitiesInput(subscriptionCharge, subscription))
|
|
23355
23522
|
return null;
|
|
23356
|
-
return (jsxs(Fragment, { children: [jsx(Text$
|
|
23523
|
+
return (jsxs(Fragment, { children: [jsx(Text$1, __assign({ className: "bunny-font-medium bunny-text-orange-600 bunny-col-span-full", style: { fontSize: "11px" } }, { children: subscription.plan.name })), 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() })), 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 })), jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-items-end" }, { children: [jsx(QuantityInput, { charge: subscriptionCharge, chargeIndex: chargeIndex, editingQuote: editingQuote, setEditingQuoteData: setEditingQuoteData, subscription: subscription, subscriptionIndex: subscriptionIndex, subscriptions: subscriptions }), jsx("div", {})] })), jsx(Divider, { className: "bunny-col-span-full bunny-my-2" })] }));
|
|
23357
23524
|
};
|
|
23358
23525
|
|
|
23359
23526
|
var QuantityChangeGridTitle = function (_a) {
|
|
@@ -23464,7 +23631,7 @@ var SubscriptionsNavigation = function (_a) {
|
|
|
23464
23631
|
return (jsxs(Fragment, { children: [!isMobile && expiredSwitchVisible && (jsx(HideExpiredToggle, { hideExpired: hideExpired, setHideExpired: setHideExpired })), jsx("div", __assign({ className: "bunny-flex bunny-grow bunny-gap-2 ".concat(isMobile ? 'bunny-flex-col' : 'bunny-justify-end') }, { children: canShowChangeQuantitiesButton && (jsx(ChangeQuantitiesButton, { canShowChangeQuantitiesButton: canShowChangeQuantitiesButton, setQuantityDrawerOpen: setQuantityDrawerOpen })) }))] }));
|
|
23465
23632
|
};
|
|
23466
23633
|
|
|
23467
|
-
var Text
|
|
23634
|
+
var Text = Typography.Text;
|
|
23468
23635
|
var SubscriptionsWrapper = function (_a) {
|
|
23469
23636
|
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;
|
|
23470
23637
|
var defaultStyles = {
|
|
@@ -23623,7 +23790,7 @@ var Subscriptions = function (_a) {
|
|
|
23623
23790
|
setIsChangingPlan(false);
|
|
23624
23791
|
}, handlePortalErrors: handlePortalErrors }));
|
|
23625
23792
|
}
|
|
23626
|
-
return (jsxs("div", __assign({ className: className }, { children: [!hideTitle ? jsx(PageTitle, { title: 'Subscriptions' }) : null, jsx(PageHeaderWithActions, __assign({ title: jsx(Fragment, { children: !hideExpiredToggle && (jsxs(Text
|
|
23793
|
+
return (jsxs("div", __assign({ className: className }, { children: [!hideTitle ? jsx(PageTitle, { title: 'Subscriptions' }) : null, jsx(PageHeaderWithActions, __assign({ title: jsx(Fragment, { children: !hideExpiredToggle && (jsxs(Text, __assign({ className: "bunny-flex bunny-items-center bunny-justify-between", style: { minWidth: '120px' } }, { children: [hideExpired ? 'Active subscriptions' : 'All subscriptions', isMobile && expiredSwitchVisible && (jsx(HideExpiredToggle, { hideExpired: hideExpired, setHideExpired: setHideExpiredState }))] }))) }) }, { children: !isMobile && (jsx(SubscriptionsNavigation, { expiredSwitchVisible: !hideExpiredToggle && expiredSwitchVisible, hideExpired: hideExpired, setHideExpired: setHideExpiredState, setQuantityDrawerOpen: setQuantityDrawerOpen, subscriptions: subscriptions })) })), jsx(SubscriptionsListContainer, { companyName: companyName, hideExpired: hideExpired, onCancelSubscriptionClick: onCancelSubscriptionClick, onChangePlanClick: onChangePlanClick, subscriptions: subscriptions, subscriptionsAreLoading: subscriptionsAreLoading, noSubscriptionsComponent: noSubscriptionsComponent }), isMobile && (jsx("div", __assign({ className: "bunny-pt-4 bunny-pb-2" }, { children: jsx(SubscriptionsNavigation, { expiredSwitchVisible: expiredSwitchVisible, hideExpired: hideExpired, setHideExpired: setHideExpiredState, setQuantityDrawerOpen: setQuantityDrawerOpen, subscriptions: subscriptions }) }))), jsx(QuantityChangeDrawerDesktop, { editingQuote: quote, editingQuoteData: editingQuoteData, onClose: onClose, open: quantityDrawerOpen, openCheckout: function () { return setPayModalVisible(true); }, setEditingQuoteData: setEditingQuoteData, subscriptions: subscriptions }), jsx(Checkout, { onCancel: onCancel, onSuccess: onSuccess, onFail: onFail, open: payModalVisible, quote: quote, token: token, storedPaymentMethod: defaultPaymentMethod })] })));
|
|
23627
23794
|
};
|
|
23628
23795
|
var PageHeaderWithActions = function (_a) {
|
|
23629
23796
|
var children = _a.children, title = _a.title;
|
|
@@ -23638,248 +23805,4 @@ var PageSubTitle = function (_a) {
|
|
|
23638
23805
|
return (jsx("div", __assign({ className: "bunny-shrink-0 bunny-font-medium", style: { color: secondaryColor } }, { children: title })));
|
|
23639
23806
|
};
|
|
23640
23807
|
|
|
23641
|
-
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";
|
|
23642
|
-
var billingDetailsUpdate = function (_a) {
|
|
23643
|
-
var attributes = _a.attributes, token = _a.token, apiHost = _a.apiHost;
|
|
23644
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
23645
|
-
var vars, response, errors;
|
|
23646
|
-
var _b;
|
|
23647
|
-
return __generator(this, function (_c) {
|
|
23648
|
-
switch (_c.label) {
|
|
23649
|
-
case 0:
|
|
23650
|
-
vars = { attributes: attributes };
|
|
23651
|
-
return [4 /*yield*/, gqlRequest({
|
|
23652
|
-
query: MUTATION,
|
|
23653
|
-
token: token,
|
|
23654
|
-
vars: vars,
|
|
23655
|
-
apiHost: apiHost,
|
|
23656
|
-
})];
|
|
23657
|
-
case 1:
|
|
23658
|
-
response = _c.sent();
|
|
23659
|
-
errors = (_b = response === null || response === void 0 ? void 0 : response.billingDetailsUpdate) === null || _b === void 0 ? void 0 : _b.errors;
|
|
23660
|
-
if (errors)
|
|
23661
|
-
throw errors;
|
|
23662
|
-
return [2 /*return*/, response.billingDetailsUpdate];
|
|
23663
|
-
}
|
|
23664
|
-
});
|
|
23665
|
-
});
|
|
23666
|
-
};
|
|
23667
|
-
|
|
23668
|
-
// TODO: move this to common
|
|
23669
|
-
var billingDetailsQuery = function () {
|
|
23670
|
-
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}";
|
|
23671
|
-
};
|
|
23672
|
-
var getBillingDetails = function (_a) {
|
|
23673
|
-
var token = _a.token, apiHost = _a.apiHost;
|
|
23674
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
23675
|
-
var response;
|
|
23676
|
-
var _b;
|
|
23677
|
-
return __generator(this, function (_c) {
|
|
23678
|
-
switch (_c.label) {
|
|
23679
|
-
case 0: return [4 /*yield*/, gqlRequest({
|
|
23680
|
-
query: billingDetailsQuery(),
|
|
23681
|
-
token: token,
|
|
23682
|
-
apiHost: apiHost,
|
|
23683
|
-
})];
|
|
23684
|
-
case 1:
|
|
23685
|
-
response = _c.sent();
|
|
23686
|
-
if (response === null || response === void 0 ? void 0 : response.errors) {
|
|
23687
|
-
throw new Error((_b = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _b === void 0 ? void 0 : _b.message);
|
|
23688
|
-
}
|
|
23689
|
-
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.billingDetails];
|
|
23690
|
-
}
|
|
23691
|
-
});
|
|
23692
|
-
});
|
|
23693
|
-
};
|
|
23694
|
-
|
|
23695
|
-
var Text = Typography.Text;
|
|
23696
|
-
function BillingDetailsSection(_a) {
|
|
23697
|
-
var _this = this;
|
|
23698
|
-
var hidePaymentMethodForm = _a.hidePaymentMethodForm, countryListFilter = _a.countryListFilter;
|
|
23699
|
-
// State
|
|
23700
|
-
var _b = useState(false), isFormEdited = _b[0], setIsFormEdited = _b[1];
|
|
23701
|
-
var _c = useState(false), formIsValid = _c[0], setFormIsValid = _c[1];
|
|
23702
|
-
var form = Form.useForm()[0];
|
|
23703
|
-
var values = Form.useWatch([], form);
|
|
23704
|
-
// Context
|
|
23705
|
-
var apiHost = useContext(BunnyContext).apiHost;
|
|
23706
|
-
var token = useToken();
|
|
23707
|
-
// Hooks
|
|
23708
|
-
var isMobile = useIsMobile();
|
|
23709
|
-
var queryClient = useQueryClient();
|
|
23710
|
-
var showErrorNotification = useErrorNotification();
|
|
23711
|
-
var showSuccessNotification = useSuccessNotification();
|
|
23712
|
-
// Queries
|
|
23713
|
-
var _d = useQuery({
|
|
23714
|
-
queryKey: QueryKeyFactory.default.billingDetailsKey({ token: token }),
|
|
23715
|
-
queryFn: function () { return getBillingDetails({ token: token, apiHost: apiHost }); },
|
|
23716
|
-
}), billingDetails = _d.data, isLoadingBillingDetails = _d.isLoading;
|
|
23717
|
-
var _e = useMutation({
|
|
23718
|
-
mutationFn: function (changedFormData) { return __awaiter(_this, void 0, void 0, function () {
|
|
23719
|
-
var updatedBillingDetails;
|
|
23720
|
-
return __generator(this, function (_a) {
|
|
23721
|
-
switch (_a.label) {
|
|
23722
|
-
case 0: return [4 /*yield*/, billingDetailsUpdate({
|
|
23723
|
-
attributes: {
|
|
23724
|
-
name: changedFormData.name,
|
|
23725
|
-
billingStreet: changedFormData.billingStreet,
|
|
23726
|
-
billingCity: changedFormData.billingCity,
|
|
23727
|
-
billingZip: changedFormData.billingZip,
|
|
23728
|
-
billingState: changedFormData.billingState,
|
|
23729
|
-
billingCountry: changedFormData.billingCountry,
|
|
23730
|
-
billingContactEmail: changedFormData.billingContactEmail,
|
|
23731
|
-
taxNumber: changedFormData.taxNumber,
|
|
23732
|
-
},
|
|
23733
|
-
token: token,
|
|
23734
|
-
apiHost: apiHost,
|
|
23735
|
-
})];
|
|
23736
|
-
case 1:
|
|
23737
|
-
updatedBillingDetails = _a.sent();
|
|
23738
|
-
queryClient.setQueryData(QueryKeyFactory.default.billingDetailsKey({ token: token }), function (old) {
|
|
23739
|
-
return __assign(__assign({}, old), updatedBillingDetails.billingDetails);
|
|
23740
|
-
});
|
|
23741
|
-
return [2 /*return*/, updatedBillingDetails];
|
|
23742
|
-
}
|
|
23743
|
-
});
|
|
23744
|
-
}); },
|
|
23745
|
-
onSuccess: function () {
|
|
23746
|
-
showSuccessNotification('Your account details have been saved');
|
|
23747
|
-
queryClient.invalidateQueries({
|
|
23748
|
-
queryKey: QueryKeyFactory.default.taxationRequiredAccountFieldsKey({
|
|
23749
|
-
token: token,
|
|
23750
|
-
}),
|
|
23751
|
-
});
|
|
23752
|
-
},
|
|
23753
|
-
}), updateBillingDetails = _e.mutate, isUpdatingBillingDetails = _e.isPending;
|
|
23754
|
-
// Set form values when billing details are loaded
|
|
23755
|
-
useEffect(function () {
|
|
23756
|
-
var _a;
|
|
23757
|
-
if (billingDetails) {
|
|
23758
|
-
form.setFieldsValue({
|
|
23759
|
-
billingStreet: billingDetails.billingStreet,
|
|
23760
|
-
billingCity: billingDetails.billingCity,
|
|
23761
|
-
billingZip: billingDetails.billingZip,
|
|
23762
|
-
billingState: billingDetails.billingState,
|
|
23763
|
-
billingCountry: billingDetails.billingCountry,
|
|
23764
|
-
billingContactEmail: (_a = billingDetails.billingContact) === null || _a === void 0 ? void 0 : _a.email,
|
|
23765
|
-
taxNumber: billingDetails.taxNumber,
|
|
23766
|
-
});
|
|
23767
|
-
}
|
|
23768
|
-
}, [billingDetails]);
|
|
23769
|
-
useEffect(function () {
|
|
23770
|
-
form
|
|
23771
|
-
.validateFields({ validateOnly: true })
|
|
23772
|
-
.then(function () { return setFormIsValid(true); })
|
|
23773
|
-
.catch(function () { return setFormIsValid(false); });
|
|
23774
|
-
var isFormEdited = function () {
|
|
23775
|
-
var _a;
|
|
23776
|
-
if (!billingDetails)
|
|
23777
|
-
return false;
|
|
23778
|
-
var currentValues = form.getFieldsValue();
|
|
23779
|
-
var accountValues = {
|
|
23780
|
-
billingStreet: billingDetails.billingStreet,
|
|
23781
|
-
billingCity: billingDetails.billingCity,
|
|
23782
|
-
billingZip: billingDetails.billingZip,
|
|
23783
|
-
billingState: billingDetails.billingState,
|
|
23784
|
-
billingCountry: billingDetails.billingCountry,
|
|
23785
|
-
billingContactEmail: (_a = billingDetails.billingContact) === null || _a === void 0 ? void 0 : _a.email,
|
|
23786
|
-
taxNumber: billingDetails.taxNumber,
|
|
23787
|
-
};
|
|
23788
|
-
return Object.keys(currentValues).some(function (key) {
|
|
23789
|
-
var value = accountValues[key];
|
|
23790
|
-
return currentValues[key] !== value;
|
|
23791
|
-
});
|
|
23792
|
-
};
|
|
23793
|
-
setIsFormEdited(isFormEdited());
|
|
23794
|
-
}, [form, values, billingDetails]);
|
|
23795
|
-
// Validate form fields when isFormEdited changes
|
|
23796
|
-
useEffect(function () {
|
|
23797
|
-
var validateOnly = isFormEdited ? false : true;
|
|
23798
|
-
form.validateFields({ validateOnly: validateOnly });
|
|
23799
|
-
}, [isFormEdited]);
|
|
23800
|
-
var saveBillingDetails = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
23801
|
-
var _this = this;
|
|
23802
|
-
return __generator(this, function (_a) {
|
|
23803
|
-
form.validateFields({ validateOnly: false }).then(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
23804
|
-
var error_1;
|
|
23805
|
-
return __generator(this, function (_a) {
|
|
23806
|
-
switch (_a.label) {
|
|
23807
|
-
case 0:
|
|
23808
|
-
_a.trys.push([0, 2, 3, 4]);
|
|
23809
|
-
return [4 /*yield*/, form.validateFields()];
|
|
23810
|
-
case 1:
|
|
23811
|
-
_a.sent();
|
|
23812
|
-
updateBillingDetails(form.getFieldsValue());
|
|
23813
|
-
return [3 /*break*/, 4];
|
|
23814
|
-
case 2:
|
|
23815
|
-
error_1 = _a.sent();
|
|
23816
|
-
if (error_1 instanceof Error) {
|
|
23817
|
-
showErrorNotification('Failed to update account', error_1.message);
|
|
23818
|
-
}
|
|
23819
|
-
else {
|
|
23820
|
-
showErrorNotification('Please fill out all required fields');
|
|
23821
|
-
}
|
|
23822
|
-
return [3 /*break*/, 4];
|
|
23823
|
-
case 3:
|
|
23824
|
-
setIsFormEdited(false);
|
|
23825
|
-
return [7 /*endfinally*/];
|
|
23826
|
-
case 4: return [2 /*return*/];
|
|
23827
|
-
}
|
|
23828
|
-
});
|
|
23829
|
-
}); });
|
|
23830
|
-
return [2 /*return*/];
|
|
23831
|
-
});
|
|
23832
|
-
}); };
|
|
23833
|
-
var filteredCountryList = useMemo(function () {
|
|
23834
|
-
return countryListFilter ? Lists.COUNTRY_LIST.filter(countryListFilter) : Lists.COUNTRY_LIST;
|
|
23835
|
-
}, [countryListFilter]);
|
|
23836
|
-
return (jsx("div", __assign({ className: "".concat(isMobile || hidePaymentMethodForm ? 'bunny-w-full' : 'bunny-w-1/2') }, { children: jsxs("div", __assign({ className: "bunny-px-4" }, { children: [jsxs(Skeleton, __assign({ loading: isLoadingBillingDetails }, { children: [jsx("div", __assign({ className: "bunny-mb-2" }, { children: jsx(Text, __assign({ className: "bunny-font-medium bunny-text-lg" }, { children: (billingDetails === null || billingDetails === void 0 ? void 0 : billingDetails.name) || 'No company name' })) })), jsxs(Form, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-2", form: form, layout: "vertical", disabled: isUpdatingBillingDetails, autoComplete: "off" }, { children: [jsx(Form.Item, __assign({ label: "Street address", name: "billingStreet", rules: [{ required: true, message: 'Street address is required' }] }, { children: jsx(Input, {}) })), jsxs("div", __assign({ className: "bunny-flex bunny-gap-4" }, { children: [jsx(Form.Item, __assign({ label: "City", name: "billingCity", rules: [{ required: true, message: 'City is required' }], className: "bunny-flex-1" }, { children: jsx(Input, {}) })), jsx(Form.Item, __assign({ label: "Zipcode", name: "billingZip", rules: [{ required: true, message: 'Zipcode is required' }], className: "bunny-flex-1" }, { children: jsx(Input, {}) }))] })), jsxs("div", __assign({ className: "bunny-flex ".concat(isMobile ? 'bunny-flex-row bunny-pb-2' : 'bunny-flex-row', " bunny-gap-4") }, { children: [jsx("div", __assign({ className: "bunny-flex-1 bunny-w-1/2" }, { children: jsx(Form.Item, __assign({ label: "State", name: "billingState", rules: [
|
|
23837
|
-
{
|
|
23838
|
-
required: false,
|
|
23839
|
-
},
|
|
23840
|
-
] }, { children: jsx(Input, {}) })) })), jsx("div", __assign({ className: "bunny-flex-1 bunny-w-1/2" }, { children: jsx(Form.Item, __assign({ label: "Country", name: "billingCountry", rules: [{ required: true, message: 'Country is required' }] }, { children: jsx(Select, { className: "bunny-w-full", options: filteredCountryList, placeholder: "Select a country", popupMatchSelectWidth: false, showSearch: true, filterOption: function (input, option) {
|
|
23841
|
-
var _a, _b;
|
|
23842
|
-
return ((_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a : '').toLowerCase().includes(input.toLowerCase()) ||
|
|
23843
|
-
((_b = option === null || option === void 0 ? void 0 : option.value) !== null && _b !== void 0 ? _b : '').toLowerCase().includes(input.toLowerCase());
|
|
23844
|
-
} }) })) }))] })), jsx(Form.Item, __assign({ label: "Email", name: "billingContactEmail", rules: [
|
|
23845
|
-
{
|
|
23846
|
-
required: true,
|
|
23847
|
-
message: 'Email is required',
|
|
23848
|
-
type: 'email',
|
|
23849
|
-
},
|
|
23850
|
-
] }, { children: jsx(Input, {}) })), jsx(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: jsx(Input, {}) }))] }))] })), jsx(Button, __assign({ disabled: !isFormEdited || isUpdatingBillingDetails || !formIsValid, className: "bunny-w-full bunny-mt-4", type: "primary", onClick: saveBillingDetails }, { children: "Save" }))] })) })));
|
|
23851
|
-
}
|
|
23852
|
-
|
|
23853
|
-
var BillingDetails = function (_a) {
|
|
23854
|
-
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;
|
|
23855
|
-
// Hooks
|
|
23856
|
-
var isMobile = useIsMobile();
|
|
23857
|
-
return (jsx(WrapperComponent, __assign({ isCardEnabled: isCardEnabled, shadow: shadow, className: className }, { children: 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 ? (jsx(BillingDetailsSection, { hidePaymentMethodForm: hidePaymentMethodForm, countryListFilter: countryListFilter })) : null, !hideBillingDetailsForm && !hidePaymentMethodForm ? jsx(ResponsiveDivider, {}) : null, !hidePaymentMethodForm ? (jsx(PaymentFormSection, { hideBillingDetailsForm: hideBillingDetailsForm, isUpgradeFromTrial: isUpgradeFromTrial, onSavePaymentMethod: onSavePaymentMethod })) : null] })) })));
|
|
23858
|
-
};
|
|
23859
|
-
var WrapperComponent = function (_a) {
|
|
23860
|
-
var children = _a.children, isCardEnabled = _a.isCardEnabled, shadow = _a.shadow, className = _a.className;
|
|
23861
|
-
return (jsx("div", __assign({ className: "".concat(className) }, { children: isCardEnabled ? jsx(Card, __assign({ className: "".concat(shadow) }, { children: children })) : jsx("div", { children: children }) })));
|
|
23862
|
-
};
|
|
23863
|
-
var ResponsiveDivider = function () {
|
|
23864
|
-
var isMobile = useIsMobile();
|
|
23865
|
-
return isMobile ? (jsx("div", __assign({ className: "bunny-mx-4" }, { children: jsx(Divider, {}) }))) : (jsx("div", { children: jsx(Divider, { className: "bunny-h-full", type: "vertical" }) }));
|
|
23866
|
-
};
|
|
23867
|
-
var PaymentFormSection = function (_a) {
|
|
23868
|
-
var hideBillingDetailsForm = _a.hideBillingDetailsForm, isUpgradeFromTrial = _a.isUpgradeFromTrial, onSavePaymentMethod = _a.onSavePaymentMethod;
|
|
23869
|
-
var isMobile = useIsMobile();
|
|
23870
|
-
var onTokenExpired = useContext(BunnyContext).onTokenExpired;
|
|
23871
|
-
var handleAllErrorFormats = useAllErrorFormats(onTokenExpired);
|
|
23872
|
-
var showSuccessNotification = useSuccessNotification();
|
|
23873
|
-
return (jsx("div", __assign({ className: "".concat(isMobile || hideBillingDetailsForm ? 'bunny-w-full' : 'bunny-w-1/2 bunny-pt-4', " bunny-flex bunny-justify-center") }, { children: jsx(PaymentForm, { onFail: function (error) {
|
|
23874
|
-
handleAllErrorFormats(error);
|
|
23875
|
-
}, onSavePaymentMethod: function (response) {
|
|
23876
|
-
showSuccessNotification(isUpgradeFromTrial
|
|
23877
|
-
? 'Payment method saved! Your trial will automatically convert to a paid subscription.'
|
|
23878
|
-
: 'Payment method saved successfully!');
|
|
23879
|
-
// TODO: onSavePaymentMethod(response: any) should be cleaned up to have a response type (not any)
|
|
23880
|
-
// and work with both stripe and demo pay requests
|
|
23881
|
-
onSavePaymentMethod === null || onSavePaymentMethod === void 0 ? void 0 : onSavePaymentMethod(response);
|
|
23882
|
-
} }) })));
|
|
23883
|
-
};
|
|
23884
|
-
|
|
23885
23808
|
export { BillingDetails, BunnyProvider, Footer, Invoice, MiniCreditCard, PaymentForm, Quote, Quotes, Signup, SubscriptionsWrapper as Subscriptions, Transactions };
|