@stigg/react-sdk 4.9.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.
Files changed (79) hide show
  1. package/dist/components/checkout/hooks/useAddonsStepModel.d.ts +2 -2
  2. package/dist/components/checkout/steps/addons/addon.utils.d.ts +3 -3
  3. package/dist/components/common/LongText.d.ts +3 -4
  4. package/dist/components/customerPortal/CustomerPortal.d.ts +1 -1
  5. package/dist/components/customerPortal/billing/InformationGrid.d.ts +1 -1
  6. package/dist/components/customerPortal/hooks/useCustomerPortal.d.ts +2 -2
  7. package/dist/components/customerPortal/subscriptionOverview/SubscriptionsOverviewHeader.d.ts +0 -2
  8. package/dist/components/customerPortal/subscriptionOverview/subscriptionView/SubscriptionView.d.ts +1 -1
  9. package/dist/components/customerPortal/usage/featureUsage/EntitlementCTAButton.d.ts +1 -1
  10. package/dist/components/paywall/hooks/useLoadPaywallData.d.ts +2 -2
  11. package/dist/components/paywall/utils/hasPricePoints.d.ts +2 -2
  12. package/dist/components/utils/getFeatureName.d.ts +1 -1
  13. package/dist/components/utils/getPlanPrice.d.ts +1 -2
  14. package/dist/components/utils/priceTierUtils.d.ts +1 -1
  15. package/dist/react-sdk.cjs.development.js +111 -85
  16. package/dist/react-sdk.cjs.development.js.map +1 -1
  17. package/dist/react-sdk.cjs.production.min.js +1 -1
  18. package/dist/react-sdk.cjs.production.min.js.map +1 -1
  19. package/dist/react-sdk.esm.js +111 -85
  20. package/dist/react-sdk.esm.js.map +1 -1
  21. package/package.json +7 -5
  22. package/src/components/checkout/CheckoutContainer.tsx +2 -0
  23. package/src/components/checkout/components/Button.tsx +4 -2
  24. package/src/components/checkout/hooks/useAddonsStepModel.ts +2 -2
  25. package/src/components/checkout/hooks/useCouponModel.ts +1 -1
  26. package/src/components/checkout/steps/addons/addon.utils.ts +30 -30
  27. package/src/components/common/LongText.tsx +2 -4
  28. package/src/components/common/PoweredByStigg.tsx +2 -3
  29. package/src/components/common/Typography.tsx +1 -1
  30. package/src/components/common/iconColor.ts +2 -4
  31. package/src/components/customerPortal/CustomerPortal.style.ts +2 -2
  32. package/src/components/customerPortal/CustomerPortal.tsx +1 -1
  33. package/src/components/customerPortal/CustomerPortalProvider.tsx +2 -2
  34. package/src/components/customerPortal/billing/InformationGrid.tsx +2 -3
  35. package/src/components/customerPortal/billing/InvoicesSection.tsx +9 -4
  36. package/src/components/customerPortal/billing/PaymentDetailsSection.tsx +3 -3
  37. package/src/components/customerPortal/common/ExternalLinkButton.tsx +3 -4
  38. package/src/components/customerPortal/common/SectionContainer.tsx +1 -1
  39. package/src/components/customerPortal/common/SectionHeader.ts +4 -2
  40. package/src/components/customerPortal/common/SectionTitle.tsx +2 -2
  41. package/src/components/customerPortal/common/SkeletonButton.tsx +1 -1
  42. package/src/components/customerPortal/hooks/useCustomerPortal.ts +3 -3
  43. package/src/components/customerPortal/subscriptionOverview/ContactCustomerSupport.tsx +5 -4
  44. package/src/components/customerPortal/subscriptionOverview/SubscriptionsOverview.tsx +3 -3
  45. package/src/components/customerPortal/subscriptionOverview/SubscriptionsOverviewHeader.tsx +4 -11
  46. package/src/components/customerPortal/subscriptionOverview/charges/ChargeItem.tsx +3 -3
  47. package/src/components/customerPortal/subscriptionOverview/charges/ChargeList.tsx +3 -3
  48. package/src/components/customerPortal/subscriptionOverview/subscriptionScheduledUpdates/SubscriptionScheduledUpdateRow.tsx +1 -1
  49. package/src/components/customerPortal/subscriptionOverview/subscriptionScheduledUpdates/SubscriptionScheduledUpdatesAlert.tsx +2 -2
  50. package/src/components/customerPortal/subscriptionOverview/subscriptionView/SubscriptionView.tsx +9 -5
  51. package/src/components/customerPortal/subscriptionOverview/subscriptionView/TrialPanel.tsx +2 -2
  52. package/src/components/customerPortal/subscriptionOverview/tabs/AddonsList.tsx +1 -1
  53. package/src/components/customerPortal/subscriptionOverview/tabs/Promotions.tsx +2 -2
  54. package/src/components/customerPortal/subscriptionOverview/tabs/SubscriptionTabs.tsx +3 -3
  55. package/src/components/customerPortal/subscriptionOverview/upcomingBilling/NextEstimatedBill.tsx +2 -2
  56. package/src/components/customerPortal/subscriptionOverview/upcomingBilling/NoUpcomingBilling.tsx +5 -3
  57. package/src/components/customerPortal/subscriptionOverview/upcomingBilling/UpcomingBilling.tsx +1 -1
  58. package/src/components/customerPortal/types.ts +2 -2
  59. package/src/components/customerPortal/usage/CustomerUsageData.tsx +4 -4
  60. package/src/components/customerPortal/usage/featureUsage/EntitlementCTAButton.tsx +13 -6
  61. package/src/components/customerPortal/usage/featureUsage/FeatureUsage.style.ts +1 -1
  62. package/src/components/customerPortal/usage/featureUsage/FeatureUsage.tsx +5 -7
  63. package/src/components/customerPortal/usage/featureUsage/FeatureUsageProgressBar.tsx +1 -1
  64. package/src/components/hooks/useChargeSort.ts +2 -2
  65. package/src/components/hooks/useWaitForCheckoutCompleted.ts +12 -4
  66. package/src/components/paywall/PlanEntitlements.tsx +4 -4
  67. package/src/components/paywall/hooks/useLoadPaywallData.ts +4 -4
  68. package/src/components/paywall/paywallTextOverrides.ts +2 -2
  69. package/src/components/paywall/utils/computeDefaultBillingPeriod.ts +2 -2
  70. package/src/components/paywall/utils/hasPricePoints.ts +6 -6
  71. package/src/components/utils/calculateDiscountRate.ts +3 -3
  72. package/src/components/utils/getFeatureName.ts +11 -7
  73. package/src/components/utils/getPaidPriceText.ts +4 -4
  74. package/src/components/utils/getPlanPrice.ts +4 -5
  75. package/src/components/utils/getSubscriptionScheduleUpdateTexts.tsx +1 -1
  76. package/src/components/utils/priceTierUtils.ts +18 -16
  77. package/src/components/utils/priceUtils.ts +2 -1
  78. package/src/custom.d.ts +1 -0
  79. package/src/types.ts +1 -1
