@stigg/react-sdk 4.4.0-beta.1 → 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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.4.0-beta.1",
2
+ "version": "4.4.0-beta.2",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -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
- theme,
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, activeSubscription, customer } = checkoutState || {};
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,
@@ -1,3 +1,4 @@
1
1
  export { CheckoutTheme } from './theme';
2
2
  export { Checkout, CheckoutProps } from './Checkout';
3
+ export { OnCheckoutCompletedParams, OnCheckoutParams, CheckoutResult } from './CheckoutContainer';
3
4
  export { CheckoutLocalization } from './textOverrides';
@@ -46,7 +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
+ // billingInformation={{ taxPercentage: 27 }}
50
50
  />
51
51
  </Wrapper>
52
52
  );
@@ -55,8 +55,9 @@ 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
- // baseUri: 'https://api-staging.stigg.io',
61
- // 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
+ // disableEdge: false,
61
+ baseUri: 'https://api-staging.stigg.io',
62
+ apiKey: 'client-79584f52-7ef9-4c58-b9ac-5080acf492e4:71f2274c-100a-4fa4-8a43-48fa3b16c627',
62
63
  };