@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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.4.0-beta.2",
2
+ "version": "4.4.0-beta.3",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -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 = (step: number): StepProps => {
24
- switch (step) {
25
- case 0:
23
+ const getStepProps = (currentStep: CheckoutStep): StepProps => {
24
+ switch (currentStep.key) {
25
+ case CheckoutStepKey.PLAN:
26
26
  return { allowChangePlan: true, content: <CheckoutPlanStep /> };
27
- case 1:
27
+ case CheckoutStepKey.ADDONS:
28
28
  return { content: <CheckoutAddonsStep /> };
29
- case 2:
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 { progressBarState } = useProgressBarModel();
52
- const { activeStep } = progressBarState;
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(activeStep);
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
- // baseUri: 'http://localhost:4000',
59
- // apiKey: 'client-72b058a6-0f22-4c86-adce-bf266d12e12e:9f356ceb-c94c-42a4-9572-10b12824da81',
60
- // disableEdge: false,
61
- baseUri: 'https://api-staging.stigg.io',
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
  };