@bunnyapp/components 1.5.0-beta.11.3 → 1.5.0-beta.13

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 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.11.1';
157
+ var PACKAGE_VERSION = '1.5.0-beta.12';
158
158
  var createRequestHeaders = function (token) {
159
159
  var headers = createClientDevHeaders({ token: token });
160
160
  // Add the components version header
@@ -480,7 +480,7 @@ var InvoiceQuoteView = function (_a) {
480
480
  color: secondaryColor,
481
481
  }, type: "link" }, { children: backButtonName || 'Back' }))) : null }), !hideDownloadButton ? (jsxRuntime.jsx(antd.Button, __assign({ icon: jsxRuntime.jsx(icons.DownloadOutlined, {}), onClick: function () {
482
482
  return downloadFile(apiHost + '/api/pdf/invoice/' + formattedInvoice.id, token);
483
- } }, { children: "Download" }))) : null] }))) : null, isMobile ? (jsxRuntime.jsxs(MarkupContainer, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4 bunny-grow bunny-w-full bunny-shadow-padding-xb bunny-overflow-auto" }, { children: [targetUrl ? (jsxRuntime.jsx(DocumentTemplatePreview, { targetUrl: targetUrl })) : (jsxRuntime.jsx(interweave.Markup, { content: html })), children] }))) : (jsxRuntime.jsxs(MarkupContainer, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4 bunny-p-4 bunny-w-full bunny-bg-white ".concat(shadow ? shadow : 'bunny-shadow-md', " bunny-rounded-md"), style: {
483
+ } }, { children: "Download" }))) : null] }))) : null, isMobile ? (jsxRuntime.jsxs(MarkupContainer, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4 bunny-grow bunny-shadow-padding-xb bunny-overflow-auto" }, { children: [targetUrl ? (jsxRuntime.jsx(DocumentTemplatePreview, { targetUrl: targetUrl })) : (jsxRuntime.jsx(interweave.Markup, { content: html })), children] }))) : (jsxRuntime.jsxs(MarkupContainer, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4 bunny-p-4 bunny-bg-white ".concat(shadow ? shadow : 'bunny-shadow-md', " bunny-rounded-md"), style: {
484
484
  minWidth: '750px',
485
485
  } }, { children: [targetUrl ? (jsxRuntime.jsx(DocumentTemplatePreview, { targetUrl: targetUrl })) : (jsxRuntime.jsx(interweave.Markup, { content: html })), children] })))] })));
486
486
  };
@@ -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 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 }";
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 }";
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 (_c) {
20865
- switch (_c.label) {
20862
+ var response, combinedSubscriptions;
20863
+ var _b, _c;
20864
+ return __generator(this, function (_d) {
20865
+ switch (_d.label) {
20866
20866
  case 0: return [4 /*yield*/, gqlRequest({
20867
20867
  isInPreviewMode: isInPreviewMode,
20868
20868
  query: SUBSCRIPTIONS_QUERY,
@@ -20870,8 +20870,9 @@ var getSubscriptions = function (_a) {
20870
20870
  apiHost: apiHost,
20871
20871
  })];
20872
20872
  case 1:
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];
20873
+ response = _d.sent();
20874
+ combinedSubscriptions = (_c = (_b = response === null || response === void 0 ? void 0 : response.subscriptions) === null || _b === void 0 ? void 0 : _b.nodes) === null || _c === void 0 ? void 0 : _c.map(function (subscription) { return (__assign(__assign({}, subscription), { charges: common.sortSubscriptionCharges(subscription.charges) })); });
20875
+ return [2 /*return*/, combinedSubscriptions];
20875
20876
  }
20876
20877
  });
20877
20878
  });
@@ -21079,12 +21080,12 @@ var QuoteCheckout = function (_a) {
21079
21080
  removeCoupon(couponCode);
21080
21081
  }
21081
21082
  });
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" }))] })) }))) }));
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" }))] })) }))) }));
21083
21084
  };
21084
21085
  var PaymentFormWrapper = function (_a) {
21085
21086
  var children = _a.children, setMaxHeight = _a.setMaxHeight, className = _a.className;
21086
21087
  var isMobile = common.useIsMobile();
21087
- return (jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-flex-col bunny-w-full bunny-gap-6 ".concat(isMobile ? 'bunny-shadow-padding-xb' : '', " ").concat(className), style: __assign({}, (isMobile
21088
+ return (jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-w-full bunny-flex-col bunny-gap-6 ".concat(isMobile ? 'bunny-shadow-padding-xb' : '', " ").concat(className), style: __assign({}, (isMobile
21088
21089
  ? setMaxHeight
21089
21090
  ? { maxHeight: '60vh' }
21090
21091
  : {}
@@ -21227,8 +21228,7 @@ var createQuoteParams = function (quote, subscriptionQuantity, editedSubscriptio
21227
21228
  var canShowChangeQuantities = function (_a) {
21228
21229
  var subscriptions = _a.subscriptions;
21229
21230
  return subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.some(function (subscription) {
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) {
21231
+ return subscription.charges.some(function (charge) {
21232
21232
  return canShowQuantitiesInput(charge, subscription);
21233
21233
  });
21234
21234
  });
@@ -21307,10 +21307,6 @@ 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
- };
21314
21310
 
21315
21311
  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");
21316
21312
  var quoteChargeCreate = function (_a) {
@@ -21377,9 +21373,6 @@ var useQuoteChangeUpdate = function () {
21377
21373
  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 })];
21378
21374
  case 1:
21379
21375
  response = _a.sent();
21380
- if (response.errors) {
21381
- throw new Error(response.errors[0].message);
21382
- }
21383
21376
  return [2 /*return*/, response];
21384
21377
  }
21385
21378
  });
@@ -21415,7 +21408,7 @@ var formatDateForApi = function (date) {
21415
21408
  return date.format('YYYY-MM-DD');
21416
21409
  };
21417
21410
  var QuantityInput = function (_a) {
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;
21411
+ var charge = _a.charge, chargeIndex = _a.chargeIndex, editingQuote = _a.editingQuote, setEditingQuoteData = _a.setEditingQuoteData, subscription = _a.subscription, subscriptionIndex = _a.subscriptionIndex, subscriptions = _a.subscriptions, setUpdatingChargeQuantityId = _a.setUpdatingChargeQuantityId, updatingChargeQuantityId = _a.updatingChargeQuantityId;
21419
21412
  // Context
21420
21413
  var token = useToken();
21421
21414
  var apiHost = react.useContext(BunnyContext).apiHost;
@@ -21430,8 +21423,7 @@ var QuantityInput = function (_a) {
21430
21423
  var quantityDisabled =
21431
21424
  // If we are editing a quote, we disable the quantity input
21432
21425
  // If we don't have a editedSubscription, we disable the quantity input
21433
- (updatingChargeQuantityId &&
21434
- updatingChargeQuantityId !== getUpdatingChargeQuantityId(charge, subscription)) ||
21426
+ (updatingChargeQuantityId && updatingChargeQuantityId !== charge.id) ||
21435
21427
  // If the subscription is not self-service, we disable the quantity input
21436
21428
  !charge.selfServiceQuantity;
21437
21429
  var value = (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.quantity) === undefined ? '' : editedSubscription.quantity;
@@ -21457,8 +21449,8 @@ var QuantityInput = function (_a) {
21457
21449
  },
21458
21450
  }).mutate;
21459
21451
  var createQuote = reactQuery.useMutation({
21460
- mutationFn: function (subscriptionId) {
21461
- return createSubscriptionQuote([subscriptionId], apiHost, token);
21452
+ mutationFn: function (subscriptionIds) {
21453
+ return createSubscriptionQuote(subscriptionIds, apiHost, token);
21462
21454
  },
21463
21455
  onSuccess: function (subscriptionUpdateData) {
21464
21456
  var _a, _b;
@@ -21498,10 +21490,6 @@ var QuantityInput = function (_a) {
21498
21490
  token: token,
21499
21491
  }),
21500
21492
  });
21501
- setErrorUpdatingQuantity(false);
21502
- },
21503
- onError: function () {
21504
- setErrorUpdatingQuantity(true);
21505
21493
  },
21506
21494
  });
21507
21495
  // Handlers
