@bunnyapp/components 1.7.0-beta.44 → 1.7.0-beta.46
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 +211 -218
- package/dist/cjs/types/src/components/Subscriptions/Upgrade/PlanPicker/planPickerDesktop/featureAddons/FeatureAddonRow.d.ts +0 -3
- package/dist/cjs/types/src/components/Subscriptions/Upgrade/PlanPicker/planPickerDesktop/priceListCardDesktop/PriceListCardDesktop.d.ts +1 -17
- package/dist/cjs/types/src/components/Subscriptions/Upgrade/PlanPicker/planPickerMobile/PriceListCardMobile.d.ts +1 -3
- package/dist/cjs/types/src/components/Subscriptions/Upgrade/PlanPicker/priceListCard/PriceDescription/BillingPeriodDescription.d.ts +12 -0
- package/dist/cjs/types/src/components/Subscriptions/Upgrade/PlanPicker/priceListCard/PriceDescription/PriceListCardPriceDescription.d.ts +13 -6
- package/dist/cjs/types/src/components/Subscriptions/Upgrade/PlanPicker/priceListCard/PriceListCard.d.ts +1 -1
- package/dist/cjs/types/src/components/Subscriptions/Upgrade/PlanPicker/priceListCard/priceListCardUtils.d.ts +0 -4
- package/dist/cjs/types/src/components/priceListPricing/PricingTooltip.d.ts +6 -5
- package/dist/cjs/types/src/components/priceListPricing/components/ChargePriceTiers.d.ts +2 -1
- package/dist/cjs/types/src/components/priceListPricing/components/PriceTierPrice.d.ts +10 -3
- package/dist/cjs/types/src/utils/priceListChargeUtils/priceListChargePriceDescription.d.ts +13 -0
- package/dist/cjs/types/src/utils/priceListUtils/getActiveCharges.d.ts +10 -0
- package/dist/cjs/types/src/utils/priceListUtils/getPrice.d.ts +2 -2
- package/dist/cjs/types/src/utils/priceListUtils/getPricingUnit.d.ts +16 -0
- package/dist/cjs/types/src/utils/priceListUtils/priceDescription.d.ts +11 -4
- package/dist/esm/index.js +211 -218
- package/dist/esm/types/src/components/Subscriptions/Upgrade/PlanPicker/planPickerDesktop/featureAddons/FeatureAddonRow.d.ts +0 -3
- package/dist/esm/types/src/components/Subscriptions/Upgrade/PlanPicker/planPickerDesktop/priceListCardDesktop/PriceListCardDesktop.d.ts +1 -17
- package/dist/esm/types/src/components/Subscriptions/Upgrade/PlanPicker/planPickerMobile/PriceListCardMobile.d.ts +1 -3
- package/dist/esm/types/src/components/Subscriptions/Upgrade/PlanPicker/priceListCard/PriceDescription/BillingPeriodDescription.d.ts +12 -0
- package/dist/esm/types/src/components/Subscriptions/Upgrade/PlanPicker/priceListCard/PriceDescription/PriceListCardPriceDescription.d.ts +13 -6
- package/dist/esm/types/src/components/Subscriptions/Upgrade/PlanPicker/priceListCard/PriceListCard.d.ts +1 -1
- package/dist/esm/types/src/components/Subscriptions/Upgrade/PlanPicker/priceListCard/priceListCardUtils.d.ts +0 -4
- package/dist/esm/types/src/components/priceListPricing/PricingTooltip.d.ts +6 -5
- package/dist/esm/types/src/components/priceListPricing/components/ChargePriceTiers.d.ts +2 -1
- package/dist/esm/types/src/components/priceListPricing/components/PriceTierPrice.d.ts +10 -3
- package/dist/esm/types/src/utils/priceListChargeUtils/priceListChargePriceDescription.d.ts +13 -0
- package/dist/esm/types/src/utils/priceListUtils/getActiveCharges.d.ts +10 -0
- package/dist/esm/types/src/utils/priceListUtils/getPrice.d.ts +2 -2
- package/dist/esm/types/src/utils/priceListUtils/getPricingUnit.d.ts +16 -0
- package/dist/esm/types/src/utils/priceListUtils/priceDescription.d.ts +11 -4
- package/package.json +1 -1
- package/dist/cjs/types/src/components/Subscriptions/Upgrade/PlanPicker/priceListCard/PriceDescription/utils/hasMultipleRecurringCharges.d.ts +0 -12
- package/dist/cjs/types/src/utils/priceListUtils/doesPriceListHaveFlatFeeCharges.d.ts +0 -12
- package/dist/esm/types/src/components/Subscriptions/Upgrade/PlanPicker/priceListCard/PriceDescription/utils/hasMultipleRecurringCharges.d.ts +0 -12
- package/dist/esm/types/src/utils/priceListUtils/doesPriceListHaveFlatFeeCharges.d.ts +0 -12
package/dist/esm/index.js
CHANGED
|
@@ -1281,7 +1281,7 @@ const DEFAULT_CONFIG = {
|
|
|
1281
1281
|
};
|
|
1282
1282
|
|
|
1283
1283
|
// This will be replaced at build time by rollup-plugin-replace
|
|
1284
|
-
const PACKAGE_VERSION = '1.7.0-beta.
|
|
1284
|
+
const PACKAGE_VERSION = '1.7.0-beta.45';
|
|
1285
1285
|
const createRequestHeaders = (token) => {
|
|
1286
1286
|
const headers = createClientDevHeaders({ token });
|
|
1287
1287
|
// Add the components version header
|
|
@@ -26494,6 +26494,36 @@ const everythingInPlusString = ({ priceList }) => {
|
|
|
26494
26494
|
return `Everything in ${priceList.plan.name}, plus`;
|
|
26495
26495
|
};
|
|
26496
26496
|
|
|
26497
|
+
const ChargeHasPriceTiers_PriceListChargeFragment = t(`
|
|
26498
|
+
fragment ChargeHasPriceTiers_PriceListChargeFragment on PriceListCharge {
|
|
26499
|
+
priceListChargeTiers {
|
|
26500
|
+
starts
|
|
26501
|
+
price
|
|
26502
|
+
}
|
|
26503
|
+
}
|
|
26504
|
+
`);
|
|
26505
|
+
function chargeHasPriceTiers(maskedCharge) {
|
|
26506
|
+
var _a;
|
|
26507
|
+
// Read fragments
|
|
26508
|
+
const charge = readFragment(ChargeHasPriceTiers_PriceListChargeFragment, maskedCharge);
|
|
26509
|
+
return ((_a = charge.priceListChargeTiers) === null || _a === void 0 ? void 0 : _a.length) && charge.priceListChargeTiers.length > 1;
|
|
26510
|
+
}
|
|
26511
|
+
|
|
26512
|
+
const PriceListHasPriceTiers_PriceListFragment = t(`
|
|
26513
|
+
fragment PriceListHasPriceTiers_PriceListFragment on PriceList {
|
|
26514
|
+
charges {
|
|
26515
|
+
...ChargeHasPriceTiers_PriceListChargeFragment
|
|
26516
|
+
}
|
|
26517
|
+
}
|
|
26518
|
+
`, [ChargeHasPriceTiers_PriceListChargeFragment]);
|
|
26519
|
+
// a pricelist has price tiers if any of its charges have > 1 price tier
|
|
26520
|
+
const priceListHasPriceTiers = (maskedPriceList) => {
|
|
26521
|
+
var _a;
|
|
26522
|
+
// Read fragments
|
|
26523
|
+
const priceList = readFragment(PriceListHasPriceTiers_PriceListFragment, maskedPriceList);
|
|
26524
|
+
return (_a = priceList.charges) === null || _a === void 0 ? void 0 : _a.some(chargeHasPriceTiers);
|
|
26525
|
+
};
|
|
26526
|
+
|
|
26497
26527
|
const TOOLTIP_BG_COLOR = '#2F353B';
|
|
26498
26528
|
|
|
26499
26529
|
function Tooltip(props) {
|
|
@@ -26507,53 +26537,97 @@ function Tooltip(props) {
|
|
|
26507
26537
|
} }));
|
|
26508
26538
|
}
|
|
26509
26539
|
|
|
26510
|
-
const
|
|
26511
|
-
fragment
|
|
26512
|
-
|
|
26513
|
-
|
|
26540
|
+
const priceListChargePriceDescription_PriceListChargeFragment = t(`
|
|
26541
|
+
fragment priceListChargePriceDescription_PriceListChargeFragment on PriceListCharge {
|
|
26542
|
+
showPriceAsMonthly
|
|
26543
|
+
billingPeriod
|
|
26544
|
+
feature {
|
|
26545
|
+
unitName
|
|
26546
|
+
}
|
|
26514
26547
|
}
|
|
26515
26548
|
`);
|
|
26516
|
-
function
|
|
26517
|
-
|
|
26518
|
-
//
|
|
26519
|
-
|
|
26520
|
-
|
|
26521
|
-
|
|
26522
|
-
|
|
26523
|
-
|
|
26524
|
-
|
|
26525
|
-
|
|
26526
|
-
|
|
26527
|
-
|
|
26549
|
+
function priceListChargePriceDescription(maskedPriceListCharge) {
|
|
26550
|
+
var _a;
|
|
26551
|
+
// Read fragments
|
|
26552
|
+
const priceListCharge = readFragment(priceListChargePriceDescription_PriceListChargeFragment, maskedPriceListCharge);
|
|
26553
|
+
const billingPeriod = priceListCharge.billingPeriod;
|
|
26554
|
+
const periodLabel = billingPeriod ? PERIOD_LABELS[billingPeriod] : null;
|
|
26555
|
+
const unitName = (_a = priceListCharge.feature) === null || _a === void 0 ? void 0 : _a.unitName;
|
|
26556
|
+
return `Per ${unitName ? `${unitName} / ` : ''}${priceListCharge.showPriceAsMonthly ? 'month' : periodLabel}`;
|
|
26557
|
+
}
|
|
26558
|
+
|
|
26559
|
+
const GetActiveCharges_PriceListChargeFragment = t(`
|
|
26560
|
+
fragment GetActiveCharges_PriceListChargeFragment on PriceListCharge {
|
|
26561
|
+
deprecated
|
|
26562
|
+
featureAddon
|
|
26528
26563
|
}
|
|
26529
|
-
|
|
26564
|
+
`);
|
|
26565
|
+
// Active charges: any charge that is not deprecated and not a feature addon
|
|
26566
|
+
function getActiveCharges(charges) {
|
|
26567
|
+
return charges.filter(maskedCharge => {
|
|
26568
|
+
const charge = readFragment(GetActiveCharges_PriceListChargeFragment, maskedCharge);
|
|
26569
|
+
return !charge.deprecated && !charge.featureAddon;
|
|
26570
|
+
});
|
|
26530
26571
|
}
|
|
26531
26572
|
|
|
26532
|
-
const
|
|
26533
|
-
fragment
|
|
26573
|
+
const getPriceListUnitName_PriceListFragment = t(`
|
|
26574
|
+
fragment getPriceListUnitName_PriceListFragment on PriceList {
|
|
26534
26575
|
charges {
|
|
26535
|
-
|
|
26536
|
-
|
|
26576
|
+
chargeType
|
|
26577
|
+
featureAddon
|
|
26578
|
+
deprecated
|
|
26579
|
+
feature {
|
|
26580
|
+
unitName
|
|
26581
|
+
}
|
|
26537
26582
|
}
|
|
26538
26583
|
}
|
|
26539
|
-
|
|
26540
|
-
function
|
|
26541
|
-
var _a, _b;
|
|
26584
|
+
`, []);
|
|
26585
|
+
function getPriceListUnitName(maskedPriceList) {
|
|
26586
|
+
var _a, _b, _c;
|
|
26542
26587
|
// Read fragments
|
|
26543
|
-
const priceList = readFragment(
|
|
26544
|
-
|
|
26545
|
-
|
|
26546
|
-
|
|
26588
|
+
const priceList = readFragment(getPriceListUnitName_PriceListFragment, maskedPriceList);
|
|
26589
|
+
const activeCharges = (_a = priceList.charges) === null || _a === void 0 ? void 0 : _a.filter(charge => !charge.deprecated && !charge.featureAddon);
|
|
26590
|
+
const recurringCharges = activeCharges === null || activeCharges === void 0 ? void 0 : activeCharges.filter(charge => charge.chargeType === 'RECURRING');
|
|
26591
|
+
const usageCharges = activeCharges === null || activeCharges === void 0 ? void 0 : activeCharges.filter(charge => charge.chargeType === 'USAGE');
|
|
26592
|
+
// Strategy 1: If only 1 recurring charge
|
|
26593
|
+
// return that charge.unit
|
|
26594
|
+
if ((recurringCharges === null || recurringCharges === void 0 ? void 0 : recurringCharges.length) === 1) {
|
|
26595
|
+
return (_b = recurringCharges[0].feature) === null || _b === void 0 ? void 0 : _b.unitName;
|
|
26596
|
+
}
|
|
26597
|
+
// Strategy 2: If only 1 usage charge
|
|
26598
|
+
// return that charge.unit
|
|
26599
|
+
if ((usageCharges === null || usageCharges === void 0 ? void 0 : usageCharges.length) === 1) {
|
|
26600
|
+
return (_c = usageCharges[0].feature) === null || _c === void 0 ? void 0 : _c.unitName;
|
|
26601
|
+
}
|
|
26602
|
+
// Stragey 3: Else there are conflicting charges
|
|
26603
|
+
// return null
|
|
26604
|
+
return null;
|
|
26547
26605
|
}
|
|
26548
26606
|
|
|
26549
|
-
|
|
26550
|
-
|
|
26607
|
+
const priceDescriptionString_PriceListFragment = t(`
|
|
26608
|
+
fragment priceDescriptionString_PriceListFragment on PriceList {
|
|
26609
|
+
showPriceAsMonthly
|
|
26610
|
+
periodMonths
|
|
26611
|
+
...getPriceListUnitName_PriceListFragment
|
|
26612
|
+
}
|
|
26613
|
+
`, [getPriceListUnitName_PriceListFragment]);
|
|
26614
|
+
function priceDescriptionString(maskedPriceList) {
|
|
26615
|
+
// Read fragments
|
|
26616
|
+
const priceList = readFragment(priceDescriptionString_PriceListFragment, maskedPriceList);
|
|
26617
|
+
const periodMonthsConverted = periodMonthsConverter(priceList.periodMonths);
|
|
26551
26618
|
const periodLabel = periodMonthsConverted ? PERIOD_LABELS[periodMonthsConverted] : null;
|
|
26552
|
-
|
|
26619
|
+
const unitName = getPriceListUnitName(priceList);
|
|
26620
|
+
return `Per ${unitName ? `${unitName} / ` : ''}${priceList.showPriceAsMonthly ? 'month' : periodLabel}`;
|
|
26553
26621
|
}
|
|
26554
26622
|
|
|
26555
26623
|
const { Text: Text$e } = Typography;
|
|
26556
|
-
const
|
|
26624
|
+
const PriceTierPrice_PriceTierFragment = t(`
|
|
26625
|
+
fragment PriceTierPrice_PriceTierFragment on PriceListChargeTier {
|
|
26626
|
+
price
|
|
26627
|
+
}
|
|
26628
|
+
`);
|
|
26629
|
+
const PriceTierPrice = ({ currencyId, priceDecimals, tier: maskedTier, }) => {
|
|
26630
|
+
const tier = readFragment(PriceTierPrice_PriceTierFragment, maskedTier);
|
|
26557
26631
|
return (jsx(Text$e, { className: "bunny-text-white", children: formatCurrency(tier.price, currencyId, priceDecimals) }));
|
|
26558
26632
|
};
|
|
26559
26633
|
|
|
@@ -26584,11 +26658,11 @@ const ChargePriceTiers_PriceListChargeFragment = t(`
|
|
|
26584
26658
|
priceDecimals
|
|
26585
26659
|
priceListChargeTiers {
|
|
26586
26660
|
starts
|
|
26587
|
-
price
|
|
26588
26661
|
...PriceTierRow_PriceTierFragment
|
|
26662
|
+
...PriceTierPrice_PriceTierFragment
|
|
26589
26663
|
}
|
|
26590
26664
|
}
|
|
26591
|
-
`, [PriceTierRow_PriceTierFragment]);
|
|
26665
|
+
`, [PriceTierRow_PriceTierFragment, PriceTierPrice_PriceTierFragment]);
|
|
26592
26666
|
const ChargePriceTiers = ({ charge: maskedCharge, currencyId, }) => {
|
|
26593
26667
|
var _a;
|
|
26594
26668
|
const charge = readFragment(ChargePriceTiers_PriceListChargeFragment, maskedCharge);
|
|
@@ -26604,21 +26678,6 @@ const ChargePriceTiers = ({ charge: maskedCharge, currencyId, }) => {
|
|
|
26604
26678
|
}) })] }));
|
|
26605
26679
|
};
|
|
26606
26680
|
|
|
26607
|
-
const ChargeHasPriceTiers_PriceListChargeFragment = t(`
|
|
26608
|
-
fragment ChargeHasPriceTiers_PriceListChargeFragment on PriceListCharge {
|
|
26609
|
-
priceListChargeTiers {
|
|
26610
|
-
starts
|
|
26611
|
-
price
|
|
26612
|
-
}
|
|
26613
|
-
}
|
|
26614
|
-
`);
|
|
26615
|
-
function chargeHasPriceTiers(maskedCharge) {
|
|
26616
|
-
var _a;
|
|
26617
|
-
// Read fragments
|
|
26618
|
-
const charge = readFragment(ChargeHasPriceTiers_PriceListChargeFragment, maskedCharge);
|
|
26619
|
-
return ((_a = charge.priceListChargeTiers) === null || _a === void 0 ? void 0 : _a.length) && charge.priceListChargeTiers.length > 1;
|
|
26620
|
-
}
|
|
26621
|
-
|
|
26622
26681
|
const getFirstTierPrice = (charge, currencyId) => {
|
|
26623
26682
|
var _a, _b, _c;
|
|
26624
26683
|
const price = (_b = (_a = charge.priceListChargeTiers) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.price;
|
|
@@ -26650,75 +26709,41 @@ const PricingTooltip_PriceListChargeFragment = t(`
|
|
|
26650
26709
|
priceDecimals
|
|
26651
26710
|
basePrice
|
|
26652
26711
|
name
|
|
26712
|
+
...priceListChargePriceDescription_PriceListChargeFragment
|
|
26653
26713
|
...ChargeHasPriceTiers_PriceListChargeFragment
|
|
26654
26714
|
...ChargePriceTiers_PriceListChargeFragment
|
|
26715
|
+
...GetActiveCharges_PriceListChargeFragment
|
|
26655
26716
|
}
|
|
26656
|
-
`, [
|
|
26717
|
+
`, [
|
|
26718
|
+
ChargeHasPriceTiers_PriceListChargeFragment,
|
|
26719
|
+
ChargePriceTiers_PriceListChargeFragment,
|
|
26720
|
+
GetActiveCharges_PriceListChargeFragment,
|
|
26721
|
+
priceListChargePriceDescription_PriceListChargeFragment
|
|
26722
|
+
]);
|
|
26657
26723
|
const PricingTooltip_PriceListFragment = t(`
|
|
26658
26724
|
fragment PricingTooltip_PriceListFragment on PriceList {
|
|
26659
|
-
showPriceAsMonthly
|
|
26660
|
-
periodMonths
|
|
26661
26725
|
currencyId
|
|
26662
26726
|
monthlyBasePrice
|
|
26663
26727
|
basePrice
|
|
26664
|
-
...
|
|
26728
|
+
...priceDescriptionString_PriceListFragment
|
|
26665
26729
|
}
|
|
26666
|
-
`, [
|
|
26667
|
-
const PricingTooltip = ({ className, priceListCharges: maskedPriceListCharges, currencyId,
|
|
26730
|
+
`, [priceDescriptionString_PriceListFragment]);
|
|
26731
|
+
const PricingTooltip = ({ className, priceListCharges: maskedPriceListCharges, currencyId, }) => {
|
|
26668
26732
|
// Read fragments
|
|
26669
|
-
const priceList = readFragment(PricingTooltip_PriceListFragment, maskedPriceList);
|
|
26670
26733
|
const priceListCharges = maskedPriceListCharges.map(charge => readFragment(PricingTooltip_PriceListChargeFragment, charge));
|
|
26671
|
-
const
|
|
26734
|
+
const activeCharges = getActiveCharges(priceListCharges);
|
|
26672
26735
|
const content = useMemo(() => {
|
|
26673
|
-
return (jsx("div", { className: "bunny-flex bunny-flex-col bunny-gap-3", children:
|
|
26674
|
-
var _a;
|
|
26736
|
+
return (jsx("div", { className: "bunny-flex bunny-flex-col bunny-gap-3", children: activeCharges === null || activeCharges === void 0 ? void 0 : activeCharges.map((charge, index) => {
|
|
26675
26737
|
const hasPriceTiers = chargeHasPriceTiers(charge);
|
|
26676
26738
|
if (hasPriceTiers) {
|
|
26677
26739
|
return jsx(ChargePriceTiers, { charge: charge, currencyId: currencyId }, index);
|
|
26678
26740
|
}
|
|
26679
|
-
return (jsxs("div", { className: "bunny-flex bunny-flex-col bunny-gap-1", children: [jsx("div", { className: "bunny-text-white bunny-font-bold", children: charge.name }), jsxs("div", { className: "bunny-text-gray-400 bunny-text-xs/3", children: [getChargeBasePrice(charge, currencyId), ' ',
|
|
26680
|
-
unitName: (_a = charge.feature) === null || _a === void 0 ? void 0 : _a.unitName,
|
|
26681
|
-
showPriceAsMonthly: priceList === null || priceList === void 0 ? void 0 : priceList.showPriceAsMonthly,
|
|
26682
|
-
periodMonths: priceList === null || priceList === void 0 ? void 0 : priceList.periodMonths,
|
|
26683
|
-
priceListHasFlatFeeCharges: doesPriceListHaveFlatFeeCharges(priceList),
|
|
26684
|
-
})] })] }, index));
|
|
26741
|
+
return (jsxs("div", { className: "bunny-flex bunny-flex-col bunny-gap-1", children: [jsx("div", { className: "bunny-text-white bunny-font-bold", children: charge.name }), jsxs("div", { className: "bunny-text-gray-400 bunny-text-xs/3", children: [getChargeBasePrice(charge, currencyId), ' ', priceListChargePriceDescription(charge)] })] }, index));
|
|
26685
26742
|
}) }));
|
|
26686
|
-
}, [
|
|
26743
|
+
}, [activeCharges, currencyId]);
|
|
26687
26744
|
return (jsx(Tooltip, { className: `bunny-text-gray-400 bunny-text-sm ${className}`, title: content, children: jsx(InfoCircleOutlined, { className: "bunny-text-gray-400 ", size: 15 }) }));
|
|
26688
26745
|
};
|
|
26689
26746
|
|
|
26690
|
-
const PriceListHasPriceTiers_PriceListFragment = t(`
|
|
26691
|
-
fragment PriceListHasPriceTiers_PriceListFragment on PriceList {
|
|
26692
|
-
charges {
|
|
26693
|
-
...ChargeHasPriceTiers_PriceListChargeFragment
|
|
26694
|
-
}
|
|
26695
|
-
}
|
|
26696
|
-
`, [ChargeHasPriceTiers_PriceListChargeFragment]);
|
|
26697
|
-
// a pricelist has price tiers if any of its charges have > 1 price tier
|
|
26698
|
-
const priceListHasPriceTiers = (maskedPriceList) => {
|
|
26699
|
-
var _a;
|
|
26700
|
-
// Read fragments
|
|
26701
|
-
const priceList = readFragment(PriceListHasPriceTiers_PriceListFragment, maskedPriceList);
|
|
26702
|
-
return (_a = priceList.charges) === null || _a === void 0 ? void 0 : _a.some(chargeHasPriceTiers);
|
|
26703
|
-
};
|
|
26704
|
-
|
|
26705
|
-
const HasMultipleRecurringCharges_PriceListFragment = t(`
|
|
26706
|
-
fragment HasMultipleRecurringCharges_PriceListFragment on PriceList {
|
|
26707
|
-
charges {
|
|
26708
|
-
chargeType
|
|
26709
|
-
featureAddon
|
|
26710
|
-
}
|
|
26711
|
-
}
|
|
26712
|
-
`);
|
|
26713
|
-
// Exclude add-on charges because they may not be present in the quote/subscription
|
|
26714
|
-
// Exclude usage charges because their price depends on the usage (we don't know what the usage will be)
|
|
26715
|
-
const hasMultipleRecurringCharges = (maskedPriceList) => {
|
|
26716
|
-
var _a, _b;
|
|
26717
|
-
// Read fragments
|
|
26718
|
-
const priceList = readFragment(HasMultipleRecurringCharges_PriceListFragment, maskedPriceList);
|
|
26719
|
-
return (((_b = (_a = priceList.charges) === null || _a === void 0 ? void 0 : _a.filter(charge => charge.chargeType !== t.scalar('ChargeType', 'USAGE') && charge.featureAddon !== true).length) !== null && _b !== void 0 ? _b : 0) > 1);
|
|
26720
|
-
};
|
|
26721
|
-
|
|
26722
26747
|
/**
|
|
26723
26748
|
* It is possible for html based descriptions to return something like '<p></p>'
|
|
26724
26749
|
* In which case a null check or character length count doesn't work.
|
|
@@ -26729,6 +26754,22 @@ function isEmptyHTML(html) {
|
|
|
26729
26754
|
return /^<[^>]*>(\s*)<\/[^>]*>$/.test(html);
|
|
26730
26755
|
}
|
|
26731
26756
|
|
|
26757
|
+
const BillingPeriodDescription_PriceListFragment = t(`
|
|
26758
|
+
fragment BillingPeriodDescription_PriceListFragment on PriceList {
|
|
26759
|
+
periodMonths
|
|
26760
|
+
}
|
|
26761
|
+
`);
|
|
26762
|
+
const BillingPeriodDescription = ({ priceList: maskedPriceList, }) => {
|
|
26763
|
+
// Read fragments
|
|
26764
|
+
const priceList = readFragment(BillingPeriodDescription_PriceListFragment, maskedPriceList);
|
|
26765
|
+
const periodMonthsConverted = periodMonthsConverter(priceList.periodMonths);
|
|
26766
|
+
const billingPeriodText = periodMonthsConverted
|
|
26767
|
+
? BillingPeriodConverter$1[periodMonthsConverted]
|
|
26768
|
+
: 'undefined';
|
|
26769
|
+
const showDescription = priceList.periodMonths && priceList.periodMonths > 1;
|
|
26770
|
+
return (jsx(Fragment, { children: showDescription && (jsxs("div", { children: ["Billed ", billingPeriodText] })) }));
|
|
26771
|
+
};
|
|
26772
|
+
|
|
26732
26773
|
const { Text: Text$b } = Typography;
|
|
26733
26774
|
const MarkupWrapper = defaultStyled.div `
|
|
26734
26775
|
padding: 0 !important;
|
|
@@ -26745,28 +26786,32 @@ const PriceListCardPriceDescription_PriceListFragment = t(`
|
|
|
26745
26786
|
plan {
|
|
26746
26787
|
pricingDescription
|
|
26747
26788
|
}
|
|
26748
|
-
|
|
26789
|
+
charges {
|
|
26790
|
+
...GetActiveCharges_PriceListChargeFragment
|
|
26791
|
+
...PricingTooltip_PriceListChargeFragment
|
|
26792
|
+
}
|
|
26793
|
+
currencyId
|
|
26749
26794
|
periodMonths
|
|
26750
|
-
...
|
|
26751
|
-
...
|
|
26795
|
+
...priceDescriptionString_PriceListFragment
|
|
26796
|
+
...BillingPeriodDescription_PriceListFragment
|
|
26797
|
+
...PriceListHasPriceTiers_PriceListFragment
|
|
26752
26798
|
}
|
|
26753
|
-
`, [
|
|
26754
|
-
|
|
26755
|
-
|
|
26799
|
+
`, [
|
|
26800
|
+
priceDescriptionString_PriceListFragment,
|
|
26801
|
+
BillingPeriodDescription_PriceListFragment,
|
|
26802
|
+
PriceListHasPriceTiers_PriceListFragment,
|
|
26803
|
+
GetActiveCharges_PriceListChargeFragment,
|
|
26804
|
+
PricingTooltip_PriceListChargeFragment
|
|
26805
|
+
]);
|
|
26806
|
+
const PriceListCardPriceDescription = ({ priceList: maskedPriceList, }) => {
|
|
26807
|
+
var _a, _b;
|
|
26756
26808
|
// Read fragments
|
|
26757
26809
|
const priceList = readFragment(PriceListCardPriceDescription_PriceListFragment, maskedPriceList);
|
|
26810
|
+
const activeCharges = getActiveCharges((_a = priceList.charges) !== null && _a !== void 0 ? _a : []);
|
|
26811
|
+
const showPricingTooltip = priceListHasPriceTiers(priceList) || activeCharges.length > 1;
|
|
26758
26812
|
if (priceList.periodMonths && priceList.periodMonths <= 0)
|
|
26759
26813
|
return null;
|
|
26760
|
-
|
|
26761
|
-
const billingPeriodText = periodMonthsConverted
|
|
26762
|
-
? BillingPeriodConverter$1[periodMonthsConverted]
|
|
26763
|
-
: 'undefined';
|
|
26764
|
-
return (jsxs(Text$b, { className: "bunny-text-start bunny-text-gray-400 bunny-text-sm", children: [jsx("div", { children: ((_a = priceList.plan) === null || _a === void 0 ? void 0 : _a.pricingDescription) && !isEmptyHTML(priceList.plan.pricingDescription) ? (jsx(MarkupWrapper, { children: jsx(Markup, { content: priceList.plan.pricingDescription }) })) : (priceDescriptionString({
|
|
26765
|
-
unitName: hasMultipleRecurringCharges(priceList) ? undefined : feature === null || feature === void 0 ? void 0 : feature.unitName,
|
|
26766
|
-
showPriceAsMonthly: priceList.showPriceAsMonthly,
|
|
26767
|
-
periodMonths: priceList.periodMonths,
|
|
26768
|
-
priceListHasFlatFeeCharges: doesPriceListHaveFlatFeeCharges(priceList),
|
|
26769
|
-
})) }), priceList.periodMonths && priceList.periodMonths > 1 && (jsxs("div", { children: ["Billed ", billingPeriodText] }))] }));
|
|
26814
|
+
return (jsxs(Text$b, { className: "bunny-text-start bunny-text-gray-400 bunny-text-sm", children: [jsxs("div", { className: "bunny-flex bunny-flex-row bunny-gap-2 bunny-items-center", children: [jsx("div", { children: ((_b = priceList.plan) === null || _b === void 0 ? void 0 : _b.pricingDescription) && !isEmptyHTML(priceList.plan.pricingDescription) ? (jsx(MarkupWrapper, { children: jsx(Markup, { content: priceList.plan.pricingDescription }) })) : (priceDescriptionString(priceList)) }), showPricingTooltip && (jsx(PricingTooltip, { priceListCharges: activeCharges, currencyId: priceList.currencyId }))] }), jsx(BillingPeriodDescription, { priceList: priceList })] }));
|
|
26770
26815
|
};
|
|
26771
26816
|
|
|
26772
26817
|
/**
|
|
@@ -26803,6 +26848,28 @@ const PriceListCardDescription = ({ description, className }) => {
|
|
|
26803
26848
|
return jsx(TruncatedText, { className: `bunny-text-gray-400 bunny-text-sm ${className !== null && className !== void 0 ? className : ''}`, text: description });
|
|
26804
26849
|
};
|
|
26805
26850
|
|
|
26851
|
+
const filterDeprecatedCharges_PriceListChargeFragment = t(`
|
|
26852
|
+
fragment filterDeprecatedCharges_PriceListChargeFragment on PriceListCharge {
|
|
26853
|
+
deprecated
|
|
26854
|
+
removeOnRenewal
|
|
26855
|
+
}
|
|
26856
|
+
`);
|
|
26857
|
+
function filterDeprecatedCharges(quoteChangeKind, maskedCharge) {
|
|
26858
|
+
const charge = readFragment(filterDeprecatedCharges_PriceListChargeFragment, maskedCharge);
|
|
26859
|
+
// If kind are not subscribe, reinstate or renew, then the deprecated charge is grandfathered in and can be displayed
|
|
26860
|
+
if (quoteChangeKind &&
|
|
26861
|
+
!(quoteChangeKind === t.scalar('QuoteChangeKind', 'SUBSCRIBE') ||
|
|
26862
|
+
quoteChangeKind === t.scalar('QuoteChangeKind', 'REINSTATE') ||
|
|
26863
|
+
quoteChangeKind === t.scalar('QuoteChangeKind', 'RENEW'))) {
|
|
26864
|
+
return true;
|
|
26865
|
+
}
|
|
26866
|
+
const deprecated = charge.deprecated;
|
|
26867
|
+
if (deprecated && quoteChangeKind === t.scalar('QuoteChangeKind', 'RENEW')) {
|
|
26868
|
+
return !charge.removeOnRenewal;
|
|
26869
|
+
}
|
|
26870
|
+
return !deprecated;
|
|
26871
|
+
}
|
|
26872
|
+
|
|
26806
26873
|
const GetPrice_PriceListFragment = t(`
|
|
26807
26874
|
fragment GetPrice_PriceListFragment on PriceList {
|
|
26808
26875
|
showPriceAsMonthly
|
|
@@ -26811,37 +26878,21 @@ const GetPrice_PriceListFragment = t(`
|
|
|
26811
26878
|
charges {
|
|
26812
26879
|
basePrice
|
|
26813
26880
|
chargeType
|
|
26814
|
-
featureAddon
|
|
26815
|
-
deprecated
|
|
26816
26881
|
...filterDeprecatedCharges_PriceListChargeFragment
|
|
26882
|
+
...GetActiveCharges_PriceListChargeFragment
|
|
26817
26883
|
}
|
|
26818
26884
|
}
|
|
26819
|
-
`, [filterDeprecatedCharges_PriceListChargeFragment]);
|
|
26885
|
+
`, [filterDeprecatedCharges_PriceListChargeFragment, GetActiveCharges_PriceListChargeFragment]);
|
|
26820
26886
|
function getPrice(maskedPriceList) {
|
|
26821
|
-
var _a
|
|
26887
|
+
var _a;
|
|
26822
26888
|
// Read fragments
|
|
26823
26889
|
const priceList = readFragment(GetPrice_PriceListFragment, maskedPriceList);
|
|
26824
|
-
|
|
26825
|
-
|
|
26826
|
-
//
|
|
26827
|
-
|
|
26828
|
-
|
|
26829
|
-
|
|
26830
|
-
if (!filterDeprecatedCharges(undefined, charge)) {
|
|
26831
|
-
return false;
|
|
26832
|
-
}
|
|
26833
|
-
// Exclude featureAddon charges
|
|
26834
|
-
if (charge.featureAddon === true) {
|
|
26835
|
-
return false;
|
|
26836
|
-
}
|
|
26837
|
-
// Keep only USAGE charges
|
|
26838
|
-
return charge.chargeType === t.scalar('ChargeType', 'USAGE');
|
|
26839
|
-
})) !== null && _b !== void 0 ? _b : [];
|
|
26840
|
-
// If there are any usage charges, sum their basePrice
|
|
26841
|
-
if (usageCharges.length > 0) {
|
|
26842
|
-
return usageCharges.reduce((sum, charge) => sum + charge.basePrice, 0);
|
|
26843
|
-
}
|
|
26844
|
-
// =================================================================
|
|
26890
|
+
const activeCharges = getActiveCharges((_a = priceList.charges) !== null && _a !== void 0 ? _a : []);
|
|
26891
|
+
const onlyUsageChargesExist = activeCharges === null || activeCharges === void 0 ? void 0 : activeCharges.every(charge => charge.chargeType === 'USAGE');
|
|
26892
|
+
// HACK: If there are ONLY usage charges, sum their basePrice
|
|
26893
|
+
if (onlyUsageChargesExist) {
|
|
26894
|
+
return activeCharges === null || activeCharges === void 0 ? void 0 : activeCharges.reduce((sum, charge) => sum + charge.basePrice, 0);
|
|
26895
|
+
}
|
|
26845
26896
|
// Otherwise, return the priceList basePrice or monthlyBasePrice
|
|
26846
26897
|
if (priceList.showPriceAsMonthly) {
|
|
26847
26898
|
return priceList.monthlyBasePrice;
|
|
@@ -26930,32 +26981,19 @@ const PriceListCardDesktop_PriceListFragment = t(`
|
|
|
26930
26981
|
contactUsUrl
|
|
26931
26982
|
name
|
|
26932
26983
|
}
|
|
26933
|
-
charges {
|
|
26934
|
-
id
|
|
26935
|
-
featureAddon
|
|
26936
|
-
priceListChargeTiers {
|
|
26937
|
-
starts
|
|
26938
|
-
price
|
|
26939
|
-
}
|
|
26940
|
-
...PricingTooltip_PriceListChargeFragment
|
|
26941
|
-
}
|
|
26942
|
-
currencyId
|
|
26943
26984
|
...PriceListCardButton_PriceListFragment
|
|
26944
26985
|
...PriceListHasPriceTiers_PriceListFragment
|
|
26945
|
-
...PricingTooltip_PriceListFragment
|
|
26946
26986
|
...PriceListCardPrice_PriceListFragment
|
|
26947
26987
|
...PriceListCardPriceDescription_PriceListFragment
|
|
26948
26988
|
}
|
|
26949
26989
|
`, [
|
|
26950
26990
|
PriceListCardButton_PriceListFragment,
|
|
26951
|
-
PricingTooltip_PriceListChargeFragment,
|
|
26952
26991
|
PriceListHasPriceTiers_PriceListFragment,
|
|
26953
|
-
PricingTooltip_PriceListFragment,
|
|
26954
26992
|
PriceListCardPrice_PriceListFragment,
|
|
26955
26993
|
PriceListCardPriceDescription_PriceListFragment,
|
|
26956
26994
|
]);
|
|
26957
|
-
const PriceListCardDesktop = ({ hideButton, description, disableSelectCurrentPlan,
|
|
26958
|
-
var _a, _b
|
|
26995
|
+
const PriceListCardDesktop = ({ hideButton, description, disableSelectCurrentPlan, isPriceListCurrentSubscription, isSelected, priceList: maskedPriceList, subscriptionPlan, trialRemainingDays, noBorder, onClickPriceListCard, }) => {
|
|
26996
|
+
var _a, _b;
|
|
26959
26997
|
// Read fragments
|
|
26960
26998
|
const priceList = readFragment(PriceListCardDesktop_PriceListFragment, maskedPriceList);
|
|
26961
26999
|
return (jsx(PlanPickerGridCell, { noBorder: noBorder, children: jsxs("div", { className: `bunny-flex bunny-flex-col bunny-items-start bunny-justify-between bunny-w-full bunny-rounded-md bunny-gap-4 bunny-pt-4 bunny-px-4 ${disableSelectCurrentPlan ? '' : 'cursor-pointer'} bunny-box-border`, onClick: () => {
|
|
@@ -26974,7 +27012,7 @@ const PriceListCardDesktop = ({ hideButton, description, disableSelectCurrentPla
|
|
|
26974
27012
|
display: 'grid',
|
|
26975
27013
|
gridTemplateRows: 'auto minmax(40px, auto)',
|
|
26976
27014
|
alignItems: 'start',
|
|
26977
|
-
}, children: [jsx(PriceListCardPrice, { priceList: priceList }),
|
|
27015
|
+
}, children: [jsx(PriceListCardPrice, { priceList: priceList }), jsx("div", { className: "bunny-flex bunny-flex-row bunny-gap-2 bunny-items-center", children: jsx(PriceListCardPriceDescription, { priceList: priceList }) })] })] }), !hideButton && (jsx(PriceListCardButton, { disableSelectCurrentPlan: disableSelectCurrentPlan, isPriceListCurrentSubscription: isPriceListCurrentSubscription, isSelected: isSelected, priceList: priceList, subscriptionPlan: subscriptionPlan }))] }) }));
|
|
26978
27016
|
};
|
|
26979
27017
|
|
|
26980
27018
|
const CheckIcon = ({ backgroundColor, size, }) => {
|
|
@@ -26997,7 +27035,7 @@ const PriceListCardMobile_PriceListFragment = t(`
|
|
|
26997
27035
|
PriceListCardPrice_PriceListFragment,
|
|
26998
27036
|
PriceListCardButton_PriceListFragment,
|
|
26999
27037
|
]);
|
|
27000
|
-
const PriceListCardMobile = ({ description,
|
|
27038
|
+
const PriceListCardMobile = ({ description, isPriceListCurrentSubscription, isSelected, priceList: maskedPriceList, subscriptionPlan, trialRemainingDays, disableOnClickPriceListCard, onClickPriceListCard, }) => {
|
|
27001
27039
|
var _a, _b;
|
|
27002
27040
|
// Context
|
|
27003
27041
|
const { brandColor } = useBrand();
|
|
@@ -27012,7 +27050,7 @@ const PriceListCardMobile = ({ description, feature, isPriceListCurrentSubscript
|
|
|
27012
27050
|
}, children: [isSelected && (jsx("div", { className: "bunny-absolute", style: {
|
|
27013
27051
|
top: '10px',
|
|
27014
27052
|
right: '10px',
|
|
27015
|
-
}, children: jsx(CheckIcon, { backgroundColor: brandColor, size: "20px" }) })), jsxs("div", { className: "bunny-flex bunny-flex-col bunny-items-center bunny-grow bunny-gap-2", children: [jsxs("div", { className: "bunny-flex bunny-flex-col bunny-items-center bunny-gap-2", children: [jsx(PriceListCardTitle, { isPriceListCurrentSubscription: isPriceListCurrentSubscription, planName: (_b = (_a = priceList.plan) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : 'undefined', trialRemainingDays: trialRemainingDays }), jsx(PriceListCardDescription, { description: description })] }), jsxs("div", { className: "bunny-flex bunny-flex-col bunny-items-center bunny-gap-2", children: [jsx(PriceListCardPrice, { priceList: priceList }), jsx(PriceListCardPriceDescription, {
|
|
27053
|
+
}, children: jsx(CheckIcon, { backgroundColor: brandColor, size: "20px" }) })), jsxs("div", { className: "bunny-flex bunny-flex-col bunny-items-center bunny-grow bunny-gap-2", children: [jsxs("div", { className: "bunny-flex bunny-flex-col bunny-items-center bunny-gap-2", children: [jsx(PriceListCardTitle, { isPriceListCurrentSubscription: isPriceListCurrentSubscription, planName: (_b = (_a = priceList.plan) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : 'undefined', trialRemainingDays: trialRemainingDays }), jsx(PriceListCardDescription, { description: description })] }), jsxs("div", { className: "bunny-flex bunny-flex-col bunny-items-center bunny-gap-2", children: [jsx(PriceListCardPrice, { priceList: priceList }), jsx(PriceListCardPriceDescription, { priceList: priceList })] }), jsx(PriceListCardButton, { disableSelectCurrentPlan: disableOnClickPriceListCard, isPriceListCurrentSubscription: isPriceListCurrentSubscription, isSelected: isSelected, priceList: priceList, subscriptionPlan: subscriptionPlan })] })] }));
|
|
27016
27054
|
};
|
|
27017
27055
|
|
|
27018
27056
|
function getAddonsForBillingPeriod(billingPeriod, addonPlans) {
|
|
@@ -27046,43 +27084,6 @@ const removeHTMLTagsRegex = /<br>(?=(?:\s*<[^>]*>)*$)|(<br>)|<[^>]*>/gi;
|
|
|
27046
27084
|
const createPlanDescription = (planDescription) => {
|
|
27047
27085
|
return (planDescription || '').replace(removeHTMLTagsRegex, (_, y) => (y ? ' & ' : ''));
|
|
27048
27086
|
};
|
|
27049
|
-
const getActivePlanPriceData = (priceList, selectedPriceList) => {
|
|
27050
|
-
if (!priceList) {
|
|
27051
|
-
return;
|
|
27052
|
-
}
|
|
27053
|
-
// If a period option is selected, return the charge that matches the selected period option
|
|
27054
|
-
let activeBillingPLCharge;
|
|
27055
|
-
// Default to first price list charge
|
|
27056
|
-
let lowestPLCharge;
|
|
27057
|
-
// Find the lowest price list charge with a billing period that matches the selected period option
|
|
27058
|
-
if (priceList.id === (selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id)) {
|
|
27059
|
-
activeBillingPLCharge = priceList.charges[0];
|
|
27060
|
-
}
|
|
27061
|
-
for (let j = 0; j < priceList.charges.length; j++) {
|
|
27062
|
-
const charge = priceList.charges[j];
|
|
27063
|
-
if (charge.chargeType === ChargeType$1.USAGE || charge.featureAddon === true)
|
|
27064
|
-
continue;
|
|
27065
|
-
if (activeBillingPLCharge) {
|
|
27066
|
-
// If we already found a charge with the same billing period check if this charge is lower
|
|
27067
|
-
if (charge.basePrice < activeBillingPLCharge.basePrice &&
|
|
27068
|
-
charge.billingPeriod === (activeBillingPLCharge === null || activeBillingPLCharge === void 0 ? void 0 : activeBillingPLCharge.billingPeriod)) {
|
|
27069
|
-
activeBillingPLCharge = charge;
|
|
27070
|
-
}
|
|
27071
|
-
}
|
|
27072
|
-
// If a period option is selected, only return the charge if it matches the selected period option
|
|
27073
|
-
else if (selectedPriceList &&
|
|
27074
|
-
charge.billingPeriod === periodMonthsConverter(selectedPriceList.periodMonths)) {
|
|
27075
|
-
activeBillingPLCharge = charge;
|
|
27076
|
-
}
|
|
27077
|
-
// Otherwise, return the lowest price list charge
|
|
27078
|
-
else if (charge.basePrice < ((lowestPLCharge === null || lowestPLCharge === void 0 ? void 0 : lowestPLCharge.basePrice) || -1)) {
|
|
27079
|
-
lowestPLCharge = charge;
|
|
27080
|
-
}
|
|
27081
|
-
}
|
|
27082
|
-
return {
|
|
27083
|
-
activeCharge: activeBillingPLCharge || lowestPLCharge,
|
|
27084
|
-
};
|
|
27085
|
-
};
|
|
27086
27087
|
|
|
27087
27088
|
const PriceListCard_PriceListFragment = t(`
|
|
27088
27089
|
fragment PriceListCard_PriceListFragment on PriceList {
|
|
@@ -27096,17 +27097,15 @@ const PriceListCard_PriceListFragment = t(`
|
|
|
27096
27097
|
}
|
|
27097
27098
|
`, [PriceListCardDesktop_PriceListFragment, PriceListCardMobile_PriceListFragment]);
|
|
27098
27099
|
const PriceListCard = ({ hideButton, isSelected, priceList: maskedPriceList, subscriptions, trialRemainingDays, noBorder, onClickPriceListCard, disableCurrentPlan = false, }) => {
|
|
27099
|
-
var _a, _b, _c
|
|
27100
|
+
var _a, _b, _c;
|
|
27100
27101
|
const isMobile = useIsMobile();
|
|
27101
27102
|
const upgradingSubscription = useUpgradingSubscription();
|
|
27102
27103
|
// Read fragments
|
|
27103
27104
|
const priceList = readFragment(PriceListCard_PriceListFragment, maskedPriceList);
|
|
27104
27105
|
// Derived state
|
|
27105
27106
|
const description = createPlanDescription((_b = (_a = priceList.plan) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : '');
|
|
27106
|
-
// Get the active price list charge for this plan
|
|
27107
|
-
const activeCharge = (_c = getActivePlanPriceData(priceList, priceList)) === null || _c === void 0 ? void 0 : _c.activeCharge;
|
|
27108
27107
|
// Is the price list the current price list for the upgradingSubscription
|
|
27109
|
-
const isPriceListCurrentSubscription = ((
|
|
27108
|
+
const isPriceListCurrentSubscription = ((_c = upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.priceList) === null || _c === void 0 ? void 0 : _c.id) === priceList.id;
|
|
27110
27109
|
const disableSelectCurrentPlan = disableCurrentPlan;
|
|
27111
27110
|
// We now support updating quantities by clicking the current plan. Therefore we shouldn't disable current plan
|
|
27112
27111
|
// disableCurrentPlan ??
|
|
@@ -27121,13 +27120,9 @@ const PriceListCard = ({ hideButton, isSelected, priceList: maskedPriceList, sub
|
|
|
27121
27120
|
subscription.state !== t.scalar('SubscriptionState', 'EXPIRED') &&
|
|
27122
27121
|
((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === t.scalar('SubscriptionState', 'TRIAL_EXPIRED');
|
|
27123
27122
|
});
|
|
27124
|
-
|
|
27125
|
-
return null;
|
|
27126
|
-
}
|
|
27127
|
-
const { feature } = activeCharge;
|
|
27128
|
-
return isMobile ? (jsx(PriceListCardMobile, { description: description, feature: feature, isPriceListCurrentSubscription: isPriceListCurrentSubscription, isSelected: isSelected, priceList: priceList, trialRemainingDays: trialRemainingDays, subscriptionPlan: subscriptionPlan,
|
|
27123
|
+
return isMobile ? (jsx(PriceListCardMobile, { description: description, isPriceListCurrentSubscription: isPriceListCurrentSubscription, isSelected: isSelected, priceList: priceList, trialRemainingDays: trialRemainingDays, subscriptionPlan: subscriptionPlan,
|
|
27129
27124
|
// TODO: naming mismatch disableOnClickPriceListCard vs disableSelectCurrentPlan, maybe also functionality mismatch? (ignore for now, mobile won't ever show this currently)
|
|
27130
|
-
disableOnClickPriceListCard: disableSelectCurrentPlan, onClickPriceListCard: onClickPriceListCard })) : (jsx(PriceListCardDesktop, { hideButton: hideButton, description: description, disableSelectCurrentPlan: disableSelectCurrentPlan,
|
|
27125
|
+
disableOnClickPriceListCard: disableSelectCurrentPlan, onClickPriceListCard: onClickPriceListCard })) : (jsx(PriceListCardDesktop, { hideButton: hideButton, description: description, disableSelectCurrentPlan: disableSelectCurrentPlan, isPriceListCurrentSubscription: isPriceListCurrentSubscription, isSelected: isSelected, priceList: priceList, trialRemainingDays: trialRemainingDays, subscriptionPlan: subscriptionPlan, noBorder: noBorder, onClickPriceListCard: onClickPriceListCard }));
|
|
27131
27126
|
};
|
|
27132
27127
|
|
|
27133
27128
|
const mutation$a = t(`
|
|
@@ -27293,9 +27288,8 @@ const FeatureAddonRow_PriceListFragment = t(`
|
|
|
27293
27288
|
id
|
|
27294
27289
|
name
|
|
27295
27290
|
}
|
|
27296
|
-
...PricingTooltip_PriceListFragment
|
|
27297
27291
|
}
|
|
27298
|
-
|
|
27292
|
+
`);
|
|
27299
27293
|
const FeatureAddonRow_PriceListChargeFragment = t(`
|
|
27300
27294
|
fragment FeatureAddonRow_PriceListChargeFragment on PriceListCharge {
|
|
27301
27295
|
id
|
|
@@ -27316,7 +27310,7 @@ function FeatureAddonRow({ featureAddon: maskedFeatureAddon, priceList: maskedPr
|
|
|
27316
27310
|
const isPurchased = isAddonPurchased(featureAddon, upgradingSubscription);
|
|
27317
27311
|
const isDisabled = !isPriceListSelected || isPurchased;
|
|
27318
27312
|
const checked = isChecked || isPurchased;
|
|
27319
|
-
return (jsxs("div", { className: "bunny-flex bunny-flex-row bunny-flex-wrap bunny-items-center bunny-justify-between bunny-gap-1", children: [jsxs("div", { className: "bunny-flex bunny-flex-row bunny-gap-1", children: [jsx(Text$7, { className: "bunny-flex bunny-text-sm bunny-items-center bunny-gap-1 bunny-text-gray-600", children: featureAddon.name }), jsx(PricingTooltip, { priceListCharges: [featureAddon], currencyId: priceList.currencyId
|
|
27313
|
+
return (jsxs("div", { className: "bunny-flex bunny-flex-row bunny-flex-wrap bunny-items-center bunny-justify-between bunny-gap-1", children: [jsxs("div", { className: "bunny-flex bunny-flex-row bunny-gap-1", children: [jsx(Text$7, { className: "bunny-flex bunny-text-sm bunny-items-center bunny-gap-1 bunny-text-gray-600", children: featureAddon.name }), jsx(PricingTooltip, { priceListCharges: [featureAddon], currencyId: priceList.currencyId })] }), jsx(Switch, { id: featureAddonSwitchTestId(featureAddon.name), size: "small", loading: isPending, disabled: isDisabled || !quote, checked: checked, onChange: checked => {
|
|
27320
27314
|
if (checked) {
|
|
27321
27315
|
handleAddFeatureAddon();
|
|
27322
27316
|
}
|
|
@@ -27692,20 +27686,19 @@ const AddonPlanRow_PriceListFragment = t(`
|
|
|
27692
27686
|
PriceListCardPriceDescription_PriceListFragment,
|
|
27693
27687
|
]);
|
|
27694
27688
|
function AddonPlanRow({ addonPriceList: maskedAddonPriceList, selectedPriceList, onClickSelect, isPurchased, }) {
|
|
27695
|
-
var _a, _b, _c, _d, _e, _f
|
|
27689
|
+
var _a, _b, _c, _d, _e, _f;
|
|
27696
27690
|
// Read fragments
|
|
27697
27691
|
const addonPriceList = readFragment(AddonPlanRow_PriceListFragment, maskedAddonPriceList);
|
|
27698
27692
|
const { quote: maskedQuote, setIsAddonPlanLoading } = useContext(QuoteContext);
|
|
27699
27693
|
const quote = readFragment(AddonPlanRow_QuoteFragment, maskedQuote);
|
|
27700
27694
|
const { shadow, isInPreviewMode } = useSubscriptionProps();
|
|
27701
27695
|
const { isPending, addedQuoteChange, addAddonQuoteChange, deleteQuoteChange } = useToggleAddonPlan(quote, addonPriceList.id, selectedPriceList, setIsAddonPlanLoading);
|
|
27702
|
-
const activeCharge = (_a = getActivePlanPriceData(addonPriceList, selectedPriceList)) === null || _a === void 0 ? void 0 : _a.activeCharge;
|
|
27703
27696
|
// Derived state
|
|
27704
27697
|
const switchDisabled = isInPreviewMode || isPurchased;
|
|
27705
|
-
const hasCustomPrice = !isEmptyHTML((
|
|
27706
|
-
return (jsxs("div", { className: `bunny-flex bunny-flex-row bunny-gap-2 bunny-justify-between bunny-items-center bunny-p-4 bunny-rounded-md bunny-bg-white ${shadow ? `shadow-${shadow}` : ''} bunny-mb-2`, children: [jsxs("div", { className: "bunny-flex bunny-flex-row bunny-gap-2 bunny-items-center bunny-min-w-0 bunny-flex-1", children: [jsx(Shrink0Wrapper, { className: "bunny-font-medium bunny-text-center bunny-text-orange-600", children: (
|
|
27698
|
+
const hasCustomPrice = !isEmptyHTML((_a = addonPriceList.plan) === null || _a === void 0 ? void 0 : _a.pricingDescription);
|
|
27699
|
+
return (jsxs("div", { className: `bunny-flex bunny-flex-row bunny-gap-2 bunny-justify-between bunny-items-center bunny-p-4 bunny-rounded-md bunny-bg-white ${shadow ? `shadow-${shadow}` : ''} bunny-mb-2`, children: [jsxs("div", { className: "bunny-flex bunny-flex-row bunny-gap-2 bunny-items-center bunny-min-w-0 bunny-flex-1", children: [jsx(Shrink0Wrapper, { className: "bunny-font-medium bunny-text-center bunny-text-orange-600", children: (_b = addonPriceList.plan) === null || _b === void 0 ? void 0 : _b.name }), jsx("div", { className: "bunny-min-w-0 bunny-flex-1", children: jsx(PriceListCardDescription, { description: (_d = (_c = addonPriceList.plan) === null || _c === void 0 ? void 0 : _c.description) !== null && _d !== void 0 ? _d : '', className: "bunny-whitespace-nowrap" }) })] }), jsxs("div", { className: "bunny-flex bunny-flex-row bunny-gap-2 bunny-items-center bunny-shrink-0", children: [!hasCustomPrice && (jsx(Shrink0Wrapper, { children: jsx(PriceListCardPrice, { priceList: addonPriceList, className: "bunny-whitespace-nowrap bunny-text-sm bunny-font-medium bunny-text-gray-900" }) })), jsx(Shrink0Wrapper, { children: jsx(PriceListCardPriceDescription, { priceList: addonPriceList }) }), jsx(Shrink0Wrapper, { children: jsx(Button, { type: "link", onClick: () => {
|
|
27707
27700
|
onClickSelect();
|
|
27708
|
-
}, children: jsx(InfoCircleOutlined, {}) }) }), jsx(Switch, { id: addonPlanSwitchTestId((
|
|
27701
|
+
}, children: jsx(InfoCircleOutlined, {}) }) }), jsx(Switch, { id: addonPlanSwitchTestId((_f = (_e = addonPriceList.plan) === null || _e === void 0 ? void 0 : _e.name) !== null && _f !== void 0 ? _f : ''), loading: isPending && !switchDisabled, checked: addedQuoteChange || isPurchased, onChange: (checked) => {
|
|
27709
27702
|
if (checked) {
|
|
27710
27703
|
addAddonQuoteChange();
|
|
27711
27704
|
}
|
|
@@ -28529,16 +28522,16 @@ const QuantityInput = ({ charge: maskedCharge, subscription: maskedSubscription,
|
|
|
28529
28522
|
}
|
|
28530
28523
|
// Used to disable all other quantity inputs for this subscription
|
|
28531
28524
|
setUpdatingChargeQuantityId(getUpdatingChargeQuantityId(charge.priceListChargeId, subscription.id));
|
|
28532
|
-
const
|
|
28533
|
-
debouncedQuantityUpdate(charge.priceListChargeId,
|
|
28525
|
+
const oldQuantity = (_a = charge.quantity) !== null && _a !== void 0 ? _a : 0;
|
|
28526
|
+
debouncedQuantityUpdate(charge.priceListChargeId, quantity, oldQuantity, subscription.id, quote, quoteId);
|
|
28534
28527
|
}
|
|
28535
28528
|
};
|
|
28536
28529
|
const debouncedDeleteQuote = useCallback(lodashExports.debounce((quoteId) => {
|
|
28537
28530
|
deleteQuote({ id: quoteId, apiHost, token });
|
|
28538
28531
|
}, DEBOUNCE_TIME), []);
|
|
28539
|
-
const debouncedQuantityUpdate = useCallback(lodashExports.debounce((priceListChargeId,
|
|
28532
|
+
const debouncedQuantityUpdate = useCallback(lodashExports.debounce((priceListChargeId, quantity, oldQuantity, subscriptionId, quote, quoteId) => {
|
|
28540
28533
|
var _a;
|
|
28541
|
-
if (
|
|
28534
|
+
if (quantity === oldQuantity) {
|
|
28542
28535
|
setErrorUpdatingQuantity(true);
|
|
28543
28536
|
showErrorNotification('New quantity cannot be the same as current');
|
|
28544
28537
|
return;
|
|
@@ -28553,7 +28546,7 @@ const QuantityInput = ({ charge: maskedCharge, subscription: maskedSubscription,
|
|
|
28553
28546
|
if (quoteCharge) {
|
|
28554
28547
|
updateQuoteCharge({
|
|
28555
28548
|
quoteChargeId: quoteCharge.id,
|
|
28556
|
-
quantity
|
|
28549
|
+
quantity,
|
|
28557
28550
|
});
|
|
28558
28551
|
}
|
|
28559
28552
|
}
|