@stigg/react-sdk 4.4.0-beta.0 → 4.4.0-beta.2
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/CheckoutProvider.d.ts +1 -1
- package/dist/components/checkout/index.d.ts +1 -0
- package/dist/react-sdk.cjs.development.js +12 -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 +12 -9
- package/dist/react-sdk.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/components/checkout/Checkout.tsx +1 -2
- package/src/components/checkout/CheckoutProvider.tsx +10 -14
- package/src/components/checkout/hooks/usePreviewSubscription.ts +1 -2
- package/src/components/checkout/index.ts +1 -0
- package/src/components/checkout/summary/CheckoutSuccess.tsx +2 -4
- package/src/stories/Checkout.stories.tsx +2 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "4.4.0-beta.
|
|
2
|
+
"version": "4.4.0-beta.2",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"@emotion/react": "^11.10.5",
|
|
102
102
|
"@emotion/styled": "^11.10.5",
|
|
103
103
|
"@mui/material": "^5.10.13",
|
|
104
|
-
"@stigg/js-client-sdk": "2.
|
|
104
|
+
"@stigg/js-client-sdk": "2.21.0",
|
|
105
105
|
"@stripe/react-stripe-js": "^2.1.1",
|
|
106
106
|
"@stripe/stripe-js": "^1.54.1",
|
|
107
107
|
"@types/styled-components": "^5.1.26",
|
|
@@ -22,8 +22,7 @@ export const Checkout = ({
|
|
|
22
22
|
planId={planId}
|
|
23
23
|
preferredBillingPeriod={preferredBillingPeriod}
|
|
24
24
|
billingCountryCode={billingCountryCode}
|
|
25
|
-
billableFeatures={billableFeatures}
|
|
26
|
-
>
|
|
25
|
+
billableFeatures={billableFeatures}>
|
|
27
26
|
<CheckoutContainer {...containerProps} />
|
|
28
27
|
</CheckoutProvider>
|
|
29
28
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { produce } from 'immer';
|
|
2
|
-
import React, { useCallback, useContext, useMemo, useState } from 'react';
|
|
2
|
+
import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
3
3
|
|
|
4
4
|
import { BillableFeature, BillingPeriod, GetCheckoutStateResults } from '@stigg/js-client-sdk';
|
|
5
5
|
|
|
@@ -58,12 +58,16 @@ const CheckoutContextProvider: React.FC<{ children: React.ReactNode; initialStat
|
|
|
58
58
|
}) => {
|
|
59
59
|
const [state, innerSetState] = useState(initialState);
|
|
60
60
|
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
innerSetState(initialState);
|
|
63
|
+
}, [initialState]);
|
|
64
|
+
|
|
61
65
|
const setState = useCallback(
|
|
62
66
|
(updater: (state: CheckoutContextState) => void) => innerSetState((old) => produce(old, (draft) => updater(draft))),
|
|
63
67
|
[innerSetState],
|
|
64
68
|
);
|
|
65
69
|
|
|
66
|
-
const [contextValue, setContextValue] = useMemo(() => [state, setState], [state]);
|
|
70
|
+
const [contextValue, setContextValue] = useMemo(() => [state, setState], [setState, state]);
|
|
67
71
|
|
|
68
72
|
return <CheckoutContext.Provider value={[contextValue, setContextValue]}>{children}</CheckoutContext.Provider>;
|
|
69
73
|
};
|
|
@@ -82,11 +86,11 @@ export function CheckoutProvider({
|
|
|
82
86
|
children,
|
|
83
87
|
textOverrides,
|
|
84
88
|
theme,
|
|
89
|
+
preferredBillingPeriod,
|
|
90
|
+
billableFeatures,
|
|
85
91
|
resourceId,
|
|
86
92
|
planId,
|
|
87
|
-
preferredBillingPeriod,
|
|
88
93
|
billingCountryCode,
|
|
89
|
-
billableFeatures,
|
|
90
94
|
}: {
|
|
91
95
|
children: React.ReactNode;
|
|
92
96
|
} & CheckoutProviderProps) {
|
|
@@ -130,16 +134,8 @@ export function CheckoutProvider({
|
|
|
130
134
|
};
|
|
131
135
|
|
|
132
136
|
return initialState;
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
textOverrides,
|
|
136
|
-
preferredBillingPeriod,
|
|
137
|
-
billingCountryCode,
|
|
138
|
-
billableFeatures,
|
|
139
|
-
globalTheme,
|
|
140
|
-
checkout,
|
|
141
|
-
isLoading,
|
|
142
|
-
]);
|
|
137
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
138
|
+
}, [preferredBillingPeriod, billingCountryCode, checkout, isLoading]);
|
|
143
139
|
|
|
144
140
|
return (
|
|
145
141
|
<SdkThemeProvider key={checkout?.plan.id} componentTheme={configuration}>
|
|
@@ -10,7 +10,7 @@ export const usePreviewSubscriptionAction = () => {
|
|
|
10
10
|
const subscription = useSubscriptionModel();
|
|
11
11
|
const [{ resourceId, planStep }] = useCheckoutContext();
|
|
12
12
|
const { checkoutState } = useCheckoutModel();
|
|
13
|
-
const { plan,
|
|
13
|
+
const { plan, customer } = checkoutState || {};
|
|
14
14
|
|
|
15
15
|
const previewSubscriptionAction = useCallback(
|
|
16
16
|
async ({ promotionCode }: { promotionCode?: string | null } = {}) => {
|
|
@@ -43,7 +43,6 @@ export const usePreviewSubscriptionAction = () => {
|
|
|
43
43
|
return { subscriptionPreview, errorMessage };
|
|
44
44
|
},
|
|
45
45
|
[
|
|
46
|
-
activeSubscription,
|
|
47
46
|
customer,
|
|
48
47
|
plan,
|
|
49
48
|
resourceId,
|
|
@@ -7,9 +7,7 @@ import animationData from '../../../assets/lottie/checkout-success.json';
|
|
|
7
7
|
|
|
8
8
|
export const ANIMATION_DURATION = 5000;
|
|
9
9
|
|
|
10
|
-
const BACKGROUND_COLOR = Color('#0b2f7a')
|
|
11
|
-
.alpha(0.3)
|
|
12
|
-
.toString();
|
|
10
|
+
const BACKGROUND_COLOR = Color('#0b2f7a').alpha(0.3).toString();
|
|
13
11
|
|
|
14
12
|
const CheckoutSuccessContainer = styled(Box)`
|
|
15
13
|
position: absolute;
|
|
@@ -26,7 +24,7 @@ const CheckoutSuccessContainer = styled(Box)`
|
|
|
26
24
|
export function CheckoutSuccess() {
|
|
27
25
|
return (
|
|
28
26
|
<CheckoutSuccessContainer>
|
|
29
|
-
<Lottie options={{ loop: false, autoplay: true, animationData }} />
|
|
27
|
+
<Lottie width={350} options={{ loop: false, autoplay: true, animationData }} />
|
|
30
28
|
</CheckoutSuccessContainer>
|
|
31
29
|
);
|
|
32
30
|
}
|
|
@@ -46,6 +46,7 @@ const Template: ComponentStory<any> = (args) => (
|
|
|
46
46
|
onChangePlan={({ currentPlan }) => {
|
|
47
47
|
console.log('plan changed clicked!', { currentPlan });
|
|
48
48
|
}}
|
|
49
|
+
// billingInformation={{ taxPercentage: 27 }}
|
|
49
50
|
/>
|
|
50
51
|
</Wrapper>
|
|
51
52
|
);
|
|
@@ -56,6 +57,7 @@ DefaultCheckout.args = {
|
|
|
56
57
|
planId: 'plan-revvenu-essentials',
|
|
57
58
|
// baseUri: 'http://localhost:4000',
|
|
58
59
|
// apiKey: 'client-72b058a6-0f22-4c86-adce-bf266d12e12e:9f356ceb-c94c-42a4-9572-10b12824da81',
|
|
60
|
+
// disableEdge: false,
|
|
59
61
|
baseUri: 'https://api-staging.stigg.io',
|
|
60
62
|
apiKey: 'client-79584f52-7ef9-4c58-b9ac-5080acf492e4:71f2274c-100a-4fa4-8a43-48fa3b16c627',
|
|
61
63
|
};
|