@@ -21518,18 +21506,12 @@ var QuantityInput = function (_a) {
21518
21506
  quantity: quantity,
21519
21507
  subscription: subscription,
21520
21508
  });
21521
- if (quantity === charge.quantity) {
21522
- setEditingQuoteData(undefined);
21523
- showErrorNotification('New quantity cannot be the same as current');
21509
+ if (quantity !== undefined && quantity !== charge.quantity) {
21510
+ setUpdatingChargeQuantityId(charge.id);
21524
21511
  }
21525
21512
  else {
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
- }
21513
+ setUpdatingChargeQuantityId(undefined);
21514
+ setEditingQuoteData(undefined);
21533
21515
  }
21534
21516
  };
21535
21517
  var handleSubscriptionUpdate = function (editedSubscription) {
@@ -21537,17 +21519,31 @@ var QuantityInput = function (_a) {
21537
21519
  return;
21538
21520
  // If we are not editing a quote, we create a new one
21539
21521
  if (!editingQuote) {
21540
- createQuote.mutate(editedSubscription.subscription.id);
21522
+ var subscriptionIds = [];
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);
21541
21532
  }
21542
21533
  else {
21543
21534
  // If we are editing a quote, we update the quote change
21544
21535
  var _a = createQuoteParams(editingQuote, charge.quantity, editedSubscription), charges = _a.charges, quoteChange = _a.quoteChange;
21545
- if (quoteChange && charges.length > 0) {
21536
+ if (quoteChange && charges.length > 0 && charges[0].quantity > 0) {
21546
21537
  updateQuote.mutate({
21547
21538
  charges: charges,
21548
21539
  quoteChangeId: quoteChange.id,
21549
21540
  });
21550
21541
  }
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
+ }
21551
21547
  }
21552
21548
  };
21553
21549
  // Initial subscription quantity if is on mobile
@@ -21576,8 +21572,13 @@ var QuantityInput = function (_a) {
21576
21572
  handleSubscriptionUpdate(editedSubscription);
21577
21573
  }, 1000);
21578
21574
  return function () { return clearTimeout(debounce); };
21575
+ // eslint-disable-next-line
21579
21576
  }, [editedSubscription]);
21580
- return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(antd.Input, { className: "bunny-text-right", disabled: quantityDisabled, onChange: function (e) {
21577
+ return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(antd.Input, { className: "bunny-text-right", disabled: quantityDisabled, onBlur: function () {
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) {
21581
21582
  onChangeQuantity(chargeIndex, e.target.value, charge.priceListChargeId, subscription, subscriptionIndex);
21582
21583
  }, status: isQuantityLowerThanOriginal(charge.quantity) ? 'error' : '', style: { width: '96px' }, value: value }) }));
21583
21584
  };
@@ -21585,11 +21586,11 @@ var QuantityInput = function (_a) {
21585
21586
  var Text$b = antd.Typography.Text;
21586
21587
  var QuantityChangeGridRow = function (_a) {
21587
21588
  var _b;
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;
21589
+ var chargeIndex = _a.chargeIndex, editingQuote = _a.editingQuote, subscriptions = _a.subscriptions, subscriptionIndex = _a.subscriptionIndex, setEditingQuoteData = _a.setEditingQuoteData, subscription = _a.subscription, subscriptionCharge = _a.subscriptionCharge, setUpdatingChargeQuantityId = _a.setUpdatingChargeQuantityId, updatingChargeQuantityId = _a.updatingChargeQuantityId;
21589
21590
  if (!canShowQuantitiesInput(subscriptionCharge, subscription))
21590
21591
  return null;
21591
21592
  var brandColor = react.useContext(BrandContext).brandColor;
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" })] }));
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, subscriptions: subscriptions, setUpdatingChargeQuantityId: setUpdatingChargeQuantityId, updatingChargeQuantityId: updatingChargeQuantityId }), jsxRuntime.jsx("div", {})] })), jsxRuntime.jsx(antd.Divider, { className: "bunny-col-span-full bunny-my-2" })] }));
21593
21594
  };
21594
21595
 
21595
21596
  var QuantityChangeGridTitle = function (_a) {
@@ -21598,10 +21599,11 @@ var QuantityChangeGridTitle = function (_a) {
21598
21599
  };
21599
21600
 
21600
21601
  var QuoteChangeSummarySection = function (_a) {
21601
- var editingQuote = _a.editingQuote, editingQuoteData = _a.editingQuoteData, openCheckout = _a.openCheckout, setEditingQuoteData = _a.setEditingQuoteData, errorUpdatingQuantity = _a.errorUpdatingQuantity;
21602
+ var editingQuote = _a.editingQuote, editingQuoteData = _a.editingQuoteData, openCheckout = _a.openCheckout, setEditingQuoteData = _a.setEditingQuoteData;
21602
21603
  var apiHost = react.useContext(BunnyContext).apiHost;
21603
21604
  var isMobile = common.useIsMobile();
21604
21605
  var token = useToken();
21606
+ // const apiHost = getApiHost();
21605
21607
  var showSuccessNotification = common.useSuccessNotification();
21606
21608
  var trialUpgradeMutation = reactQuery.useMutation({
21607
21609
  mutationFn: function (quoteId) { return checkout({ quoteId: quoteId, token: token, apiHost: apiHost }); },
@@ -21612,7 +21614,7 @@ var QuoteChangeSummarySection = function (_a) {
21612
21614
  });
21613
21615
  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)
21614
21616
  ? function () { return trialUpgradeMutation.mutate(editingQuoteData.id); }
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' })) }))] })));
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' })) }))] })));
21616
21618
  };
21617
21619
 
21618
21620
  var QUANTITY_CHANGE_HEADER_TITLE = 'Update unit quantity';
@@ -21620,7 +21622,6 @@ var QUANTITY_CHANGE_HEADER_DESCRIPTION = 'Adjust quantities below. The change wi
21620
21622
  var QuantityChangeDrawerDesktop = function (_a) {
21621
21623
  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;
21622
21624
  var _b = react.useState(open), openLocal = _b[0], setOpenLocal = _b[1];
21623
- var _c = react.useState(false), errorUpdatingQuantity = _c[0], setErrorUpdatingQuantity = _c[1];
21624
21625
  var isMobile = common.useIsMobile();
21625
21626
  react.useEffect(function () {
21626
21627
  var timeoutId;
@@ -21656,17 +21657,17 @@ var QuantityChangeDrawerDesktop = function (_a) {
21656
21657
  rowGap: '0.25rem',
21657
21658
  columnGap: '1rem',
21658
21659
  } }, { 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) {
21659
- var _a, _b;
21660
+ var _a;
21660
21661
  var isTrial = ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.TRIAL;
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) {
21662
+ return (jsxRuntime.jsx("div", __assign({ className: "bunny-contents" }, { children: subscription.charges.map(function (charge, chargeIndex) {
21662
21663
  var _a;
21663
21664
  if ((isTrial && !charge.trial) ||
21664
21665
  (!isTrial && charge.trial) ||
21665
21666
  ((_a = charge.chargeType) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === 'USAGE')
21666
21667
  return null;
21667
- return (jsxRuntime.jsx(QuantityChangeGridRow, { chargeIndex: chargeIndex, editingQuote: editingQuote, setEditingQuoteData: setEditingQuoteData, subscription: subscription, subscriptionCharge: charge, subscriptionIndex: index, setUpdatingChargeQuantityId: setUpdatingChargeQuantityId, updatingChargeQuantityId: updatingChargeQuantityId, setErrorUpdatingQuantity: setErrorUpdatingQuantity }, chargeIndex));
21668
+ return (jsxRuntime.jsx(QuantityChangeGridRow, { chargeIndex: chargeIndex, editingQuote: editingQuote, setEditingQuoteData: setEditingQuoteData, subscription: subscription, subscriptionCharge: charge, subscriptionIndex: index, subscriptions: subscriptions, setUpdatingChargeQuantityId: setUpdatingChargeQuantityId, updatingChargeQuantityId: updatingChargeQuantityId }, chargeIndex));
21668
21669
  }) }), index));
21669
- })] })), jsxRuntime.jsx(QuoteChangeSummarySection, { editingQuote: editingQuote, editingQuoteData: editingQuoteData, openCheckout: openCheckout, setEditingQuoteData: setEditingQuoteData, errorUpdatingQuantity: errorUpdatingQuantity })] })));
21670
+ })] })), jsxRuntime.jsx(QuoteChangeSummarySection, { editingQuote: editingQuote, editingQuoteData: editingQuoteData, openCheckout: openCheckout, setEditingQuoteData: setEditingQuoteData })] })));
21670
21671
  };
