@lookiero/checkout 9.8.0 → 9.8.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.
@@ -24,7 +24,7 @@ const order = {
24
24
  coupon: "MYLOOKIERO",
25
25
  };
26
26
  const customer = {
27
- customerId: "9413fe3a-09fc-4264-905e-040bb7b4ca75",
27
+ customerId: "74cb4f76-3f14-4983-81a6-2ee2a9a275d4",
28
28
  country: Country.ES,
29
29
  segment: Segment.WOMEN,
30
30
  };
@@ -39,7 +39,7 @@ const apiUrl = Platform.OS !== "web"
39
39
  : __DEV__
40
40
  ? "/local-to-dev"
41
41
  : "/checkout/api";
42
- const authToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjU2NTIwMjgsImV4cCI6MTczOTQ0MTYwMSwiZGlzcGxheU5hbWUiOiJNaWtlbCIsImNvdW50cnlfY29kZSI6IkVTIiwiYWNjZXNzVmlhIjoiZW1haWwiLCJzdWJzY3JpcHRpb25TdGFydGluZ0RhdGUiOiIyMDI0LTExLTE4IiwiaW1wZXJzb25hdGVkIjpmYWxzZSwidXVpZCI6Ijk0MTNmZTNhLTA5ZmMtNDI2NC05MDVlLTA0MGJiN2I0Y2E3NSIsImlhdCI6MTczNjc2MzIwMn0.ZaFu4743f9XR0aK3LgMMhbmRHNloHtC1Sm0FDUtj8B8";
42
+ const authToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjU2NDg3OTAsImV4cCI6MTc0MjM2OTcyNywiZGlzcGxheU5hbWUiOiJUZXN0aW5nIiwiY291bnRyeV9jb2RlIjoiRVMiLCJhY2Nlc3NWaWEiOiJlbWFpbCIsInN1YnNjcmlwdGlvblN0YXJ0aW5nRGF0ZSI6IjIwMjQtMTEtMDgiLCJpbXBlcnNvbmF0ZWQiOmZhbHNlLCJ1dWlkIjoiNzRjYjRmNzYtM2YxNC00OTgzLTgxYTYtMmVlMmE5YTI3NWQ0IiwiaWF0IjoxNzM5OTUwNTI3fQ.ajNczGc6YhM23--PsqlAoDrp_GN87TnHEBOYyg2hoWM";
43
43
  const getAuthToken = () => Promise.resolve(authToken);
44
44
  const externalTranslationsUrl = Platform.OS !== "web"
45
45
  ? "https://backend-for-user.dev.envs.lookiero.tech/api/v2/translations"
@@ -9,7 +9,6 @@ interface OnChangeCheckoutQuestionFeedbackFunction {
9
9
  (args: OnChangeCheckoutQuestionFeedbackFunctionArgs): void;
10
10
  }
11
11
  interface CheckoutQuestionFeedbackContextProviderProps {
12
- readonly feedback: CheckoutFeedbackProjection | undefined;
13
12
  readonly onChanged?: OnChangeCheckoutQuestionFeedbackFunction;
14
13
  readonly children: ReactNode;
15
14
  }
@@ -1,8 +1,8 @@
1
- import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
1
+ import React, { createContext, useCallback, useContext, useMemo, useState } from "react";
2
2
  import invariant from "tiny-invariant";
3
3
  const CheckoutQuestionFeedbackContext = createContext(null);
