@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
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.9.0",
2
+ "version": "4.11.0",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -18,7 +18,8 @@
18
18
  "lint-fix": "yarn run lint --fix",
19
19
  "size": "size-limit",
20
20
  "analyze": "size-limit --why",
21
- "fix:prettier": "prettier \"src/**/*.ts\" --write",
21
+ "fix:prettier": "prettier \"src/**/*.(js|jsx|ts|tsx)\" --write",
22
+ "pretty-quick": "pretty-quick --staged --pattern 'src/**/*.*(js|jsx|ts|tsx)'",
22
23
  "storybook": "export NODE_OPTIONS=--openssl-legacy-provider && start-storybook -p 6006",
23
24
  "build-storybook": "build-storybook",
24
25
  "prepare": "husky install",
@@ -88,14 +89,15 @@
88
89
  "eslint-plugin-import": "^2.28.1",
89
90
  "eslint-plugin-jest": "^25.3.2",
90
91
  "eslint-plugin-jsx-a11y": "^6.3.1",
91
- "eslint-plugin-prettier": "^5.0.0",
92
+ "eslint-plugin-prettier": "^4.0.0",
92
93
  "eslint-plugin-react": "^7.28.0",
93
94
  "eslint-plugin-react-hooks": "^4.2.0",
94
95
  "eslint-plugin-unused-imports": "^2.0.0",
95
96
  "husky": "^7.0.4",
96
97
  "lint-staged": "^14.0.1",
97
98
  "postcss": "^8.4.24",
98
- "prettier": "^3.0.2",
99
+ "prettier": "^2.4.1",
100
+ "pretty-quick": "^3.1.3",
99
101
  "react": "^18.0.0",
100
102
  "react-dom": "^18.0.0",
101
103
  "rollup-plugin-postcss": "^4.0.2",
@@ -120,10 +122,10 @@
120
122
  "immer": "^10.0.2",
121
123
  "lodash": "^4.17.21",
122
124
  "lodash-es": "^4.17.21",
125
+ "lottie-react": "^2.4.0",
123
126
  "moment": "^2.29.4",
124
127
  "react-feather": "^2.0.10",
125
128
  "react-loading-skeleton": "^3.1.0",
126
- "lottie-react": "^2.4.0",
127
129
  "react-spinners": "^0.13.3",
128
130
  "react-switch": "^7.0.0",
129
131
  "styled-components": "^5.3.6",