21671
21672
 
21672
21673
  var QuantityDrawerContainer = function (_a) {
@@ -22256,7 +22257,7 @@ var ADDON_CARD_COLUMNS = [
22256
22257
  },
22257
22258
  ];
22258
22259
  var SubscriptionCardDesktop = function (_a) {
22259
- var _b, _c;
22260
+ var _b;
22260
22261
  var onChangePlanClick = _a.onChangePlanClick, onCancelSubscriptionClick = _a.onCancelSubscriptionClick, subscription = _a.subscription, isAddon = _a.isAddon;
22261
22262
  var shadow = react.useContext(SubscriptionsContext).shadow;
22262
22263
  // Derived state
@@ -22269,21 +22270,21 @@ var SubscriptionCardDesktop = function (_a) {
22269
22270
  } }), jsxRuntime.jsxs("div", __assign({ className: "bunny-grid bunny-w-full", style: {
22270
22271
  gridTemplateColumns: CARD_COLUMNS.map(function (column) { return column.width; }).join(' '),
22271
22272
  rowGap: '0.75rem',
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) {
22273
+ } }, { children: [jsxRuntime.jsx(SubscriptionCardColumnHeaders, { columns: CARD_COLUMNS }), subscription.charges.map(function (charge, chargeIndex) {
22273
22274
  if ((isTrial && !charge.trial) || (!isTrial && charge.trial))
22274
22275
  return null;
22275
22276
  return (jsxRuntime.jsx(SubscriptionCardDesktopRow, { charge: charge, chargeIndex: chargeIndex, subscription: subscription }, chargeIndex));
22276
22277
  })] }))] })));
22277
22278
  };
22278
22279
  var SubscriptionCardDesktopRow = function (_a) {
22279
- var _b, _c, _d;
22280
+ var _b, _c;
22280
22281
  var charge = _a.charge, chargeIndex = _a.chargeIndex, subscription = _a.subscription;
22281
22282
  // Context
22282
22283
  var apiHost = react.useContext(BunnyContext).apiHost;
22283
22284
  var token = useToken();
22284
22285
  // Derived state
22285
22286
  var isRamp = charge.isRamp;
22286
- var prevCharge = (_b = subscription === null || subscription === void 0 ? void 0 : subscription.chargeReport) === null || _b === void 0 ? void 0 : _b[chargeIndex - 1];
22287
+ var prevCharge = subscription.charges[chargeIndex - 1];
22287
22288
  var isFirstRampRow = chargeIndex === 0 || (prevCharge === null || prevCharge === void 0 ? void 0 : prevCharge.priceListChargeId) !== charge.priceListChargeId;
22288
22289
  var chargePeriod = "".concat(common.formatDate(charge.startDate), " - ").concat(common.formatDate(charge.endDate));
22289
22290
  // Queries
@@ -22303,15 +22304,15 @@ var SubscriptionCardDesktopRow = function (_a) {
22303
22304
  var isDiscount = charge.kind === common.QuoteChangeKind.DISCOUNT;
22304
22305
  var dontShowChargeName = (prevCharge === null || prevCharge === void 0 ? void 0 : prevCharge.priceListChargeId) === charge.priceListChargeId &&
22305
22306
  !isDiscount &&
22306
- (!isTrial || (prevCharge === null || prevCharge === void 0 ? void 0 : prevCharge.trial)) &&
22307
- (isTrial || !(prevCharge === null || prevCharge === void 0 ? void 0 : prevCharge.trial));
22307
+ (!isTrial || prevCharge.trial) &&
22308
+ (isTrial || !prevCharge.trial);
22308
22309
  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
22309
22310
  ? ''
22310
22311
  : charge.chargeType === common.ChargeType.USAGE
22311
22312
  ? data && jsxRuntime.jsx(FeatureUsageGraph, { charge: charge, featureUsage: data })
22312
22313
  : charge.isAmendment
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 }) }))] })));
22314
+ ? "+".concat((_b = charge.quantity) === null || _b === void 0 ? void 0 : _b.toLocaleString())
22315
+ : (_c = charge.quantity) === null || _c === void 0 ? void 0 : _c.toLocaleString() })), jsxRuntime.jsx(SubscriptionsListCell, __assign({ right: true }, { children: jsxRuntime.jsx(SubscriptionChargeUnitPrice, { charge: charge, currencyId: subscription.currencyId }) })), jsxRuntime.jsx(SubscriptionsListCell, __assign({ right: true }, { children: jsxRuntime.jsx(SubscriptionChargeTotal, { charge: charge, subscription: subscription }) }))] })));
22315
22316
  };
22316
22317
 
22317
22318
  function AddonSubscriptionsCards(_a) {
@@ -22352,7 +22353,7 @@ var CHARGE_COLUMNS = [
22352
22353
  },
22353
22354
  ];
22354
22355
  var SubscriptionCard = function (_a) {
22355
- var _b, _c;
22356
+ var _b;
22356
22357
  var subscription = _a.subscription;
22357
22358
  var darkMode = react.useContext(BunnyContext).darkMode;
22358
22359
  // Derived state
@@ -22367,7 +22368,7 @@ var SubscriptionCard = function (_a) {
22367
22368
  gridTemplateColumns: "1fr auto auto auto",
22368
22369
  rowGap: '0.75rem',
22369
22370
  backgroundColor: backgroundColor,
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) {
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.charges.map(function (charge, chargeIndex) {
22371
22372
  if ((isTrial && !charge.trial) || (!isTrial && charge.trial))
22372
22373
  return null;
22373
22374
  var isRamp = charge.isRamp;
@@ -24011,12 +24012,12 @@ var PlanPicker = function (_a) {
24011
24012
  upgradingSubscription: upgradingSubscription,
24012
24013
  });
24013
24014
  },
24014
- enabled: !areSubscriptionsLoading && Boolean(upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id),
24015
+ enabled: isInPreviewMode || (!areSubscriptionsLoading && Boolean(upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id)),
24015
24016
  }), priceListChangeOptions = _e.data, arePlanChangeOptionsLoading = _e.isLoading;
24016
24017
  if (!priceListChangeOptions) {
24017
24018
  return null;
24018
24019
  }
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 : [] })) }));
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 })) }));
24020
24021
  };
24021
24022
 
24022
24023
  var Text$1 = antd.Typography.Text;
@@ -24028,8 +24029,14 @@ var PreviewModeAdvisary = function (_a) {
24028
24029
  };
24029
24030
 
24030
24031
  var UpgradeWrapper = function (_a) {
24031
- var onChangePlanCancel = _a.onChangePlanCancel, handlePortalErrors = _a.handlePortalErrors, upgradingSubscription = _a.upgradingSubscription;
24032
- return (jsxRuntime.jsx(SubscriptionsContext.Provider, __assign({ value: { upgradingSubscription: upgradingSubscription, setUpgradingSubscription: function () { }, isInPreviewMode: false } }, { children: jsxRuntime.jsx(QuoteProvider, { children: jsxRuntime.jsx(Upgrade, { onChangePlanCancel: onChangePlanCancel, handlePortalErrors: handlePortalErrors }) }) })));
24032
+ var onChangePlanCancel = _a.onChangePlanCancel, handlePortalErrors = _a.handlePortalErrors, upgradingSubscription = _a.upgradingSubscription, isInPreviewMode = _a.isInPreviewMode, productId = _a.productId, className = _a.className;
24033
+ return (jsxRuntime.jsx(SubscriptionsContext.Provider, __assign({ value: {
24034
+ upgradingSubscription: upgradingSubscription,
24035
+ setUpgradingSubscription: function () { },
24036
+ isInPreviewMode: isInPreviewMode,
24037
+ productId: productId,
24038
+ className: className,
24039
+ } }, { children: jsxRuntime.jsx(QuoteProvider, { children: jsxRuntime.jsx(Upgrade, { onChangePlanCancel: onChangePlanCancel, handlePortalErrors: handlePortalErrors }) }) })));
24033
24040
  };
