@stigg/react-sdk 4.10.0 → 4.11.0
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/components/checkout/hooks/useAddonsStepModel.d.ts +2 -2
- package/dist/components/checkout/steps/addons/addon.utils.d.ts +3 -3
- package/dist/components/common/LongText.d.ts +3 -4
- package/dist/components/customerPortal/CustomerPortal.d.ts +1 -1
- package/dist/components/customerPortal/billing/InformationGrid.d.ts +1 -1
- package/dist/components/customerPortal/hooks/useCustomerPortal.d.ts +2 -2
- package/dist/components/customerPortal/subscriptionOverview/SubscriptionsOverviewHeader.d.ts +0 -2
- package/dist/components/paywall/hooks/useLoadPaywallData.d.ts +2 -2
- package/dist/components/paywall/utils/hasPricePoints.d.ts +2 -2
- package/dist/components/utils/getFeatureName.d.ts +1 -1
- package/dist/components/utils/getPlanPrice.d.ts +1 -2
- package/dist/components/utils/priceTierUtils.d.ts +1 -1
- package/dist/react-sdk.cjs.development.js +98 -72
- package/dist/react-sdk.cjs.development.js.map +1 -1
- package/dist/react-sdk.cjs.production.min.js +1 -1
- package/dist/react-sdk.cjs.production.min.js.map +1 -1
- package/dist/react-sdk.esm.js +98 -72
- package/dist/react-sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/checkout/CheckoutContainer.tsx +2 -0
- package/src/components/checkout/components/Button.tsx +4 -2
- package/src/components/checkout/hooks/useAddonsStepModel.ts +2 -2
- package/src/components/checkout/steps/addons/addon.utils.ts +26 -26
- package/src/components/common/LongText.tsx +2 -4
- package/src/components/common/PoweredByStigg.tsx +1 -1
- package/src/components/common/Typography.tsx +1 -1
- package/src/components/customerPortal/CustomerPortal.tsx +1 -1
- package/src/components/customerPortal/CustomerPortalProvider.tsx +1 -0
- package/src/components/customerPortal/billing/InformationGrid.tsx +1 -1
- package/src/components/customerPortal/billing/PaymentDetailsSection.tsx +3 -3
- package/src/components/customerPortal/common/ExternalLinkButton.tsx +1 -1
- package/src/components/customerPortal/common/SectionTitle.tsx +2 -2
- package/src/components/customerPortal/hooks/useCustomerPortal.ts +3 -3
- package/src/components/customerPortal/subscriptionOverview/ContactCustomerSupport.tsx +4 -2
- package/src/components/customerPortal/subscriptionOverview/SubscriptionsOverview.tsx +2 -1
- package/src/components/customerPortal/subscriptionOverview/SubscriptionsOverviewHeader.tsx +1 -3
- package/src/components/customerPortal/subscriptionOverview/charges/ChargeItem.tsx +2 -2
- package/src/components/customerPortal/subscriptionOverview/charges/ChargeList.tsx +2 -2
- package/src/components/customerPortal/subscriptionOverview/subscriptionScheduledUpdates/SubscriptionScheduledUpdateRow.tsx +1 -1
- package/src/components/customerPortal/subscriptionOverview/subscriptionScheduledUpdates/SubscriptionScheduledUpdatesAlert.tsx +2 -2
- package/src/components/customerPortal/subscriptionOverview/subscriptionView/SubscriptionView.tsx +1 -1
- package/src/components/customerPortal/subscriptionOverview/subscriptionView/TrialPanel.tsx +2 -2
- package/src/components/customerPortal/subscriptionOverview/tabs/Promotions.tsx +1 -1
- package/src/components/customerPortal/subscriptionOverview/tabs/SubscriptionTabs.tsx +1 -1
- package/src/components/customerPortal/subscriptionOverview/upcomingBilling/NextEstimatedBill.tsx +2 -2
- package/src/components/customerPortal/subscriptionOverview/upcomingBilling/NoUpcomingBilling.tsx +1 -1
- package/src/components/customerPortal/usage/CustomerUsageData.tsx +4 -4
- package/src/components/customerPortal/usage/featureUsage/EntitlementCTAButton.tsx +3 -3
- package/src/components/customerPortal/usage/featureUsage/FeatureUsage.tsx +3 -3
- package/src/components/customerPortal/usage/featureUsage/FeatureUsageProgressBar.tsx +1 -1
- package/src/components/hooks/useWaitForCheckoutCompleted.ts +12 -4
- package/src/components/paywall/hooks/useLoadPaywallData.ts +4 -4
- package/src/components/paywall/utils/computeDefaultBillingPeriod.ts +1 -1
- package/src/components/paywall/utils/hasPricePoints.ts +5 -5
- package/src/components/utils/getFeatureName.ts +4 -4
- package/src/components/utils/getPaidPriceText.ts +4 -4
- package/src/components/utils/getPlanPrice.ts +2 -3
- package/src/components/utils/getSubscriptionScheduleUpdateTexts.tsx +1 -1
- package/src/components/utils/priceTierUtils.ts +13 -13
- package/src/components/utils/priceUtils.ts +2 -1
- package/src/custom.d.ts +1 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { PaywallPlan } from '../types';
|
|
2
1
|
import { BillingPeriod } from '@stigg/js-client-sdk';
|
|
3
|
-
|
|
4
|
-
export function hasPricePointsForPlans(plans: PaywallPlan[], billingPeriod: BillingPeriod): boolean {
|
|
5
|
-
return plans.some((plan) => hasPricePoints(plan, billingPeriod));
|
|
6
|
-
}
|
|
2
|
+
import { PaywallPlan } from '../types';
|
|
7
3
|
|
|
8
4
|
export function hasPricePoints(plan: PaywallPlan, billingPeriod: BillingPeriod): boolean {
|
|
9
5
|
return plan.pricePoints.some((pricePoint) => pricePoint.billingPeriod === billingPeriod);
|
|
10
6
|
}
|
|
7
|
+
|
|
8
|
+
export function hasPricePointsForPlans(plans: PaywallPlan[], billingPeriod: BillingPeriod): boolean {
|
|
9
|
+
return plans.some((plan) => hasPricePoints(plan, billingPeriod));
|
|
10
|
+
}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { FeatureFragment } from '@stigg/api-client-js/src/generated/sdk';
|
|
2
2
|
import lowercase from 'lodash/lowerCase';
|
|
3
3
|
|
|
4
|
-
export function getFeatureDisplayName(feature: FeatureFragment) {
|
|
5
|
-
return getFeatureDisplayNameText(feature.displayName, feature.featureUnits, feature.featureUnitsPlural);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
4
|
export function getFeatureDisplayNameText(
|
|
9
5
|
featureDisplayName: string,
|
|
10
6
|
featureUnits: string | undefined | null,
|
|
@@ -24,3 +20,7 @@ export function getFeatureDisplayNameText(
|
|
|
24
20
|
|
|
25
21
|
return `${featureDisplayName} (${featureUnitsPlural})`;
|
|
26
22
|
}
|
|
23
|
+
|
|
24
|
+
export function getFeatureDisplayName(feature: FeatureFragment) {
|
|
25
|
+
return getFeatureDisplayNameText(feature.displayName, feature.featureUnits, feature.featureUnitsPlural);
|
|
26
|
+
}
|
|
@@ -69,9 +69,9 @@ export function getPaidPriceText({
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
return {
|
|
72
|
-
price: currencyPriceFormatter({ amount: priceNumber, currency
|
|
73
|
-
unit
|
|
74
|
-
tiers
|
|
75
|
-
tierUnits
|
|
72
|
+
price: currencyPriceFormatter({ amount: priceNumber, currency, locale }),
|
|
73
|
+
unit,
|
|
74
|
+
tiers,
|
|
75
|
+
tierUnits,
|
|
76
76
|
};
|
|
77
77
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BillingPeriod, PriceTierFragment, PricingType } from '@stigg/js-client-sdk';
|
|
2
|
-
import { PaywallPlan } from '../paywall';
|
|
3
|
-
import { PaywallLocalization } from '../paywall';
|
|
2
|
+
import { PaywallPlan, PaywallLocalization } from '../paywall';
|
|
4
3
|
import { getPaidPriceText } from './getPaidPriceText';
|
|
5
4
|
|
|
6
5
|
export type PlanPriceText = {
|
|
@@ -24,7 +23,7 @@ export function getPlanPrice(
|
|
|
24
23
|
return paywallLocale.price.free(plan.paywallCurrency);
|
|
25
24
|
}
|
|
26
25
|
|
|
27
|
-
return paywallLocale.price.free
|
|
26
|
+
return paywallLocale.price.free;
|
|
28
27
|
case PricingType.Custom:
|
|
29
28
|
return {
|
|
30
29
|
price: paywallLocale.price.custom,
|
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
CustomerPortalSubscriptionScheduledUpdateDataFragment,
|
|
7
7
|
SubscriptionScheduleType,
|
|
8
8
|
} from '@stigg/js-client-sdk';
|
|
9
|
-
import { BillingPeriodChangeVariables, UnitAmountChangeVariables } from '../../types';
|
|
10
9
|
import { CustomerPortalSubscriptionPriceFragment } from '@stigg/api-client-js/src/generated/sdk';
|
|
11
10
|
import { compact, map } from 'lodash';
|
|
11
|
+
import { BillingPeriodChangeVariables, UnitAmountChangeVariables } from '../../types';
|
|
12
12
|
|
|
13
13
|
const formatDate = (date: string) => moment.utc(date).format('MMMM Do, yyyy');
|
|
14
14
|
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { PaywallPlan } from '../paywall/types';
|
|
2
|
-
|
|
3
1
|
import { BillingModel, TiersMode, BillingPeriod, Price, PriceTierFragment, Subscription } from '@stigg/js-client-sdk';
|
|
2
|
+
import { PaywallPlan } from '../paywall/types';
|
|
4
3
|
|
|
5
4
|
export function getPriceFeatureUnit(price: Price) {
|
|
6
5
|
if (!price.feature) {
|
|
7
6
|
return '';
|
|
8
7
|
}
|
|
9
8
|
|
|
10
|
-
return (price.feature
|
|
9
|
+
return (price.feature.unitQuantity !== 1 ? price.feature.unitsPlural : price.feature.units) || '';
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
export function getTierByQuantity(tiers: PriceTierFragment[], quantity: number) {
|
|
14
|
-
if (!tiers) return;
|
|
13
|
+
if (!tiers) return undefined;
|
|
15
14
|
|
|
16
15
|
const ascendingTiers = [...tiers];
|
|
17
16
|
ascendingTiers.sort((a, b) => a.upTo - b.upTo);
|
|
@@ -32,16 +31,17 @@ export function calculateTierPrice(
|
|
|
32
31
|
shouldShowMonthlyPriceAmount: boolean,
|
|
33
32
|
): number {
|
|
34
33
|
switch (price.tiersMode) {
|
|
35
|
-
case TiersMode.Volume:
|
|
34
|
+
case TiersMode.Volume: {
|
|
36
35
|
const unitPrice =
|
|
37
36
|
selectedBillingPeriod === BillingPeriod.Annually && shouldShowMonthlyPriceAmount
|
|
38
37
|
? currentTier.unitPrice.amount / 12
|
|
39
38
|
: currentTier.unitPrice.amount;
|
|
40
39
|
|
|
41
40
|
return unitPrice * currentTier.upTo;
|
|
41
|
+
}
|
|
42
|
+
default:
|
|
43
|
+
return 0;
|
|
42
44
|
}
|
|
43
|
-
|
|
44
|
-
return 0;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export function getSelectedTier(
|
|
@@ -54,9 +54,9 @@ export function getSelectedTier(
|
|
|
54
54
|
(price) => price.billingPeriod === billingPeriod && price.isTieredPrice,
|
|
55
55
|
);
|
|
56
56
|
|
|
57
|
-
if (planTierPrices.length
|
|
57
|
+
if (planTierPrices.length === 1) {
|
|
58
58
|
const [price] = planTierPrices;
|
|
59
|
-
const featureId = price.feature
|
|
59
|
+
const { featureId } = price.feature!;
|
|
60
60
|
|
|
61
61
|
let currentTier = price.tiers![0];
|
|
62
62
|
|
|
@@ -65,7 +65,7 @@ export function getSelectedTier(
|
|
|
65
65
|
} else if (currentSubscription) {
|
|
66
66
|
const tieredPrice = currentSubscription.prices.find(
|
|
67
67
|
(subscriptionPrice) =>
|
|
68
|
-
subscriptionPrice.pricingModel
|
|
68
|
+
subscriptionPrice.pricingModel === BillingModel.PerUnit &&
|
|
69
69
|
subscriptionPrice.tiersMode &&
|
|
70
70
|
subscriptionPrice.feature?.featureId === featureId,
|
|
71
71
|
);
|
|
@@ -99,7 +99,7 @@ export function compareSelectedTierToCurrentTier(
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
const currentTierPrice = currentSubscription.prices.find(
|
|
102
|
-
(price) => price.pricingModel
|
|
102
|
+
(price) => price.pricingModel === BillingModel.PerUnit && price.tiersMode,
|
|
103
103
|
);
|
|
104
104
|
if (!currentTierPrice) {
|
|
105
105
|
return PriceTierComparison.Equal;
|
|
@@ -116,11 +116,11 @@ export function compareSelectedTierToCurrentTier(
|
|
|
116
116
|
return PriceTierComparison.Equal;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
if (selectedTier.upTo < unitQuantity
|
|
119
|
+
if (selectedTier.upTo < unitQuantity) {
|
|
120
120
|
return PriceTierComparison.Lower;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
if (selectedTier.upTo > unitQuantity
|
|
123
|
+
if (selectedTier.upTo > unitQuantity) {
|
|
124
124
|
return PriceTierComparison.Higher;
|
|
125
125
|
}
|
|
126
126
|
|
|
@@ -3,7 +3,8 @@ import { Price } from '@stigg/js-client-sdk';
|
|
|
3
3
|
export const getValidPriceQuantity = (price: Price, quantity: number) => {
|
|
4
4
|
if (price.minUnitQuantity && quantity < price.minUnitQuantity) {
|
|
5
5
|
return price.minUnitQuantity;
|
|
6
|
-
}
|
|
6
|
+
}
|
|
7
|
+
if (price.maxUnitQuantity && quantity > price.maxUnitQuantity) {
|
|
7
8
|
return price.maxUnitQuantity;
|
|
8
9
|
}
|
|
9
10
|
return quantity;
|