4
- const CheckoutQuestionFeedbackProvider = ({ feedback = {}, onChanged, children, }) => {
5
- const [contextFeedback, setContextFeedback] = useState(feedback);
4
+ const CheckoutQuestionFeedbackProvider = ({ onChanged, children, }) => {
5
+ const [contextFeedback, setContextFeedback] = useState({});
6
6
  const onChange = useCallback(({ checkoutQuestionId, checkoutQuestionFeedback }) => {
7
7
  setContextFeedback((feedback) => checkoutQuestionFeedback
8
8
  ? { ...feedback, [checkoutQuestionId]: checkoutQuestionFeedback }
@@ -13,7 +13,6 @@ const CheckoutQuestionFeedbackProvider = ({ feedback = {}, onChanged, children,
13
13
  hasFeedback: Boolean(contextFeedback[checkoutQuestionId]),
14
14
  });
15
15
  }, [contextFeedback, onChanged]);
16
- useEffect(() => setContextFeedback(feedback), [feedback]);
17
16
  const value = useMemo(() => ({
18
17
  feedback: contextFeedback,
19
18
  onChange,
@@ -80,7 +80,7 @@ const Feedback = ({ layout: Layout }) => {
80
80
  const dependenciesLoaded = dependenciesLoadedStatuses.includes(checkoutStatus) && dependenciesLoadedStatuses.includes(checkoutQuestionsStatus);
81
81
  if (!dependenciesLoaded)
82
82
  return React.createElement(Spinner, null);
83
- return (React.createElement(CheckoutQuestionFeedbackProvider, { feedback: {}, onChanged: handleOnChangedFeedback },
83
+ return (React.createElement(CheckoutQuestionFeedbackProvider, { onChanged: handleOnChangedFeedback },
84
84
  React.createElement(Layout, null,
85
85
  React.createElement(Body, { style: { row: [style.container, isDesktop && style.containerDesktop] } },
86
86
  React.createElement(CheckoutQuestionsForm, { checkoutQuestions: checkoutQuestions || [], submitButtonDisabled: giveCheckoutFeedbackStatus === CommandStatus.LOADING, onSubmit: handleOnSubmit })))));
@@ -1 +1 @@
1
- export declare const VERSION = "9.8.0";
1
+ export declare const VERSION = "9.8.2";
@@ -1 +1 @@
1
- export const VERSION = "9.8.0";
1
+ export const VERSION = "9.8.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "9.8.0",
3
+ "version": "9.8.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "sideEffects": "false",
package/src/ExpoRoot.tsx CHANGED
@@ -32,7 +32,7 @@ const order: Order = {
32
32
  };
33
33
 
34
34
  const customer: Customer = {
35
- customerId: "9413fe3a-09fc-4264-905e-040bb7b4ca75",
35
+ customerId: "74cb4f76-3f14-4983-81a6-2ee2a9a275d4",
36
36
  country: Country.ES,
37
37
  segment: Segment.WOMEN,
38
38
  };
@@ -51,7 +51,7 @@ const apiUrl =
51
51
  ? "/local-to-dev"
52
52
  : "/checkout/api";
53
53
  const authToken =
54
- "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjU2NTIwMjgsImV4cCI6MTczOTQ0MTYwMSwiZGlzcGxheU5hbWUiOiJNaWtlbCIsImNvdW50cnlfY29kZSI6IkVTIiwiYWNjZXNzVmlhIjoiZW1haWwiLCJzdWJzY3JpcHRpb25TdGFydGluZ0RhdGUiOiIyMDI0LTExLTE4IiwiaW1wZXJzb25hdGVkIjpmYWxzZSwidXVpZCI6Ijk0MTNmZTNhLTA5ZmMtNDI2NC05MDVlLTA0MGJiN2I0Y2E3NSIsImlhdCI6MTczNjc2MzIwMn0.ZaFu4743f9XR0aK3LgMMhbmRHNloHtC1Sm0FDUtj8B8";
54
+ "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjU2NDg3OTAsImV4cCI6MTc0MjM2OTcyNywiZGlzcGxheU5hbWUiOiJUZXN0aW5nIiwiY291bnRyeV9jb2RlIjoiRVMiLCJhY2Nlc3NWaWEiOiJlbWFpbCIsInN1YnNjcmlwdGlvblN0YXJ0aW5nRGF0ZSI6IjIwMjQtMTEtMDgiLCJpbXBlcnNvbmF0ZWQiOmZhbHNlLCJ1dWlkIjoiNzRjYjRmNzYtM2YxNC00OTgzLTgxYTYtMmVlMmE5YTI3NWQ0IiwiaWF0IjoxNzM5OTUwNTI3fQ.ajNczGc6YhM23--PsqlAoDrp_GN87TnHEBOYyg2hoWM";
55
55
  const getAuthToken = () => Promise.resolve(authToken);
56
56
 
57
57
  const externalTranslationsUrl =
@@ -48,7 +48,7 @@ const checkoutQuestionItems: CheckoutQuestionItems = {
48
48
  };
49
49
 
50
50
  const Wrapper = ({ children }: { children: ReactNode }) => (
51
- <CheckoutQuestionFeedbackProvider feedback={{}}>
51
+ <CheckoutQuestionFeedbackProvider>
52
52
  <CheckoutQuestionItemProvider checkoutQuestionItems={checkoutQuestionItems}>
53
53
  {children}
54
54
  </CheckoutQuestionItemProvider>
@@ -1,50 +1,20 @@
1
1
  import { act, renderHook } from "@testing-library/react-native";
2
- import { CheckoutFeedbackProjection } from "../../../../../../projection/checkoutFeedback/checkoutFeedback";
3
2
  import { createWrapper } from "../../../../test/createWrapper";
4
3
  import {
5
4
  CheckoutQuestionFeedbackProvider,
6
- useCheckoutQuestionFeedback as sut,
7
5
  useCheckoutQuestionFeedbackForId as sutForId,
8
6
  } from "./useCheckoutQuestionFeedback";
9
7
 
10
- const initialFeedback: CheckoutFeedbackProjection = {
11
- ["0ad1dba8-b02c-4121-a1e3-981f1c30800d"]: "9251dc2c-d76a-484d-9299-346929af932f",
12
- ["542c4d24-e1da-484f-8c3a-7d89ee135adc"]: "68c0bb98-b00a-4b86-af43-528fe903cb69",
13
- };
14
8
  const checkoutQuestionId = "542c4d24-e1da-484f-8c3a-7d89ee135adc";
15
9
  const mockOnChanged = jest.fn();
16
10
 
17
11
  describe("useCheckoutQuestionFeedback hook", () => {
18
- it("returns the customer's feedback from the context's local state", () => {
19
- const { result } = renderHook(() => sut(), {
20
- wrapper: createWrapper({
21
- wrapper: CheckoutQuestionFeedbackProvider,
22
- initialProps: { feedback: initialFeedback, children: null, onChanged: mockOnChanged },
23
- }),
24
- });
25
-
26
- expect(result.current).toStrictEqual(initialFeedback);
27
- });
28
-
29
- it("returns the customer's feedback for the checkoutQuestion from the context's local state", async () => {
30
- const { result } = renderHook(() => sutForId({ id: checkoutQuestionId }), {
31
- wrapper: createWrapper({
32
- wrapper: CheckoutQuestionFeedbackProvider,
33
- initialProps: { feedback: initialFeedback, children: null, onChanged: mockOnChanged },
34
- }),
35
- });
36
-
37
- const { feedback: initialCheckoutQuestionFeedback } = result.current;
38
-
39
- expect(initialCheckoutQuestionFeedback).toEqual(initialFeedback[checkoutQuestionId]);
40
- });
41
-
42
12
  it("returns the customer's feedback for the checkoutQuestion from the context's local state after updating it", async () => {
43
13
  const feedbackToUpdate = "f3742fa1-e6e9-4321-baea-9622b57416f4";
44
14
  const { result } = renderHook(() => sutForId({ id: checkoutQuestionId }), {
45
15
  wrapper: createWrapper({
46
16
  wrapper: CheckoutQuestionFeedbackProvider,
47
- initialProps: { feedback: initialFeedback, children: null, onChanged: mockOnChanged },
17
+ initialProps: { children: null, onChanged: mockOnChanged },
48
18
  }),
49
19
  });
50
20
 
@@ -55,7 +25,7 @@ describe("useCheckoutQuestionFeedback hook", () => {
55
25
  expect(mockOnChanged).toHaveBeenCalledWith({
56
26
  checkoutQuestionId,
57
27
  checkoutQuestionFeedback: feedbackToUpdate,
58
- hasFeedback: true,
28
+ hasFeedback: false,
59
29
  });
60
30
 
61
31
  const { feedback: updatedCheckoutQuestionFeedback } = result.current;
@@ -1,4 +1,4 @@
1
- import React, { createContext, FC, ReactNode, useCallback, useContext, useEffect, useMemo, useState } from "react";
1
+ import React, { createContext, FC, ReactNode, useCallback, useContext, useMemo, useState } from "react";
2
2
  import invariant from "tiny-invariant";
3
3
  import { CheckoutFeedbackProjection } from "../../../../../../projection/checkoutFeedback/checkoutFeedback";
4
4
 
@@ -22,17 +22,15 @@ const CheckoutQuestionFeedbackContext = createContext<CheckoutQuestionFeedbackCo
22
22
  );
23
23
 
24
24
  interface CheckoutQuestionFeedbackContextProviderProps {
25
- readonly feedback: CheckoutFeedbackProjection | undefined;
26
25
  readonly onChanged?: OnChangeCheckoutQuestionFeedbackFunction;
27
26
  readonly children: ReactNode;
28
27
  }
29
28
 
30
29
  const CheckoutQuestionFeedbackProvider: FC<CheckoutQuestionFeedbackContextProviderProps> = ({
31
- feedback = {},
32
30
  onChanged,
33
31
  children,
34
32
  }) => {
35
- const [contextFeedback, setContextFeedback] = useState<CheckoutFeedbackProjection>(feedback);
33
+ const [contextFeedback, setContextFeedback] = useState<CheckoutFeedbackProjection>({});
36
34
  const onChange = useCallback<OnChangeCheckoutQuestionFeedbackFunction>(
37
35
  ({ checkoutQuestionId, checkoutQuestionFeedback }) => {
38
36
  setContextFeedback((feedback) =>
@@ -52,8 +50,6 @@ const CheckoutQuestionFeedbackProvider: FC<CheckoutQuestionFeedbackContextProvid
52
50
  [contextFeedback, onChanged],
53
51
  );
54
52
 
55
- useEffect(() => setContextFeedback(feedback), [feedback]);
56
-
57
53
  const value = useMemo(
58
54
  () => ({
59
55
  feedback: contextFeedback,
@@ -115,7 +115,7 @@ const Feedback: FC<FeedbackProps> = ({ layout: Layout }) => {
115
115
  if (!dependenciesLoaded) return <Spinner />;
116
116
 
117
117
  return (
118
- <CheckoutQuestionFeedbackProvider feedback={{}} onChanged={handleOnChangedFeedback}>
118
+ <CheckoutQuestionFeedbackProvider onChanged={handleOnChangedFeedback}>
119
119
  <Layout>
120
120
  <Body style={{ row: [style.container, isDesktop && style.containerDesktop] }}>
121
121
  <CheckoutQuestionsForm
@@ -9,7 +9,7 @@ import { CheckoutQuestionsForm } from "./CheckoutQuestionsForm";
9
9
  const mockOnSubmit = jest.fn();
10
10
 
11
11
  const Wrapper = ({ children }: { children: ReactNode }) => (
12
- <CheckoutQuestionFeedbackProvider feedback={{}}>{children}</CheckoutQuestionFeedbackProvider>
12
+ <CheckoutQuestionFeedbackProvider>{children}</CheckoutQuestionFeedbackProvider>
13
13
  );
14
14
 
15
15
  describe("CheckoutQuestionsForm component)", () => {