24034
24041
  var Upgrade = function (_a) {
24035
24042
  var onChangePlanCancel = _a.onChangePlanCancel, handlePortalErrors = _a.handlePortalErrors;
@@ -24110,7 +24117,7 @@ var Subscriptions = function (_a) {
24110
24117
  // Context
24111
24118
  var token = useToken();
24112
24119
  var apiHost = react.useContext(BunnyContext).apiHost;
24113
- var _b = react.useContext(SubscriptionsContext), setUpgradingSubscription = _b.setUpgradingSubscription, className = _b.className, isInPreviewMode = _b.isInPreviewMode, hideExpiredOverride = _b.hideExpired, upgradingSubscription = _b.upgradingSubscription;
24120
+ var _b = react.useContext(SubscriptionsContext), setUpgradingSubscription = _b.setUpgradingSubscription, className = _b.className, isInPreviewMode = _b.isInPreviewMode, hideExpiredOverride = _b.hideExpired, upgradingSubscription = _b.upgradingSubscription, productId = _b.productId;
24114
24121
  // Local state
24115
24122
  var _c = react.useState(true), hideExpiredState = _c[0], setHideExpiredState = _c[1];
24116
24123
  var _d = react.useState(false), expiredSwitchVisible = _d[0], setExpiredSwitchVisible = _d[1];
@@ -24169,7 +24176,7 @@ var Subscriptions = function (_a) {
24169
24176
  ((_c = subscription.state) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === common.SubscriptionState.CANCELED;
24170
24177
  });
24171
24178
  react.useEffect(function () {
24172
- if (allSubscriptionsExpired && subscriptions && subscriptions.length > 0) {
24179
+ if (allSubscriptionsExpired && subscriptions.length > 0) {
24173
24180
  setHideExpiredState(false);
24174
24181
  }
24175
24182
  else {
@@ -24177,7 +24184,7 @@ var Subscriptions = function (_a) {
24177
24184
  }
24178
24185
  }, [allSubscriptionsExpired, subscriptions, isChangingPlan]);
24179
24186
  react.useEffect(function () {
24180
- if (hasExpiredOrCanceledSubscriptions && subscriptions && subscriptions.length > 0) {
24187
+ if (hasExpiredOrCanceledSubscriptions && subscriptions.length > 0) {
24181
24188
  setExpiredSwitchVisible(true);
24182
24189
  }
24183
24190
  else {
@@ -24185,11 +24192,11 @@ var Subscriptions = function (_a) {
24185
24192
  }
24186
24193
  }, [hasExpiredOrCanceledSubscriptions, subscriptions]);
24187
24194
  if (isChangingPlan || isInPreviewMode) {
24188
- return (jsxRuntime.jsx(UpgradeWrapper, { onChangePlanCancel: function () {
24195
+ return (jsxRuntime.jsx(UpgradeWrapper, { isInPreviewMode: isInPreviewMode, productId: productId !== null && productId !== void 0 ? productId : undefined, onChangePlanCancel: function () {
24189
24196
  setIsChangingPlan(false);
24190
- }, handlePortalErrors: handlePortalErrors, upgradingSubscription: upgradingSubscription }));
24197
+ }, handlePortalErrors: handlePortalErrors, upgradingSubscription: upgradingSubscription, className: className }));
24191
24198
  }
24192
- 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 })] })));
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 })] })));
24193
24200
  };
24194
24201
  var PageHeaderWithActions = function (_a) {
24195
24202
  var children = _a.children, title = _a.title;
@@ -1,5 +1,5 @@
1
1
  declare function useHasActiveSubscription({ token, apiHost, }: {
2
2
  token: string;
3
3
  apiHost: string;
4
- }): boolean | undefined;
4
+ }): any;
5
5
  export default useHasActiveSubscription;
@@ -1,7 +1,10 @@
1
1
  import { Subscription } from '@bunnyapp/common';
2
- declare const UpgradeWrapper: ({ onChangePlanCancel, handlePortalErrors, upgradingSubscription, }: {
2
+ declare const UpgradeWrapper: ({ onChangePlanCancel, handlePortalErrors, upgradingSubscription, isInPreviewMode, productId, className, }: {
3
3
  onChangePlanCancel: () => void;
4
4
  handlePortalErrors?: ((error: any) => void) | undefined;
5
5
  upgradingSubscription?: Subscription | undefined;
6
+ isInPreviewMode: boolean;
7
+ productId: string | undefined;
8
+ className?: string | undefined;
6
9
  }) => import("react/jsx-runtime").JSX.Element;
7
10
  export default UpgradeWrapper;
@@ -1,13 +1,13 @@
1
1
  import { Quote, Subscription, SubscriptionCharge } from '@bunnyapp/common';
2
- declare const QuantityChangeGridRow: ({ chargeIndex, editingQuote, subscriptionIndex, setEditingQuoteData, subscription, subscriptionCharge, setUpdatingChargeQuantityId, updatingChargeQuantityId, setErrorUpdatingQuantity, }: {
2
+ declare const QuantityChangeGridRow: ({ chargeIndex, editingQuote, subscriptions, subscriptionIndex, setEditingQuoteData, subscription, subscriptionCharge, setUpdatingChargeQuantityId, updatingChargeQuantityId, }: {
3
3
  chargeIndex: number;
4
4
  editingQuote?: Quote | undefined;
5
+ subscriptions: Subscription[];
5
6
  subscriptionIndex: number;
6
7
  setEditingQuoteData: (value: any) => void;
7
8
  subscription: Subscription;
8
9
  subscriptionCharge: SubscriptionCharge;
9
10
  setUpdatingChargeQuantityId: (updatingChargeQuantityId: string | undefined) => void;
10
11
  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, setUpdatingChargeQuantityId, updatingChargeQuantityId, setErrorUpdatingQuantity, }: {
9
+ declare const QuantityInput: ({ charge, chargeIndex, editingQuote, setEditingQuoteData, subscription, subscriptionIndex, subscriptions, setUpdatingChargeQuantityId, updatingChargeQuantityId, }: {
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[];
19
20
  setUpdatingChargeQuantityId: (updatingChargeQuantityId: string | undefined) => void;
20
21
  updatingChargeQuantityId: string | undefined;
21
- setErrorUpdatingQuantity: (errorUpdatingQuantity: boolean) => void;
22
22
  }) => import("react/jsx-runtime").JSX.Element;
23
23
  export default QuantityInput;
@@ -1,10 +1,9 @@
1
1
  import { Quote } from '@bunnyapp/common';
2
2
  import { EditingQuoteDataType } from '../SubscriptionsListContainer';
3
- declare const QuoteChangeSummarySection: ({ editingQuote, editingQuoteData, openCheckout, setEditingQuoteData, errorUpdatingQuantity, }: {
3
+ declare const QuoteChangeSummarySection: ({ editingQuote, editingQuoteData, openCheckout, setEditingQuoteData, }: {
4
4
  editingQuote?: Quote | undefined;
5
5
  editingQuoteData?: EditingQuoteDataType | undefined;
6
6
  openCheckout: () => void;
7
7
  setEditingQuoteData: (editingQuoteData: EditingQuoteDataType | undefined) => void;
8
- errorUpdatingQuantity: boolean;
9
8
  }) => import("react/jsx-runtime").JSX.Element;
10
9
  export default QuoteChangeSummarySection;
@@ -25,4 +25,3 @@ 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<any>;
11
+ }[], quoteChangeId: string, apiHost: string, token?: string) => Promise<unknown>;
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,7 +1,6 @@
1
- import { Subscription } from '@bunnyapp/common';
2
1
  declare const getSubscriptions: ({ apiHost, isInPreviewMode, token, }: {
3
2
  apiHost: string;
4
3
  isInPreviewMode?: boolean | undefined;
5
4
  token?: string | undefined;
6
- }) => Promise<Subscription[]>;
5
+ }) => Promise<any>;
7
6
  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, SubscriptionState, QuoteChangeKind, getAccount, PricingModel, BillingPeriod, MODAL_MAX_HEIGHT, DataInterval, ChargeType, StringUtils, PERIOD_LABELS, PricingStyle, SLATE_100 } from '@bunnyapp/common';
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, sortSubscriptionCharges, 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.11.1';
146
+ var PACKAGE_VERSION = '1.5.0-beta.12';
147
147
  var createRequestHeaders = function (token) {
148
148
  var headers = createClientDevHeaders({ token: token });
149
149
  // Add the components version header
@@ -469,7 +469,7 @@ var InvoiceQuoteView = function (_a) {
469
469
  color: secondaryColor,
470
470
  }, type: "link" }, { children: backButtonName || 'Back' }))) : null }), !hideDownloadButton ? (jsx(Button, __assign({ icon: jsx(DownloadOutlined, {}), onClick: function () {
471
471
  return downloadFile(apiHost + '/api/pdf/invoice/' + formattedInvoice.id, token);
472
- } }, { children: "Download" }))) : null] }))) : null, isMobile ? (jsxs(MarkupContainer, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4 bunny-grow bunny-w-full bunny-shadow-padding-xb bunny-overflow-auto" }, { children: [targetUrl ? (jsx(DocumentTemplatePreview, { targetUrl: targetUrl })) : (jsx(Markup, { content: html })), children] }))) : (jsxs(MarkupContainer, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4 bunny-p-4 bunny-w-full bunny-bg-white ".concat(shadow ? shadow : 'bunny-shadow-md', " bunny-rounded-md"), style: {
472
+ } }, { children: "Download" }))) : null] }))) : null, isMobile ? (jsxs(MarkupContainer, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4 bunny-grow bunny-shadow-padding-xb bunny-overflow-auto" }, { children: [targetUrl ? (jsx(DocumentTemplatePreview, { targetUrl: targetUrl })) : (jsx(Markup, { content: html })), children] }))) : (jsxs(MarkupContainer, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4 bunny-p-4 bunny-bg-white ".concat(shadow ? shadow : 'bunny-shadow-md', " bunny-rounded-md"), style: {
473
473
  minWidth: '750px',
474
474
  } }, { children: [targetUrl ? (jsx(DocumentTemplatePreview, { targetUrl: targetUrl })) : (jsx(Markup, { content: html })), children] })))] })));
