@stigg/react-sdk 4.14.0 → 4.15.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/customerPortal/CustomerPortal.d.ts +2 -2
- package/dist/components/customerPortal/CustomerPortalContainer.d.ts +4 -0
- package/dist/components/customerPortal/index.d.ts +3 -0
- package/dist/components/customerPortal/subscriptionOverview/SubscriptionsOverview.d.ts +2 -1
- package/dist/components/customerPortal/subscriptionOverview/SubscriptionsOverviewHeader.d.ts +2 -1
- package/dist/components/customerPortal/subscriptionOverview/charges/ChargeItem.d.ts +2 -1
- package/dist/components/customerPortal/subscriptionOverview/charges/ChargeList.d.ts +2 -1
- package/dist/components/customerPortal/subscriptionOverview/subscriptionView/SubscriptionView.d.ts +2 -1
- package/dist/components/customerPortal/subscriptionOverview/subscriptionView/TrialPanel.d.ts +2 -1
- package/dist/components/customerPortal/types.d.ts +10 -1
- package/dist/components/customerPortal/usage/CustomerUsageData.d.ts +2 -1
- package/dist/components/customerPortal/usage/featureUsage/EntitlementCTAButton.d.ts +2 -1
- package/dist/components/customerPortal/usage/featureUsage/FeatureUsage.d.ts +2 -1
- package/dist/components/paywall/index.d.ts +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/react-sdk.cjs.development.js +33 -9
- 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 +36 -10
- package/dist/react-sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/customerPortal/CustomerPortal.tsx +2 -2
- package/src/components/customerPortal/CustomerPortalContainer.tsx +8 -3
- package/src/components/customerPortal/index.ts +3 -0
- package/src/components/customerPortal/subscriptionOverview/SubscriptionsOverview.tsx +2 -1
- package/src/components/customerPortal/subscriptionOverview/SubscriptionsOverviewHeader.tsx +7 -2
- package/src/components/customerPortal/subscriptionOverview/charges/ChargeItem.tsx +2 -1
- package/src/components/customerPortal/subscriptionOverview/charges/ChargeList.tsx +2 -1
- package/src/components/customerPortal/subscriptionOverview/subscriptionView/SubscriptionView.tsx +2 -1
- package/src/components/customerPortal/subscriptionOverview/subscriptionView/TrialPanel.tsx +6 -2
- package/src/components/customerPortal/types.ts +15 -1
- package/src/components/customerPortal/usage/CustomerUsageData.tsx +2 -1
- package/src/components/customerPortal/usage/featureUsage/EntitlementCTAButton.tsx +6 -3
- package/src/components/customerPortal/usage/featureUsage/FeatureUsage.tsx +2 -1
- package/src/components/paywall/index.ts +1 -1
- package/src/index.ts +9 -1
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ import { CustomerPortalContainer } from './CustomerPortalContainer';
|
|
|
5
5
|
import { DeepPartial } from '../../types';
|
|
6
6
|
import { CustomerPortalLocalization } from './customerPortalTextOverrides';
|
|
7
7
|
import { CustomerPortalTheme } from './customerPortalTheme';
|
|
8
|
-
import { OnBuyMoreCallbackFn } from './types';
|
|
8
|
+
import { OnBuyMoreCallbackFn, OnManageSubscriptionFn } from './types';
|
|
9
9
|
|
|
10
10
|
export type CustomerPortalSection =
|
|
11
11
|
| 'usage'
|
|
@@ -16,7 +16,7 @@ export type CustomerPortalSection =
|
|
|
16
16
|
| 'invoices';
|
|
17
17
|
|
|
18
18
|
export type CustomerPortalProps = {
|
|
19
|
-
onManageSubscription?:
|
|
19
|
+
onManageSubscription?: OnManageSubscriptionFn;
|
|
20
20
|
onBuyMore?: OnBuyMoreCallbackFn;
|
|
21
21
|
onCancelScheduledUpdates?: (subscription: CustomerPortalSubscription) => Promise<void> | void;
|
|
22
22
|
onContactSupport?: () => Promise<void> | void;
|
|
@@ -8,6 +8,9 @@ import { CustomerPortalLayout, CustomerPortalSections } from './CustomerPortal.s
|
|
|
8
8
|
import { CustomerPortalProps } from './CustomerPortal';
|
|
9
9
|
import { InvoicesSection, useStiggContext } from '../..';
|
|
10
10
|
import { CustomerUsageData } from './usage/CustomerUsageData';
|
|
11
|
+
import { CustomerPortalIntentionType } from './types';
|
|
12
|
+
|
|
13
|
+
export type OnManageClick = ({ intentionType }: { intentionType: CustomerPortalIntentionType }) => void;
|
|
11
14
|
|
|
12
15
|
export function CustomerPortalContainer({
|
|
13
16
|
onManageSubscription,
|
|
@@ -21,10 +24,12 @@ export function CustomerPortalContainer({
|
|
|
21
24
|
const { customerPortal, textOverrides, theme, isLoading } = useCustomerPortalContext();
|
|
22
25
|
const customerPortalSectionRef = useRef<HTMLDivElement>(null);
|
|
23
26
|
|
|
24
|
-
const onManageClick = () => {
|
|
27
|
+
const onManageClick: OnManageClick = ({ intentionType }: { intentionType: CustomerPortalIntentionType }) => {
|
|
25
28
|
if (onManageSubscription) {
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
void onManageSubscription({
|
|
30
|
+
intentionType,
|
|
31
|
+
customerSubscriptions: customerPortal?.subscriptions ?? [],
|
|
32
|
+
});
|
|
28
33
|
} else {
|
|
29
34
|
customerPortalSectionRef?.current?.scrollIntoView({ behavior: 'smooth' });
|
|
30
35
|
}
|
|
@@ -6,3 +6,6 @@ export { CustomerUsageData, CustomerUsageDataProps } from './usage/CustomerUsage
|
|
|
6
6
|
export { AddonsList } from './subscriptionOverview/tabs/AddonsList';
|
|
7
7
|
export { Promotions } from './subscriptionOverview/tabs/Promotions';
|
|
8
8
|
export { CustomerPortalProvider } from './CustomerPortalProvider';
|
|
9
|
+
export { CustomerPortalLocalization } from './customerPortalTextOverrides';
|
|
10
|
+
export { CustomerPortalTheme } from './customerPortalTheme';
|
|
11
|
+
export * from './types';
|
|
@@ -11,9 +11,10 @@ import { UpcomingBilling } from './upcomingBilling/UpcomingBilling';
|
|
|
11
11
|
import { SubscriptionView } from './subscriptionView/SubscriptionView';
|
|
12
12
|
import { ChargeList } from './charges/ChargeList';
|
|
13
13
|
import { OnBuyMoreCallbackFn } from '../types';
|
|
14
|
+
import { OnManageClick } from '../CustomerPortalContainer';
|
|
14
15
|
|
|
15
16
|
export type SubscriptionsOverviewProps = {
|
|
16
|
-
onManageSubscription:
|
|
17
|
+
onManageSubscription: OnManageClick;
|
|
17
18
|
onBuyMore?: OnBuyMoreCallbackFn;
|
|
18
19
|
onCancelScheduledUpdates?: (subscription: CustomerPortalSubscription) => void;
|
|
19
20
|
onContactSupport?: () => void;
|
|
@@ -6,9 +6,11 @@ import EditIcon from '../../../assets/edit-icon.svg';
|
|
|
6
6
|
import { CustomerPortalLocalization } from '../customerPortalTextOverrides';
|
|
7
7
|
import { SectionHeader } from '../common/SectionHeader';
|
|
8
8
|
import { SectionTitle } from '../common/SectionTitle';
|
|
9
|
+
import { OnManageClick } from '../CustomerPortalContainer';
|
|
10
|
+
import { CustomerPortalIntentionType } from '../types';
|
|
9
11
|
|
|
10
12
|
type SubscriptionsOverviewHeaderProps = {
|
|
11
|
-
onManageSubscription:
|
|
13
|
+
onManageSubscription: OnManageClick;
|
|
12
14
|
hideManageButton: boolean;
|
|
13
15
|
textOverrides: CustomerPortalLocalization;
|
|
14
16
|
};
|
|
@@ -28,7 +30,10 @@ export function SubscriptionsOverviewHeader({
|
|
|
28
30
|
<SectionHeader className="stigg-customer-portal-overview-header" $disableMargin>
|
|
29
31
|
<SectionTitle title="Subscription" className="stigg-overview-title" />
|
|
30
32
|
{!hideManageButton && (
|
|
31
|
-
<StyledButton
|
|
33
|
+
<StyledButton
|
|
34
|
+
className="stigg-manage-subscription-button"
|
|
35
|
+
variant="outlined"
|
|
36
|
+
onClick={() => onManageSubscription({ intentionType: CustomerPortalIntentionType.MANAGE_SUBSCRIPTION })}>
|
|
32
37
|
<StyledEditIcon className="stigg-manage-subscription-button-image" />
|
|
33
38
|
<Typography
|
|
34
39
|
className="stigg-manage-subscription-button-text"
|
|
@@ -7,6 +7,7 @@ import { FeatureUsageProgressBar } from '../../usage/featureUsage/FeatureUsagePr
|
|
|
7
7
|
import { LongText } from '../../../common/LongText';
|
|
8
8
|
import { EntitlementCtaButton } from '../../usage/featureUsage/EntitlementCTAButton';
|
|
9
9
|
import { OnBuyMoreCallbackFn } from '../../types';
|
|
10
|
+
import { OnManageClick } from '../../CustomerPortalContainer';
|
|
10
11
|
|
|
11
12
|
export type UsageBasedChargeProps = {
|
|
12
13
|
entitlement: Exclude<CustomerPortalEntitlement, 'feature'>;
|
|
@@ -14,7 +15,7 @@ export type UsageBasedChargeProps = {
|
|
|
14
15
|
amount: number;
|
|
15
16
|
currency: Currency;
|
|
16
17
|
onBuyMore?: OnBuyMoreCallbackFn;
|
|
17
|
-
onManageSubscription:
|
|
18
|
+
onManageSubscription: OnManageClick;
|
|
18
19
|
canUpgradeSubscription: boolean;
|
|
19
20
|
hasCustomSubscription: boolean;
|
|
20
21
|
hideChargePrice?: boolean;
|
|
@@ -3,12 +3,13 @@ import React from 'react';
|
|
|
3
3
|
import { keyBy } from 'lodash';
|
|
4
4
|
import { ChargeItem } from './ChargeItem';
|
|
5
5
|
import { OnBuyMoreCallbackFn } from '../../types';
|
|
6
|
+
import { OnManageClick } from '../../CustomerPortalContainer';
|
|
6
7
|
|
|
7
8
|
export type ChargesProps = {
|
|
8
9
|
subscription: CustomerPortalSubscription;
|
|
9
10
|
entitlements: CustomerPortalEntitlement[];
|
|
10
11
|
onBuyMore?: OnBuyMoreCallbackFn;
|
|
11
|
-
onManageSubscription:
|
|
12
|
+
onManageSubscription: OnManageClick;
|
|
12
13
|
canUpgradeSubscription: boolean;
|
|
13
14
|
hasCustomSubscription: boolean;
|
|
14
15
|
};
|
package/src/components/customerPortal/subscriptionOverview/subscriptionView/SubscriptionView.tsx
CHANGED
|
@@ -3,11 +3,12 @@ import { CustomerPortalSubscription } from '@stigg/js-client-sdk';
|
|
|
3
3
|
import { Typography } from '../../../common/Typography';
|
|
4
4
|
import { TrialPanel } from './TrialPanel';
|
|
5
5
|
import { CustomerPortalTheme } from '../../customerPortalTheme';
|
|
6
|
+
import { OnManageClick } from '../../CustomerPortalContainer';
|
|
6
7
|
|
|
7
8
|
type SubscriptionViewProps = {
|
|
8
9
|
mainSubscription: CustomerPortalSubscription;
|
|
9
10
|
trialSubscription: CustomerPortalSubscription | undefined;
|
|
10
|
-
onManageSubscription:
|
|
11
|
+
onManageSubscription: OnManageClick;
|
|
11
12
|
theme: CustomerPortalTheme;
|
|
12
13
|
};
|
|
13
14
|
|
|
@@ -5,6 +5,8 @@ import Link from '@mui/material/Link';
|
|
|
5
5
|
import SandClockIcon from '../../../../assets/sand-clock.svg';
|
|
6
6
|
import { Typography } from '../../../common/Typography';
|
|
7
7
|
import { LongText } from '../../../common/LongText';
|
|
8
|
+
import { OnManageClick } from '../../CustomerPortalContainer';
|
|
9
|
+
import { CustomerPortalIntentionType } from '../../types';
|
|
8
10
|
|
|
9
11
|
const OnTrialBadge = styled.div`
|
|
10
12
|
width: 100%;
|
|
@@ -30,7 +32,7 @@ export function TrialPanel({
|
|
|
30
32
|
}: {
|
|
31
33
|
subscription: CustomerPortalSubscription | undefined;
|
|
32
34
|
includePlanName: boolean;
|
|
33
|
-
onManageSubscription
|
|
35
|
+
onManageSubscription: OnManageClick;
|
|
34
36
|
}) {
|
|
35
37
|
if (subscription?.status !== SubscriptionStatus.InTrial) {
|
|
36
38
|
return null;
|
|
@@ -47,7 +49,9 @@ export function TrialPanel({
|
|
|
47
49
|
</LongText>
|
|
48
50
|
</div>
|
|
49
51
|
|
|
50
|
-
<StyledLink
|
|
52
|
+
<StyledLink
|
|
53
|
+
className="stigg-subscription-trial-upgrade-button"
|
|
54
|
+
onClick={() => onManageSubscription({ intentionType: CustomerPortalIntentionType.UPGRADE_TRIAL_PLAN })}>
|
|
51
55
|
<Typography color="white">Upgrade plan</Typography>
|
|
52
56
|
</StyledLink>
|
|
53
57
|
</OnTrialBadge>
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
import { CustomerPortalEntitlement } from '@stigg/js-client-sdk';
|
|
1
|
+
import { CustomerPortalEntitlement, CustomerPortalSubscription } from '@stigg/js-client-sdk';
|
|
2
2
|
import { FeatureFragment } from '@stigg/api-client-js/src/generated/sdk';
|
|
3
3
|
|
|
4
4
|
export type OnBuyMoreCallbackFn = (feature: FeatureFragment, entitlement: CustomerPortalEntitlement) => void;
|
|
5
|
+
|
|
6
|
+
export enum CustomerPortalIntentionType {
|
|
7
|
+
MANAGE_SUBSCRIPTION = 'MANAGE_SUBSCRIPTION',
|
|
8
|
+
UPGRADE_PLAN = 'UPGRADE_PLAN',
|
|
9
|
+
UPGRADE_TRIAL_PLAN = 'UPGRADE_TRIAL_PLAN',
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type OnManageSubscriptionFn = ({
|
|
13
|
+
intentionType,
|
|
14
|
+
customerSubscriptions,
|
|
15
|
+
}: {
|
|
16
|
+
intentionType: CustomerPortalIntentionType;
|
|
17
|
+
customerSubscriptions: CustomerPortalSubscription[];
|
|
18
|
+
}) => Promise<void> | void;
|
|
@@ -11,11 +11,12 @@ import { SectionHeader } from '../common/SectionHeader';
|
|
|
11
11
|
import { SectionTitle } from '../common/SectionTitle';
|
|
12
12
|
import { StyledButton } from '../common/StyledButton';
|
|
13
13
|
import { OnBuyMoreCallbackFn } from '../types';
|
|
14
|
+
import { OnManageClick } from '../CustomerPortalContainer';
|
|
14
15
|
|
|
15
16
|
const MAX_BOXES = 6;
|
|
16
17
|
|
|
17
18
|
export type CustomerUsageDataProps = {
|
|
18
|
-
onManageSubscription?:
|
|
19
|
+
onManageSubscription?: OnManageClick;
|
|
19
20
|
onBuyMore?: OnBuyMoreCallbackFn;
|
|
20
21
|
};
|
|
21
22
|
|
|
@@ -5,7 +5,8 @@ import React from 'react';
|
|
|
5
5
|
import styled from 'styled-components';
|
|
6
6
|
import { getUsagePercentage, USAGE_PERCENTAGE_WARNING_THRESHOLD } from './FeatureUsage.helper';
|
|
7
7
|
import { Typography } from '../../../common/Typography';
|
|
8
|
-
import { OnBuyMoreCallbackFn } from '../../types';
|
|
8
|
+
import { CustomerPortalIntentionType, OnBuyMoreCallbackFn } from '../../types';
|
|
9
|
+
import { OnManageClick } from '../../CustomerPortalContainer';
|
|
9
10
|
|
|
10
11
|
const StyledButton = styled(Button)`
|
|
11
12
|
text-transform: none;
|
|
@@ -16,7 +17,7 @@ const StyledButton = styled(Button)`
|
|
|
16
17
|
export type EntitlementCtaButtonProps = {
|
|
17
18
|
entitlement: Exclude<CustomerPortalEntitlement, 'feature'>;
|
|
18
19
|
feature: FeatureFragment;
|
|
19
|
-
onManageSubscription:
|
|
20
|
+
onManageSubscription: OnManageClick | undefined;
|
|
20
21
|
onBuyMore?: OnBuyMoreCallbackFn;
|
|
21
22
|
canBuyMore: boolean;
|
|
22
23
|
canUpgradeSubscription: boolean;
|
|
@@ -50,7 +51,9 @@ export function EntitlementCtaButton({
|
|
|
50
51
|
|
|
51
52
|
if (canUpgradeSubscription) {
|
|
52
53
|
return onManageSubscription ? (
|
|
53
|
-
<StyledButton
|
|
54
|
+
<StyledButton
|
|
55
|
+
variant="text"
|
|
56
|
+
onClick={() => onManageSubscription({ intentionType: CustomerPortalIntentionType.UPGRADE_PLAN })}>
|
|
54
57
|
<Typography color="primary.main">Upgrade</Typography>
|
|
55
58
|
</StyledButton>
|
|
56
59
|
) : null;
|
|
@@ -13,11 +13,12 @@ import { InformationTooltip } from '../../../common/InformationTooltip';
|
|
|
13
13
|
import { LongText } from '../../../common/LongText';
|
|
14
14
|
import { EntitlementCtaButton } from './EntitlementCTAButton';
|
|
15
15
|
import { OnBuyMoreCallbackFn } from '../../types';
|
|
16
|
+
import { OnManageClick } from '../../CustomerPortalContainer';
|
|
16
17
|
|
|
17
18
|
export type UsageBoxProps = {
|
|
18
19
|
entitlement: CustomerPortalEntitlement;
|
|
19
20
|
subscriptionPrice: CustomerPortalSubscriptionPriceFragment | undefined;
|
|
20
|
-
onManageSubscription:
|
|
21
|
+
onManageSubscription: OnManageClick | undefined;
|
|
21
22
|
onBuyMore?: OnBuyMoreCallbackFn;
|
|
22
23
|
hasCustomSubscription: boolean;
|
|
23
24
|
canUpgradeSubscription: boolean;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { PaywallContainer as Paywall, PaywallContainerProps as PaywallProps } from './PaywallContainer';
|
|
2
|
-
export
|
|
2
|
+
export * from './types';
|
|
3
3
|
export { PaywallLocalization, PlanPriceText, CurrentPlanParams } from './paywallTextOverrides';
|
package/src/index.ts
CHANGED
|
@@ -10,6 +10,9 @@ export {
|
|
|
10
10
|
PaywallLocalization,
|
|
11
11
|
PlanPriceText,
|
|
12
12
|
CurrentPlanParams,
|
|
13
|
+
PaywallData,
|
|
14
|
+
SelectDefaultTierIndexFn,
|
|
15
|
+
ShouldHidePlanFn,
|
|
13
16
|
} from './components/paywall';
|
|
14
17
|
export {
|
|
15
18
|
CustomerPortalProvider,
|
|
@@ -24,6 +27,11 @@ export {
|
|
|
24
27
|
SubscriptionsOverview,
|
|
25
28
|
SubscriptionsOverviewProps,
|
|
26
29
|
Promotions,
|
|
30
|
+
CustomerPortalIntentionType,
|
|
31
|
+
OnBuyMoreCallbackFn,
|
|
32
|
+
OnManageSubscriptionFn,
|
|
33
|
+
CustomerPortalLocalization,
|
|
34
|
+
CustomerPortalTheme,
|
|
27
35
|
} from './components/customerPortal';
|
|
28
36
|
export {
|
|
29
37
|
StiggProvider,
|
|
@@ -49,5 +57,5 @@ export {
|
|
|
49
57
|
TaxDetailsInput,
|
|
50
58
|
} from './components/checkout';
|
|
51
59
|
export { useWaitForCheckoutCompleted, ProvisionStatus } from './components/hooks';
|
|
52
|
-
export { HorizontalAlignment, TextAlignment } from './theme/types';
|
|
60
|
+
export { HorizontalAlignment, TextAlignment, FontVariant, FontWeight, StiggTheme } from './theme/types';
|
|
53
61
|
export { CustomizedTheme as Theme } from './theme/Theme';
|