@stigg/react-sdk 4.4.0-beta.2 → 4.4.0-beta.3
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/useProgressBarModel.d.ts +1 -0
- package/dist/react-sdk.cjs.development.js +9 -8
- 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 +9 -8
- package/dist/react-sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/checkout/CheckoutContainer.tsx +9 -9
- package/src/components/checkout/hooks/useProgressBarModel.ts +3 -0
- package/src/stories/Checkout.stories.tsx +4 -5
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import { ApplySubscription, CheckoutStatePlan } from '@stigg/js-client-sdk';
|
|
|
4
4
|
import { CheckoutContent, CheckoutLayout, CheckoutPanel } from './CheckoutContainer.style';
|
|
5
5
|
import { CheckoutProgressBar } from './progressBar/CheckoutProgressBar';
|
|
6
6
|
import { CheckoutSummary, CheckoutSummarySkeleton } from './summary';
|
|
7
|
-
import { useProgressBarModel } from './hooks';
|
|
7
|
+
import { CheckoutStep, CheckoutStepKey, useProgressBarModel } from './hooks';
|
|
8
8
|
import { PlanHeader } from './planHeader';
|
|
9
9
|
import { CheckoutAddonsStep } from './steps/addons';
|
|
10
10
|
import { PaymentStep } from './steps/payment';
|
|
@@ -20,13 +20,13 @@ type StepProps = {
|
|
|
20
20
|
content: React.ReactNode;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
const getStepProps = (
|
|
24
|
-
switch (
|
|
25
|
-
case
|
|
23
|
+
const getStepProps = (currentStep: CheckoutStep): StepProps => {
|
|
24
|
+
switch (currentStep.key) {
|
|
25
|
+
case CheckoutStepKey.PLAN:
|
|
26
26
|
return { allowChangePlan: true, content: <CheckoutPlanStep /> };
|
|
27
|
-
case
|
|
27
|
+
case CheckoutStepKey.ADDONS:
|
|
28
28
|
return { content: <CheckoutAddonsStep /> };
|
|
29
|
-
case
|
|
29
|
+
case CheckoutStepKey.PAYMENT:
|
|
30
30
|
return { content: <PaymentStep /> };
|
|
31
31
|
default:
|
|
32
32
|
return { content: null };
|
|
@@ -48,8 +48,8 @@ export type CheckoutContainerProps = {
|
|
|
48
48
|
export function CheckoutContainer({ onCheckout, onCheckoutCompleted, onChangePlan }: CheckoutContainerProps) {
|
|
49
49
|
const { stripePromise, setupIntentClientSecret } = useStripeIntegration();
|
|
50
50
|
const [{ stiggTheme, widgetState }] = useCheckoutContext();
|
|
51
|
-
const {
|
|
52
|
-
|
|
51
|
+
const { currentStep } = useProgressBarModel();
|
|
52
|
+
|
|
53
53
|
const { isLoadingCheckoutData } = widgetState;
|
|
54
54
|
|
|
55
55
|
// uncomment for fun!
|
|
@@ -57,7 +57,7 @@ export function CheckoutContainer({ onCheckout, onCheckoutCompleted, onChangePla
|
|
|
57
57
|
// return <SurpriseStep />;
|
|
58
58
|
// }
|
|
59
59
|
|
|
60
|
-
const { content, allowChangePlan } = getStepProps(
|
|
60
|
+
const { content, allowChangePlan } = getStepProps(currentStep);
|
|
61
61
|
|
|
62
62
|
const checkoutContent = (
|
|
63
63
|
<>
|
|
@@ -78,7 +78,10 @@ function useGoNext() {
|
|
|
78
78
|
|
|
79
79
|
export function useProgressBarModel() {
|
|
80
80
|
const progressBarState = useProgressBarState();
|
|
81
|
+
const currentStep = progressBarState.steps[progressBarState.activeStep];
|
|
82
|
+
|
|
81
83
|
return {
|
|
84
|
+
currentStep,
|
|
82
85
|
progressBarState,
|
|
83
86
|
isLastStep: progressBarState.activeStep === progressBarState.steps.length - 1,
|
|
84
87
|
isCheckoutComplete: isCheckoutComplete(progressBarState),
|
|
@@ -55,9 +55,8 @@ export const DefaultCheckout = Template.bind({});
|
|
|
55
55
|
DefaultCheckout.args = {
|
|
56
56
|
...defaultArgsWithCustomer,
|
|
57
57
|
planId: 'plan-revvenu-essentials',
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
//
|
|
61
|
-
|
|
62
|
-
apiKey: 'client-79584f52-7ef9-4c58-b9ac-5080acf492e4:71f2274c-100a-4fa4-8a43-48fa3b16c627',
|
|
58
|
+
baseUri: 'http://localhost:4000',
|
|
59
|
+
apiKey: 'client-72b058a6-0f22-4c86-adce-bf266d12e12e:9f356ceb-c94c-42a4-9572-10b12824da81',
|
|
60
|
+
// baseUri: 'https://api-staging.stigg.io',
|
|
61
|
+
// apiKey: 'client-79584f52-7ef9-4c58-b9ac-5080acf492e4:71f2274c-100a-4fa4-8a43-48fa3b16c627',
|
|
63
62
|
};
|