475
475
  };
@@ -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 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 }";
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 }";
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 (_c) {
20854
- switch (_c.label) {
20851
+ var response, combinedSubscriptions;
20852
+ var _b, _c;
20853
+ return __generator(this, function (_d) {
20854
+ switch (_d.label) {
20855
20855
  case 0: return [4 /*yield*/, gqlRequest({
20856
20856
  isInPreviewMode: isInPreviewMode,
20857
20857
  query: SUBSCRIPTIONS_QUERY,
@@ -20859,8 +20859,9 @@ var getSubscriptions = function (_a) {
20859
20859
  apiHost: apiHost,
20860
20860
  })];
20861
20861
  case 1:
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];
20862
+ response = _d.sent();
20863
+ combinedSubscriptions = (_c = (_b = response === null || response === void 0 ? void 0 : response.subscriptions) === null || _b === void 0 ? void 0 : _b.nodes) === null || _c === void 0 ? void 0 : _c.map(function (subscription) { return (__assign(__assign({}, subscription), { charges: sortSubscriptionCharges(subscription.charges) })); });
20864
+ return [2 /*return*/, combinedSubscriptions];
20864
20865
  }
20865
20866
  });
20866
20867
  });
@@ -21068,12 +21069,12 @@ var QuoteCheckout = function (_a) {
21068
21069
  removeCoupon(couponCode);
21069
21070
  }
21070
21071
  });
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" }))] })) }))) }));
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" }))] })) }))) }));
21072
21073
  };
21073
21074
  var PaymentFormWrapper = function (_a) {
21074
21075
  var children = _a.children, setMaxHeight = _a.setMaxHeight, className = _a.className;
21075
21076
  var isMobile = useIsMobile();
21076
- return (jsx("div", __assign({ className: "bunny-flex bunny-flex-col bunny-w-full bunny-gap-6 ".concat(isMobile ? 'bunny-shadow-padding-xb' : '', " ").concat(className), style: __assign({}, (isMobile
21077
+ return (jsx("div", __assign({ className: "bunny-flex bunny-w-full bunny-flex-col bunny-gap-6 ".concat(isMobile ? 'bunny-shadow-padding-xb' : '', " ").concat(className), style: __assign({}, (isMobile
21077
21078
  ? setMaxHeight
21078
21079
  ? { maxHeight: '60vh' }
21079
21080
  : {}
@@ -21216,8 +21217,7 @@ var createQuoteParams = function (quote, subscriptionQuantity, editedSubscriptio
21216
21217
  var canShowChangeQuantities = function (_a) {
21217
21218
  var subscriptions = _a.subscriptions;
21218
21219
  return subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.some(function (subscription) {
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) {
21220
+ return subscription.charges.some(function (charge) {
21221
21221
  return canShowQuantitiesInput(charge, subscription);
21222
21222
  });
21223
21223
  });
@@ -21296,10 +21296,6 @@ 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
- };
21303
21299
 
21304
21300
  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");
21305
21301
  var quoteChargeCreate = function (_a) {
@@ -21366,9 +21362,6 @@ var useQuoteChangeUpdate = function () {
21366
21362
  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 })];
21367
21363
  case 1:
21368
21364
  response = _a.sent();
21369
- if (response.errors) {
21370
- throw new Error(response.errors[0].message);
21371
- }
21372
21365
  return [2 /*return*/, response];
21373
21366
  }
21374
21367
  });
@@ -21404,7 +21397,7 @@ var formatDateForApi = function (date) {
21404
21397
  return date.format('YYYY-MM-DD');
21405
21398
  };
21406
21399
  var QuantityInput = function (_a) {
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;
21400
+ var charge = _a.charge, chargeIndex = _a.chargeIndex, editingQuote = _a.editingQuote, setEditingQuoteData = _a.setEditingQuoteData, subscription = _a.subscription, subscriptionIndex = _a.subscriptionIndex, subscriptions = _a.subscriptions, setUpdatingChargeQuantityId = _a.setUpdatingChargeQuantityId, updatingChargeQuantityId = _a.updatingChargeQuantityId;
21408
21401
  // Context
21409
21402
  var token = useToken();
21410
21403
  var apiHost = useContext(BunnyContext).apiHost;
@@ -21419,8 +21412,7 @@ var QuantityInput = function (_a) {
21419
21412
  var quantityDisabled =
21420
21413
  // If we are editing a quote, we disable the quantity input
21421
21414
  // If we don't have a editedSubscription, we disable the quantity input
21422
- (updatingChargeQuantityId &&
21423
- updatingChargeQuantityId !== getUpdatingChargeQuantityId(charge, subscription)) ||
21415
+ (updatingChargeQuantityId && updatingChargeQuantityId !== charge.id) ||
21424
21416
  // If the subscription is not self-service, we disable the quantity input
21425
21417
  !charge.selfServiceQuantity;
21426
21418
  var value = (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.quantity) === undefined ? '' : editedSubscription.quantity;
@@ -21446,8 +21438,8 @@ var QuantityInput = function (_a) {
21446
21438
  },
21447
21439
  }).mutate;
21448
21440
  var createQuote = useMutation({
21449
- mutationFn: function (subscriptionId) {
21450
- return createSubscriptionQuote([subscriptionId], apiHost, token);
21441
+ mutationFn: function (subscriptionIds) {
21442
+ return createSubscriptionQuote(subscriptionIds, apiHost, token);
21451
21443
  },
21452
21444
  onSuccess: function (subscriptionUpdateData) {
21453
21445
  var _a, _b;
@@ -21487,10 +21479,6 @@ var QuantityInput = function (_a) {
21487
21479
  token: token,
21488
21480
  }),
21489
21481
  });
21490
- setErrorUpdatingQuantity(false);
21491
- },
21492
- onError: function () {
21493
- setErrorUpdatingQuantity(true);
21494
21482
  },
21495
21483
  });
21496
21484
  // Handlers
@@ -21507,18 +21495,12 @@ var QuantityInput = function (_a) {
21507
21495
  quantity: quantity,
21508
21496
  subscription: subscription,
21509
21497
  });
21510
- if (quantity === charge.quantity) {
21511
- setEditingQuoteData(undefined);
21512
- showErrorNotification('New quantity cannot be the same as current');
21498
+ if (quantity !== undefined && quantity !== charge.quantity) {
21499
+ setUpdatingChargeQuantityId(charge.id);
21513
21500
  }
21514
21501
  else {
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
- }
21502
+ setUpdatingChargeQuantityId(undefined);
21503
+ setEditingQuoteData(undefined);
21522
21504
  }
21523
21505
  };
21524
21506
  var handleSubscriptionUpdate = function (editedSubscription) {
@@ -21526,17 +21508,31 @@ var QuantityInput = function (_a) {
21526
21508
  return;
21527
21509
  // If we are not editing a quote, we create a new one
21528
21510
  if (!editingQuote) {
21529
- createQuote.mutate(editedSubscription.subscription.id);
21511
+ var subscriptionIds = [];
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);
21530
21521
  }
21531
21522
  else {
21532
21523
  // If we are editing a quote, we update the quote change
21533
21524
  var _a = createQuoteParams(editingQuote, charge.quantity, editedSubscription), charges = _a.charges, quoteChange = _a.quoteChange;
21534
- if (quoteChange && charges.length > 0) {
21525
+ if (quoteChange && charges.length > 0 && charges[0].quantity > 0) {
21535
21526
  updateQuote.mutate({
21536
21527
  charges: charges,
21537
21528
  quoteChangeId: quoteChange.id,
21538
21529
  });
21539
21530
  }
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
+ }
21540
21536
  }
21541
21537
  };
21542
21538
  // Initial subscription quantity if is on mobile
@@ -21565,8 +21561,13 @@ var QuantityInput = function (_a) {
21565
21561
  handleSubscriptionUpdate(editedSubscription);
21566
21562
  }, 1000);
21567
21563
  return function () { return clearTimeout(debounce); };
21564
+ // eslint-disable-next-line
21568
21565
  }, [editedSubscription]);
21569
- return (jsx(Fragment, { children: jsx(Input, { className: "bunny-text-right", disabled: quantityDisabled, onChange: function (e) {
21566
+ return (jsx(Fragment, { children: jsx(Input, { className: "bunny-text-right", disabled: quantityDisabled, onBlur: function () {
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) {
21570
21571
  onChangeQuantity(chargeIndex, e.target.value, charge.priceListChargeId, subscription, subscriptionIndex);
21571
21572
  }, status: isQuantityLowerThanOriginal(charge.quantity) ? 'error' : '', style: { width: '96px' }, value: value }) }));
21572
21573
  };
@@ -21574,11 +21575,11 @@ var QuantityInput = function (_a) {
21574
21575
  var Text$b = Typography.Text;
21575
21576
  var QuantityChangeGridRow = function (_a) {
21576
21577
  var _b;
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;
21578
+ var chargeIndex = _a.chargeIndex, editingQuote = _a.editingQuote, subscriptions = _a.subscriptions, subscriptionIndex = _a.subscriptionIndex, setEditingQuoteData = _a.setEditingQuoteData, subscription = _a.subscription, subscriptionCharge = _a.subscriptionCharge, setUpdatingChargeQuantityId = _a.setUpdatingChargeQuantityId, updatingChargeQuantityId = _a.updatingChargeQuantityId;
21578
21579
  if (!canShowQuantitiesInput(subscriptionCharge, subscription))
21579
21580
  return null;
21580
21581
  var brandColor = useContext(BrandContext).brandColor;
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" })] }));
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, subscriptions: subscriptions, setUpdatingChargeQuantityId: setUpdatingChargeQuantityId, updatingChargeQuantityId: updatingChargeQuantityId }), jsx("div", {})] })), jsx(Divider, { className: "bunny-col-span-full bunny-my-2" })] }));
21582
21583
  };