@@ -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!.unitQuantity != 1 ? price.feature!.unitsPlural : price.feature!.units) || '';
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(
@@ -50,20 +50,22 @@ export function getSelectedTier(
50
50
  currentSubscription: Subscription | null,
51
51
  selectedTierByFeature: Record<string, PriceTierFragment>,
52
52
  ): Record<string, PriceTierFragment> {
53
- const planTierPrices = plan.pricePoints.filter(price => price.billingPeriod === billingPeriod && price.isTieredPrice);
53
+ const planTierPrices = plan.pricePoints.filter(
54
+ (price) => price.billingPeriod === billingPeriod && price.isTieredPrice,
55
+ );
54
56
 
55
- if (planTierPrices.length == 1) {
57
+ if (planTierPrices.length === 1) {
56
58
  const [price] = planTierPrices;
57
- const featureId = price.feature!.featureId;
59
+ const { featureId } = price.feature!;
58
60
 
59
61
  let currentTier = price.tiers![0];
60
62
 
61
63
  if (selectedTierByFeature[featureId]) {
62
- currentTier = price.tiers?.find(tier => tier.upTo === selectedTierByFeature[featureId].upTo) || currentTier;
64
+ currentTier = price.tiers?.find((tier) => tier.upTo === selectedTierByFeature[featureId].upTo) || currentTier;
63
65
  } else if (currentSubscription) {
64
66
  const tieredPrice = currentSubscription.prices.find(
65
- subscriptionPrice =>
66
- subscriptionPrice.pricingModel == BillingModel.PerUnit &&
67
+ (subscriptionPrice) =>
68
+ subscriptionPrice.pricingModel === BillingModel.PerUnit &&
67
69
  subscriptionPrice.tiersMode &&
68
70
  subscriptionPrice.feature?.featureId === featureId,
69
71
  );
@@ -97,7 +99,7 @@ export function compareSelectedTierToCurrentTier(
97
99
  }
98
100
 
99
101
  const currentTierPrice = currentSubscription.prices.find(
100
- price => price.pricingModel == BillingModel.PerUnit && price.tiersMode,
102
+ (price) => price.pricingModel === BillingModel.PerUnit && price.tiersMode,
101
103
  );
102
104
  if (!currentTierPrice) {
103
105
  return PriceTierComparison.Equal;
@@ -114,11 +116,11 @@ export function compareSelectedTierToCurrentTier(
114
116
  return PriceTierComparison.Equal;
115
117
  }
116
118
 
117
- if (selectedTier.upTo < unitQuantity!) {
119
+ if (selectedTier.upTo < unitQuantity) {
118
120
  return PriceTierComparison.Lower;
119
121
  }
120
122
 
121
- if (selectedTier.upTo > unitQuantity!) {
123
+ if (selectedTier.upTo > unitQuantity) {
122
124
  return PriceTierComparison.Higher;
123
125
  }
124
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
- } else if (price.maxUnitQuantity && quantity > price.maxUnitQuantity) {
6
+ }
7
+ if (price.maxUnitQuantity && quantity > price.maxUnitQuantity) {
7
8
  return price.maxUnitQuantity;
8
9
  }
9
10
  return quantity;
package/src/custom.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  declare module '*.svg' {
2
2
  import { ReactElement, SVGProps } from 'react';
3
+
3
4
  const content: (props: SVGProps<SVGElement>) => ReactElement;
4
5
  export default content;
5
6
  }
package/src/types.ts CHANGED
@@ -19,4 +19,4 @@ export type BillingPeriodChangeVariables = {
19
19
  export type UnitAmountChangeVariables = {
20
20
  newUnitAmount?: number;
21
21
  featureId: string;
22
- };
22
+ };