@lookiero/checkout 11.5.0 → 12.0.0
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/index.d.ts +1 -2
- package/dist/src/ExpoRoot.d.ts +0 -1
- package/dist/src/ExpoRoot.js +2 -3
- package/dist/src/infrastructure/ui/routing/CheckoutMiddleware.d.ts +1 -1
- package/dist/src/infrastructure/ui/routing/CheckoutMiddleware.js +4 -2
- package/dist/src/infrastructure/ui/test/render.js +1 -1
- package/dist/src/infrastructure/ui/views/App.d.ts +1 -1
- package/dist/src/projection/returnQuestion/returnQuestion.typeguard.d.ts +2 -2
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/index.ts +1 -1
- package/jest.config.js +0 -3
- package/jest.setup.js +9 -1
- package/package.json +22 -20
- package/src/ExpoRoot.tsx +2 -3
- package/src/infrastructure/ui/hooks/useCheckoutFlow.test.tsx +11 -1
- package/src/infrastructure/ui/hooks/useQueryBus.test.tsx +1 -1
- package/src/infrastructure/ui/hooks/useStaticInfo.test.tsx +1 -1
- package/src/infrastructure/ui/routing/CheckoutMiddleware.tsx +5 -3
- package/src/infrastructure/ui/test/render.tsx +1 -1
- package/src/infrastructure/ui/views/App.tsx +1 -1
- package/src/infrastructure/ui/views/checkout/Checkout.test.tsx +9 -2
- package/src/infrastructure/ui/views/feedback/Feedback.test.tsx +7 -1
- package/src/infrastructure/ui/views/item/Item.test.tsx +7 -1
- package/src/infrastructure/ui/views/item/components/getOutOfCheckoutModal/__snapshots__/GetOutOfCheckoutModal.test.tsx.snap +34 -43
- package/src/infrastructure/ui/views/item/components/itemActions/__snapshots__/ItemActions.test.tsx.snap +34 -43
- package/src/infrastructure/ui/views/item/components/productVariantSlider/__snapshots__/ProductVariantSlider.test.tsx.snap +76 -99
- package/src/infrastructure/ui/views/item/components/selectModal/__snapshots__/SelecModal.test.tsx.snap +34 -43
- package/src/infrastructure/ui/views/item/components/sizeWithoutStockModal/__snapshots__/SizeWithoutStockModal.test.tsx.snap +34 -43
- package/src/infrastructure/ui/views/item/views/itemWithCustomerDecission/ItemWithCustomerDecission.test.tsx +7 -1
- package/src/infrastructure/ui/views/item/views/itemWithoutCustomerDecission/ItemWithoutCustomerDecission.test.tsx +7 -1
- package/src/infrastructure/ui/views/item/views/productVariant/__snapshots__/ProductVariant.test.tsx.snap +228 -297
- package/src/infrastructure/ui/views/return/Return.test.tsx +8 -1
- package/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.test.tsx +2 -1
- package/src/infrastructure/ui/views/shared/components/productVariant/__snapshots__/ProductVariant.test.tsx.snap +26 -32
- package/src/infrastructure/ui/views/summary/Summary.test.tsx +7 -1
- package/src/infrastructure/ui/views/summary/components/collapsiblePricing/__snapshots__/CollapsiblePricing.test.tsx.snap +16 -24
- package/src/infrastructure/ui/views/summaryTabs/SummaryTabs.test.tsx +7 -1
- package/src/infrastructure/ui/views/summaryTabs/components/checkoutItemsTabs/__snapshots__/CheckoutItemsTabs.test.tsx.snap +105 -135
package/dist/index.d.ts
CHANGED
|
@@ -33,6 +33,5 @@ interface BootstrapFunction {
|
|
|
33
33
|
(args: BootstrapFunctionArgs): BootstrapFunctionReturn;
|
|
34
34
|
}
|
|
35
35
|
declare const bootstrap: BootstrapFunction;
|
|
36
|
-
export type { Project };
|
|
37
36
|
export { bootstrap, translationEndpoint, translationExternalEndpoint, Country, Segment, CheckoutStatus, Tradename };
|
|
38
|
-
export type { SentryEnvironment, KameleoonEnvironment, Customer, SubscriptionProjection as Subscription, OrderProjection as Order, Locale, };
|
|
37
|
+
export type { Project, SentryEnvironment, KameleoonEnvironment, Customer, SubscriptionProjection as Subscription, OrderProjection as Order, Locale, };
|
package/dist/src/ExpoRoot.d.ts
CHANGED
package/dist/src/ExpoRoot.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { PortalProvider } from "@gorhom/portal";
|
|
2
2
|
import { useFonts } from "expo-font";
|
|
3
|
-
import "expo/build/Expo.fx";
|
|
4
3
|
import React, { useCallback, useState } from "react";
|
|
5
4
|
import { Platform, ScrollView } from "react-native";
|
|
6
5
|
import { Navigate, Route, Routes } from "react-router-native";
|
|
@@ -29,7 +28,7 @@ const order = {
|
|
|
29
28
|
coupon: "MYLOOKIERO",
|
|
30
29
|
};
|
|
31
30
|
const customer = {
|
|
32
|
-
customerId: "
|
|
31
|
+
customerId: "5c38e826-3d01-4a4b-a3d1-8a4166dc2a31",
|
|
33
32
|
country: Country.NL,
|
|
34
33
|
segment: Segment.WOMEN,
|
|
35
34
|
email: "email@example.com",
|
|
@@ -46,7 +45,7 @@ const apiUrl = Platform.OS !== "web"
|
|
|
46
45
|
: __DEV__
|
|
47
46
|
? "/local-to-dev"
|
|
48
47
|
: "/checkout/api";
|
|
49
|
-
const authToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.
|
|
48
|
+
const authToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjU3MDEwMTIsImV4cCI6MTc1MDMyMTgwOSwiZGlzcGxheU5hbWUiOiJUZXN0aW5nIiwiY291bnRyeV9jb2RlIjoiRVMiLCJhY2Nlc3NWaWEiOiJlbWFpbCIsInN1YnNjcmlwdGlvblN0YXJ0aW5nRGF0ZSI6IjIwMjUtMDUtMTkiLCJpbXBlcnNvbmF0ZWQiOmZhbHNlLCJ1dWlkIjoiNWMzOGU4MjYtM2QwMS00YTRiLWEzZDEtOGE0MTY2ZGMyYTMxIiwidHJhZGVuYW1lIjoiTE9PS0lFUk8iLCJpYXQiOjE3NDc2NDM0MDl9.-amqZAXKy9KKeo9a7bOQigWw1flM99OBlddxbMBA_PU";
|
|
50
49
|
const getAuthToken = () => Promise.resolve(authToken);
|
|
51
50
|
const externalTranslationsUrl = Platform.OS !== "web"
|
|
52
51
|
? "https://backend-for-user.dev.envs.lookiero.tech/api/v2/translations"
|
|
@@ -34,7 +34,7 @@ const CheckoutMiddleware = ({ customerId, onNotAccessible, loader = React.create
|
|
|
34
34
|
const feedbackRouteMatchRef = useRef(feedbackRouteMatch);
|
|
35
35
|
feedbackRouteMatchRef.current = feedbackRouteMatch;
|
|
36
36
|
const [checkout] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
|
|
37
|
-
const checkoutItemsRef = useRef();
|
|
37
|
+
const checkoutItemsRef = useRef([]);
|
|
38
38
|
/* This hook is mounted at this level, although not being used directly, for optimization (regarding cache) */
|
|
39
39
|
useViewIsSizeChangeEnabledByCheckoutId({ checkoutId: checkout?.id });
|
|
40
40
|
const [startCheckout] = useStartCheckout({ checkoutId: checkout?.id, logger });
|
|
@@ -55,7 +55,9 @@ const CheckoutMiddleware = ({ customerId, onNotAccessible, loader = React.create
|
|
|
55
55
|
*/
|
|
56
56
|
const itemWithoutCustomerDecision = checkout?.items.find((item) => item.status === CheckoutItemStatus.INITIAL &&
|
|
57
57
|
checkoutItemsRef.current?.find((previousItem) => previousItem.id === item.id && previousItem.status !== CheckoutItemStatus.INITIAL)) || checkout?.items.find((item) => item.status === CheckoutItemStatus.INITIAL);
|
|
58
|
-
|
|
58
|
+
if (checkout) {
|
|
59
|
+
checkoutItemsRef.current = checkout.items;
|
|
60
|
+
}
|
|
59
61
|
/* Navigate to the summary if required */
|
|
60
62
|
if (itemWithoutCustomerDecision === undefined &&
|
|
61
63
|
!(summaryRouteMatchRef.current ||
|
|
@@ -9,7 +9,7 @@ const I18nProvider = createI18nProvider({ domain: DOMAIN });
|
|
|
9
9
|
const renderWrapper = ({ locale, messages = {}, wrapper: Wrapper = Fragment, logger = mock() }) =>
|
|
10
10
|
// eslint-disable-next-line react/display-name, react/prop-types
|
|
11
11
|
({ children }) => (React.createElement(Aurora, null,
|
|
12
|
-
React.createElement(I18nProvider, { locale: locale, messages: messages, onError: () =>
|
|
12
|
+
React.createElement(I18nProvider, { locale: locale, messages: messages, onError: () => { }, onWarn: () => { } },
|
|
13
13
|
React.createElement(LoggerProvider, { logger: logger },
|
|
14
14
|
React.createElement(Wrapper, null, children)))));
|
|
15
15
|
const renderWithProviders = (ui, { locale, messages, wrapper } = { locale: "en" }) => render(ui, { wrapper: renderWrapper({ locale, messages, wrapper }) });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReturnQuestionProjection, ReturnQuestionTypesWithChildren } from "./returnQuestion";
|
|
1
|
+
import { ReturnQuestionProjection, ReturnQuestionTypesWithChildren, ReturnQuestionTypesWithOptionalTranslationKeys } from "./returnQuestion";
|
|
2
2
|
import { ReturnQuestionType } from "./returnQuestion.constants";
|
|
3
|
-
declare const returnQuestionWithTranslationKey: (question: ReturnQuestionProjection) => question is ReturnQuestionProjection<ReturnQuestionType
|
|
3
|
+
declare const returnQuestionWithTranslationKey: (question: ReturnQuestionProjection) => question is ReturnQuestionProjection<Exclude<ReturnQuestionType, ReturnQuestionTypesWithOptionalTranslationKeys>>;
|
|
4
4
|
declare const returnQuestionHasChildren: (question: ReturnQuestionProjection) => question is ReturnQuestionProjection<ReturnQuestionTypesWithChildren>;
|
|
5
5
|
export { returnQuestionWithTranslationKey, returnQuestionHasChildren };
|
package/dist/src/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "
|
|
1
|
+
export declare const VERSION = "12.0.0";
|
package/dist/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "
|
|
1
|
+
export const VERSION = "12.0.0";
|
package/index.ts
CHANGED
|
@@ -58,9 +58,9 @@ const bootstrap: BootstrapFunction = ({ apiUrl, getAuthToken, translations, sent
|
|
|
58
58
|
};
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
export type { Project };
|
|
62
61
|
export { bootstrap, translationEndpoint, translationExternalEndpoint, Country, Segment, CheckoutStatus, Tradename };
|
|
63
62
|
export type {
|
|
63
|
+
Project,
|
|
64
64
|
SentryEnvironment,
|
|
65
65
|
KameleoonEnvironment,
|
|
66
66
|
Customer,
|
package/jest.config.js
CHANGED
package/jest.setup.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import mockAsyncStorage from "@react-native-async-storage/async-storage/jest/async-storage-mock";
|
|
2
|
-
import "@testing-library/jest-native/extend-expect";
|
|
3
2
|
import "@lookiero/sty-psp-jest-config/jest.setup.base";
|
|
4
3
|
|
|
5
4
|
require("react-native-reanimated").setUpTests();
|
|
6
5
|
|
|
6
|
+
jest.mock('react-native-reanimated', () => {
|
|
7
|
+
const Reanimated = jest.requireActual('react-native-reanimated/mock');
|
|
8
|
+
|
|
9
|
+
// Override call to prevent warnings in newer versions
|
|
10
|
+
Reanimated.default.call = () => {};
|
|
11
|
+
|
|
12
|
+
return Reanimated;
|
|
13
|
+
});
|
|
14
|
+
|
|
7
15
|
jest.mock("@react-native-async-storage/async-storage", () => mockAsyncStorage);
|
|
8
16
|
|
|
9
17
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lookiero/checkout",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"sideEffects": "false",
|
|
@@ -22,23 +22,23 @@
|
|
|
22
22
|
"@lookiero/messaging": "^8.1.1",
|
|
23
23
|
"@lookiero/messaging-react": "^8.1.1",
|
|
24
24
|
"@lookiero/sty-psp-ab-testing": "^0.3",
|
|
25
|
-
"@lookiero/sty-psp-expo-config": "^0
|
|
25
|
+
"@lookiero/sty-psp-expo-config": "^1.0",
|
|
26
26
|
"@lookiero/sty-psp-http": "^2.0",
|
|
27
27
|
"@lookiero/sty-psp-i18n": "^1.0",
|
|
28
28
|
"@lookiero/sty-psp-locale": "^0.4",
|
|
29
|
-
"@lookiero/sty-psp-logging": "^0
|
|
30
|
-
"@lookiero/sty-psp-notifications": "^
|
|
31
|
-
"@lookiero/sty-psp-react-native": "^0
|
|
29
|
+
"@lookiero/sty-psp-logging": "^1.0",
|
|
30
|
+
"@lookiero/sty-psp-notifications": "^2.0",
|
|
31
|
+
"@lookiero/sty-psp-react-native": "^1.0",
|
|
32
32
|
"@lookiero/sty-psp-segment": "^0.1",
|
|
33
33
|
"@lookiero/sty-psp-storage": "^0.2",
|
|
34
|
-
"@lookiero/sty-psp-tracking": "^0
|
|
35
|
-
"@lookiero/sty-
|
|
36
|
-
"@lookiero/sty-psp-ui": "^1.
|
|
37
|
-
"@lookiero/sty-psp-ui-settings": "^0.2",
|
|
34
|
+
"@lookiero/sty-psp-tracking": "^1.0",
|
|
35
|
+
"@lookiero/sty-psp-ui": "^2.0",
|
|
36
|
+
"@lookiero/sty-psp-ui-settings": "^1.0",
|
|
38
37
|
"@lookiero/sty-psp-units": "^0.1",
|
|
39
38
|
"@lookiero/sty-psp-uuid": "^0.2",
|
|
39
|
+
"@lookiero/sty-sp-tradename": "^1.0",
|
|
40
40
|
"react-native-keyboard-aware-scroll-view": "^0.9.5",
|
|
41
|
-
"react-native-svg": "15.
|
|
41
|
+
"react-native-svg": "15.8.0",
|
|
42
42
|
"tiny-invariant": "^1.3.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
@@ -52,20 +52,22 @@
|
|
|
52
52
|
"@lookiero/sty-psp-scripts": "*",
|
|
53
53
|
"@lookiero/sty-psp-typescript": "*",
|
|
54
54
|
"@react-native-async-storage/async-storage": "1.23.1",
|
|
55
|
+
"@react-native/assets-registry": "^0.79.2",
|
|
55
56
|
"@remix-run/router": ">=1.10",
|
|
56
|
-
"@testing-library/react-native": ">=
|
|
57
|
+
"@testing-library/react-native": ">=13",
|
|
57
58
|
"@types/jest-when": ">=3",
|
|
58
59
|
"apollo-boost": "0.4.4",
|
|
59
60
|
"buffer": "5.6.0",
|
|
60
61
|
"cypress": "^13.14.2",
|
|
61
62
|
"detox": "^20.11.0",
|
|
62
|
-
"expo-crypto": "~
|
|
63
|
+
"expo-crypto": "~14.0.2",
|
|
63
64
|
"jest-mock-extended": ">=3",
|
|
64
65
|
"jest-when": ">=3",
|
|
65
|
-
"
|
|
66
|
+
"metro": "^0.81.0",
|
|
67
|
+
"react-native-gesture-handler": "~2.20.2",
|
|
66
68
|
"react-native-get-random-values": "~1.11.0",
|
|
67
|
-
"react-native-reanimated": "~3.
|
|
68
|
-
"react-native-safe-area-context": "4.
|
|
69
|
+
"react-native-reanimated": "~3.16.1",
|
|
70
|
+
"react-native-safe-area-context": "4.12.0",
|
|
69
71
|
"webpack-bundle-analyzer": "^4.10.2"
|
|
70
72
|
},
|
|
71
73
|
"peerDependencies": {
|
|
@@ -77,14 +79,14 @@
|
|
|
77
79
|
"@lookiero/i18n-react": ">=2",
|
|
78
80
|
"@lookiero/payments-front": ">=7",
|
|
79
81
|
"apollo-boost": "0.4.4",
|
|
80
|
-
"expo": ">=
|
|
82
|
+
"expo": ">=52",
|
|
81
83
|
"expo-font": ">=12",
|
|
82
84
|
"react": ">=18",
|
|
83
|
-
"react-native": ">=0.
|
|
84
|
-
"react-native-gesture-handler": "
|
|
85
|
+
"react-native": ">=0.76",
|
|
86
|
+
"react-native-gesture-handler": ">=2.20",
|
|
85
87
|
"react-native-get-random-values": ">=1.11",
|
|
86
|
-
"react-native-reanimated": "
|
|
87
|
-
"react-native-safe-area-context": ">=4.
|
|
88
|
+
"react-native-reanimated": ">=3.16",
|
|
89
|
+
"react-native-safe-area-context": ">=4.12",
|
|
88
90
|
"react-router-dom": ">=6.14",
|
|
89
91
|
"react-router-native": ">=6.14",
|
|
90
92
|
"uuid": ">=9"
|
package/src/ExpoRoot.tsx
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { PortalProvider } from "@gorhom/portal";
|
|
2
2
|
import { useFonts } from "expo-font";
|
|
3
|
-
import "expo/build/Expo.fx";
|
|
4
3
|
import React, { FC, useCallback, useState } from "react";
|
|
5
4
|
import { Platform, ScrollView } from "react-native";
|
|
6
5
|
import { Navigate, Route, Routes } from "react-router-native";
|
|
@@ -38,7 +37,7 @@ const order: OrderProjection = {
|
|
|
38
37
|
};
|
|
39
38
|
|
|
40
39
|
const customer: Customer = {
|
|
41
|
-
customerId: "
|
|
40
|
+
customerId: "5c38e826-3d01-4a4b-a3d1-8a4166dc2a31",
|
|
42
41
|
country: Country.NL,
|
|
43
42
|
segment: Segment.WOMEN,
|
|
44
43
|
email: "email@example.com",
|
|
@@ -59,7 +58,7 @@ const apiUrl =
|
|
|
59
58
|
? "/local-to-dev"
|
|
60
59
|
: "/checkout/api";
|
|
61
60
|
const authToken =
|
|
62
|
-
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.
|
|
61
|
+
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjU3MDEwMTIsImV4cCI6MTc1MDMyMTgwOSwiZGlzcGxheU5hbWUiOiJUZXN0aW5nIiwiY291bnRyeV9jb2RlIjoiRVMiLCJhY2Nlc3NWaWEiOiJlbWFpbCIsInN1YnNjcmlwdGlvblN0YXJ0aW5nRGF0ZSI6IjIwMjUtMDUtMTkiLCJpbXBlcnNvbmF0ZWQiOmZhbHNlLCJ1dWlkIjoiNWMzOGU4MjYtM2QwMS00YTRiLWEzZDEtOGE0MTY2ZGMyYTMxIiwidHJhZGVuYW1lIjoiTE9PS0lFUk8iLCJpYXQiOjE3NDc2NDM0MDl9.-amqZAXKy9KKeo9a7bOQigWw1flM99OBlddxbMBA_PU";
|
|
63
62
|
const getAuthToken = () => Promise.resolve(authToken);
|
|
64
63
|
|
|
65
64
|
const externalTranslationsUrl =
|
|
@@ -6,6 +6,7 @@ import { NotificationLevel, useCreateToastNotification } from "@lookiero/sty-psp
|
|
|
6
6
|
import { Segment } from "@lookiero/sty-psp-segment";
|
|
7
7
|
import { CheckoutItemStatus } from "../../../domain/checkoutItem/model/checkoutItem";
|
|
8
8
|
import { CheckoutBookingProjection } from "../../../projection/checkoutBooking/checkoutBooking";
|
|
9
|
+
import { Customer } from "../../../projection/customer/customer";
|
|
9
10
|
import { OrderProjection } from "../../../projection/order/order";
|
|
10
11
|
import { SubscriptionProjection } from "../../../projection/subscription/subscription";
|
|
11
12
|
import { useSubmitCheckout } from "../../domain/checkout/react/useSubmitCheckout";
|
|
@@ -45,8 +46,17 @@ const country = Country.ES;
|
|
|
45
46
|
const email = "email@example.com";
|
|
46
47
|
const name = "Adèle Léonce Émilie";
|
|
47
48
|
const segment = Segment.WOMEN;
|
|
49
|
+
|
|
50
|
+
const mockCustomer: Customer = {
|
|
51
|
+
customerId,
|
|
52
|
+
country,
|
|
53
|
+
segment,
|
|
54
|
+
name,
|
|
55
|
+
email,
|
|
56
|
+
};
|
|
57
|
+
|
|
48
58
|
jest.mock("./useStaticInfo", () => ({
|
|
49
|
-
useStaticInfo: () => ({ customer:
|
|
59
|
+
useStaticInfo: () => ({ customer: mockCustomer, basePath }),
|
|
50
60
|
}));
|
|
51
61
|
|
|
52
62
|
// const errorChargeStatuses = Object.values(ChargeStatus).filter((status) => status !== ChargeStatus.EXECUTED);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { renderHook, waitFor } from "@testing-library/react-native";
|
|
2
2
|
import { mockFn } from "jest-mock-extended";
|
|
3
|
-
import React, { FC } from "react";
|
|
3
|
+
import React, { FC, JSX } from "react";
|
|
4
4
|
import { QueryBus } from "@lookiero/messaging";
|
|
5
5
|
import { QueryBusProvider, useQueryBus as sut } from "./useQueryBus";
|
|
6
6
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { renderHook, waitFor } from "@testing-library/react-native";
|
|
2
|
-
import React, { FC } from "react";
|
|
2
|
+
import React, { FC, JSX } from "react";
|
|
3
3
|
import { Tradename } from "@lookiero/sty-sp-tradename";
|
|
4
4
|
import { Customer } from "../../../projection/customer/customer";
|
|
5
5
|
import { KameleoonEnvironment } from "../../ab-testing/kameleoonEnvironment";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { FC, useEffect, useRef } from "react";
|
|
1
|
+
import React, { FC, JSX, useEffect, useRef } from "react";
|
|
2
2
|
import { generatePath, useMatch, useNavigate } from "react-router-native";
|
|
3
3
|
import { Spinner } from "@lookiero/aurora";
|
|
4
4
|
import { useLogger } from "@lookiero/sty-psp-logging";
|
|
@@ -50,7 +50,7 @@ const CheckoutMiddleware: FC<CheckoutMiddlewareProps> = ({
|
|
|
50
50
|
feedbackRouteMatchRef.current = feedbackRouteMatch;
|
|
51
51
|
|
|
52
52
|
const [checkout] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
|
|
53
|
-
const checkoutItemsRef = useRef<CheckoutItemProjection[]>();
|
|
53
|
+
const checkoutItemsRef = useRef<CheckoutItemProjection[]>([]);
|
|
54
54
|
|
|
55
55
|
/* This hook is mounted at this level, although not being used directly, for optimization (regarding cache) */
|
|
56
56
|
useViewIsSizeChangeEnabledByCheckoutId({ checkoutId: checkout?.id });
|
|
@@ -84,7 +84,9 @@ const CheckoutMiddleware: FC<CheckoutMiddlewareProps> = ({
|
|
|
84
84
|
),
|
|
85
85
|
) || checkout?.items.find((item) => item.status === CheckoutItemStatus.INITIAL);
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
if (checkout) {
|
|
88
|
+
checkoutItemsRef.current = checkout.items;
|
|
89
|
+
}
|
|
88
90
|
|
|
89
91
|
/* Navigate to the summary if required */
|
|
90
92
|
if (
|
|
@@ -26,7 +26,7 @@ const renderWrapper: RenderWrapperFunction =
|
|
|
26
26
|
// eslint-disable-next-line react/display-name, react/prop-types
|
|
27
27
|
({ children }) => (
|
|
28
28
|
<Aurora>
|
|
29
|
-
<I18nProvider locale={locale as string} messages={messages} onError={() =>
|
|
29
|
+
<I18nProvider locale={locale as string} messages={messages} onError={() => {}} onWarn={() => {}}>
|
|
30
30
|
<LoggerProvider logger={logger}>
|
|
31
31
|
<Wrapper>{children}</Wrapper>
|
|
32
32
|
</LoggerProvider>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PortalHost } from "@gorhom/portal";
|
|
2
|
-
import React, { FC } from "react";
|
|
2
|
+
import React, { FC, JSX } from "react";
|
|
3
3
|
import { StatusBar } from "react-native";
|
|
4
4
|
import { SafeAreaProvider } from "react-native-safe-area-context";
|
|
5
5
|
import { Notifications } from "@lookiero/sty-psp-notifications";
|
|
@@ -6,6 +6,7 @@ import { Country } from "@lookiero/sty-psp-locale";
|
|
|
6
6
|
import { Segment } from "@lookiero/sty-psp-segment";
|
|
7
7
|
import { DummyLayout } from "@lookiero/sty-psp-ui";
|
|
8
8
|
import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
|
|
9
|
+
import { Customer } from "../../../../projection/customer/customer";
|
|
9
10
|
import { OrderProjection } from "../../../../projection/order/order";
|
|
10
11
|
import { SubscriptionProjection } from "../../../../projection/subscription/subscription";
|
|
11
12
|
import { checkout } from "../../../projection/checkout/checkout.mock";
|
|
@@ -22,6 +23,11 @@ const customerId = "a8fff6d7-708c-41a7-b42a-58c5706d33df";
|
|
|
22
23
|
const basePath = "/checkout";
|
|
23
24
|
const country = Country.ES;
|
|
24
25
|
const segment = Segment.WOMEN;
|
|
26
|
+
const mockCustomer: Customer = {
|
|
27
|
+
customerId,
|
|
28
|
+
country,
|
|
29
|
+
segment,
|
|
30
|
+
} as Customer;
|
|
25
31
|
const mockCheckout = checkout({
|
|
26
32
|
items: [
|
|
27
33
|
{ status: CheckoutItemStatus.RETURNED },
|
|
@@ -41,14 +47,15 @@ const mockUseRedirect = jest.fn(() => ({ returnUrl: "https://web2.dev.aws.lookie
|
|
|
41
47
|
|
|
42
48
|
const mockOnSuccess = jest.fn();
|
|
43
49
|
const mockCheckoutFlow = jest.fn();
|
|
50
|
+
const mockStatus = QueryStatus.SUCCESS;
|
|
44
51
|
const paymentFlowTestId = "payment-flow";
|
|
45
52
|
const mockPaymentFlowComponent: ReactNode = <View testID={paymentFlowTestId}>PaymentFlow</View>;
|
|
46
53
|
jest.mock("../../hooks/useCheckoutFlow", () => ({
|
|
47
|
-
useCheckoutFlow: () => [mockCheckoutFlow,
|
|
54
|
+
useCheckoutFlow: () => [mockCheckoutFlow, mockStatus, mockPaymentFlowComponent],
|
|
48
55
|
}));
|
|
49
56
|
|
|
50
57
|
jest.mock("../../hooks/useStaticInfo", () => ({
|
|
51
|
-
useStaticInfo: () => ({ customer:
|
|
58
|
+
useStaticInfo: () => ({ customer: mockCustomer, basePath }),
|
|
52
59
|
}));
|
|
53
60
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
54
61
|
jest.mock("./components/paymentInstrument/PaymentInstrument", () => ({ PaymentInstrument: () => null }));
|
|
@@ -5,6 +5,7 @@ import { Country } from "@lookiero/sty-psp-locale";
|
|
|
5
5
|
import { Segment } from "@lookiero/sty-psp-segment";
|
|
6
6
|
import { DummyLayout } from "@lookiero/sty-psp-ui";
|
|
7
7
|
import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
|
|
8
|
+
import { Customer } from "../../../../projection/customer/customer";
|
|
8
9
|
import { useGiveCheckoutFeedback } from "../../../domain/checkoutFeedback/react/useGiveCheckoutFeedback";
|
|
9
10
|
import { checkout } from "../../../projection/checkout/checkout.mock";
|
|
10
11
|
import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
|
|
@@ -25,9 +26,14 @@ const checkoutMock = checkout({
|
|
|
25
26
|
],
|
|
26
27
|
});
|
|
27
28
|
const mockGiveCheckoutFeedback = jest.fn();
|
|
29
|
+
const mockCustomer: Customer = {
|
|
30
|
+
customerId,
|
|
31
|
+
country,
|
|
32
|
+
segment,
|
|
33
|
+
} as Customer;
|
|
28
34
|
|
|
29
35
|
jest.mock("../../hooks/useStaticInfo", () => ({
|
|
30
|
-
useStaticInfo: () => ({ customer:
|
|
36
|
+
useStaticInfo: () => ({ customer: mockCustomer }),
|
|
31
37
|
}));
|
|
32
38
|
|
|
33
39
|
jest.mock("../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId");
|
|
@@ -5,6 +5,7 @@ import { Country } from "@lookiero/sty-psp-locale";
|
|
|
5
5
|
import { Segment } from "@lookiero/sty-psp-segment";
|
|
6
6
|
import { DummyLayout } from "@lookiero/sty-psp-ui";
|
|
7
7
|
import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
|
|
8
|
+
import { Customer } from "../../../../projection/customer/customer";
|
|
8
9
|
import { useBookCheckoutBookingForCheckoutItem } from "../../../domain/checkoutBooking/react/useBookCheckoutBookingForCheckoutItem";
|
|
9
10
|
import { useKeepCheckoutItem } from "../../../domain/checkoutItem/react/useKeepCheckoutItem";
|
|
10
11
|
import { useReplaceCheckoutItem } from "../../../domain/checkoutItem/react/useReplaceCheckoutItem";
|
|
@@ -26,9 +27,14 @@ const mockFirstCheckoutItemId = "a5422445-0e62-4b11-8a3f-1bb5469ee154";
|
|
|
26
27
|
const customerId = "a8fff6d7-708c-41a7-b42a-58c5706d33df";
|
|
27
28
|
const country = Country.ES;
|
|
28
29
|
const segment = Segment.WOMEN;
|
|
30
|
+
const mockCustomer: Customer = {
|
|
31
|
+
customerId,
|
|
32
|
+
country,
|
|
33
|
+
segment,
|
|
34
|
+
} as Customer;
|
|
29
35
|
|
|
30
36
|
jest.mock("../../hooks/useStaticInfo", () => ({
|
|
31
|
-
useStaticInfo: () => ({ customer:
|
|
37
|
+
useStaticInfo: () => ({ customer: mockCustomer }),
|
|
32
38
|
}));
|
|
33
39
|
|
|
34
40
|
const mockNavigate = jest.fn();
|
|
@@ -58,15 +58,7 @@ exports[`GetOutOfCheckoutModal component matches the snapshot 1`] = `
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
accessible={true}
|
|
61
|
-
collapsable={false}
|
|
62
61
|
focusable={true}
|
|
63
|
-
jestAnimatedStyle={
|
|
64
|
-
{
|
|
65
|
-
"value": {
|
|
66
|
-
"opacity": 1,
|
|
67
|
-
},
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
62
|
onClick={[Function]}
|
|
71
63
|
onResponderGrant={[Function]}
|
|
72
64
|
onResponderMove={[Function]}
|
|
@@ -75,14 +67,19 @@ exports[`GetOutOfCheckoutModal component matches the snapshot 1`] = `
|
|
|
75
67
|
onResponderTerminationRequest={[Function]}
|
|
76
68
|
onStartShouldSetResponder={[Function]}
|
|
77
69
|
style={
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
70
|
+
[
|
|
71
|
+
{
|
|
72
|
+
"backgroundColor": "rgba(12, 10, 10, 0.7)",
|
|
73
|
+
"height": "100%",
|
|
74
|
+
"position": "absolute",
|
|
75
|
+
"width": "100%",
|
|
76
|
+
"zIndex": 1,
|
|
77
|
+
},
|
|
78
|
+
undefined,
|
|
79
|
+
{
|
|
80
|
+
"opacity": 1,
|
|
81
|
+
},
|
|
82
|
+
]
|
|
86
83
|
}
|
|
87
84
|
testID="modal-close-button"
|
|
88
85
|
/>
|
|
@@ -116,10 +113,26 @@ exports[`GetOutOfCheckoutModal component matches the snapshot 1`] = `
|
|
|
116
113
|
}
|
|
117
114
|
>
|
|
118
115
|
<View
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
116
|
+
pointerEvents="auto"
|
|
117
|
+
style={
|
|
118
|
+
[
|
|
119
|
+
{
|
|
120
|
+
"backgroundColor": "#FFFFFF",
|
|
121
|
+
"borderRadius": 16,
|
|
122
|
+
"position": "absolute",
|
|
123
|
+
"width": "100%",
|
|
124
|
+
"zIndex": 3,
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"borderBottomLeftRadius": 0,
|
|
128
|
+
"borderBottomRightRadius": 0,
|
|
129
|
+
},
|
|
130
|
+
undefined,
|
|
131
|
+
{
|
|
132
|
+
"maxHeight": 800,
|
|
133
|
+
},
|
|
134
|
+
undefined,
|
|
135
|
+
{
|
|
123
136
|
"opacity": 1,
|
|
124
137
|
"transform": [
|
|
125
138
|
{
|
|
@@ -130,29 +143,7 @@ exports[`GetOutOfCheckoutModal component matches the snapshot 1`] = `
|
|
|
130
143
|
},
|
|
131
144
|
],
|
|
132
145
|
},
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
pointerEvents="auto"
|
|
136
|
-
style={
|
|
137
|
-
{
|
|
138
|
-
"backgroundColor": "#FFFFFF",
|
|
139
|
-
"borderBottomLeftRadius": 0,
|
|
140
|
-
"borderBottomRightRadius": 0,
|
|
141
|
-
"borderRadius": 16,
|
|
142
|
-
"maxHeight": 800,
|
|
143
|
-
"opacity": 1,
|
|
144
|
-
"position": "absolute",
|
|
145
|
-
"transform": [
|
|
146
|
-
{
|
|
147
|
-
"translateY": 0,
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
"scale": 1,
|
|
151
|
-
},
|
|
152
|
-
],
|
|
153
|
-
"width": "100%",
|
|
154
|
-
"zIndex": 3,
|
|
155
|
-
}
|
|
146
|
+
]
|
|
156
147
|
}
|
|
157
148
|
>
|
|
158
149
|
<View
|
|
@@ -632,15 +632,7 @@ exports[`ItemActions component matches the snapshot 1`] = `
|
|
|
632
632
|
}
|
|
633
633
|
}
|
|
634
634
|
accessible={true}
|
|
635
|
-
collapsable={false}
|
|
636
635
|
focusable={false}
|
|
637
|
-
jestAnimatedStyle={
|
|
638
|
-
{
|
|
639
|
-
"value": {
|
|
640
|
-
"opacity": 0,
|
|
641
|
-
},
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
636
|
onClick={[Function]}
|
|
645
637
|
onResponderGrant={[Function]}
|
|
646
638
|
onResponderMove={[Function]}
|
|
@@ -649,14 +641,19 @@ exports[`ItemActions component matches the snapshot 1`] = `
|
|
|
649
641
|
onResponderTerminationRequest={[Function]}
|
|
650
642
|
onStartShouldSetResponder={[Function]}
|
|
651
643
|
style={
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
644
|
+
[
|
|
645
|
+
{
|
|
646
|
+
"backgroundColor": "rgba(12, 10, 10, 0.7)",
|
|
647
|
+
"height": "100%",
|
|
648
|
+
"position": "absolute",
|
|
649
|
+
"width": "100%",
|
|
650
|
+
"zIndex": 1,
|
|
651
|
+
},
|
|
652
|
+
undefined,
|
|
653
|
+
{
|
|
654
|
+
"opacity": 0,
|
|
655
|
+
},
|
|
656
|
+
]
|
|
660
657
|
}
|
|
661
658
|
testID="modal-close-button"
|
|
662
659
|
/>
|
|
@@ -690,10 +687,26 @@ exports[`ItemActions component matches the snapshot 1`] = `
|
|
|
690
687
|
}
|
|
691
688
|
>
|
|
692
689
|
<View
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
690
|
+
pointerEvents="none"
|
|
691
|
+
style={
|
|
692
|
+
[
|
|
693
|
+
{
|
|
694
|
+
"backgroundColor": "#FFFFFF",
|
|
695
|
+
"borderRadius": 16,
|
|
696
|
+
"position": "absolute",
|
|
697
|
+
"width": "100%",
|
|
698
|
+
"zIndex": 3,
|
|
699
|
+
},
|
|
700
|
+
{
|
|
701
|
+
"borderBottomLeftRadius": 0,
|
|
702
|
+
"borderBottomRightRadius": 0,
|
|
703
|
+
},
|
|
704
|
+
undefined,
|
|
705
|
+
{
|
|
706
|
+
"maxHeight": 800,
|
|
707
|
+
},
|
|
708
|
+
undefined,
|
|
709
|
+
{
|
|
697
710
|
"opacity": 1,
|
|
698
711
|
"transform": [
|
|
699
712
|
{
|
|
@@ -704,29 +717,7 @@ exports[`ItemActions component matches the snapshot 1`] = `
|
|
|
704
717
|
},
|
|
705
718
|
],
|
|
706
719
|
},
|
|
707
|
-
|
|
708
|
-
}
|
|
709
|
-
pointerEvents="none"
|
|
710
|
-
style={
|
|
711
|
-
{
|
|
712
|
-
"backgroundColor": "#FFFFFF",
|
|
713
|
-
"borderBottomLeftRadius": 0,
|
|
714
|
-
"borderBottomRightRadius": 0,
|
|
715
|
-
"borderRadius": 16,
|
|
716
|
-
"maxHeight": 800,
|
|
717
|
-
"opacity": 1,
|
|
718
|
-
"position": "absolute",
|
|
719
|
-
"transform": [
|
|
720
|
-
{
|
|
721
|
-
"translateY": 800,
|
|
722
|
-
},
|
|
723
|
-
{
|
|
724
|
-
"scale": 1,
|
|
725
|
-
},
|
|
726
|
-
],
|
|
727
|
-
"width": "100%",
|
|
728
|
-
"zIndex": 3,
|
|
729
|
-
}
|
|
720
|
+
]
|
|
730
721
|
}
|
|
731
722
|
>
|
|
732
723
|
<View
|