21583
21584
 
21584
21585
  var QuantityChangeGridTitle = function (_a) {
@@ -21587,10 +21588,11 @@ var QuantityChangeGridTitle = function (_a) {
21587
21588
  };
21588
21589
 
21589
21590
  var QuoteChangeSummarySection = function (_a) {
21590
- var editingQuote = _a.editingQuote, editingQuoteData = _a.editingQuoteData, openCheckout = _a.openCheckout, setEditingQuoteData = _a.setEditingQuoteData, errorUpdatingQuantity = _a.errorUpdatingQuantity;
21591
+ var editingQuote = _a.editingQuote, editingQuoteData = _a.editingQuoteData, openCheckout = _a.openCheckout, setEditingQuoteData = _a.setEditingQuoteData;
21591
21592
  var apiHost = useContext(BunnyContext).apiHost;
21592
21593
  var isMobile = useIsMobile();
21593
21594
  var token = useToken();
21595
+ // const apiHost = getApiHost();
21594
21596
  var showSuccessNotification = useSuccessNotification();
21595
21597
  var trialUpgradeMutation = useMutation({
21596
21598
  mutationFn: function (quoteId) { return checkout({ quoteId: quoteId, token: token, apiHost: apiHost }); },
@@ -21601,7 +21603,7 @@ var QuoteChangeSummarySection = function (_a) {
21601
21603
  });
21602
21604
  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)
21603
21605
  ? function () { return trialUpgradeMutation.mutate(editingQuoteData.id); }
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' })) }))] })));
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' })) }))] })));
21605
21607
  };
21606
21608
 
21607
21609
  var QUANTITY_CHANGE_HEADER_TITLE = 'Update unit quantity';
@@ -21609,7 +21611,6 @@ var QUANTITY_CHANGE_HEADER_DESCRIPTION = 'Adjust quantities below. The change wi
21609
21611
  var QuantityChangeDrawerDesktop = function (_a) {
21610
21612
  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;
21611
21613
  var _b = useState(open), openLocal = _b[0], setOpenLocal = _b[1];
21612
- var _c = useState(false), errorUpdatingQuantity = _c[0], setErrorUpdatingQuantity = _c[1];
21613
21614
  var isMobile = useIsMobile();
21614
21615
  useEffect(function () {
21615
21616
  var timeoutId;
@@ -21645,17 +21646,17 @@ var QuantityChangeDrawerDesktop = function (_a) {
21645
21646
  rowGap: '0.25rem',
21646
21647
  columnGap: '1rem',
21647
21648
  } }, { 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) {
21648
- var _a, _b;
21649
+ var _a;
21649
21650
  var isTrial = ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === SubscriptionState.TRIAL;
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) {
21651
+ return (jsx("div", __assign({ className: "bunny-contents" }, { children: subscription.charges.map(function (charge, chargeIndex) {
21651
21652
  var _a;
21652
21653
  if ((isTrial && !charge.trial) ||
21653
21654
  (!isTrial && charge.trial) ||
21654
21655
  ((_a = charge.chargeType) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === 'USAGE')
21655
21656
  return null;
21656
- return (jsx(QuantityChangeGridRow, { chargeIndex: chargeIndex, editingQuote: editingQuote, setEditingQuoteData: setEditingQuoteData, subscription: subscription, subscriptionCharge: charge, subscriptionIndex: index, setUpdatingChargeQuantityId: setUpdatingChargeQuantityId, updatingChargeQuantityId: updatingChargeQuantityId, setErrorUpdatingQuantity: setErrorUpdatingQuantity }, chargeIndex));
21657
+ return (jsx(QuantityChangeGridRow, { chargeIndex: chargeIndex, editingQuote: editingQuote, setEditingQuoteData: setEditingQuoteData, subscription: subscription, subscriptionCharge: charge, subscriptionIndex: index, subscriptions: subscriptions, setUpdatingChargeQuantityId: setUpdatingChargeQuantityId, updatingChargeQuantityId: updatingChargeQuantityId }, chargeIndex));
21657
21658
  }) }), index));
21658
- })] })), jsx(QuoteChangeSummarySection, { editingQuote: editingQuote, editingQuoteData: editingQuoteData, openCheckout: openCheckout, setEditingQuoteData: setEditingQuoteData, errorUpdatingQuantity: errorUpdatingQuantity })] })));
21659
+ })] })), jsx(QuoteChangeSummarySection, { editingQuote: editingQuote, editingQuoteData: editingQuoteData, openCheckout: openCheckout, setEditingQuoteData: setEditingQuoteData })] })));
21659
21660
  };
