@bunnyapp/components 1.5.0-beta.13 → 1.5.0-beta.14
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 +63 -64
- package/dist/cjs/src/components/PaymentForm/hooks/useHasActiveSubscription.d.ts +1 -1
- package/dist/cjs/src/components/Subscriptions/quantityChangeDrawer/QuantityChangeGridRow.d.ts +2 -2
- package/dist/cjs/src/components/Subscriptions/quantityChangeDrawer/QuantityInput.d.ts +2 -2
- package/dist/cjs/src/components/Subscriptions/quantityChangeDrawer/QuoteChangeSummarySection.d.ts +2 -1
- package/dist/cjs/src/components/Subscriptions/subscriptionsList/subscriptionUtils.d.ts +1 -0
- package/dist/cjs/src/graphql/QuoteRequests.d.ts +1 -1
- package/dist/cjs/src/graphql/queries/getSubscriptions.d.ts +2 -1
- package/dist/esm/index.js +64 -65
- package/dist/esm/src/components/PaymentForm/hooks/useHasActiveSubscription.d.ts +1 -1
- package/dist/esm/src/components/Subscriptions/quantityChangeDrawer/QuantityChangeGridRow.d.ts +2 -2
- package/dist/esm/src/components/Subscriptions/quantityChangeDrawer/QuantityInput.d.ts +2 -2
- package/dist/esm/src/components/Subscriptions/quantityChangeDrawer/QuoteChangeSummarySection.d.ts +2 -1
- package/dist/esm/src/components/Subscriptions/subscriptionsList/subscriptionUtils.d.ts +1 -0
- package/dist/esm/src/graphql/QuoteRequests.d.ts +1 -1
- package/dist/esm/src/graphql/queries/getSubscriptions.d.ts +2 -1
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -154,7 +154,7 @@ var BrandContext = react.createContext({
|
|
|
154
154
|
});
|
|
155
155
|
|
|
156
156
|
// This will be replaced at build time by rollup-plugin-replace
|
|
157
|
-
var PACKAGE_VERSION = '1.5.0-beta.
|
|
157
|
+
var PACKAGE_VERSION = '1.5.0-beta.13';
|
|
158
158
|
var createRequestHeaders = function (token) {
|
|
159
159
|
var headers = createClientDevHeaders({ token: token });
|
|
160
160
|
// Add the components version header
|
|
@@ -20855,14 +20855,14 @@ function Signup(_a) {
|
|
|
20855
20855
|
|
|
20856
20856
|
var SubscriptionsContext = react.createContext({});
|
|
20857
20857
|
|
|
20858
|
-
var SUBSCRIPTIONS_QUERY = "\nquery subscriptions {\n subscriptions {\n nodes {\n addonSubscriptions {\n id\n priceList { id }\n plan { id }\n }\n cancellationDate\n currencyId\n endDate\n evergreen\n id\n period\n plan { id name selfServiceBuy selfServiceCancel selfServiceRenew }\n priceList {\n id\n periodMonths\n name\n plan {\n id\n addon\n addonPlans { id }\n }\n }\n product { id name showProductNameOnLineItem }\n startDate\n state\n trialEndDate\n trialPeriod\n trialStartDate\n account { id }\n daysLeftInTrial\n trialExpirationAction\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 }";
|
|
20858
|
+
var SUBSCRIPTIONS_QUERY = "\nquery subscriptions {\n subscriptions {\n nodes {\n addonSubscriptions {\n id\n priceList { id }\n plan { id }\n }\n cancellationDate\n currencyId\n endDate\n evergreen\n id\n period\n plan { id name selfServiceBuy selfServiceCancel selfServiceRenew }\n priceList {\n id\n periodMonths\n name\n plan {\n id\n addon\n addonPlans { id }\n }\n }\n product { id name showProductNameOnLineItem }\n startDate\n state\n trialEndDate\n trialPeriod\n trialStartDate\n account { id }\n daysLeftInTrial\n trialExpirationAction\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 chargeReport {\n priceListCharge {\n priceListChargeTiers {\n price\n starts\n }\n featureAddon\n id\n code\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 currentCharges {\n priceListCharge {\n priceListChargeTiers {\n price\n starts\n }\n featureAddon\n id\n code\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 }";
|
|
20859
20859
|
var getSubscriptions = function (_a) {
|
|
20860
20860
|
var apiHost = _a.apiHost, isInPreviewMode = _a.isInPreviewMode, token = _a.token;
|
|
20861
20861
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
20862
|
-
var response
|
|
20863
|
-
var _b
|
|
20864
|
-
return __generator(this, function (
|
|
20865
|
-
switch (
|
|
20862
|
+
var response;
|
|
20863
|
+
var _b;
|
|
20864
|
+
return __generator(this, function (_c) {
|
|
20865
|
+
switch (_c.label) {
|
|
20866
20866
|
case 0: return [4 /*yield*/, gqlRequest({
|
|
20867
20867
|
isInPreviewMode: isInPreviewMode,
|
|
20868
20868
|
query: SUBSCRIPTIONS_QUERY,
|
|
@@ -20870,9 +20870,8 @@ var getSubscriptions = function (_a) {
|
|
|
20870
20870
|
apiHost: apiHost,
|
|
20871
20871
|
})];
|
|
20872
20872
|
case 1:
|
|
20873
|
-
response =
|
|
20874
|
-
|
|
20875
|
-
return [2 /*return*/, combinedSubscriptions];
|
|
20873
|
+
response = _c.sent();
|
|
20874
|
+
return [2 /*return*/, (_b = response === null || response === void 0 ? void 0 : response.subscriptions) === null || _b === void 0 ? void 0 : _b.nodes];
|
|
20876
20875
|
}
|
|
20877
20876
|
});
|
|
20878
20877
|
});
|
|
@@ -21080,7 +21079,7 @@ var QuoteCheckout = function (_a) {
|
|
|
21080
21079
|
removeCoupon(couponCode);
|
|
21081
21080
|
}
|
|
21082
21081
|
});
|
|
21083
|
-
} }, { children: "Remove coupon(s)" })))] }))) : (jsxRuntime.jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-2 ".concat(isMobile ? 'bunny-shadow-padding-x' : '') }, { children: [jsxRuntime.jsx(antd.Button, __assign({ onClick: handleCheckoutNoPayment, type: "primary" }, { children: isSaving ? 'Processing...' : 'Complete order' })), jsxRuntime.jsx("div", __assign({ className: "bunny-text-xs bunny-text-slate-500" }, { children: "No payment is required" }))] })) }))) }));
|
|
21082
|
+
} }, { children: "Remove coupon(s)" })))] }))) : (jsxRuntime.jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-2 bunny-px-4 ".concat(isMobile ? 'bunny-shadow-padding-x' : '') }, { children: [jsxRuntime.jsx(antd.Button, __assign({ onClick: handleCheckoutNoPayment, type: "primary" }, { children: isSaving ? 'Processing...' : 'Complete order' })), jsxRuntime.jsx("div", __assign({ className: "bunny-text-xs bunny-text-slate-500" }, { children: "No payment is required" }))] })) }))) }));
|
|
21084
21083
|
};
|
|
21085
21084
|
var PaymentFormWrapper = function (_a) {
|
|
21086
21085
|
var children = _a.children, setMaxHeight = _a.setMaxHeight, className = _a.className;
|
|
@@ -21228,7 +21227,8 @@ var createQuoteParams = function (quote, subscriptionQuantity, editedSubscriptio
|
|
|
21228
21227
|
var canShowChangeQuantities = function (_a) {
|
|
21229
21228
|
var subscriptions = _a.subscriptions;
|
|
21230
21229
|
return subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.some(function (subscription) {
|
|
21231
|
-
|
|
21230
|
+
var _a;
|
|
21231
|
+
return (_a = subscription === null || subscription === void 0 ? void 0 : subscription.chargeReport) === null || _a === void 0 ? void 0 : _a.some(function (charge) {
|
|
21232
21232
|
return canShowQuantitiesInput(charge, subscription);
|
|
21233
21233
|
});
|
|
21234
21234
|
});
|
|
@@ -21307,6 +21307,10 @@ var getApplicablePriceTier = function (charge, currencyId, priceDecimals) {
|
|
|
21307
21307
|
? "".concat(starts, "-").concat(ends, ": ").concat(common.formatCurrency(selectedTier.price, currencyId, priceDecimals))
|
|
21308
21308
|
: "".concat(common.formatCurrency(selectedTier.price, currencyId, priceDecimals));
|
|
21309
21309
|
};
|
|
21310
|
+
// Create an id using the charge id and the subscription id
|
|
21311
|
+
var getUpdatingChargeQuantityId = function (charge, subscription) {
|
|
21312
|
+
return "".concat(charge.priceListChargeId, "-").concat(subscription.id);
|
|
21313
|
+
};
|
|
21310
21314
|
|
|
21311
21315
|
var QUOTE_CHARGE_CREATE = "\n".concat(QUOTE_FIELDS(), "\nmutation QuoteChargeCreate ($quoteChangeId: ID!, $startDate: ISO8601Date!, $endDate: ISO8601Date, $priceListChargeId: ID, $subscriptionChargeId: ID, $price: Float, $quantity: Int) {\n quoteChargeCreate(\n endDate: $endDate\n price: $price\n priceListChargeId: $priceListChargeId\n quantity: $quantity\n quoteChangeId: $quoteChangeId\n startDate: $startDate\n subscriptionChargeId: $subscriptionChargeId\n ) {\n quoteCharge {\n quoteChange {\n id\n quoteId\n quote {\n ...QuoteFields\n }\n }\n id\n }\n }\n}\n\n");
|
|
21312
21316
|
var quoteChargeCreate = function (_a) {
|
|
@@ -21373,6 +21377,9 @@ var useQuoteChangeUpdate = function () {
|
|
|
21373
21377
|
case 0: return [4 /*yield*/, graphQLRequest("mutation QuoteChangeUpdate($charges:[QuoteChargeAttributes!], $id:ID!) {\n quoteChangeUpdate(id:$id, charges:$charges) {\n quoteChange { id quoteId }\n errors\n }\n }", apiHost, token, { charges: charges, id: quoteChangeId })];
|
|
21374
21378
|
case 1:
|
|
21375
21379
|
response = _a.sent();
|
|
21380
|
+
if (response.errors) {
|
|
21381
|
+
throw new Error(response.errors[0].message);
|
|
21382
|
+
}
|
|
21376
21383
|
return [2 /*return*/, response];
|
|
21377
21384
|
}
|
|
21378
21385
|
});
|
|
@@ -21408,7 +21415,7 @@ var formatDateForApi = function (date) {
|
|
|
21408
21415
|
return date.format('YYYY-MM-DD');
|
|
21409
21416
|
};
|
|
21410
21417
|
var QuantityInput = function (_a) {
|
|
21411
|
-
var charge = _a.charge, chargeIndex = _a.chargeIndex, editingQuote = _a.editingQuote, setEditingQuoteData = _a.setEditingQuoteData, subscription = _a.subscription, subscriptionIndex = _a.subscriptionIndex,
|
|
21418
|
+
var charge = _a.charge, chargeIndex = _a.chargeIndex, editingQuote = _a.editingQuote, setEditingQuoteData = _a.setEditingQuoteData, subscription = _a.subscription, subscriptionIndex = _a.subscriptionIndex, setUpdatingChargeQuantityId = _a.setUpdatingChargeQuantityId, updatingChargeQuantityId = _a.updatingChargeQuantityId, setErrorUpdatingQuantity = _a.setErrorUpdatingQuantity;
|
|
21412
21419
|
// Context
|
|
21413
21420
|
var token = useToken();
|
|
21414
21421
|
var apiHost = react.useContext(BunnyContext).apiHost;
|
|
@@ -21423,7 +21430,8 @@ var QuantityInput = function (_a) {
|
|
|
21423
21430
|
var quantityDisabled =
|
|
21424
21431
|
// If we are editing a quote, we disable the quantity input
|
|
21425
21432
|
// If we don't have a editedSubscription, we disable the quantity input
|
|
21426
|
-
(updatingChargeQuantityId &&
|
|
21433
|
+
(updatingChargeQuantityId &&
|
|
21434
|
+
updatingChargeQuantityId !== getUpdatingChargeQuantityId(charge, subscription)) ||
|
|
21427
21435
|
// If the subscription is not self-service, we disable the quantity input
|
|
21428
21436
|
!charge.selfServiceQuantity;
|
|
21429
21437
|
var value = (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.quantity) === undefined ? '' : editedSubscription.quantity;
|
|
@@ -21449,8 +21457,8 @@ var QuantityInput = function (_a) {
|
|
|
21449
21457
|
},
|
|
21450
21458
|
}).mutate;
|
|
21451
21459
|
var createQuote = reactQuery.useMutation({
|
|
21452
|
-
mutationFn: function (
|
|
21453
|
-
return createSubscriptionQuote(
|
|
21460
|
+
mutationFn: function (subscriptionId) {
|
|
21461
|
+
return createSubscriptionQuote([subscriptionId], apiHost, token);
|
|
21454
21462
|
},
|
|
21455
21463
|
onSuccess: function (subscriptionUpdateData) {
|
|
21456
21464
|
var _a, _b;
|
|
@@ -21490,6 +21498,10 @@ var QuantityInput = function (_a) {
|
|
|
21490
21498
|
token: token,
|
|
21491
21499
|
}),
|
|
21492
21500
|
});
|
|
21501
|
+
setErrorUpdatingQuantity(false);
|
|
21502
|
+
},
|
|
21503
|
+
onError: function () {
|
|
21504
|
+
setErrorUpdatingQuantity(true);
|
|
21493
21505
|
},
|
|
21494
21506
|
});
|
|
21495
21507
|
// Handlers
|
|
@@ -21506,12 +21518,18 @@ var QuantityInput = function (_a) {
|
|
|
21506
21518
|
quantity: quantity,
|
|
21507
21519
|
subscription: subscription,
|
|
21508
21520
|
});
|
|
21509
|
-
if (quantity
|
|
21510
|
-
|
|
21521
|
+
if (quantity === charge.quantity) {
|
|
21522
|
+
setEditingQuoteData(undefined);
|
|
21523
|
+
showErrorNotification('New quantity cannot be the same as current');
|
|
21511
21524
|
}
|
|
21512
21525
|
else {
|
|
21513
|
-
|
|
21514
|
-
|
|
21526
|
+
if (quantity !== undefined && quantity !== charge.quantity) {
|
|
21527
|
+
if (!(charge === null || charge === void 0 ? void 0 : charge.priceListChargeId)) {
|
|
21528
|
+
showErrorNotification('Charge ID is not found');
|
|
21529
|
+
return;
|
|
21530
|
+
}
|
|
21531
|
+
setUpdatingChargeQuantityId(getUpdatingChargeQuantityId(charge, subscription));
|
|
21532
|
+
}
|
|
21515
21533
|
}
|
|
21516
21534
|
};
|
|
21517
21535
|
var handleSubscriptionUpdate = function (editedSubscription) {
|
|
@@ -21519,31 +21537,17 @@ var QuantityInput = function (_a) {
|
|
|
21519
21537
|
return;
|
|
21520
21538
|
// If we are not editing a quote, we create a new one
|
|
21521
21539
|
if (!editingQuote) {
|
|
21522
|
-
|
|
21523
|
-
var charge_1 = subscriptions[editedSubscription.subscriptionIndex].charges[editedSubscription.chargeIndex];
|
|
21524
|
-
if (isQuantityLowerThanOriginal(charge_1.quantity)) {
|
|
21525
|
-
// If the quantity is lower than the original, we remove the quote
|
|
21526
|
-
setEditingQuoteData(undefined);
|
|
21527
|
-
setUpdatingChargeQuantityId(undefined);
|
|
21528
|
-
return;
|
|
21529
|
-
}
|
|
21530
|
-
subscriptionIds.push(editedSubscription.subscription.id);
|
|
21531
|
-
createQuote.mutate(subscriptionIds);
|
|
21540
|
+
createQuote.mutate(editedSubscription.subscription.id);
|
|
21532
21541
|
}
|
|
21533
21542
|
else {
|
|
21534
21543
|
// If we are editing a quote, we update the quote change
|
|
21535
21544
|
var _a = createQuoteParams(editingQuote, charge.quantity, editedSubscription), charges = _a.charges, quoteChange = _a.quoteChange;
|
|
21536
|
-
if (quoteChange && charges.length > 0
|
|
21545
|
+
if (quoteChange && charges.length > 0) {
|
|
21537
21546
|
updateQuote.mutate({
|
|
21538
21547
|
charges: charges,
|
|
21539
21548
|
quoteChangeId: quoteChange.id,
|
|
21540
21549
|
});
|
|
21541
21550
|
}
|
|
21542
|
-
else {
|
|
21543
|
-
// Reset the editing quote data and the updating charge quantity ID to their initial states
|
|
21544
|
-
setEditingQuoteData(undefined);
|
|
21545
|
-
setUpdatingChargeQuantityId(undefined);
|
|
21546
|
-
}
|
|
21547
21551
|
}
|
|
21548
21552
|
};
|
|
21549
21553
|
// Initial subscription quantity if is on mobile
|
|
@@ -21572,13 +21576,8 @@ var QuantityInput = function (_a) {
|
|
|
21572
21576
|
handleSubscriptionUpdate(editedSubscription);
|
|
21573
21577
|
}, 1000);
|
|
21574
21578
|
return function () { return clearTimeout(debounce); };
|
|
21575
|
-
// eslint-disable-next-line
|
|
21576
21579
|
}, [editedSubscription]);
|
|
21577
|
-
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(antd.Input, { className: "bunny-text-right", disabled: quantityDisabled,
|
|
21578
|
-
if (typeof value === 'number' && value < charge.quantity) {
|
|
21579
|
-
showErrorNotification('New value is less than the original quantity. This is not allowed');
|
|
21580
|
-
}
|
|
21581
|
-
}, onChange: function (e) {
|
|
21580
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(antd.Input, { className: "bunny-text-right", disabled: quantityDisabled, onChange: function (e) {
|
|
21582
21581
|
onChangeQuantity(chargeIndex, e.target.value, charge.priceListChargeId, subscription, subscriptionIndex);
|
|
21583
21582
|
}, status: isQuantityLowerThanOriginal(charge.quantity) ? 'error' : '', style: { width: '96px' }, value: value }) }));
|
|
21584
21583
|
};
|
|
@@ -21586,11 +21585,11 @@ var QuantityInput = function (_a) {
|
|
|
21586
21585
|
var Text$b = antd.Typography.Text;
|
|
21587
21586
|
var QuantityChangeGridRow = function (_a) {
|
|
21588
21587
|
var _b;
|
|
21589
|
-
var chargeIndex = _a.chargeIndex, editingQuote = _a.editingQuote,
|
|
21588
|
+
var chargeIndex = _a.chargeIndex, editingQuote = _a.editingQuote, subscriptionIndex = _a.subscriptionIndex, setEditingQuoteData = _a.setEditingQuoteData, subscription = _a.subscription, subscriptionCharge = _a.subscriptionCharge, setUpdatingChargeQuantityId = _a.setUpdatingChargeQuantityId, updatingChargeQuantityId = _a.updatingChargeQuantityId, setErrorUpdatingQuantity = _a.setErrorUpdatingQuantity;
|
|
21590
21589
|
if (!canShowQuantitiesInput(subscriptionCharge, subscription))
|
|
21591
21590
|
return null;
|
|
21592
21591
|
var brandColor = react.useContext(BrandContext).brandColor;
|
|
21593
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Text$b, __assign({ className: "bunny-font-medium bunny-col-span-full", style: { fontSize: '11px', color: brandColor } }, { children: subscription.plan.name })), jsxRuntime.jsx(Text$b, __assign({ className: "bunny-font-medium bunny-text-base bunny-text-gray-900" }, { children: (_b = subscriptionCharge.name) === null || _b === void 0 ? void 0 : _b.toUpperCase() })), jsxRuntime.jsx(Text$b, __assign({ className: "bunny-flex bunny-items-center bunny-justify-end bunny-font-medium bunny-text-base bunny-text-gray-900" }, { children: subscriptionCharge.quantity })), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-items-end" }, { children: [jsxRuntime.jsx(QuantityInput, { charge: subscriptionCharge, chargeIndex: chargeIndex, editingQuote: editingQuote, setEditingQuoteData: setEditingQuoteData, subscription: subscription, subscriptionIndex: subscriptionIndex,
|
|
21592
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Text$b, __assign({ className: "bunny-font-medium bunny-col-span-full", style: { fontSize: '11px', color: brandColor } }, { children: subscription.plan.name })), jsxRuntime.jsx(Text$b, __assign({ className: "bunny-font-medium bunny-text-base bunny-text-gray-900" }, { children: (_b = subscriptionCharge.name) === null || _b === void 0 ? void 0 : _b.toUpperCase() })), jsxRuntime.jsx(Text$b, __assign({ className: "bunny-flex bunny-items-center bunny-justify-end bunny-font-medium bunny-text-base bunny-text-gray-900" }, { children: subscriptionCharge.quantity })), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-items-end" }, { children: [jsxRuntime.jsx(QuantityInput, { charge: subscriptionCharge, chargeIndex: chargeIndex, editingQuote: editingQuote, setEditingQuoteData: setEditingQuoteData, subscription: subscription, subscriptionIndex: subscriptionIndex, setUpdatingChargeQuantityId: setUpdatingChargeQuantityId, updatingChargeQuantityId: updatingChargeQuantityId, setErrorUpdatingQuantity: setErrorUpdatingQuantity }), jsxRuntime.jsx("div", {})] })), jsxRuntime.jsx(antd.Divider, { className: "bunny-col-span-full bunny-my-2" })] }));
|
|
21594
21593
|
};
|
|
21595
21594
|
|
|
21596
21595
|
var QuantityChangeGridTitle = function (_a) {
|
|
@@ -21599,11 +21598,10 @@ var QuantityChangeGridTitle = function (_a) {
|
|
|
21599
21598
|
};
|
|
21600
21599
|
|
|
21601
21600
|
var QuoteChangeSummarySection = function (_a) {
|
|
21602
|
-
var editingQuote = _a.editingQuote, editingQuoteData = _a.editingQuoteData, openCheckout = _a.openCheckout, setEditingQuoteData = _a.setEditingQuoteData;
|
|
21601
|
+
var editingQuote = _a.editingQuote, editingQuoteData = _a.editingQuoteData, openCheckout = _a.openCheckout, setEditingQuoteData = _a.setEditingQuoteData, errorUpdatingQuantity = _a.errorUpdatingQuantity;
|
|
21603
21602
|
var apiHost = react.useContext(BunnyContext).apiHost;
|
|
21604
21603
|
var isMobile = common.useIsMobile();
|
|
21605
21604
|
var token = useToken();
|
|
21606
|
-
// const apiHost = getApiHost();
|
|
21607
21605
|
var showSuccessNotification = common.useSuccessNotification();
|
|
21608
21606
|
var trialUpgradeMutation = reactQuery.useMutation({
|
|
21609
21607
|
mutationFn: function (quoteId) { return checkout({ quoteId: quoteId, token: token, apiHost: apiHost }); },
|
|
@@ -21614,7 +21612,7 @@ var QuoteChangeSummarySection = function (_a) {
|
|
|
21614
21612
|
});
|
|
21615
21613
|
return (jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-items-end" }, { children: [editingQuote && (jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-mb-8" }, { children: [jsxRuntime.jsx("div", __assign({ className: "bunny-text-slate-500 bunny-text-right bunny-text-xs bunny-mb-2" }, { children: "TOTAL" })), jsxRuntime.jsx("div", __assign({ className: "bunny-text-right ".concat(isMobile ? 'bunny-text-2xl' : 'bunny-text-xl') }, { children: common.formatCurrency(getQuoteAmountDue(editingQuote), (editingQuote === null || editingQuote === void 0 ? void 0 : editingQuote.currencyId) || '') }))] }))), jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-items-center bunny-justify-end ".concat(isMobile ? 'bunny-w-full' : '') }, { children: jsxRuntime.jsx(antd.Button, __assign({ className: "bunny-w-full", onClick: (editingQuoteData === null || editingQuoteData === void 0 ? void 0 : editingQuoteData.isTrial)
|
|
21616
21614
|
? function () { return trialUpgradeMutation.mutate(editingQuoteData.id); }
|
|
21617
|
-
: openCheckout, disabled: !editingQuoteData || !editingQuote, size: isMobile ? 'large' : 'middle', type: "primary" }, { children: (editingQuoteData === null || editingQuoteData === void 0 ? void 0 : editingQuoteData.isTrial) ? 'Activate Trial' : 'Proceed to checkout' })) }))] })));
|
|
21615
|
+
: openCheckout, disabled: !editingQuoteData || !editingQuote || errorUpdatingQuantity, size: isMobile ? 'large' : 'middle', type: "primary" }, { children: (editingQuoteData === null || editingQuoteData === void 0 ? void 0 : editingQuoteData.isTrial) ? 'Activate Trial' : 'Proceed to checkout' })) }))] })));
|
|
21618
21616
|
};
|
|
21619
21617
|
|
|
21620
21618
|
var QUANTITY_CHANGE_HEADER_TITLE = 'Update unit quantity';
|
|
@@ -21622,6 +21620,7 @@ var QUANTITY_CHANGE_HEADER_DESCRIPTION = 'Adjust quantities below. The change wi
|
|
|
21622
21620
|
var QuantityChangeDrawerDesktop = function (_a) {
|
|
21623
21621
|
var editingQuote = _a.editingQuote, editingQuoteData = _a.editingQuoteData, onClose = _a.onClose, open = _a.open, openCheckout = _a.openCheckout, setEditingQuoteData = _a.setEditingQuoteData, subscriptions = _a.subscriptions, setUpdatingChargeQuantityId = _a.setUpdatingChargeQuantityId, updatingChargeQuantityId = _a.updatingChargeQuantityId;
|
|
21624
21622
|
var _b = react.useState(open), openLocal = _b[0], setOpenLocal = _b[1];
|
|
21623
|
+
var _c = react.useState(false), errorUpdatingQuantity = _c[0], setErrorUpdatingQuantity = _c[1];
|
|
21625
21624
|
var isMobile = common.useIsMobile();
|
|
21626
21625
|
react.useEffect(function () {
|
|
21627
21626
|
var timeoutId;
|
|
@@ -21657,17 +21656,17 @@ var QuantityChangeDrawerDesktop = function (_a) {
|
|
|
21657
21656
|
rowGap: '0.25rem',
|
|
21658
21657
|
columnGap: '1rem',
|
|
21659
21658
|
} }, { children: [jsxRuntime.jsx(QuantityChangeGridTitle, { children: "ACTIVE SUBSCRIPTIONS" }), jsxRuntime.jsx(QuantityChangeGridTitle, __assign({ right: true }, { children: "CURRENT QUANTITY" })), jsxRuntime.jsx(QuantityChangeGridTitle, __assign({ right: true }, { children: "NEW QUANTITY" })), jsxRuntime.jsx(antd.Divider, { className: "bunny-col-span-full" }), subscriptions.map(function (subscription, index) {
|
|
21660
|
-
var _a;
|
|
21659
|
+
var _a, _b;
|
|
21661
21660
|
var isTrial = ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.TRIAL;
|
|
21662
|
-
return (jsxRuntime.jsx("div", __assign({ className: "bunny-contents" }, { children: subscription.
|
|
21661
|
+
return (jsxRuntime.jsx("div", __assign({ className: "bunny-contents" }, { children: (_b = subscription === null || subscription === void 0 ? void 0 : subscription.currentCharges) === null || _b === void 0 ? void 0 : _b.map(function (charge, chargeIndex) {
|
|
21663
21662
|
var _a;
|
|
21664
21663
|
if ((isTrial && !charge.trial) ||
|
|
21665
21664
|
(!isTrial && charge.trial) ||
|
|
21666
21665
|
((_a = charge.chargeType) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === 'USAGE')
|
|
21667
21666
|
return null;
|
|
21668
|
-
return (jsxRuntime.jsx(QuantityChangeGridRow, { chargeIndex: chargeIndex, editingQuote: editingQuote, setEditingQuoteData: setEditingQuoteData, subscription: subscription, subscriptionCharge: charge, subscriptionIndex: index,
|
|
21667
|
+
return (jsxRuntime.jsx(QuantityChangeGridRow, { chargeIndex: chargeIndex, editingQuote: editingQuote, setEditingQuoteData: setEditingQuoteData, subscription: subscription, subscriptionCharge: charge, subscriptionIndex: index, setUpdatingChargeQuantityId: setUpdatingChargeQuantityId, updatingChargeQuantityId: updatingChargeQuantityId, setErrorUpdatingQuantity: setErrorUpdatingQuantity }, chargeIndex));
|
|
21669
21668
|
}) }), index));
|
|
21670
|
-
})] })), jsxRuntime.jsx(QuoteChangeSummarySection, { editingQuote: editingQuote, editingQuoteData: editingQuoteData, openCheckout: openCheckout, setEditingQuoteData: setEditingQuoteData })] })));
|
|
21669
|
+
})] })), jsxRuntime.jsx(QuoteChangeSummarySection, { editingQuote: editingQuote, editingQuoteData: editingQuoteData, openCheckout: openCheckout, setEditingQuoteData: setEditingQuoteData, errorUpdatingQuantity: errorUpdatingQuantity })] })));
|
|
21671
21670
|
};
|
|
21672
21671
|
|
|
21673
21672
|
var QuantityDrawerContainer = function (_a) {
|
|
@@ -22257,7 +22256,7 @@ var ADDON_CARD_COLUMNS = [
|
|
|
22257
22256
|
},
|
|
22258
22257
|
];
|
|
22259
22258
|
var SubscriptionCardDesktop = function (_a) {
|
|
22260
|
-
var _b;
|
|
22259
|
+
var _b, _c;
|
|
22261
22260
|
var onChangePlanClick = _a.onChangePlanClick, onCancelSubscriptionClick = _a.onCancelSubscriptionClick, subscription = _a.subscription, isAddon = _a.isAddon;
|
|
22262
22261
|
var shadow = react.useContext(SubscriptionsContext).shadow;
|
|
22263
22262
|
// Derived state
|
|
@@ -22270,21 +22269,21 @@ var SubscriptionCardDesktop = function (_a) {
|
|
|
22270
22269
|
} }), jsxRuntime.jsxs("div", __assign({ className: "bunny-grid bunny-w-full", style: {
|
|
22271
22270
|
gridTemplateColumns: CARD_COLUMNS.map(function (column) { return column.width; }).join(' '),
|
|
22272
22271
|
rowGap: '0.75rem',
|
|
22273
|
-
} }, { children: [jsxRuntime.jsx(SubscriptionCardColumnHeaders, { columns: CARD_COLUMNS }), subscription.
|
|
22272
|
+
} }, { children: [jsxRuntime.jsx(SubscriptionCardColumnHeaders, { columns: CARD_COLUMNS }), (_c = subscription === null || subscription === void 0 ? void 0 : subscription.chargeReport) === null || _c === void 0 ? void 0 : _c.map(function (charge, chargeIndex) {
|
|
22274
22273
|
if ((isTrial && !charge.trial) || (!isTrial && charge.trial))
|
|
22275
22274
|
return null;
|
|
22276
22275
|
return (jsxRuntime.jsx(SubscriptionCardDesktopRow, { charge: charge, chargeIndex: chargeIndex, subscription: subscription }, chargeIndex));
|
|
22277
22276
|
})] }))] })));
|
|
22278
22277
|
};
|
|
22279
22278
|
var SubscriptionCardDesktopRow = function (_a) {
|
|
22280
|
-
var _b, _c;
|
|
22279
|
+
var _b, _c, _d;
|
|
22281
22280
|
var charge = _a.charge, chargeIndex = _a.chargeIndex, subscription = _a.subscription;
|
|
22282
22281
|
// Context
|
|
22283
22282
|
var apiHost = react.useContext(BunnyContext).apiHost;
|
|
22284
22283
|
var token = useToken();
|
|
22285
22284
|
// Derived state
|
|
22286
22285
|
var isRamp = charge.isRamp;
|
|
22287
|
-
var prevCharge = subscription.
|
|
22286
|
+
var prevCharge = (_b = subscription === null || subscription === void 0 ? void 0 : subscription.chargeReport) === null || _b === void 0 ? void 0 : _b[chargeIndex - 1];
|
|
22288
22287
|
var isFirstRampRow = chargeIndex === 0 || (prevCharge === null || prevCharge === void 0 ? void 0 : prevCharge.priceListChargeId) !== charge.priceListChargeId;
|
|
22289
22288
|
var chargePeriod = "".concat(common.formatDate(charge.startDate), " - ").concat(common.formatDate(charge.endDate));
|
|
22290
22289
|
// Queries
|
|
@@ -22304,15 +22303,15 @@ var SubscriptionCardDesktopRow = function (_a) {
|
|
|
22304
22303
|
var isDiscount = charge.kind === common.QuoteChangeKind.DISCOUNT;
|
|
22305
22304
|
var dontShowChargeName = (prevCharge === null || prevCharge === void 0 ? void 0 : prevCharge.priceListChargeId) === charge.priceListChargeId &&
|
|
22306
22305
|
!isDiscount &&
|
|
22307
|
-
(!isTrial || prevCharge.trial) &&
|
|
22308
|
-
(isTrial || !prevCharge.trial);
|
|
22306
|
+
(!isTrial || (prevCharge === null || prevCharge === void 0 ? void 0 : prevCharge.trial)) &&
|
|
22307
|
+
(isTrial || !(prevCharge === null || prevCharge === void 0 ? void 0 : prevCharge.trial));
|
|
22309
22308
|
return (jsxRuntime.jsxs("div", __assign({ className: "bunny-contents" }, { children: [(isRampFirstRow || !isRamp) && (jsxRuntime.jsx(SubscriptionsListCell, __assign({ gridColumn: isRamp ? '1/-1' : '1' }, { children: jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-items-center bunny-gap-2 ".concat(isDiscount ? 'bunny-pl-4' : '') }, { children: jsxRuntime.jsx("div", { children: isRampFirstRow || (!isRamp && !dontShowChargeName) ? charge.name : '' }) })) }))), jsxRuntime.jsx(SubscriptionsListCell, __assign({ gridColumn: 2 }, { children: jsxRuntime.jsx("div", { children: chargePeriod }) })), jsxRuntime.jsx(SubscriptionsListCell, __assign({ right: true }, { children: charge.kind === common.QuoteChangeKind.DISCOUNT
|
|
22310
22309
|
? ''
|
|
22311
22310
|
: charge.chargeType === common.ChargeType.USAGE
|
|
22312
22311
|
? data && jsxRuntime.jsx(FeatureUsageGraph, { charge: charge, featureUsage: data })
|
|
22313
22312
|
: charge.isAmendment
|
|
22314
|
-
? "+".concat((
|
|
22315
|
-
: (
|
|
22313
|
+
? "+".concat((_c = charge.quantity) === null || _c === void 0 ? void 0 : _c.toLocaleString())
|
|
22314
|
+
: (_d = charge.quantity) === null || _d === void 0 ? void 0 : _d.toLocaleString() })), jsxRuntime.jsx(SubscriptionsListCell, __assign({ right: true }, { children: jsxRuntime.jsx(SubscriptionChargeUnitPrice, { charge: charge, currencyId: subscription.currencyId }) })), jsxRuntime.jsx(SubscriptionsListCell, __assign({ right: true }, { children: jsxRuntime.jsx(SubscriptionChargeTotal, { charge: charge, subscription: subscription }) }))] })));
|
|
22316
22315
|
};
|
|
22317
22316
|
|
|
22318
22317
|
function AddonSubscriptionsCards(_a) {
|
|
@@ -22353,7 +22352,7 @@ var CHARGE_COLUMNS = [
|
|
|
22353
22352
|
},
|
|
22354
22353
|
];
|
|
22355
22354
|
var SubscriptionCard = function (_a) {
|
|
22356
|
-
var _b;
|
|
22355
|
+
var _b, _c;
|
|
22357
22356
|
var subscription = _a.subscription;
|
|
22358
22357
|
var darkMode = react.useContext(BunnyContext).darkMode;
|
|
22359
22358
|
// Derived state
|
|
@@ -22368,7 +22367,7 @@ var SubscriptionCard = function (_a) {
|
|
|
22368
22367
|
gridTemplateColumns: "1fr auto auto auto",
|
|
22369
22368
|
rowGap: '0.75rem',
|
|
22370
22369
|
backgroundColor: backgroundColor,
|
|
22371
|
-
} }, { children: [CHARGE_COLUMNS.map(function (subscriptionColumn, index) { return (jsxRuntime.jsx(SubscriptionCardCellMobile, __assign({ className: "bunny-text-slate-400 ".concat(subscriptionColumn.className), style: { fontSize: '11px' } }, { children: subscriptionColumn.title }), index)); }), subscription.
|
|
22370
|
+
} }, { children: [CHARGE_COLUMNS.map(function (subscriptionColumn, index) { return (jsxRuntime.jsx(SubscriptionCardCellMobile, __assign({ className: "bunny-text-slate-400 ".concat(subscriptionColumn.className), style: { fontSize: '11px' } }, { children: subscriptionColumn.title }), index)); }), (_c = subscription === null || subscription === void 0 ? void 0 : subscription.chargeReport) === null || _c === void 0 ? void 0 : _c.map(function (charge, chargeIndex) {
|
|
22372
22371
|
if ((isTrial && !charge.trial) || (!isTrial && charge.trial))
|
|
22373
22372
|
return null;
|
|
22374
22373
|
var isRamp = charge.isRamp;
|
|
@@ -24017,7 +24016,7 @@ var PlanPicker = function (_a) {
|
|
|
24017
24016
|
if (!priceListChangeOptions) {
|
|
24018
24017
|
return null;
|
|
24019
24018
|
}
|
|
24020
|
-
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: ((_b = priceListChangeOptions === null || priceListChangeOptions === void 0 ? void 0 : priceListChangeOptions.priceLists) === null || _b === void 0 ? void 0 : _b.length) === 0 ? (jsxRuntime.jsx(ErrorView, { message: "There are no plans available" })) : (jsxRuntime.jsx(PriceListSelector, { arePlanChangeOptionsLoading: arePlanChangeOptionsLoading, areSubscriptionsLoading: areSubscriptionsLoading, priceListChangeOptions: priceListChangeOptions, subscriptions: subscriptions })) }));
|
|
24019
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: ((_b = priceListChangeOptions === null || priceListChangeOptions === void 0 ? void 0 : priceListChangeOptions.priceLists) === null || _b === void 0 ? void 0 : _b.length) === 0 ? (jsxRuntime.jsx(ErrorView, { message: "There are no plans available" })) : (jsxRuntime.jsx(PriceListSelector, { arePlanChangeOptionsLoading: arePlanChangeOptionsLoading, areSubscriptionsLoading: areSubscriptionsLoading, priceListChangeOptions: priceListChangeOptions, subscriptions: subscriptions !== null && subscriptions !== void 0 ? subscriptions : [] })) }));
|
|
24021
24020
|
};
|
|
24022
24021
|
|
|
24023
24022
|
var Text$1 = antd.Typography.Text;
|
|
@@ -24176,7 +24175,7 @@ var Subscriptions = function (_a) {
|
|
|
24176
24175
|
((_c = subscription.state) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === common.SubscriptionState.CANCELED;
|
|
24177
24176
|
});
|
|
24178
24177
|
react.useEffect(function () {
|
|
24179
|
-
if (allSubscriptionsExpired && subscriptions.length > 0) {
|
|
24178
|
+
if (allSubscriptionsExpired && subscriptions && subscriptions.length > 0) {
|
|
24180
24179
|
setHideExpiredState(false);
|
|
24181
24180
|
}
|
|
24182
24181
|
else {
|
|
@@ -24184,7 +24183,7 @@ var Subscriptions = function (_a) {
|
|
|
24184
24183
|
}
|
|
24185
24184
|
}, [allSubscriptionsExpired, subscriptions, isChangingPlan]);
|
|
24186
24185
|
react.useEffect(function () {
|
|
24187
|
-
if (hasExpiredOrCanceledSubscriptions && subscriptions.length > 0) {
|
|
24186
|
+
if (hasExpiredOrCanceledSubscriptions && subscriptions && subscriptions.length > 0) {
|
|
24188
24187
|
setExpiredSwitchVisible(true);
|
|
24189
24188
|
}
|
|
24190
24189
|
else {
|
|
@@ -24196,7 +24195,7 @@ var Subscriptions = function (_a) {
|
|
|
24196
24195
|
setIsChangingPlan(false);
|
|
24197
24196
|
}, handlePortalErrors: handlePortalErrors, upgradingSubscription: upgradingSubscription, className: className }));
|
|
24198
24197
|
}
|
|
24199
|
-
return (jsxRuntime.jsxs("div", __assign({ className: className }, { children: [jsxRuntime.jsx(PageHeaderWithActions, __assign({ title: jsxRuntime.jsx(jsxRuntime.Fragment, { children: !hideExpiredToggle && isMobile && expiredSwitchVisible && (jsxRuntime.jsx(HideExpiredToggle, { hideExpired: hideExpired, setHideExpired: setHideExpiredState })) }) }, { children: !isMobile && (jsxRuntime.jsx(SubscriptionsNavigation, { expiredSwitchVisible: !hideExpiredToggle && expiredSwitchVisible, hideExpired: hideExpired, setHideExpired: setHideExpiredState, setQuantityDrawerOpen: setQuantityDrawerOpen, subscriptions: subscriptions })) })), jsxRuntime.jsx(SubscriptionsListContainer, { companyName: companyName, hideExpired: hideExpired, onCancelSubscriptionClick: onCancelSubscriptionClick, onChangePlanClick: onChangePlanClick, subscriptions: subscriptions, subscriptionsAreLoading: subscriptionsAreLoading, noSubscriptionsComponent: noSubscriptionsComponent }), isMobile && (jsxRuntime.jsx("div", __assign({ className: "bunny-pt-4 bunny-pb-2" }, { children: jsxRuntime.jsx(SubscriptionsNavigation, { expiredSwitchVisible: expiredSwitchVisible, hideExpired: hideExpired, setHideExpired: setHideExpiredState, setQuantityDrawerOpen: setQuantityDrawerOpen, subscriptions: subscriptions }) }))), jsxRuntime.jsx(QuantityDrawerContainer, { subscriptions: subscriptions, quantityDrawerOpen: quantityDrawerOpen, setQuantityDrawerOpen: setQuantityDrawerOpen, handlePortalErrors: handlePortalErrors, setHideExpiredState: setHideExpiredState })] })));
|
|
24198
|
+
return (jsxRuntime.jsxs("div", __assign({ className: className }, { children: [jsxRuntime.jsx(PageHeaderWithActions, __assign({ title: jsxRuntime.jsx(jsxRuntime.Fragment, { children: !hideExpiredToggle && isMobile && expiredSwitchVisible && (jsxRuntime.jsx(HideExpiredToggle, { hideExpired: hideExpired, setHideExpired: setHideExpiredState })) }) }, { children: !isMobile && (jsxRuntime.jsx(SubscriptionsNavigation, { expiredSwitchVisible: !hideExpiredToggle && expiredSwitchVisible, hideExpired: hideExpired, setHideExpired: setHideExpiredState, setQuantityDrawerOpen: setQuantityDrawerOpen, subscriptions: subscriptions !== null && subscriptions !== void 0 ? subscriptions : [] })) })), jsxRuntime.jsx(SubscriptionsListContainer, { companyName: companyName, hideExpired: hideExpired, onCancelSubscriptionClick: onCancelSubscriptionClick, onChangePlanClick: onChangePlanClick, subscriptions: subscriptions !== null && subscriptions !== void 0 ? subscriptions : [], subscriptionsAreLoading: subscriptionsAreLoading, noSubscriptionsComponent: noSubscriptionsComponent }), isMobile && (jsxRuntime.jsx("div", __assign({ className: "bunny-pt-4 bunny-pb-2" }, { children: jsxRuntime.jsx(SubscriptionsNavigation, { expiredSwitchVisible: expiredSwitchVisible, hideExpired: hideExpired, setHideExpired: setHideExpiredState, setQuantityDrawerOpen: setQuantityDrawerOpen, subscriptions: subscriptions !== null && subscriptions !== void 0 ? subscriptions : [] }) }))), jsxRuntime.jsx(QuantityDrawerContainer, { subscriptions: subscriptions !== null && subscriptions !== void 0 ? subscriptions : [], quantityDrawerOpen: quantityDrawerOpen, setQuantityDrawerOpen: setQuantityDrawerOpen, handlePortalErrors: handlePortalErrors, setHideExpiredState: setHideExpiredState })] })));
|
|
24200
24199
|
};
|
|
24201
24200
|
var PageHeaderWithActions = function (_a) {
|
|
24202
24201
|
var children = _a.children, title = _a.title;
|
package/dist/cjs/src/components/Subscriptions/quantityChangeDrawer/QuantityChangeGridRow.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Quote, Subscription, SubscriptionCharge } from '@bunnyapp/common';
|
|
2
|
-
declare const QuantityChangeGridRow: ({ chargeIndex, editingQuote,
|
|
2
|
+
declare const QuantityChangeGridRow: ({ chargeIndex, editingQuote, subscriptionIndex, setEditingQuoteData, subscription, subscriptionCharge, setUpdatingChargeQuantityId, updatingChargeQuantityId, setErrorUpdatingQuantity, }: {
|
|
3
3
|
chargeIndex: number;
|
|
4
4
|
editingQuote?: Quote | undefined;
|
|
5
|
-
subscriptions: Subscription[];
|
|
6
5
|
subscriptionIndex: number;
|
|
7
6
|
setEditingQuoteData: (value: any) => void;
|
|
8
7
|
subscription: Subscription;
|
|
9
8
|
subscriptionCharge: SubscriptionCharge;
|
|
10
9
|
setUpdatingChargeQuantityId: (updatingChargeQuantityId: string | undefined) => void;
|
|
11
10
|
updatingChargeQuantityId: string | undefined;
|
|
11
|
+
setErrorUpdatingQuantity: (errorUpdatingQuantity: boolean) => void;
|
|
12
12
|
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
13
13
|
export default QuantityChangeGridRow;
|
|
@@ -6,7 +6,7 @@ export type EditingSubscriptionType = {
|
|
|
6
6
|
subscription: Subscription;
|
|
7
7
|
subscriptionIndex: number;
|
|
8
8
|
};
|
|
9
|
-
declare const QuantityInput: ({ charge, chargeIndex, editingQuote, setEditingQuoteData, subscription, subscriptionIndex,
|
|
9
|
+
declare const QuantityInput: ({ charge, chargeIndex, editingQuote, setEditingQuoteData, subscription, subscriptionIndex, setUpdatingChargeQuantityId, updatingChargeQuantityId, setErrorUpdatingQuantity, }: {
|
|
10
10
|
charge: SubscriptionCharge;
|
|
11
11
|
chargeIndex: number;
|
|
12
12
|
editingQuote?: Quote | undefined;
|
|
@@ -16,8 +16,8 @@ declare const QuantityInput: ({ charge, chargeIndex, editingQuote, setEditingQuo
|
|
|
16
16
|
} | undefined) => void;
|
|
17
17
|
subscription: Subscription;
|
|
18
18
|
subscriptionIndex: number;
|
|
19
|
-
subscriptions: Subscription[];
|
|
20
19
|
setUpdatingChargeQuantityId: (updatingChargeQuantityId: string | undefined) => void;
|
|
21
20
|
updatingChargeQuantityId: string | undefined;
|
|
21
|
+
setErrorUpdatingQuantity: (errorUpdatingQuantity: boolean) => void;
|
|
22
22
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
23
23
|
export default QuantityInput;
|
package/dist/cjs/src/components/Subscriptions/quantityChangeDrawer/QuoteChangeSummarySection.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Quote } from '@bunnyapp/common';
|
|
2
2
|
import { EditingQuoteDataType } from '../SubscriptionsListContainer';
|
|
3
|
-
declare const QuoteChangeSummarySection: ({ editingQuote, editingQuoteData, openCheckout, setEditingQuoteData, }: {
|
|
3
|
+
declare const QuoteChangeSummarySection: ({ editingQuote, editingQuoteData, openCheckout, setEditingQuoteData, errorUpdatingQuantity, }: {
|
|
4
4
|
editingQuote?: Quote | undefined;
|
|
5
5
|
editingQuoteData?: EditingQuoteDataType | undefined;
|
|
6
6
|
openCheckout: () => void;
|
|
7
7
|
setEditingQuoteData: (editingQuoteData: EditingQuoteDataType | undefined) => void;
|
|
8
|
+
errorUpdatingQuantity: boolean;
|
|
8
9
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
9
10
|
export default QuoteChangeSummarySection;
|
|
@@ -25,3 +25,4 @@ export declare const isDiscount: (kind?: QuoteChangeKind) => boolean;
|
|
|
25
25
|
export declare const hasPriceTiers: (charge: SubscriptionCharge) => boolean;
|
|
26
26
|
export declare const hasMultiplePriceTiers: (charge: SubscriptionCharge) => boolean;
|
|
27
27
|
export declare const getApplicablePriceTier: (charge: SubscriptionCharge, currencyId: string, priceDecimals: number) => string;
|
|
28
|
+
export declare const getUpdatingChargeQuantityId: (charge: SubscriptionCharge, subscription: Subscription) => string;
|
|
@@ -8,7 +8,7 @@ export declare const useCreateSubscriptionQuote: () => (subscriptionIds: string[
|
|
|
8
8
|
export declare const useQuoteChangeUpdate: () => (charges: {
|
|
9
9
|
id: string;
|
|
10
10
|
quantity: number;
|
|
11
|
-
}[], quoteChangeId: string, apiHost: string, token?: string) => Promise<
|
|
11
|
+
}[], quoteChangeId: string, apiHost: string, token?: string) => Promise<any>;
|
|
12
12
|
export declare const useQuoteDelete: () => (quoteId: string, apiHost: string, token?: string) => Promise<unknown>;
|
|
13
13
|
export declare const quoteSubscriptionAddon: ({ subscriptionId, priceListId, apiHost, token, }: {
|
|
14
14
|
subscriptionId: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { Subscription } from '@bunnyapp/common';
|
|
1
2
|
declare const getSubscriptions: ({ apiHost, isInPreviewMode, token, }: {
|
|
2
3
|
apiHost: string;
|
|
3
4
|
isInPreviewMode?: boolean | undefined;
|
|
4
5
|
token?: string | undefined;
|
|
5
|
-
}) => Promise<
|
|
6
|
+
}) => Promise<Subscription[]>;
|
|
6
7
|
export default getSubscriptions;
|
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, Popconfirm, Table, Radio, Space, Switch } 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 as createClientDevHeaders$1, 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, PAYABLE_INVOICE_STATES, BreakpointNumbers, useGraphQLmutation, useInfoNotification, formatDate, TransactionState, SLATE_600, WHITE, TransactionKind, SLATE_500, PRIMARY_COLOR, Lists,
|
|
7
|
+
import { DEFAULT_ACCENT_COLOR, DEFAULT_BRAND_COLOR, DEFAULT_SECONDARY_COLOR, DEFAULT_TOP_NAV_IMAGE_URL, gqlRequest as gqlRequest$1, createClientDevHeaders as createClientDevHeaders$1, 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, PAYABLE_INVOICE_STATES, BreakpointNumbers, useGraphQLmutation, useInfoNotification, formatDate, TransactionState, SLATE_600, WHITE, TransactionKind, SLATE_500, PRIMARY_COLOR, Lists, SubscriptionState, QuoteChangeKind, getAccount, PricingModel, BillingPeriod, MODAL_MAX_HEIGHT, DataInterval, ChargeType, StringUtils, PERIOD_LABELS, PricingStyle, SLATE_100 } 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.5.0-beta.
|
|
146
|
+
var PACKAGE_VERSION = '1.5.0-beta.13';
|
|
147
147
|
var createRequestHeaders = function (token) {
|
|
148
148
|
var headers = createClientDevHeaders({ token: token });
|
|
149
149
|
// Add the components version header
|
|
@@ -20844,14 +20844,14 @@ function Signup(_a) {
|
|
|
20844
20844
|
|
|
20845
20845
|
var SubscriptionsContext = createContext({});
|
|
20846
20846
|
|
|
20847
|
-
var SUBSCRIPTIONS_QUERY = "\nquery subscriptions {\n subscriptions {\n nodes {\n addonSubscriptions {\n id\n priceList { id }\n plan { id }\n }\n cancellationDate\n currencyId\n endDate\n evergreen\n id\n period\n plan { id name selfServiceBuy selfServiceCancel selfServiceRenew }\n priceList {\n id\n periodMonths\n name\n plan {\n id\n addon\n addonPlans { id }\n }\n }\n product { id name showProductNameOnLineItem }\n startDate\n state\n trialEndDate\n trialPeriod\n trialStartDate\n account { id }\n daysLeftInTrial\n trialExpirationAction\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 }";
|
|
20847
|
+
var SUBSCRIPTIONS_QUERY = "\nquery subscriptions {\n subscriptions {\n nodes {\n addonSubscriptions {\n id\n priceList { id }\n plan { id }\n }\n cancellationDate\n currencyId\n endDate\n evergreen\n id\n period\n plan { id name selfServiceBuy selfServiceCancel selfServiceRenew }\n priceList {\n id\n periodMonths\n name\n plan {\n id\n addon\n addonPlans { id }\n }\n }\n product { id name showProductNameOnLineItem }\n startDate\n state\n trialEndDate\n trialPeriod\n trialStartDate\n account { id }\n daysLeftInTrial\n trialExpirationAction\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 chargeReport {\n priceListCharge {\n priceListChargeTiers {\n price\n starts\n }\n featureAddon\n id\n code\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 currentCharges {\n priceListCharge {\n priceListChargeTiers {\n price\n starts\n }\n featureAddon\n id\n code\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 }";
|
|
20848
20848
|
var getSubscriptions = function (_a) {
|
|
20849
20849
|
var apiHost = _a.apiHost, isInPreviewMode = _a.isInPreviewMode, token = _a.token;
|
|
20850
20850
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
20851
|
-
var response
|
|
20852
|
-
var _b
|
|
20853
|
-
return __generator(this, function (
|
|
20854
|
-
switch (
|
|
20851
|
+
var response;
|
|
20852
|
+
var _b;
|
|
20853
|
+
return __generator(this, function (_c) {
|
|
20854
|
+
switch (_c.label) {
|
|
20855
20855
|
case 0: return [4 /*yield*/, gqlRequest({
|
|
20856
20856
|
isInPreviewMode: isInPreviewMode,
|
|
20857
20857
|
query: SUBSCRIPTIONS_QUERY,
|
|
@@ -20859,9 +20859,8 @@ var getSubscriptions = function (_a) {
|
|
|
20859
20859
|
apiHost: apiHost,
|
|
20860
20860
|
})];
|
|
20861
20861
|
case 1:
|
|
20862
|
-
response =
|
|
20863
|
-
|
|
20864
|
-
return [2 /*return*/, combinedSubscriptions];
|
|
20862
|
+
response = _c.sent();
|
|
20863
|
+
return [2 /*return*/, (_b = response === null || response === void 0 ? void 0 : response.subscriptions) === null || _b === void 0 ? void 0 : _b.nodes];
|
|
20865
20864
|
}
|
|
20866
20865
|
});
|
|
20867
20866
|
});
|
|
@@ -21069,7 +21068,7 @@ var QuoteCheckout = function (_a) {
|
|
|
21069
21068
|
removeCoupon(couponCode);
|
|
21070
21069
|
}
|
|
21071
21070
|
});
|
|
21072
|
-
} }, { children: "Remove coupon(s)" })))] }))) : (jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-2 ".concat(isMobile ? 'bunny-shadow-padding-x' : '') }, { children: [jsx(Button, __assign({ onClick: handleCheckoutNoPayment, type: "primary" }, { children: isSaving ? 'Processing...' : 'Complete order' })), jsx("div", __assign({ className: "bunny-text-xs bunny-text-slate-500" }, { children: "No payment is required" }))] })) }))) }));
|
|
21071
|
+
} }, { children: "Remove coupon(s)" })))] }))) : (jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-2 bunny-px-4 ".concat(isMobile ? 'bunny-shadow-padding-x' : '') }, { children: [jsx(Button, __assign({ onClick: handleCheckoutNoPayment, type: "primary" }, { children: isSaving ? 'Processing...' : 'Complete order' })), jsx("div", __assign({ className: "bunny-text-xs bunny-text-slate-500" }, { children: "No payment is required" }))] })) }))) }));
|
|
21073
21072
|
};
|
|
21074
21073
|
var PaymentFormWrapper = function (_a) {
|
|
21075
21074
|
var children = _a.children, setMaxHeight = _a.setMaxHeight, className = _a.className;
|
|
@@ -21217,7 +21216,8 @@ var createQuoteParams = function (quote, subscriptionQuantity, editedSubscriptio
|
|
|
21217
21216
|
var canShowChangeQuantities = function (_a) {
|
|
21218
21217
|
var subscriptions = _a.subscriptions;
|
|
21219
21218
|
return subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.some(function (subscription) {
|
|
21220
|
-
|
|
21219
|
+
var _a;
|
|
21220
|
+
return (_a = subscription === null || subscription === void 0 ? void 0 : subscription.chargeReport) === null || _a === void 0 ? void 0 : _a.some(function (charge) {
|
|
21221
21221
|
return canShowQuantitiesInput(charge, subscription);
|
|
21222
21222
|
});
|
|
21223
21223
|
});
|
|
@@ -21296,6 +21296,10 @@ var getApplicablePriceTier = function (charge, currencyId, priceDecimals) {
|
|
|
21296
21296
|
? "".concat(starts, "-").concat(ends, ": ").concat(formatCurrency(selectedTier.price, currencyId, priceDecimals))
|
|
21297
21297
|
: "".concat(formatCurrency(selectedTier.price, currencyId, priceDecimals));
|
|
21298
21298
|
};
|
|
21299
|
+
// Create an id using the charge id and the subscription id
|
|
21300
|
+
var getUpdatingChargeQuantityId = function (charge, subscription) {
|
|
21301
|
+
return "".concat(charge.priceListChargeId, "-").concat(subscription.id);
|
|
21302
|
+
};
|
|
21299
21303
|
|
|
21300
21304
|
var QUOTE_CHARGE_CREATE = "\n".concat(QUOTE_FIELDS(), "\nmutation QuoteChargeCreate ($quoteChangeId: ID!, $startDate: ISO8601Date!, $endDate: ISO8601Date, $priceListChargeId: ID, $subscriptionChargeId: ID, $price: Float, $quantity: Int) {\n quoteChargeCreate(\n endDate: $endDate\n price: $price\n priceListChargeId: $priceListChargeId\n quantity: $quantity\n quoteChangeId: $quoteChangeId\n startDate: $startDate\n subscriptionChargeId: $subscriptionChargeId\n ) {\n quoteCharge {\n quoteChange {\n id\n quoteId\n quote {\n ...QuoteFields\n }\n }\n id\n }\n }\n}\n\n");
|
|
21301
21305
|
var quoteChargeCreate = function (_a) {
|
|
@@ -21362,6 +21366,9 @@ var useQuoteChangeUpdate = function () {
|
|
|
21362
21366
|
case 0: return [4 /*yield*/, graphQLRequest("mutation QuoteChangeUpdate($charges:[QuoteChargeAttributes!], $id:ID!) {\n quoteChangeUpdate(id:$id, charges:$charges) {\n quoteChange { id quoteId }\n errors\n }\n }", apiHost, token, { charges: charges, id: quoteChangeId })];
|
|
21363
21367
|
case 1:
|
|
21364
21368
|
response = _a.sent();
|
|
21369
|
+
if (response.errors) {
|
|
21370
|
+
throw new Error(response.errors[0].message);
|
|
21371
|
+
}
|
|
21365
21372
|
return [2 /*return*/, response];
|
|
21366
21373
|
}
|
|
21367
21374
|
});
|
|
@@ -21397,7 +21404,7 @@ var formatDateForApi = function (date) {
|
|
|
21397
21404
|
return date.format('YYYY-MM-DD');
|
|
21398
21405
|
};
|
|
21399
21406
|
var QuantityInput = function (_a) {
|
|
21400
|
-
var charge = _a.charge, chargeIndex = _a.chargeIndex, editingQuote = _a.editingQuote, setEditingQuoteData = _a.setEditingQuoteData, subscription = _a.subscription, subscriptionIndex = _a.subscriptionIndex,
|
|
21407
|
+
var charge = _a.charge, chargeIndex = _a.chargeIndex, editingQuote = _a.editingQuote, setEditingQuoteData = _a.setEditingQuoteData, subscription = _a.subscription, subscriptionIndex = _a.subscriptionIndex, setUpdatingChargeQuantityId = _a.setUpdatingChargeQuantityId, updatingChargeQuantityId = _a.updatingChargeQuantityId, setErrorUpdatingQuantity = _a.setErrorUpdatingQuantity;
|
|
21401
21408
|
// Context
|
|
21402
21409
|
var token = useToken();
|
|
21403
21410
|
var apiHost = useContext(BunnyContext).apiHost;
|
|
@@ -21412,7 +21419,8 @@ var QuantityInput = function (_a) {
|
|
|
21412
21419
|
var quantityDisabled =
|
|
21413
21420
|
// If we are editing a quote, we disable the quantity input
|
|
21414
21421
|
// If we don't have a editedSubscription, we disable the quantity input
|
|
21415
|
-
(updatingChargeQuantityId &&
|
|
21422
|
+
(updatingChargeQuantityId &&
|
|
21423
|
+
updatingChargeQuantityId !== getUpdatingChargeQuantityId(charge, subscription)) ||
|
|
21416
21424
|
// If the subscription is not self-service, we disable the quantity input
|
|
21417
21425
|
!charge.selfServiceQuantity;
|
|
21418
21426
|
var value = (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.quantity) === undefined ? '' : editedSubscription.quantity;
|
|
@@ -21438,8 +21446,8 @@ var QuantityInput = function (_a) {
|
|
|
21438
21446
|
},
|
|
21439
21447
|
}).mutate;
|
|
21440
21448
|
var createQuote = useMutation({
|
|
21441
|
-
mutationFn: function (
|
|
21442
|
-
return createSubscriptionQuote(
|
|
21449
|
+
mutationFn: function (subscriptionId) {
|
|
21450
|
+
return createSubscriptionQuote([subscriptionId], apiHost, token);
|
|
21443
21451
|
},
|
|
21444
21452
|
onSuccess: function (subscriptionUpdateData) {
|
|
21445
21453
|
var _a, _b;
|
|
@@ -21479,6 +21487,10 @@ var QuantityInput = function (_a) {
|
|
|
21479
21487
|
token: token,
|
|
21480
21488
|
}),
|
|
21481
21489
|
});
|
|
21490
|
+
setErrorUpdatingQuantity(false);
|
|
21491
|
+
},
|
|
21492
|
+
onError: function () {
|
|
21493
|
+
setErrorUpdatingQuantity(true);
|
|
21482
21494
|
},
|
|
21483
21495
|
});
|
|
21484
21496
|
// Handlers
|
|
@@ -21495,12 +21507,18 @@ var QuantityInput = function (_a) {
|
|
|
21495
21507
|
quantity: quantity,
|
|
21496
21508
|
subscription: subscription,
|
|
21497
21509
|
});
|
|
21498
|
-
if (quantity
|
|
21499
|
-
|
|
21510
|
+
if (quantity === charge.quantity) {
|
|
21511
|
+
setEditingQuoteData(undefined);
|
|
21512
|
+
showErrorNotification('New quantity cannot be the same as current');
|
|
21500
21513
|
}
|
|
21501
21514
|
else {
|
|
21502
|
-
|
|
21503
|
-
|
|
21515
|
+
if (quantity !== undefined && quantity !== charge.quantity) {
|
|
21516
|
+
if (!(charge === null || charge === void 0 ? void 0 : charge.priceListChargeId)) {
|
|
21517
|
+
showErrorNotification('Charge ID is not found');
|
|
21518
|
+
return;
|
|
21519
|
+
}
|
|
21520
|
+
setUpdatingChargeQuantityId(getUpdatingChargeQuantityId(charge, subscription));
|
|
21521
|
+
}
|
|
21504
21522
|
}
|
|
21505
21523
|
};
|
|
21506
21524
|
var handleSubscriptionUpdate = function (editedSubscription) {
|
|
@@ -21508,31 +21526,17 @@ var QuantityInput = function (_a) {
|
|
|
21508
21526
|
return;
|
|
21509
21527
|
// If we are not editing a quote, we create a new one
|
|
21510
21528
|
if (!editingQuote) {
|
|
21511
|
-
|
|
21512
|
-
var charge_1 = subscriptions[editedSubscription.subscriptionIndex].charges[editedSubscription.chargeIndex];
|
|
21513
|
-
if (isQuantityLowerThanOriginal(charge_1.quantity)) {
|
|
21514
|
-
// If the quantity is lower than the original, we remove the quote
|
|
21515
|
-
setEditingQuoteData(undefined);
|
|
21516
|
-
setUpdatingChargeQuantityId(undefined);
|
|
21517
|
-
return;
|
|
21518
|
-
}
|
|
21519
|
-
subscriptionIds.push(editedSubscription.subscription.id);
|
|
21520
|
-
createQuote.mutate(subscriptionIds);
|
|
21529
|
+
createQuote.mutate(editedSubscription.subscription.id);
|
|
21521
21530
|
}
|
|
21522
21531
|
else {
|
|
21523
21532
|
// If we are editing a quote, we update the quote change
|
|
21524
21533
|
var _a = createQuoteParams(editingQuote, charge.quantity, editedSubscription), charges = _a.charges, quoteChange = _a.quoteChange;
|
|
21525
|
-
if (quoteChange && charges.length > 0
|
|
21534
|
+
if (quoteChange && charges.length > 0) {
|
|
21526
21535
|
updateQuote.mutate({
|
|
21527
21536
|
charges: charges,
|
|
21528
21537
|
quoteChangeId: quoteChange.id,
|
|
21529
21538
|
});
|
|
21530
21539
|
}
|
|
21531
|
-
else {
|
|
21532
|
-
// Reset the editing quote data and the updating charge quantity ID to their initial states
|
|
21533
|
-
setEditingQuoteData(undefined);
|
|
21534
|
-
setUpdatingChargeQuantityId(undefined);
|
|
21535
|
-
}
|
|
21536
21540
|
}
|
|
21537
21541
|
};
|
|
21538
21542
|
// Initial subscription quantity if is on mobile
|
|
@@ -21561,13 +21565,8 @@ var QuantityInput = function (_a) {
|
|
|
21561
21565
|
handleSubscriptionUpdate(editedSubscription);
|
|
21562
21566
|
}, 1000);
|
|
21563
21567
|
return function () { return clearTimeout(debounce); };
|
|
21564
|
-
// eslint-disable-next-line
|
|
21565
21568
|
}, [editedSubscription]);
|
|
21566
|
-
return (jsx(Fragment, { children: jsx(Input, { className: "bunny-text-right", disabled: quantityDisabled,
|
|
21567
|
-
if (typeof value === 'number' && value < charge.quantity) {
|
|
21568
|
-
showErrorNotification('New value is less than the original quantity. This is not allowed');
|
|
21569
|
-
}
|
|
21570
|
-
}, onChange: function (e) {
|
|
21569
|
+
return (jsx(Fragment, { children: jsx(Input, { className: "bunny-text-right", disabled: quantityDisabled, onChange: function (e) {
|
|
21571
21570
|
onChangeQuantity(chargeIndex, e.target.value, charge.priceListChargeId, subscription, subscriptionIndex);
|
|
21572
21571
|
}, status: isQuantityLowerThanOriginal(charge.quantity) ? 'error' : '', style: { width: '96px' }, value: value }) }));
|
|
21573
21572
|
};
|
|
@@ -21575,11 +21574,11 @@ var QuantityInput = function (_a) {
|
|
|
21575
21574
|
var Text$b = Typography.Text;
|
|
21576
21575
|
var QuantityChangeGridRow = function (_a) {
|
|
21577
21576
|
var _b;
|
|
21578
|
-
var chargeIndex = _a.chargeIndex, editingQuote = _a.editingQuote,
|
|
21577
|
+
var chargeIndex = _a.chargeIndex, editingQuote = _a.editingQuote, subscriptionIndex = _a.subscriptionIndex, setEditingQuoteData = _a.setEditingQuoteData, subscription = _a.subscription, subscriptionCharge = _a.subscriptionCharge, setUpdatingChargeQuantityId = _a.setUpdatingChargeQuantityId, updatingChargeQuantityId = _a.updatingChargeQuantityId, setErrorUpdatingQuantity = _a.setErrorUpdatingQuantity;
|
|
21579
21578
|
if (!canShowQuantitiesInput(subscriptionCharge, subscription))
|
|
21580
21579
|
return null;
|
|
21581
21580
|
var brandColor = useContext(BrandContext).brandColor;
|
|
21582
|
-
return (jsxs(Fragment, { children: [jsx(Text$b, __assign({ className: "bunny-font-medium bunny-col-span-full", style: { fontSize: '11px', color: brandColor } }, { children: subscription.plan.name })), jsx(Text$b, __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$b, __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,
|
|
21581
|
+
return (jsxs(Fragment, { children: [jsx(Text$b, __assign({ className: "bunny-font-medium bunny-col-span-full", style: { fontSize: '11px', color: brandColor } }, { children: subscription.plan.name })), jsx(Text$b, __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$b, __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, setUpdatingChargeQuantityId: setUpdatingChargeQuantityId, updatingChargeQuantityId: updatingChargeQuantityId, setErrorUpdatingQuantity: setErrorUpdatingQuantity }), jsx("div", {})] })), jsx(Divider, { className: "bunny-col-span-full bunny-my-2" })] }));
|
|
21583
21582
|
};
|
|
21584
21583
|
|
|
21585
21584
|
var QuantityChangeGridTitle = function (_a) {
|
|
@@ -21588,11 +21587,10 @@ var QuantityChangeGridTitle = function (_a) {
|
|
|
21588
21587
|
};
|
|
21589
21588
|
|
|
21590
21589
|
var QuoteChangeSummarySection = function (_a) {
|
|
21591
|
-
var editingQuote = _a.editingQuote, editingQuoteData = _a.editingQuoteData, openCheckout = _a.openCheckout, setEditingQuoteData = _a.setEditingQuoteData;
|
|
21590
|
+
var editingQuote = _a.editingQuote, editingQuoteData = _a.editingQuoteData, openCheckout = _a.openCheckout, setEditingQuoteData = _a.setEditingQuoteData, errorUpdatingQuantity = _a.errorUpdatingQuantity;
|
|
21592
21591
|
var apiHost = useContext(BunnyContext).apiHost;
|
|
21593
21592
|
var isMobile = useIsMobile();
|
|
21594
21593
|
var token = useToken();
|
|
21595
|
-
// const apiHost = getApiHost();
|
|
21596
21594
|
var showSuccessNotification = useSuccessNotification();
|
|
21597
21595
|
var trialUpgradeMutation = useMutation({
|
|
21598
21596
|
mutationFn: function (quoteId) { return checkout({ quoteId: quoteId, token: token, apiHost: apiHost }); },
|
|
@@ -21603,7 +21601,7 @@ var QuoteChangeSummarySection = function (_a) {
|
|
|
21603
21601
|
});
|
|
21604
21602
|
return (jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-items-end" }, { children: [editingQuote && (jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-mb-8" }, { children: [jsx("div", __assign({ className: "bunny-text-slate-500 bunny-text-right bunny-text-xs bunny-mb-2" }, { children: "TOTAL" })), jsx("div", __assign({ className: "bunny-text-right ".concat(isMobile ? 'bunny-text-2xl' : 'bunny-text-xl') }, { children: formatCurrency(getQuoteAmountDue(editingQuote), (editingQuote === null || editingQuote === void 0 ? void 0 : editingQuote.currencyId) || '') }))] }))), jsx("div", __assign({ className: "bunny-flex bunny-items-center bunny-justify-end ".concat(isMobile ? 'bunny-w-full' : '') }, { children: jsx(Button, __assign({ className: "bunny-w-full", onClick: (editingQuoteData === null || editingQuoteData === void 0 ? void 0 : editingQuoteData.isTrial)
|
|
21605
21603
|
? function () { return trialUpgradeMutation.mutate(editingQuoteData.id); }
|
|
21606
|
-
: openCheckout, disabled: !editingQuoteData || !editingQuote, size: isMobile ? 'large' : 'middle', type: "primary" }, { children: (editingQuoteData === null || editingQuoteData === void 0 ? void 0 : editingQuoteData.isTrial) ? 'Activate Trial' : 'Proceed to checkout' })) }))] })));
|
|
21604
|
+
: openCheckout, disabled: !editingQuoteData || !editingQuote || errorUpdatingQuantity, size: isMobile ? 'large' : 'middle', type: "primary" }, { children: (editingQuoteData === null || editingQuoteData === void 0 ? void 0 : editingQuoteData.isTrial) ? 'Activate Trial' : 'Proceed to checkout' })) }))] })));
|
|
21607
21605
|
};
|
|
21608
21606
|
|
|
21609
21607
|
var QUANTITY_CHANGE_HEADER_TITLE = 'Update unit quantity';
|
|
@@ -21611,6 +21609,7 @@ var QUANTITY_CHANGE_HEADER_DESCRIPTION = 'Adjust quantities below. The change wi
|
|
|
21611
21609
|
var QuantityChangeDrawerDesktop = function (_a) {
|
|
21612
21610
|
var editingQuote = _a.editingQuote, editingQuoteData = _a.editingQuoteData, onClose = _a.onClose, open = _a.open, openCheckout = _a.openCheckout, setEditingQuoteData = _a.setEditingQuoteData, subscriptions = _a.subscriptions, setUpdatingChargeQuantityId = _a.setUpdatingChargeQuantityId, updatingChargeQuantityId = _a.updatingChargeQuantityId;
|
|
21613
21611
|
var _b = useState(open), openLocal = _b[0], setOpenLocal = _b[1];
|
|
21612
|
+
var _c = useState(false), errorUpdatingQuantity = _c[0], setErrorUpdatingQuantity = _c[1];
|
|
21614
21613
|
var isMobile = useIsMobile();
|
|
21615
21614
|
useEffect(function () {
|
|
21616
21615
|
var timeoutId;
|
|
@@ -21646,17 +21645,17 @@ var QuantityChangeDrawerDesktop = function (_a) {
|
|
|
21646
21645
|
rowGap: '0.25rem',
|
|
21647
21646
|
columnGap: '1rem',
|
|
21648
21647
|
} }, { children: [jsx(QuantityChangeGridTitle, { children: "ACTIVE SUBSCRIPTIONS" }), jsx(QuantityChangeGridTitle, __assign({ right: true }, { children: "CURRENT QUANTITY" })), jsx(QuantityChangeGridTitle, __assign({ right: true }, { children: "NEW QUANTITY" })), jsx(Divider, { className: "bunny-col-span-full" }), subscriptions.map(function (subscription, index) {
|
|
21649
|
-
var _a;
|
|
21648
|
+
var _a, _b;
|
|
21650
21649
|
var isTrial = ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === SubscriptionState.TRIAL;
|
|
21651
|
-
return (jsx("div", __assign({ className: "bunny-contents" }, { children: subscription.
|
|
21650
|
+
return (jsx("div", __assign({ className: "bunny-contents" }, { children: (_b = subscription === null || subscription === void 0 ? void 0 : subscription.currentCharges) === null || _b === void 0 ? void 0 : _b.map(function (charge, chargeIndex) {
|
|
21652
21651
|
var _a;
|
|
21653
21652
|
if ((isTrial && !charge.trial) ||
|
|
21654
21653
|
(!isTrial && charge.trial) ||
|
|
21655
21654
|
((_a = charge.chargeType) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === 'USAGE')
|
|
21656
21655
|
return null;
|
|
21657
|
-
return (jsx(QuantityChangeGridRow, { chargeIndex: chargeIndex, editingQuote: editingQuote, setEditingQuoteData: setEditingQuoteData, subscription: subscription, subscriptionCharge: charge, subscriptionIndex: index,
|
|
21656
|
+
return (jsx(QuantityChangeGridRow, { chargeIndex: chargeIndex, editingQuote: editingQuote, setEditingQuoteData: setEditingQuoteData, subscription: subscription, subscriptionCharge: charge, subscriptionIndex: index, setUpdatingChargeQuantityId: setUpdatingChargeQuantityId, updatingChargeQuantityId: updatingChargeQuantityId, setErrorUpdatingQuantity: setErrorUpdatingQuantity }, chargeIndex));
|
|
21658
21657
|
}) }), index));
|
|
21659
|
-
})] })), jsx(QuoteChangeSummarySection, { editingQuote: editingQuote, editingQuoteData: editingQuoteData, openCheckout: openCheckout, setEditingQuoteData: setEditingQuoteData })] })));
|
|
21658
|
+
})] })), jsx(QuoteChangeSummarySection, { editingQuote: editingQuote, editingQuoteData: editingQuoteData, openCheckout: openCheckout, setEditingQuoteData: setEditingQuoteData, errorUpdatingQuantity: errorUpdatingQuantity })] })));
|
|
21660
21659
|
};
|
|
21661
21660
|
|
|
21662
21661
|
var QuantityDrawerContainer = function (_a) {
|
|
@@ -22246,7 +22245,7 @@ var ADDON_CARD_COLUMNS = [
|
|
|
22246
22245
|
},
|
|
22247
22246
|
];
|
|
22248
22247
|
var SubscriptionCardDesktop = function (_a) {
|
|
22249
|
-
var _b;
|
|
22248
|
+
var _b, _c;
|
|
22250
22249
|
var onChangePlanClick = _a.onChangePlanClick, onCancelSubscriptionClick = _a.onCancelSubscriptionClick, subscription = _a.subscription, isAddon = _a.isAddon;
|
|
22251
22250
|
var shadow = useContext(SubscriptionsContext).shadow;
|
|
22252
22251
|
// Derived state
|
|
@@ -22259,21 +22258,21 @@ var SubscriptionCardDesktop = function (_a) {
|
|
|
22259
22258
|
} }), jsxs("div", __assign({ className: "bunny-grid bunny-w-full", style: {
|
|
22260
22259
|
gridTemplateColumns: CARD_COLUMNS.map(function (column) { return column.width; }).join(' '),
|
|
22261
22260
|
rowGap: '0.75rem',
|
|
22262
|
-
} }, { children: [jsx(SubscriptionCardColumnHeaders, { columns: CARD_COLUMNS }), subscription.
|
|
22261
|
+
} }, { children: [jsx(SubscriptionCardColumnHeaders, { columns: CARD_COLUMNS }), (_c = subscription === null || subscription === void 0 ? void 0 : subscription.chargeReport) === null || _c === void 0 ? void 0 : _c.map(function (charge, chargeIndex) {
|
|
22263
22262
|
if ((isTrial && !charge.trial) || (!isTrial && charge.trial))
|
|
22264
22263
|
return null;
|
|
22265
22264
|
return (jsx(SubscriptionCardDesktopRow, { charge: charge, chargeIndex: chargeIndex, subscription: subscription }, chargeIndex));
|
|
22266
22265
|
})] }))] })));
|
|
22267
22266
|
};
|
|
22268
22267
|
var SubscriptionCardDesktopRow = function (_a) {
|
|
22269
|
-
var _b, _c;
|
|
22268
|
+
var _b, _c, _d;
|
|
22270
22269
|
var charge = _a.charge, chargeIndex = _a.chargeIndex, subscription = _a.subscription;
|
|
22271
22270
|
// Context
|
|
22272
22271
|
var apiHost = useContext(BunnyContext).apiHost;
|
|
22273
22272
|
var token = useToken();
|
|
22274
22273
|
// Derived state
|
|
22275
22274
|
var isRamp = charge.isRamp;
|
|
22276
|
-
var prevCharge = subscription.
|
|
22275
|
+
var prevCharge = (_b = subscription === null || subscription === void 0 ? void 0 : subscription.chargeReport) === null || _b === void 0 ? void 0 : _b[chargeIndex - 1];
|
|
22277
22276
|
var isFirstRampRow = chargeIndex === 0 || (prevCharge === null || prevCharge === void 0 ? void 0 : prevCharge.priceListChargeId) !== charge.priceListChargeId;
|
|
22278
22277
|
var chargePeriod = "".concat(formatDate(charge.startDate), " - ").concat(formatDate(charge.endDate));
|
|
22279
22278
|
// Queries
|
|
@@ -22293,15 +22292,15 @@ var SubscriptionCardDesktopRow = function (_a) {
|
|
|
22293
22292
|
var isDiscount = charge.kind === QuoteChangeKind.DISCOUNT;
|
|
22294
22293
|
var dontShowChargeName = (prevCharge === null || prevCharge === void 0 ? void 0 : prevCharge.priceListChargeId) === charge.priceListChargeId &&
|
|
22295
22294
|
!isDiscount &&
|
|
22296
|
-
(!isTrial || prevCharge.trial) &&
|
|
22297
|
-
(isTrial || !prevCharge.trial);
|
|
22295
|
+
(!isTrial || (prevCharge === null || prevCharge === void 0 ? void 0 : prevCharge.trial)) &&
|
|
22296
|
+
(isTrial || !(prevCharge === null || prevCharge === void 0 ? void 0 : prevCharge.trial));
|
|
22298
22297
|
return (jsxs("div", __assign({ className: "bunny-contents" }, { children: [(isRampFirstRow || !isRamp) && (jsx(SubscriptionsListCell, __assign({ gridColumn: isRamp ? '1/-1' : '1' }, { children: jsx("div", __assign({ className: "bunny-flex bunny-items-center bunny-gap-2 ".concat(isDiscount ? 'bunny-pl-4' : '') }, { children: jsx("div", { children: isRampFirstRow || (!isRamp && !dontShowChargeName) ? charge.name : '' }) })) }))), jsx(SubscriptionsListCell, __assign({ gridColumn: 2 }, { children: jsx("div", { children: chargePeriod }) })), jsx(SubscriptionsListCell, __assign({ right: true }, { children: charge.kind === QuoteChangeKind.DISCOUNT
|
|
22299
22298
|
? ''
|
|
22300
22299
|
: charge.chargeType === ChargeType.USAGE
|
|
22301
22300
|
? data && jsx(FeatureUsageGraph, { charge: charge, featureUsage: data })
|
|
22302
22301
|
: charge.isAmendment
|
|
22303
|
-
? "+".concat((
|
|
22304
|
-
: (
|
|
22302
|
+
? "+".concat((_c = charge.quantity) === null || _c === void 0 ? void 0 : _c.toLocaleString())
|
|
22303
|
+
: (_d = charge.quantity) === null || _d === void 0 ? void 0 : _d.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 }) }))] })));
|
|
22305
22304
|
};
|
|
22306
22305
|
|
|
22307
22306
|
function AddonSubscriptionsCards(_a) {
|
|
@@ -22342,7 +22341,7 @@ var CHARGE_COLUMNS = [
|
|
|
22342
22341
|
},
|
|
22343
22342
|
];
|
|
22344
22343
|
var SubscriptionCard = function (_a) {
|
|
22345
|
-
var _b;
|
|
22344
|
+
var _b, _c;
|
|
22346
22345
|
var subscription = _a.subscription;
|
|
22347
22346
|
var darkMode = useContext(BunnyContext).darkMode;
|
|
22348
22347
|
// Derived state
|
|
@@ -22357,7 +22356,7 @@ var SubscriptionCard = function (_a) {
|
|
|
22357
22356
|
gridTemplateColumns: "1fr auto auto auto",
|
|
22358
22357
|
rowGap: '0.75rem',
|
|
22359
22358
|
backgroundColor: backgroundColor,
|
|
22360
|
-
} }, { children: [CHARGE_COLUMNS.map(function (subscriptionColumn, index) { return (jsx(SubscriptionCardCellMobile, __assign({ className: "bunny-text-slate-400 ".concat(subscriptionColumn.className), style: { fontSize: '11px' } }, { children: subscriptionColumn.title }), index)); }), subscription.
|
|
22359
|
+
} }, { children: [CHARGE_COLUMNS.map(function (subscriptionColumn, index) { return (jsx(SubscriptionCardCellMobile, __assign({ className: "bunny-text-slate-400 ".concat(subscriptionColumn.className), style: { fontSize: '11px' } }, { children: subscriptionColumn.title }), index)); }), (_c = subscription === null || subscription === void 0 ? void 0 : subscription.chargeReport) === null || _c === void 0 ? void 0 : _c.map(function (charge, chargeIndex) {
|
|
22361
22360
|
if ((isTrial && !charge.trial) || (!isTrial && charge.trial))
|
|
22362
22361
|
return null;
|
|
22363
22362
|
var isRamp = charge.isRamp;
|
|
@@ -24006,7 +24005,7 @@ var PlanPicker = function (_a) {
|
|
|
24006
24005
|
if (!priceListChangeOptions) {
|
|
24007
24006
|
return null;
|
|
24008
24007
|
}
|
|
24009
|
-
return (jsx(Fragment, { children: ((_b = priceListChangeOptions === null || priceListChangeOptions === void 0 ? void 0 : priceListChangeOptions.priceLists) === null || _b === void 0 ? void 0 : _b.length) === 0 ? (jsx(ErrorView, { message: "There are no plans available" })) : (jsx(PriceListSelector, { arePlanChangeOptionsLoading: arePlanChangeOptionsLoading, areSubscriptionsLoading: areSubscriptionsLoading, priceListChangeOptions: priceListChangeOptions, subscriptions: subscriptions })) }));
|
|
24008
|
+
return (jsx(Fragment, { children: ((_b = priceListChangeOptions === null || priceListChangeOptions === void 0 ? void 0 : priceListChangeOptions.priceLists) === null || _b === void 0 ? void 0 : _b.length) === 0 ? (jsx(ErrorView, { message: "There are no plans available" })) : (jsx(PriceListSelector, { arePlanChangeOptionsLoading: arePlanChangeOptionsLoading, areSubscriptionsLoading: areSubscriptionsLoading, priceListChangeOptions: priceListChangeOptions, subscriptions: subscriptions !== null && subscriptions !== void 0 ? subscriptions : [] })) }));
|
|
24010
24009
|
};
|
|
24011
24010
|
|
|
24012
24011
|
var Text$1 = Typography.Text;
|
|
@@ -24165,7 +24164,7 @@ var Subscriptions = function (_a) {
|
|
|
24165
24164
|
((_c = subscription.state) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === SubscriptionState.CANCELED;
|
|
24166
24165
|
});
|
|
24167
24166
|
useEffect(function () {
|
|
24168
|
-
if (allSubscriptionsExpired && subscriptions.length > 0) {
|
|
24167
|
+
if (allSubscriptionsExpired && subscriptions && subscriptions.length > 0) {
|
|
24169
24168
|
setHideExpiredState(false);
|
|
24170
24169
|
}
|
|
24171
24170
|
else {
|
|
@@ -24173,7 +24172,7 @@ var Subscriptions = function (_a) {
|
|
|
24173
24172
|
}
|
|
24174
24173
|
}, [allSubscriptionsExpired, subscriptions, isChangingPlan]);
|
|
24175
24174
|
useEffect(function () {
|
|
24176
|
-
if (hasExpiredOrCanceledSubscriptions && subscriptions.length > 0) {
|
|
24175
|
+
if (hasExpiredOrCanceledSubscriptions && subscriptions && subscriptions.length > 0) {
|
|
24177
24176
|
setExpiredSwitchVisible(true);
|
|
24178
24177
|
}
|
|
24179
24178
|
else {
|
|
@@ -24185,7 +24184,7 @@ var Subscriptions = function (_a) {
|
|
|
24185
24184
|
setIsChangingPlan(false);
|
|
24186
24185
|
}, handlePortalErrors: handlePortalErrors, upgradingSubscription: upgradingSubscription, className: className }));
|
|
24187
24186
|
}
|
|
24188
|
-
return (jsxs("div", __assign({ className: className }, { children: [jsx(PageHeaderWithActions, __assign({ title: jsx(Fragment, { children: !hideExpiredToggle && 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(QuantityDrawerContainer, { subscriptions: subscriptions, quantityDrawerOpen: quantityDrawerOpen, setQuantityDrawerOpen: setQuantityDrawerOpen, handlePortalErrors: handlePortalErrors, setHideExpiredState: setHideExpiredState })] })));
|
|
24187
|
+
return (jsxs("div", __assign({ className: className }, { children: [jsx(PageHeaderWithActions, __assign({ title: jsx(Fragment, { children: !hideExpiredToggle && isMobile && expiredSwitchVisible && (jsx(HideExpiredToggle, { hideExpired: hideExpired, setHideExpired: setHideExpiredState })) }) }, { children: !isMobile && (jsx(SubscriptionsNavigation, { expiredSwitchVisible: !hideExpiredToggle && expiredSwitchVisible, hideExpired: hideExpired, setHideExpired: setHideExpiredState, setQuantityDrawerOpen: setQuantityDrawerOpen, subscriptions: subscriptions !== null && subscriptions !== void 0 ? subscriptions : [] })) })), jsx(SubscriptionsListContainer, { companyName: companyName, hideExpired: hideExpired, onCancelSubscriptionClick: onCancelSubscriptionClick, onChangePlanClick: onChangePlanClick, subscriptions: subscriptions !== null && subscriptions !== void 0 ? 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 !== null && subscriptions !== void 0 ? subscriptions : [] }) }))), jsx(QuantityDrawerContainer, { subscriptions: subscriptions !== null && subscriptions !== void 0 ? subscriptions : [], quantityDrawerOpen: quantityDrawerOpen, setQuantityDrawerOpen: setQuantityDrawerOpen, handlePortalErrors: handlePortalErrors, setHideExpiredState: setHideExpiredState })] })));
|
|
24189
24188
|
};
|
|
24190
24189
|
var PageHeaderWithActions = function (_a) {
|
|
24191
24190
|
var children = _a.children, title = _a.title;
|
package/dist/esm/src/components/Subscriptions/quantityChangeDrawer/QuantityChangeGridRow.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Quote, Subscription, SubscriptionCharge } from '@bunnyapp/common';
|
|
2
|
-
declare const QuantityChangeGridRow: ({ chargeIndex, editingQuote,
|
|
2
|
+
declare const QuantityChangeGridRow: ({ chargeIndex, editingQuote, subscriptionIndex, setEditingQuoteData, subscription, subscriptionCharge, setUpdatingChargeQuantityId, updatingChargeQuantityId, setErrorUpdatingQuantity, }: {
|
|
3
3
|
chargeIndex: number;
|
|
4
4
|
editingQuote?: Quote | undefined;
|
|
5
|
-
subscriptions: Subscription[];
|
|
6
5
|
subscriptionIndex: number;
|
|
7
6
|
setEditingQuoteData: (value: any) => void;
|
|
8
7
|
subscription: Subscription;
|
|
9
8
|
subscriptionCharge: SubscriptionCharge;
|
|
10
9
|
setUpdatingChargeQuantityId: (updatingChargeQuantityId: string | undefined) => void;
|
|
11
10
|
updatingChargeQuantityId: string | undefined;
|
|
11
|
+
setErrorUpdatingQuantity: (errorUpdatingQuantity: boolean) => void;
|
|
12
12
|
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
13
13
|
export default QuantityChangeGridRow;
|
|
@@ -6,7 +6,7 @@ export type EditingSubscriptionType = {
|
|
|
6
6
|
subscription: Subscription;
|
|
7
7
|
subscriptionIndex: number;
|
|
8
8
|
};
|
|
9
|
-
declare const QuantityInput: ({ charge, chargeIndex, editingQuote, setEditingQuoteData, subscription, subscriptionIndex,
|
|
9
|
+
declare const QuantityInput: ({ charge, chargeIndex, editingQuote, setEditingQuoteData, subscription, subscriptionIndex, setUpdatingChargeQuantityId, updatingChargeQuantityId, setErrorUpdatingQuantity, }: {
|
|
10
10
|
charge: SubscriptionCharge;
|
|
11
11
|
chargeIndex: number;
|
|
12
12
|
editingQuote?: Quote | undefined;
|
|
@@ -16,8 +16,8 @@ declare const QuantityInput: ({ charge, chargeIndex, editingQuote, setEditingQuo
|
|
|
16
16
|
} | undefined) => void;
|
|
17
17
|
subscription: Subscription;
|
|
18
18
|
subscriptionIndex: number;
|
|
19
|
-
subscriptions: Subscription[];
|
|
20
19
|
setUpdatingChargeQuantityId: (updatingChargeQuantityId: string | undefined) => void;
|
|
21
20
|
updatingChargeQuantityId: string | undefined;
|
|
21
|
+
setErrorUpdatingQuantity: (errorUpdatingQuantity: boolean) => void;
|
|
22
22
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
23
23
|
export default QuantityInput;
|
package/dist/esm/src/components/Subscriptions/quantityChangeDrawer/QuoteChangeSummarySection.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Quote } from '@bunnyapp/common';
|
|
2
2
|
import { EditingQuoteDataType } from '../SubscriptionsListContainer';
|
|
3
|
-
declare const QuoteChangeSummarySection: ({ editingQuote, editingQuoteData, openCheckout, setEditingQuoteData, }: {
|
|
3
|
+
declare const QuoteChangeSummarySection: ({ editingQuote, editingQuoteData, openCheckout, setEditingQuoteData, errorUpdatingQuantity, }: {
|
|
4
4
|
editingQuote?: Quote | undefined;
|
|
5
5
|
editingQuoteData?: EditingQuoteDataType | undefined;
|
|
6
6
|
openCheckout: () => void;
|
|
7
7
|
setEditingQuoteData: (editingQuoteData: EditingQuoteDataType | undefined) => void;
|
|
8
|
+
errorUpdatingQuantity: boolean;
|
|
8
9
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
9
10
|
export default QuoteChangeSummarySection;
|
|
@@ -25,3 +25,4 @@ export declare const isDiscount: (kind?: QuoteChangeKind) => boolean;
|
|
|
25
25
|
export declare const hasPriceTiers: (charge: SubscriptionCharge) => boolean;
|
|
26
26
|
export declare const hasMultiplePriceTiers: (charge: SubscriptionCharge) => boolean;
|
|
27
27
|
export declare const getApplicablePriceTier: (charge: SubscriptionCharge, currencyId: string, priceDecimals: number) => string;
|
|
28
|
+
export declare const getUpdatingChargeQuantityId: (charge: SubscriptionCharge, subscription: Subscription) => string;
|
|
@@ -8,7 +8,7 @@ export declare const useCreateSubscriptionQuote: () => (subscriptionIds: string[
|
|
|
8
8
|
export declare const useQuoteChangeUpdate: () => (charges: {
|
|
9
9
|
id: string;
|
|
10
10
|
quantity: number;
|
|
11
|
-
}[], quoteChangeId: string, apiHost: string, token?: string) => Promise<
|
|
11
|
+
}[], quoteChangeId: string, apiHost: string, token?: string) => Promise<any>;
|
|
12
12
|
export declare const useQuoteDelete: () => (quoteId: string, apiHost: string, token?: string) => Promise<unknown>;
|
|
13
13
|
export declare const quoteSubscriptionAddon: ({ subscriptionId, priceListId, apiHost, token, }: {
|
|
14
14
|
subscriptionId: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { Subscription } from '@bunnyapp/common';
|
|
1
2
|
declare const getSubscriptions: ({ apiHost, isInPreviewMode, token, }: {
|
|
2
3
|
apiHost: string;
|
|
3
4
|
isInPreviewMode?: boolean | undefined;
|
|
4
5
|
token?: string | undefined;
|
|
5
|
-
}) => Promise<
|
|
6
|
+
}) => Promise<Subscription[]>;
|
|
6
7
|
export default getSubscriptions;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bunnyapp/components",
|
|
3
|
-
"version": "1.5.0-beta.
|
|
3
|
+
"version": "1.5.0-beta.14",
|
|
4
4
|
"description": "Components from the Bunny portal to embed Bunny UI functionality into your application.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"@ant-design/icons": "^5.6.1",
|
|
67
|
-
"@bunnyapp/common": "1.5.0-beta.
|
|
67
|
+
"@bunnyapp/common": "1.5.0-beta.6",
|
|
68
68
|
"@fortawesome/fontawesome-svg-core": "^6.7.2",
|
|
69
69
|
"@fortawesome/free-brands-svg-icons": "^6.7.2",
|
|
70
70
|
"@fortawesome/free-regular-svg-icons": "^6.7.2",
|