@@ -102,7 +102,9 @@ export function CheckoutContainer({
102
102
  <>
103
103
  {isFreeDowngrade ? (
104
104
  <DowngradeToFreePlan
105
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
105
106
  freePlan={plan!}
107
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
106
108
  activeSubscription={activeSubscription!}
107
109
  allowChangePlan
108
110
  checkoutLocalization={checkoutLocalization}
@@ -12,7 +12,8 @@ const StyledButton = styled(MuiButton, { shouldForwardProp: (prop) => !prop.star
12
12
  background-color: ${({ theme, $success, $error }) => {
13
13
  if ($success) {
14
14
  return theme.stigg.palette.success;
15
- } else if ($error) {
15
+ }
16
+ if ($error) {
16
17
  return theme.stigg.palette.error;
17
18
  }
18
19
  return '';
@@ -22,7 +23,8 @@ const StyledButton = styled(MuiButton, { shouldForwardProp: (prop) => !prop.star
22
23
  background-color: ${({ theme, $success, $error }) => {
23
24
  if ($success) {
24
25
  return theme.stigg.palette.successDark;
25
- } else if ($error) {
26
+ }
27
+ if ($error) {
26
28
  return theme.stigg.palette.errorDark;
27
29
  }
28
30
  return '';
@@ -15,7 +15,7 @@ export type AddonsStepState = {
15
15
  availableAddons?: Addon[];
16
16
  };
17
17
 
18
- type getAddonsStepInitialStateProps = {
18
+ type GetAddonsStepInitialStateProps = {
19
19
  plan?: Plan;
20
20
  billingPeriod: BillingPeriod;
21
21
  activeSubscription?: Subscription | null;
@@ -27,7 +27,7 @@ export function getAddonsStepInitialState({
27
27
  plan,
28
28
  billingPeriod,
29
29
  billingCountryCode,
30
- }: getAddonsStepInitialStateProps): AddonsStepState {
30
+ }: GetAddonsStepInitialStateProps): AddonsStepState {
31
31
  let addons: SubscriptionAddon[] = [];
32
32
  const currency = plan?.pricePoints?.[0]?.currency || Currency.Usd;
33
33
  const availableAddons = sortAddons(
@@ -13,7 +13,7 @@ function useSetPromotionCode() {
13
13
  const [, setState] = useCheckoutContext();
14
14
 
15
15
  return (promotionCode: string) =>
16
- setState(draft => {
16
+ setState((draft) => {
17
17
  draft.promotionCode = promotionCode;
18
18
  });
19
19
  }
@@ -1,7 +1,7 @@
1
1
  import sortBy from 'lodash/sortBy';
2
2
  import { Addon, BillingPeriod, Currency, SubscriptionAddon } from '@stigg/js-client-sdk';
3
3
 
4
- type filterAddonsBaseProps = {
4
+ type FilterAddonsBaseProps = {
5
5
  billingPeriod: BillingPeriod;
6
6
  currency: Currency;
7
7
  billingCountryCode?: string;
@@ -15,16 +15,39 @@ export const sortSubscriptionAddons = (addons: SubscriptionAddon[]) => {
15
15
  return sortBy(addons, 'addon.displayName');
16
16
  };
17
17
 
18
+ function filterAddonPricePointsByBillingPeriod(addon: Addon, billingPeriod: BillingPeriod) {
19
+ return addon.pricePoints.some((pricePoint) => pricePoint.billingPeriod === billingPeriod);
20
+ }
21
+
22
+ function mapAddonPricePointsByBillingCountryCode({
23
+ addon,
24
+ currency,
25
+ billingCountryCode,
26
+ }: {
27
+ addon: Addon;
28
+ currency: Currency;
29
+ billingCountryCode?: string;
30
+ }) {
31
+ return {
32
+ ...addon,
33
+ pricePoints: addon.pricePoints.filter(
34
+ (pricePoint) =>
35
+ pricePoint.currency === currency &&
36
+ (billingCountryCode ? pricePoint.billingCountryCode === billingCountryCode : true),
37
+ ),
38
+ };
39
+ }
40
+
18
41
  export function filterAddons({
19
42
  addons,
20
43
  billingPeriod,
21
44
  billingCountryCode,
22
45
  currency,
23
- }: { addons?: Addon[] } & filterAddonsBaseProps): Addon[] {
46
+ }: { addons?: Addon[] } & FilterAddonsBaseProps): Addon[] {
24
47
  return (
25
48
  addons
26
- ?.filter(addon => filterAddonPricePointsByBillingPeriod(addon, billingPeriod))
27
- ?.map(addon => mapAddonPricePointsByBillingCountryCode({ addon, currency, billingCountryCode })) || []
49
+ ?.filter((addon) => filterAddonPricePointsByBillingPeriod(addon, billingPeriod))
50
+ ?.map((addon) => mapAddonPricePointsByBillingCountryCode({ addon, currency, billingCountryCode })) || []
28
51
  );
29
52
  }
30
53
 
@@ -33,36 +56,13 @@ export function filterSubscriptionAddons({
33
56
  billingPeriod,
34
57
  billingCountryCode,
35
58
  currency,
36
- }: { addons?: SubscriptionAddon[] } & filterAddonsBaseProps): SubscriptionAddon[] {
59
+ }: { addons?: SubscriptionAddon[] } & FilterAddonsBaseProps): SubscriptionAddon[] {
37
60
  return (
38
61
  addons
39
- ?.filter(addon => filterAddonPricePointsByBillingPeriod(addon.addon, billingPeriod))
40
- ?.map(addon => ({
62
+ ?.filter((addon) => filterAddonPricePointsByBillingPeriod(addon.addon, billingPeriod))
63
+ ?.map((addon) => ({
41
64
  ...addon,
42
65
  addon: mapAddonPricePointsByBillingCountryCode({ addon: addon.addon, currency, billingCountryCode }),
43
66
  })) || []
44
67
  );
45
68
  }
46
-
47
- function filterAddonPricePointsByBillingPeriod(addon: Addon, billingPeriod: BillingPeriod) {
48
- return addon.pricePoints.some(pricePoint => pricePoint.billingPeriod === billingPeriod);
49
- }
50
-
51
- function mapAddonPricePointsByBillingCountryCode({
52
- addon,
53
- currency,
54
- billingCountryCode,
55
- }: {
56
- addon: Addon;
57
- currency: Currency;
58
- billingCountryCode?: string;
59
- }) {
60
- return {
61
- ...addon,
62
- pricePoints: addon.pricePoints.filter(
63
- pricePoint =>
64
- pricePoint.currency === currency &&
65
- (billingCountryCode ? pricePoint.billingCountryCode === billingCountryCode : true),
66
- ),
67
- };
68
- }
@@ -1,8 +1,7 @@
1
- import { CSSProperties, ReactNode, useEffect, useRef, useState } from 'react';
1
+ import React, { CSSProperties, ReactNode, useEffect, useRef, useState } from 'react';
2
2
  import styled, { css } from 'styled-components';
3
3
  import { TooltipProps } from '@mui/material/Tooltip';
4
4
  import { InformationTooltip } from './InformationTooltip';
5
- import React from 'react';
6
5
  import { Typography, TypographyProps } from './Typography';
7
6
 
8
7
  const StyledText = styled(Typography)<{ $maxLines: number; $wordBreak?: boolean; $display: string; $bold?: boolean }>`
@@ -41,7 +40,7 @@ export const LongText = ({
41
40
  className,
42
41
  display = '-webkit-box',
43
42
  style,
44
- ['data-testid']: dataTestId,
43
+ 'data-testid': dataTestId,
45
44
  }: {
46
45
  children: ReactNode;
47
46
  leaveDelay?: number;
@@ -54,7 +53,6 @@ export const LongText = ({
54
53
  className?: string;
55
54
  display?: string;
56
55
  style?: CSSProperties;
57
- leftMargin?: boolean;
58
56
  ['data-testid']?: string;
59
57
  }) => {
60
58
  const [isTextClamped, setIsTextClamped] = useState(false);
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import PoweredByStiggSvg from '../../assets/powered-by-stigg.svg';
3
2
  import styled from '@emotion/styled/macro';
3
+ import PoweredByStiggSvg from '../../assets/powered-by-stigg.svg';
4
4
 
5
5
  export const STIGG_WATERMARK_CLASSNAME = 'stigg-watermark';
6
6
 
@@ -45,8 +45,7 @@ export function PoweredByStigg({ source, showWatermark, align, style = {} }: Pow
45
45
  $alignSelf={align}
46
46
  className={STIGG_WATERMARK_CLASSNAME}
47
47
  style={{ cursor: 'pointer', ...style }}
48
- onClick={onWatermarkClick}
49
- >
48
+ onClick={onWatermarkClick}>
50
49
  <PoweredByStiggThemedSvg />
51
50
  </StyledPoweredByStigg>
52
51
  );
@@ -107,7 +107,7 @@ export const Typography = forwardRef((props: TypographyProps, ref) => {
107
107
  bold,
108
108
  ...rest
109
109
  } = props;
110
- const theme = useTheme() as Theme;
110
+ const theme = useTheme();
111
111
  const level = getLevel(variant);
112
112
  const levelClassName = `typography-level-${level}`;
113
113
  const className = props.className ? `${props.className} ${levelClassName}` : levelClassName;
@@ -1,10 +1,8 @@
1
1
  import { Theme } from '@emotion/react';
2
2
 
3
- export type IconColor =
4
- | 'primary'
5
- | 'secondary'
3
+ export type IconColor = 'primary' | 'secondary';
6
4
 
7
- export const getIconColor = (color: IconColor | string | undefined, theme: Theme ) => {
5
+ export const getIconColor = (color: IconColor | string | undefined, theme: Theme) => {
8
6
  switch (color) {
9
7
  case 'primary':
10
8
  return theme.stigg.palette.text.primary;
@@ -5,7 +5,7 @@ export const CustomerPortalLayout = styled.div`
5
5
  display: flex;
6
6
  flex-direction: column;
7
7
  align-items: center;
8
-
8
+
9
9
  & * {
10
10
  box-sizing: border-box;
11
11
  }
@@ -17,4 +17,4 @@ export const CustomerPortalSections = styled.div`
17
17
  flex-direction: column;
18
18
  align-items: center;
19
19
  row-gap: 24px;
20
- `;
20
+ `;
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
+ import { CustomerPortalSubscription } from '@stigg/js-client-sdk';
2
3
  import { CustomerPortalProvider } from './CustomerPortalProvider';
3
4
  import { CustomerPortalContainer } from './CustomerPortalContainer';
4
5
  import { DeepPartial } from '../../types';
5
6
  import { CustomerPortalLocalization } from './customerPortalTextOverrides';
6
7
  import { CustomerPortalTheme } from './customerPortalTheme';
7
- import { CustomerPortalSubscription } from '@stigg/js-client-sdk';
8
8
  import { OnBuyMoreCallbackFn } from './types';
9
9
 
10
10
  export type CustomerPortalSection =
@@ -7,6 +7,7 @@ import { CustomerPortalTheme, getResolvedCustomerPortalTheme } from './customerP
7
7
  import { SdkThemeProvider, useStiggTheme } from '../../theme/Theme';
8
8
  import { useStiggContext } from '../..';
9
9
  import { mapCustomerPortalConfiguration } from '../common/mapExternalTheme';
10
+
10
11
  export interface CustomerPortalContextValue {
11
12
  customerPortal?: CustomerPortal | null;
12
13
  textOverrides: CustomerPortalLocalization;
@@ -65,8 +66,7 @@ export function CustomerPortalProvider({
65
66
  textOverrides: resolvedTextOverrides,
66
67
  theme: customerPortalTheme,
67
68
  resourceId,
68
- }}
69
- >
69
+ }}>
70
70
  {children}
71
71
  </CustomerPortalContext.Provider>
72
72
  </SdkThemeProvider>
@@ -1,7 +1,7 @@
1
1
  import styled from '@emotion/styled/macro';
2
- import { Typography, TypographyProps } from '../../common/Typography';
3
2
  import React from 'react';
4
3
  import { FontWeight } from 'styled-typography';
4
+ import { Typography, TypographyProps } from '../../common/Typography';
5
5
 
6
6
  export const InformationGridContainer = styled.div`
7
7
  display: flex;
@@ -42,8 +42,7 @@ export function InformationGrid({ title, rows }: InformationGridProps) {
42
42
  variant="body1"
43
43
  color="secondary"
44
44
  style={{ width: 80 }}
45
- {...labelTypographyProps}
46
- >
45
+ {...labelTypographyProps}>
47
46
  {label}
48
47
  </Typography>
49
48
  <Typography className={`${classNamePrefix}-text`} variant="body1" color="secondary" {...valueTypographyProps}>
@@ -10,7 +10,9 @@ export function InvoicesSection() {
10
10
  const { customerPortal, isLoading, textOverrides, theme } = useCustomerPortalContext();
11
11
  const isLoadingData = !customerPortal || isLoading;
12
12
 
13
- const viewInvoiceHistoryButton = isLoadingData ? <SkeletonButton /> : customerPortal?.billingPortalUrl ? (
13
+ const viewInvoiceHistoryButton = isLoadingData ? (
14
+ <SkeletonButton />
15
+ ) : customerPortal?.billingPortalUrl ? (
14
16
  <ExternalLinkButton
15
17
  url={customerPortal.billingPortalUrl}
16
18
  text={textOverrides.viewInvoiceHistory}
@@ -26,10 +28,13 @@ export function InvoicesSection() {
26
28
  <SectionContainer
27
29
  className="stigg-invoices-section-layout"
28
30
  $backgroundColor={theme.backgroundColor}
29
- $borderColor={theme.borderColor}
30
- >
31
+ $borderColor={theme.borderColor}>
31
32
  <SectionHeader className="stigg-invoices-section-header">
32
- <SectionTitle isLoading={isLoadingData} className="stigg-invoices-section-title" title={textOverrides.invoicesTitle} />
33
+ <SectionTitle
34
+ isLoading={isLoadingData}
35
+ className="stigg-invoices-section-title"
36
+ title={textOverrides.invoicesTitle}
37
+ />
33
38
  {viewInvoiceHistoryButton}
34
39
  </SectionHeader>
35
40
  </SectionContainer>
@@ -1,14 +1,14 @@
1
1
  import React, { ReactElement } from 'react';
2
+ import Divider from '@mui/material/Divider';
3
+ import { padStart } from 'lodash';
4
+ import Skeleton from 'react-loading-skeleton';
2
5
  import { useCustomerPortalContext } from '../CustomerPortalProvider';
3
6
  import { SectionTitle } from '../common/SectionTitle';
4
7
  import { SectionContainer } from '../common/SectionContainer';
5
8
  import { ExternalLinkButton } from '../common/ExternalLinkButton';
6
- import Divider from '@mui/material/Divider';
7
9
  import { InformationGrid, InformationGridContainer } from './InformationGrid';
8
- import { padStart } from 'lodash';
9
10
  import { SectionHeader } from '../common/SectionHeader';
10
11
  import { SkeletonButton } from '../common/SkeletonButton';
11
- import Skeleton from 'react-loading-skeleton';
12
12
 
13
13
  export const EMPTY_CHAR = '-';
14
14
 
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import styled from '@emotion/styled/macro';
3
+ import { ExternalLink as ExternalLinkIcon } from 'react-feather';
3
4
  import { Typography } from '../../common/Typography';
4
5
  import { StyledButton } from './StyledButton';
5
- import { ExternalLink as ExternalLinkIcon } from 'react-feather';
6
6
 
7
7
  const ExternalLinkText = styled(Typography)`
8
8
  text-transform: none;
@@ -28,9 +28,8 @@ export function ExternalLinkButton({ text, url, className }: ExternalLinkButtonP
28
28
  className={className}
29
29
  variant="outlined"
30
30
  startIcon={<LinkIcon size={20} strokeWidth={2.5} />}
31
- onClick={onClick}
32
- >
31
+ onClick={onClick}>
33
32
  <ExternalLinkText color="primary.main">{text}</ExternalLinkText>
34
33
  </StyledButton>
35
34
  );
36
- }
35
+ }
@@ -8,4 +8,4 @@ export const SectionContainer = styled.div<{ $backgroundColor: string; $borderCo
8
8
  background-color: ${({ $backgroundColor }) => $backgroundColor};
9
9
  border: ${({ $borderColor }) => `1px solid ${$borderColor}`};
10
10
  padding: 64px;
11
- `;
11
+ `;
@@ -5,9 +5,11 @@ export const SectionHeader = styled.div<{ $disableMargin?: boolean }>`
5
5
  align-items: center;
6
6
  justify-content: space-between;
7
7
 
8
- ${({ $disableMargin }) => !$disableMargin && `
8
+ ${({ $disableMargin }) =>
9
+ !$disableMargin &&
10
+ `
9
11
  &:not(:last-child) {
10
12
  margin-bottom: 32px;
11
13
  }
12
14
  `};
13
- `;
15
+ `;
@@ -1,7 +1,7 @@
1
- import { Typography } from '../../common/Typography';
2
1
  import React from 'react';
3
- import { useCustomerPortalContext } from '../CustomerPortalProvider';
4
2
  import Skeleton from 'react-loading-skeleton';
3
+ import { Typography } from '../../common/Typography';
4
+ import { useCustomerPortalContext } from '../CustomerPortalProvider';
5
5
 
6
6
  export type SectionTitleProps = {
7
7
  title: string;
@@ -3,4 +3,4 @@ import React from 'react';
3
3
 
4
4
  export function SkeletonButton() {
5
5
  return <Skeleton width={220} height={42} />;
6
- }
6
+ }
@@ -3,12 +3,12 @@ import { useEffect, useState } from 'react';
3
3
  import logger from '../../../services/logger';
4
4
  import { useStiggContext } from '../../StiggProvider';
5
5
 
6
- type useCustomerPortalProps = {
6
+ type UseCustomerPortalProps = {
7
7
  resourceId?: string;
8
8
  productId?: string;
9
9
  };
10
10
 
11
- export function useCustomerPortal({ resourceId, productId }: useCustomerPortalProps) {
11
+ export function useCustomerPortal({ resourceId, productId }: UseCustomerPortalProps) {
12
12
  const { stigg, customerPortalUpdatedAt } = useStiggContext();
13
13
  const [isLoading, setIsLoading] = useState(false);
14
14
  const [customerPortal, setCustomerPortal] = useState<CustomerPortal | null>();
@@ -29,7 +29,7 @@ export function useCustomerPortal({ resourceId, productId }: useCustomerPortalPr
29
29
  };
30
30
 
31
31
  void loadCustomerPortal();
32
- }, [stigg, stigg.isCustomerLoaded, customerPortalUpdatedAt, resourceId]);
32
+ }, [stigg, stigg.isCustomerLoaded, customerPortalUpdatedAt, resourceId, productId]);
33
33
 
34
34
  return {
35
35
  customerPortal,
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
- import { Typography } from '../../common/Typography';
3
2
  import styled from '@emotion/styled/macro';
4
3
  import Button from '@mui/material/Button';
4
+ import { Typography } from '../../common/Typography';
5
5
 
6
6
  const ContactCustomerSupportLayout = styled.div`
7
7
  display: flex;
@@ -27,7 +27,9 @@ type ContactCustomerSupportProps = {
27
27
  };
28
28
 
29
29
  export function ContactCustomerSupport({ onContactSupport, label, linkLabel }: ContactCustomerSupportProps) {
30
- let contactSupportText = <Typography color={onContactSupport ? 'primary.main' : 'secondary'}>{linkLabel}</Typography>;
30
+ const contactSupportText = (
31
+ <Typography color={onContactSupport ? 'primary.main' : 'secondary'}>{linkLabel}</Typography>
32
+ );
31
33
  return (
32
34
  <ContactCustomerSupportLayout className="stigg-contact-support-layout">
33
35
  <Typography className="stigg-contact-support-label" color="secondary">
@@ -38,8 +40,7 @@ export function ContactCustomerSupport({ onContactSupport, label, linkLabel }: C
38
40
  className="stigg-contact-support-button"
39
41
  style={{ textTransform: 'none' }}
40
42
  variant="text"
41
- onClick={onContactSupport}
42
- >
43
+ onClick={onContactSupport}>
43
44
  {contactSupportText}
44
45
  </ContactSupportButton>
45
46
  ) : (
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
+ import { CustomerPortalSubscription, PricingType, SubscriptionStatus } from '@stigg/js-client-sdk';
2
3
  import { SubscriptionsOverviewHeader } from './SubscriptionsOverviewHeader';
3
4
  import { SubscriptionTabs } from './tabs/SubscriptionTabs';
4
5
  import { useCustomerPortalContext } from '../CustomerPortalProvider';
5
- import { CustomerPortalSubscription, PricingType, SubscriptionStatus } from '@stigg/js-client-sdk';
6
6
  import { SubscriptionOverviewLoader } from './SubscriptionOverviewLoader';
7
7
  import { CustomerPortalSection } from '../CustomerPortal';
8
8
  import { SubscriptionScheduledUpdatesAlert } from './subscriptionScheduledUpdates/SubscriptionScheduledUpdatesAlert';
@@ -42,8 +42,7 @@ export function SubscriptionsOverview({
42
42
  <SectionContainer
43
43
  className="stigg-customer-portal-subscriptions-overview"
44
44
  $backgroundColor={theme.backgroundColor}
45
- $borderColor={theme.borderColor}
46
- >
45
+ $borderColor={theme.borderColor}>
47
46
  {!isLoadingData && activeSubscription && activeSubscription.scheduledUpdates && (
48
47
  <SubscriptionScheduledUpdatesAlert
49
48
  theme={theme}
@@ -83,6 +82,7 @@ export function SubscriptionsOverview({
83
82
  )}
84
83
 
85
84
  <SubscriptionTabs
85
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
86
86
  customerPortal={customerPortal!}
87
87
  hiddenSections={hiddenSections}
88
88
  textOverrides={textOverrides}
@@ -1,15 +1,13 @@
1
1
  import React from 'react';
2
- import { CustomerPortal } from '@stigg/js-client-sdk';
2
+ import styled from '@emotion/styled/macro';
3
3
  import { StyledButton } from '../common/StyledButton';
4
4
  import { Typography } from '../../common/Typography';
5
5
  import EditIcon from '../../../assets/edit-icon.svg';
6
6
  import { CustomerPortalLocalization } from '../customerPortalTextOverrides';
7
- import styled from '@emotion/styled/macro';
8
7
  import { SectionHeader } from '../common/SectionHeader';
9
8
  import { SectionTitle } from '../common/SectionTitle';
10
9
 
11
10
  type SubscriptionsOverviewHeaderProps = {
12
- customerPortal?: CustomerPortal | null;
13
11
  onManageSubscription: () => void;
14
12
  hideManageButton: boolean;
15
13
  textOverrides: CustomerPortalLocalization;
@@ -28,20 +26,15 @@ export function SubscriptionsOverviewHeader({
28
26
  }: SubscriptionsOverviewHeaderProps) {
29
27
  return (
30
28
  <SectionHeader className="stigg-customer-portal-overview-header" $disableMargin>
31
- <SectionTitle title='Subscription' className="stigg-overview-title" />
29
+ <SectionTitle title="Subscription" className="stigg-overview-title" />
32
30
  {!hideManageButton && (
33
- <StyledButton
34
- className="stigg-manage-subscription-button"
35
- variant="outlined"
36
- onClick={onManageSubscription}
37
- >
31
+ <StyledButton className="stigg-manage-subscription-button" variant="outlined" onClick={onManageSubscription}>
38
32
  <StyledEditIcon className="stigg-manage-subscription-button-image" />
39
33
  <Typography
40
34
  className="stigg-manage-subscription-button-text"
41
35
  color="primary.main"
42
36
  style={{ marginLeft: '8px' }}
43
- variant="body1"
44
- >
37
+ variant="body1">
45
38
  {textOverrides?.manageSubscription}
46
39
  </Typography>
47
40
  </StyledButton>
@@ -1,10 +1,10 @@
1
1
  import { Currency, CustomerPortalEntitlement } from '@stigg/js-client-sdk';
2
2
  import React from 'react';
3
+ import { FeatureFragment } from '@stigg/api-client-js/src/generated/sdk';
3
4
  import { Typography } from '../../../common/Typography';
4
5
  import { currencyPriceFormatter } from '../../../utils/currencyUtils';
5
6
  import { FeatureUsageProgressBar } from '../../usage/featureUsage/FeatureUsageProgressBar';
6
7
  import { LongText } from '../../../common/LongText';
7
- import { FeatureFragment } from '@stigg/api-client-js/src/generated/sdk';
8
8
  import { EntitlementCtaButton } from '../../usage/featureUsage/EntitlementCTAButton';
9
9
  import { OnBuyMoreCallbackFn } from '../../types';
10
10
 
@@ -32,7 +32,7 @@ export function ChargeItem({
32
32
  hasCustomSubscription,
33
33
  }: UsageBasedChargeProps) {
34
34
  return (
35
- <div className='stigg-charge-list-item' style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
35
+ <div className="stigg-charge-list-item" style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
36
36
  <div style={{ display: 'flex', justifyContent: 'space-between', gap: 12 }}>
37
37
  <div style={{ display: 'flex', gap: 12 }}>
38
38
  <LongText variant="body1" color="primary">
@@ -49,7 +49,7 @@ export function ChargeItem({
49
49
  <EntitlementCtaButton
50
50
  entitlement={entitlement}
51
51
  feature={feature}
52
- canBuyMore={true}
52
+ canBuyMore
53
53
  onBuyMore={onBuyMore}
54
54
  onManageSubscription={onManageSubscription}
55
55
  canUpgradeSubscription={canUpgradeSubscription}
@@ -1,7 +1,7 @@
1
1
  import { BillingModel, CustomerPortalEntitlement, CustomerPortalSubscription } from '@stigg/js-client-sdk';
2
- import { ChargeItem } from './ChargeItem';
3
2
  import React from 'react';
4
3
  import { keyBy } from 'lodash';
4
+ import { ChargeItem } from './ChargeItem';
5
5
  import { OnBuyMoreCallbackFn } from '../../types';
6
6
 
7
7
  export type ChargesProps = {
@@ -32,7 +32,7 @@ export function ChargeList({
32
32
  }
33
33
 
34
34
  return (
35
- <div className='stigg-charge-list' style={{ display: 'flex', flexDirection: 'column', gap: 16, marginTop: 32 }}>
35
+ <div className="stigg-charge-list" style={{ display: 'flex', flexDirection: 'column', gap: 16, marginTop: 32 }}>
36
36
  {filteredSubscriptionPrices.map(({ feature, price, billingModel }) => {
37
37
  if (!feature || !price) {
38
38
  return null;
@@ -46,7 +46,7 @@ export function ChargeList({
46
46
 
47
47
  return (
48
48
  <ChargeItem
49
- key={feature!.refId}
49
+ key={feature.refId}
50
50
  entitlement={entitlement}
51
51
  feature={entitlement.feature}
52
52
  amount={price.amount}
@@ -7,9 +7,9 @@ import {
7
7
  SubscriptionScheduleType,
8
8
  BillingPeriod,
9
9
  } from '@stigg/js-client-sdk';
10
+ import { compact, map } from 'lodash';
10
11
  import { Typography } from '../../../common/Typography';
11
12
  import { BillingPeriodChangeVariables, UnitAmountChangeVariables } from '../../../../types';
12
- import { compact, map } from 'lodash';
13
13
 
14
14
  export type SubscriptionScheduledUpdateRowProps = {
15
15
  scheduleUpdate: CustomerPortalSubscriptionScheduledUpdateDataFragment;