21660
21661
 
21661
21662
  var QuantityDrawerContainer = function (_a) {
@@ -22245,7 +22246,7 @@ var ADDON_CARD_COLUMNS = [
22245
22246
  },
22246
22247
  ];
22247
22248
  var SubscriptionCardDesktop = function (_a) {
22248
- var _b, _c;
22249
+ var _b;
22249
22250
  var onChangePlanClick = _a.onChangePlanClick, onCancelSubscriptionClick = _a.onCancelSubscriptionClick, subscription = _a.subscription, isAddon = _a.isAddon;
22250
22251
  var shadow = useContext(SubscriptionsContext).shadow;
22251
22252
  // Derived state
@@ -22258,21 +22259,21 @@ var SubscriptionCardDesktop = function (_a) {
22258
22259
  } }), jsxs("div", __assign({ className: "bunny-grid bunny-w-full", style: {
22259
22260
  gridTemplateColumns: CARD_COLUMNS.map(function (column) { return column.width; }).join(' '),
22260
22261
  rowGap: '0.75rem',
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) {
22262
+ } }, { children: [jsx(SubscriptionCardColumnHeaders, { columns: CARD_COLUMNS }), subscription.charges.map(function (charge, chargeIndex) {
22262
22263
  if ((isTrial && !charge.trial) || (!isTrial && charge.trial))
22263
22264
  return null;
22264
22265
  return (jsx(SubscriptionCardDesktopRow, { charge: charge, chargeIndex: chargeIndex, subscription: subscription }, chargeIndex));
22265
22266
  })] }))] })));
22266
22267
  };
22267
22268
  var SubscriptionCardDesktopRow = function (_a) {
22268
- var _b, _c, _d;
22269
+ var _b, _c;
22269
22270
  var charge = _a.charge, chargeIndex = _a.chargeIndex, subscription = _a.subscription;
22270
22271
  // Context
22271
22272
  var apiHost = useContext(BunnyContext).apiHost;
22272
22273
  var token = useToken();
22273
22274
  // Derived state
22274
22275
  var isRamp = charge.isRamp;
22275
- var prevCharge = (_b = subscription === null || subscription === void 0 ? void 0 : subscription.chargeReport) === null || _b === void 0 ? void 0 : _b[chargeIndex - 1];
22276
+ var prevCharge = subscription.charges[chargeIndex - 1];
22276
22277
  var isFirstRampRow = chargeIndex === 0 || (prevCharge === null || prevCharge === void 0 ? void 0 : prevCharge.priceListChargeId) !== charge.priceListChargeId;
22277
22278
  var chargePeriod = "".concat(formatDate(charge.startDate), " - ").concat(formatDate(charge.endDate));
22278
22279
  // Queries
@@ -22292,15 +22293,15 @@ var SubscriptionCardDesktopRow = function (_a) {
22292
22293
  var isDiscount = charge.kind === QuoteChangeKind.DISCOUNT;
22293
22294
  var dontShowChargeName = (prevCharge === null || prevCharge === void 0 ? void 0 : prevCharge.priceListChargeId) === charge.priceListChargeId &&
22294
22295
  !isDiscount &&
22295
- (!isTrial || (prevCharge === null || prevCharge === void 0 ? void 0 : prevCharge.trial)) &&
22296
- (isTrial || !(prevCharge === null || prevCharge === void 0 ? void 0 : prevCharge.trial));
22296
+ (!isTrial || prevCharge.trial) &&
22297
+ (isTrial || !prevCharge.trial);
22297
22298
  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
22298
22299
  ? ''
22299
22300
  : charge.chargeType === ChargeType.USAGE
22300
22301
  ? data && jsx(FeatureUsageGraph, { charge: charge, featureUsage: data })
22301
22302
  : charge.isAmendment
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 }) }))] })));
22303
+ ? "+".concat((_b = charge.quantity) === null || _b === void 0 ? void 0 : _b.toLocaleString())
22304
+ : (_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 }) }))] })));
22304
22305
  };
22305
22306
 
22306
22307
  function AddonSubscriptionsCards(_a) {
@@ -22341,7 +22342,7 @@ var CHARGE_COLUMNS = [
22341
22342
  },
22342
22343
  ];
22343
22344
  var SubscriptionCard = function (_a) {
22344
- var _b, _c;
22345
+ var _b;
22345
22346
  var subscription = _a.subscription;
22346
22347
  var darkMode = useContext(BunnyContext).darkMode;
22347
22348
  // Derived state
@@ -22356,7 +22357,7 @@ var SubscriptionCard = function (_a) {
22356
22357
  gridTemplateColumns: "1fr auto auto auto",
22357
22358
  rowGap: '0.75rem',
22358
22359
  backgroundColor: backgroundColor,
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) {
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.charges.map(function (charge, chargeIndex) {
22360
22361
  if ((isTrial && !charge.trial) || (!isTrial && charge.trial))
22361
22362
  return null;
22362
22363
  var isRamp = charge.isRamp;
@@ -24000,12 +24001,12 @@ var PlanPicker = function (_a) {
24000
24001
  upgradingSubscription: upgradingSubscription,
24001
24002
  });
24002
24003
  },
24003
- enabled: !areSubscriptionsLoading && Boolean(upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id),
24004
+ enabled: isInPreviewMode || (!areSubscriptionsLoading && Boolean(upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id)),
24004
24005
  }), priceListChangeOptions = _e.data, arePlanChangeOptionsLoading = _e.isLoading;
24005
24006
  if (!priceListChangeOptions) {
24006
24007
  return null;
24007
24008
  }
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 : [] })) }));
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 })) }));
24009
24010
  };
24010
24011
 
24011
24012
  var Text$1 = Typography.Text;
@@ -24017,8 +24018,14 @@ var PreviewModeAdvisary = function (_a) {
24017
24018
  };
24018
24019
 
24019
24020
  var UpgradeWrapper = function (_a) {
24020
- var onChangePlanCancel = _a.onChangePlanCancel, handlePortalErrors = _a.handlePortalErrors, upgradingSubscription = _a.upgradingSubscription;
24021
- return (jsx(SubscriptionsContext.Provider, __assign({ value: { upgradingSubscription: upgradingSubscription, setUpgradingSubscription: function () { }, isInPreviewMode: false } }, { children: jsx(QuoteProvider, { children: jsx(Upgrade, { onChangePlanCancel: onChangePlanCancel, handlePortalErrors: handlePortalErrors }) }) })));
24021
+ var onChangePlanCancel = _a.onChangePlanCancel, handlePortalErrors = _a.handlePortalErrors, upgradingSubscription = _a.upgradingSubscription, isInPreviewMode = _a.isInPreviewMode, productId = _a.productId, className = _a.className;
24022
+ return (jsx(SubscriptionsContext.Provider, __assign({ value: {
24023
+ upgradingSubscription: upgradingSubscription,
24024
+ setUpgradingSubscription: function () { },
24025
+ isInPreviewMode: isInPreviewMode,
24026
+ productId: productId,
24027
+ className: className,
24028
+ } }, { children: jsx(QuoteProvider, { children: jsx(Upgrade, { onChangePlanCancel: onChangePlanCancel, handlePortalErrors: handlePortalErrors }) }) })));
24022
24029
  };
24023
24030
  var Upgrade = function (_a) {
24024
24031
  var onChangePlanCancel = _a.onChangePlanCancel, handlePortalErrors = _a.handlePortalErrors;
@@ -24099,7 +24106,7 @@ var Subscriptions = function (_a) {
24099
24106
  // Context
24100
24107
  var token = useToken();
24101
24108
  var apiHost = useContext(BunnyContext).apiHost;
24102
- var _b = useContext(SubscriptionsContext), setUpgradingSubscription = _b.setUpgradingSubscription, className = _b.className, isInPreviewMode = _b.isInPreviewMode, hideExpiredOverride = _b.hideExpired, upgradingSubscription = _b.upgradingSubscription;
24109
+ var _b = useContext(SubscriptionsContext), setUpgradingSubscription = _b.setUpgradingSubscription, className = _b.className, isInPreviewMode = _b.isInPreviewMode, hideExpiredOverride = _b.hideExpired, upgradingSubscription = _b.upgradingSubscription, productId = _b.productId;
24103
24110
  // Local state
24104
24111
  var _c = useState(true), hideExpiredState = _c[0], setHideExpiredState = _c[1];
24105
24112
  var _d = useState(false), expiredSwitchVisible = _d[0], setExpiredSwitchVisible = _d[1];
@@ -24158,7 +24165,7 @@ var Subscriptions = function (_a) {
24158
24165
  ((_c = subscription.state) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === SubscriptionState.CANCELED;
24159
24166
  });
24160
24167
  useEffect(function () {
24161
- if (allSubscriptionsExpired && subscriptions && subscriptions.length > 0) {
24168
+ if (allSubscriptionsExpired && subscriptions.length > 0) {
24162
24169
  setHideExpiredState(false);
24163
24170
  }
24164
24171
  else {
@@ -24166,7 +24173,7 @@ var Subscriptions = function (_a) {
24166
24173
  }
24167
24174
  }, [allSubscriptionsExpired, subscriptions, isChangingPlan]);
24168
24175
  useEffect(function () {
24169
- if (hasExpiredOrCanceledSubscriptions && subscriptions && subscriptions.length > 0) {
24176
+ if (hasExpiredOrCanceledSubscriptions && subscriptions.length > 0) {
24170
24177
  setExpiredSwitchVisible(true);
24171
24178
  }
24172
24179
  else {
@@ -24174,11 +24181,11 @@ var Subscriptions = function (_a) {
24174
24181
  }
24175
24182
  }, [hasExpiredOrCanceledSubscriptions, subscriptions]);
24176
24183
  if (isChangingPlan || isInPreviewMode) {
24177
- return (jsx(UpgradeWrapper, { onChangePlanCancel: function () {
24184
+ return (jsx(UpgradeWrapper, { isInPreviewMode: isInPreviewMode, productId: productId !== null && productId !== void 0 ? productId : undefined, onChangePlanCancel: function () {
24178
24185
  setIsChangingPlan(false);
24179
- }, handlePortalErrors: handlePortalErrors, upgradingSubscription: upgradingSubscription }));
24186
+ }, handlePortalErrors: handlePortalErrors, upgradingSubscription: upgradingSubscription, className: className }));
24180
24187
  }
24181
- 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 })] })));
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 })] })));
24182
24189
  };
24183
24190
  var PageHeaderWithActions = function (_a) {
24184
24191
  var children = _a.children, title = _a.title;
@@ -1,5 +1,5 @@
1
1
  declare function useHasActiveSubscription({ token, apiHost, }: {
2
2
  token: string;
3
3
  apiHost: string;
4
- }): boolean | undefined;
4
+ }): any;
5
5
  export default useHasActiveSubscription;
@@ -1,7 +1,10 @@
1
1
  import { Subscription } from '@bunnyapp/common';
2
- declare const UpgradeWrapper: ({ onChangePlanCancel, handlePortalErrors, upgradingSubscription, }: {
2
+ declare const UpgradeWrapper: ({ onChangePlanCancel, handlePortalErrors, upgradingSubscription, isInPreviewMode, productId, className, }: {
3
3
  onChangePlanCancel: () => void;
4
4
  handlePortalErrors?: ((error: any) => void) | undefined;
5
5
  upgradingSubscription?: Subscription | undefined;
6
+ isInPreviewMode: boolean;
7
+ productId: string | undefined;
8
+ className?: string | undefined;
6
9
  }) => import("react/jsx-runtime").JSX.Element;
7
10
  export default UpgradeWrapper;
@@ -1,13 +1,13 @@
1
1
  import { Quote, Subscription, SubscriptionCharge } from '@bunnyapp/common';
2
- declare const QuantityChangeGridRow: ({ chargeIndex, editingQuote, subscriptionIndex, setEditingQuoteData, subscription, subscriptionCharge, setUpdatingChargeQuantityId, updatingChargeQuantityId, setErrorUpdatingQuantity, }: {
2
+ declare const QuantityChangeGridRow: ({ chargeIndex, editingQuote, subscriptions, subscriptionIndex, setEditingQuoteData, subscription, subscriptionCharge, setUpdatingChargeQuantityId, updatingChargeQuantityId, }: {
3
3
  chargeIndex: number;
4
4
  editingQuote?: Quote | undefined;
5
+ subscriptions: Subscription[];
5
6
  subscriptionIndex: number;
6
7
  setEditingQuoteData: (value: any) => void;
7
8
  subscription: Subscription;
8
9
  subscriptionCharge: SubscriptionCharge;
9
10
  setUpdatingChargeQuantityId: (updatingChargeQuantityId: string | undefined) => void;
10
11
  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, setUpdatingChargeQuantityId, updatingChargeQuantityId, setErrorUpdatingQuantity, }: {
9
+ declare const QuantityInput: ({ charge, chargeIndex, editingQuote, setEditingQuoteData, subscription, subscriptionIndex, subscriptions, setUpdatingChargeQuantityId, updatingChargeQuantityId, }: {
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[];
19
20
  setUpdatingChargeQuantityId: (updatingChargeQuantityId: string | undefined) => void;
20
21
  updatingChargeQuantityId: string | undefined;
21
- setErrorUpdatingQuantity: (errorUpdatingQuantity: boolean) => void;
22
22
  }) => import("react/jsx-runtime").JSX.Element;
23
23
  export default QuantityInput;
@@ -1,10 +1,9 @@
1
1
  import { Quote } from '@bunnyapp/common';
2
2
  import { EditingQuoteDataType } from '../SubscriptionsListContainer';
3
- declare const QuoteChangeSummarySection: ({ editingQuote, editingQuoteData, openCheckout, setEditingQuoteData, errorUpdatingQuantity, }: {
3
+ declare const QuoteChangeSummarySection: ({ editingQuote, editingQuoteData, openCheckout, setEditingQuoteData, }: {
4
4
  editingQuote?: Quote | undefined;
5
5
  editingQuoteData?: EditingQuoteDataType | undefined;
6
6
  openCheckout: () => void;
7
7
  setEditingQuoteData: (editingQuoteData: EditingQuoteDataType | undefined) => void;
8
- errorUpdatingQuantity: boolean;
9
8
  }) => import("react/jsx-runtime").JSX.Element;
10
9
  export default QuoteChangeSummarySection;
@@ -25,4 +25,3 @@ 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<any>;
11
+ }[], quoteChangeId: string, apiHost: string, token?: string) => Promise<unknown>;
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,7 +1,6 @@
1
- import { Subscription } from '@bunnyapp/common';
2
1
  declare const getSubscriptions: ({ apiHost, isInPreviewMode, token, }: {
3
2
  apiHost: string;
4
3
  isInPreviewMode?: boolean | undefined;
5
4
  token?: string | undefined;
6
- }) => Promise<Subscription[]>;
5
+ }) => Promise<any>;
7
6
  export default getSubscriptions;
package/dist/index.d.ts CHANGED
@@ -192,10 +192,13 @@ declare const SubscriptionsWrapper: ({ handlePortalErrors, companyName, isInPrev
192
192
  hideExpiredToggle?: boolean | undefined;
193
193
  }) => react_jsx_runtime.JSX.Element;
194
194
 
195
- declare const UpgradeWrapper: ({ onChangePlanCancel, handlePortalErrors, upgradingSubscription, }: {
195
+ declare const UpgradeWrapper: ({ onChangePlanCancel, handlePortalErrors, upgradingSubscription, isInPreviewMode, productId, className, }: {
196
196
  onChangePlanCancel: () => void;
197
197
  handlePortalErrors?: ((error: any) => void) | undefined;
198
198
  upgradingSubscription?: Subscription | undefined;
199
+ isInPreviewMode: boolean;
200
+ productId: string | undefined;
201
+ className?: string | undefined;
199
202
  }) => react_jsx_runtime.JSX.Element;
200
203
 
201
204
  declare const BillingDetails: ({ className, countryListFilter, hideBillingDetailsForm, hidePaymentMethodForm, isCardEnabled, isUpgradeFromTrial, shadow, onSavePaymentMethod, }: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunnyapp/components",
3
- "version": "1.5.0-beta.11.3",
3
+ "version": "1.5.0-beta.13",
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",