@lookiero/checkout 6.6.0 → 7.0.0-beta.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 +0 -8
- package/dist/index.js +0 -3
- package/dist/public/public/assets/adaptive-icon.png +0 -0
- package/dist/public/public/assets/favicon.png +0 -0
- package/dist/public/public/assets/icon.png +0 -0
- package/dist/public/public/assets/splash.png +0 -0
- package/dist/public/public/images/not-found.png +0 -0
- package/dist/src/Expo.js +0 -2
- package/dist/src/ExpoRoot.js +8 -1
- package/dist/src/infrastructure/ab-testing/kameleoonEnvironment.d.ts +6 -2
- package/dist/src/infrastructure/delivery/baseBootstrap.js +0 -2
- package/dist/src/infrastructure/ui/components/layouts/layout/Layout.d.ts +21 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/Layout.js +1 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/components/footer/Footer.d.ts +6 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/components/footer/Footer.js +4 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.d.ts +6 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.js +5 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.style.d.ts +4 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.style.js +19 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.d.ts +3 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.js +18 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.style.d.ts +12 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.style.js +13 -0
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.js +10 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.style.d.ts +7 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.style.js +7 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.js +7 -2
- package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.d.ts +6 -0
- package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.js +11 -0
- package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.style.d.ts +8 -0
- package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.style.js +11 -0
- package/dist/src/infrastructure/ui/hooks/useNewFeedbackExperiment.d.ts +11 -0
- package/dist/src/infrastructure/ui/hooks/useNewFeedbackExperiment.js +49 -0
- package/dist/src/infrastructure/ui/routing/Routing.js +13 -13
- package/dist/src/infrastructure/ui/views/checkout/Checkout.js +4 -4
- package/dist/src/infrastructure/ui/views/feedback/Feedback.d.ts +2 -2
- package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.style.d.ts +7 -0
- package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.style.js +10 -0
- package/dist/src/infrastructure/ui/views/item/Item.js +33 -4
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.d.ts +11 -0
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.js +40 -0
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.d.ts +12 -0
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.js +15 -0
- package/dist/src/infrastructure/ui/views/return/Return.js +127 -8
- package/dist/src/infrastructure/ui/views/return/components/productVariantPreview/ProductVariantPreview.js +7 -5
- package/dist/src/infrastructure/ui/views/summary/Summary.js +4 -4
- package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.d.ts +13 -0
- package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.js +9 -0
- package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.style.d.ts +7 -0
- package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.style.js +10 -0
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/index.ts +0 -17
- package/package.json +1 -3
- package/src/Expo.tsx +0 -3
- package/src/ExpoRoot.tsx +8 -1
- package/src/infrastructure/ab-testing/kameleoonEnvironment.ts +7 -3
- package/src/infrastructure/delivery/baseBootstrap.ts +0 -5
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.style.ts +7 -1
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.test.tsx +5 -0
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.tsx +17 -2
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.test.tsx +5 -0
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.tsx +20 -11
- package/src/infrastructure/ui/hooks/useNewFeedbackExperiment.test.tsx +84 -0
- package/src/infrastructure/ui/hooks/useNewFeedbackExperiment.tsx +82 -0
- package/src/infrastructure/ui/routing/Routing.tsx +18 -21
- package/src/infrastructure/ui/views/checkout/Checkout.tsx +6 -6
- package/src/infrastructure/ui/views/feedback/Feedback.tsx +2 -2
- package/src/infrastructure/ui/views/item/Item.test.tsx +62 -6
- package/src/infrastructure/ui/views/item/Item.tsx +48 -5
- package/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.ts +18 -0
- package/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.tsx +79 -0
- package/src/infrastructure/ui/views/return/Return.tsx +200 -12
- package/src/infrastructure/ui/views/return/components/productVariantPreview/ProductVariantPreview.tsx +7 -12
- package/src/infrastructure/ui/views/summary/Summary.tsx +6 -6
- package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.d.ts +0 -15
- package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.js +0 -112
- package/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.test.ts +0 -45
- package/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.ts +0 -33
- package/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.test.tsx +0 -74
- package/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.tsx +0 -39
- package/src/infrastructure/ui/views/return/Return.test.tsx +0 -54
- package/src/infrastructure/ui/views/return/components/productVariantPreview/ProductVariantPreview.test.tsx +0 -32
- package/src/infrastructure/ui/views/return/components/productVariantPreview/__snapshots__/ProductVariantPreview.test.tsx.snap +0 -221
- package/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.test.tsx +0 -95
- package/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.tsx +0 -184
- package/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.test.ts +0 -54
- package/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.ts +0 -46
- /package/dist/src/infrastructure/ui/views/return/{components/returnQuestionsForm/ReturnQuestionsForm.style.d.ts → Return.style.d.ts} +0 -0
- /package/dist/src/infrastructure/ui/views/return/{components/returnQuestionsForm/ReturnQuestionsForm.style.js → Return.style.js} +0 -0
- /package/src/infrastructure/ui/views/return/{components/returnQuestionsForm/ReturnQuestionsForm.style.ts → Return.style.ts} +0 -0
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { PortalHost } from "@gorhom/portal";
|
|
2
|
-
import React, { useCallback, useMemo } from "react";
|
|
3
|
-
import { ScrollView } from "react-native";
|
|
4
|
-
import { generatePath, useNavigate } from "react-router-native";
|
|
5
|
-
import { Box, Button, Layout as AuroraLayout, Spinner, Text, View, useDevice } from "@lookiero/aurora";
|
|
6
|
-
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
7
|
-
import { CommandStatus } from "@lookiero/messaging-react";
|
|
8
|
-
import { useLogger } from "@lookiero/sty-psp-logging";
|
|
9
|
-
import { ReturnQuestionType } from "../../../../../../projection/returnQuestion/returnQuestion";
|
|
10
|
-
import { useReturnCheckoutItem } from "../../../../../domain/checkoutItem/react/useReturnCheckoutItem";
|
|
11
|
-
import { useListReturnQuestionsByCheckoutItemId } from "../../../../../projection/returnQuestion/react/useListReturnQuestionsByCheckoutItemId";
|
|
12
|
-
import { TrackingPage } from "../../../../../tracking/tracking";
|
|
13
|
-
import { useTrackPageView } from "../../../../../tracking/useTrackPageView";
|
|
14
|
-
import { useTrackPressBack } from "../../../../../tracking/useTrackPressBack";
|
|
15
|
-
import { useTrackPressNext } from "../../../../../tracking/useTrackPressNext";
|
|
16
|
-
import { useTrackReturnItem } from "../../../../../tracking/useTrackReturnItem";
|
|
17
|
-
import { ReturnQuestions } from "../../../../components/organisms/returnQuestions/ReturnQuestions";
|
|
18
|
-
import { useReturnQuestionFeedback } from "../../../../components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback";
|
|
19
|
-
import { ReturnQuestionItemProvider, } from "../../../../components/organisms/returnQuestions/behaviors/useReturnQuestionItem";
|
|
20
|
-
import { HostDefaultReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem";
|
|
21
|
-
import { HostRadioGroupReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem";
|
|
22
|
-
import { HostStackReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/hostStackReturnQuestionItem/form/HostStackReturnQuestionItem";
|
|
23
|
-
import { RadioReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/radioReturnQuestionItem/RadioReturnQuestionItem";
|
|
24
|
-
import { TextareaReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem";
|
|
25
|
-
import { ItemDetailHeader } from "../../../../components/templates/header/itemDetailHeader/ItemDetailHeader";
|
|
26
|
-
import { I18nMessages } from "../../../../i18n/i18n";
|
|
27
|
-
import { Routes } from "../../../../routing/routes";
|
|
28
|
-
import { useBasePath } from "../../../../routing/useBasePath";
|
|
29
|
-
import { ProductVariantPreview } from "../productVariantPreview/ProductVariantPreview";
|
|
30
|
-
import { style } from "./ReturnQuestionsForm.style";
|
|
31
|
-
const RETURN_QUESTION_FORM_PORTAL_HOST_NAME = "return-question-form-portal";
|
|
32
|
-
const returnQuestionItems = {
|
|
33
|
-
[ReturnQuestionType.HOST_DEFAULT]: HostDefaultReturnQuestionItem,
|
|
34
|
-
[ReturnQuestionType.HOST_TEXTAREA]: HostDefaultReturnQuestionItem,
|
|
35
|
-
[ReturnQuestionType.HOST_SELECT]: HostRadioGroupReturnQuestionItem,
|
|
36
|
-
[ReturnQuestionType.HOST_STACK]: HostStackReturnQuestionItem,
|
|
37
|
-
[ReturnQuestionType.TEXTAREA]: TextareaReturnQuestionItem,
|
|
38
|
-
[ReturnQuestionType.OPTION]: RadioReturnQuestionItem,
|
|
39
|
-
};
|
|
40
|
-
const ReturnQuestionsForm = ({ checkout, checkoutItem, country, layout: Layout, segment, }) => {
|
|
41
|
-
const navigate = useNavigate();
|
|
42
|
-
const basePath = useBasePath();
|
|
43
|
-
const logger = useLogger();
|
|
44
|
-
const { screen } = useDevice();
|
|
45
|
-
const titleText = useI18nMessage({ id: I18nMessages.RETURN_QUESTIONS_TITLE });
|
|
46
|
-
const descriptionText = useI18nMessage({ id: I18nMessages.RETURN_QUESTIONS_DESCRIPTION });
|
|
47
|
-
const submitButtonText = useI18nMessage({ id: I18nMessages.RETURN_QUESTIONS_SUBMIT_BUTTON });
|
|
48
|
-
const feedback = useReturnQuestionFeedback();
|
|
49
|
-
const [returnQuestions] = useListReturnQuestionsByCheckoutItemId({
|
|
50
|
-
checkoutItemId: checkoutItem.id,
|
|
51
|
-
});
|
|
52
|
-
const [returnCheckoutItem, returnCheckoutItemStatus] = useReturnCheckoutItem({
|
|
53
|
-
checkoutItemId: checkoutItem.id,
|
|
54
|
-
logger,
|
|
55
|
-
});
|
|
56
|
-
const trackReturnItem = useTrackReturnItem({
|
|
57
|
-
page: TrackingPage.RETURN,
|
|
58
|
-
country,
|
|
59
|
-
segment,
|
|
60
|
-
checkoutId: checkout.id,
|
|
61
|
-
checkoutItemId: checkoutItem.id,
|
|
62
|
-
});
|
|
63
|
-
useTrackPageView({ checkoutId: checkout.id, country, segment, page: TrackingPage.RETURN });
|
|
64
|
-
const trackPressBack = useTrackPressBack({
|
|
65
|
-
page: TrackingPage.ITEM,
|
|
66
|
-
country,
|
|
67
|
-
segment,
|
|
68
|
-
checkoutId: checkout?.id,
|
|
69
|
-
});
|
|
70
|
-
const handleOnBack = useCallback(() => {
|
|
71
|
-
trackPressBack();
|
|
72
|
-
navigate(-1);
|
|
73
|
-
}, [navigate, trackPressBack]);
|
|
74
|
-
const trackPressNext = useTrackPressNext({
|
|
75
|
-
page: TrackingPage.ITEM,
|
|
76
|
-
country,
|
|
77
|
-
segment,
|
|
78
|
-
checkoutId: checkout.id,
|
|
79
|
-
});
|
|
80
|
-
const handleOnSubmit = useCallback(async () => {
|
|
81
|
-
returnCheckoutItem({ feedbacks: feedback });
|
|
82
|
-
trackReturnItem();
|
|
83
|
-
const itemIndex = checkout.items.indexOf(checkoutItem);
|
|
84
|
-
const nextItemIndex = itemIndex === checkout.items.length - 1 ? 0 : itemIndex + 1;
|
|
85
|
-
const nextItem = checkout.items[nextItemIndex];
|
|
86
|
-
trackPressNext({ from: checkoutItem.id, to: nextItem.id });
|
|
87
|
-
navigate(generatePath(`${basePath}/${Routes.ITEM}`, { id: nextItem.id }));
|
|
88
|
-
}, [basePath, checkout.items, checkoutItem, feedback, navigate, returnCheckoutItem, trackPressNext, trackReturnItem]);
|
|
89
|
-
const header = useMemo(() => (React.createElement(Box, { style: style.headerWrapper },
|
|
90
|
-
React.createElement(ItemDetailHeader, { onBack: handleOnBack }))), [handleOnBack]);
|
|
91
|
-
const dependenciesLoaded = checkoutItem && returnQuestions && returnCheckoutItemStatus !== CommandStatus.LOADING;
|
|
92
|
-
if (!dependenciesLoaded) {
|
|
93
|
-
return React.createElement(Spinner, null);
|
|
94
|
-
}
|
|
95
|
-
return (React.createElement(ReturnQuestionItemProvider, { returnQuestionItems: returnQuestionItems },
|
|
96
|
-
React.createElement(PortalHost, { name: RETURN_QUESTION_FORM_PORTAL_HOST_NAME }),
|
|
97
|
-
React.createElement(Layout, { header: header, scrollEnabled: false, style: {
|
|
98
|
-
safeAreaView: style.safeAreaView,
|
|
99
|
-
scrollView: style.scrollView,
|
|
100
|
-
} },
|
|
101
|
-
React.createElement(ProductVariantPreview, { country: country, item: checkoutItem }),
|
|
102
|
-
React.createElement(ScrollView, { showsVerticalScrollIndicator: false, testID: "return-questions-form" },
|
|
103
|
-
React.createElement(AuroraLayout, { fullWidth: !screen.L, style: [style.layout, screen.L ? style.desktopLayoutSpacing : undefined] },
|
|
104
|
-
React.createElement(Box, { size: { L: "2/3" } },
|
|
105
|
-
React.createElement(View, { style: [style.info, !screen.S && style.desktopInfo] },
|
|
106
|
-
React.createElement(Text, { level: 3, heading: true }, titleText),
|
|
107
|
-
React.createElement(Text, { level: 1, style: style.description, detail: true }, descriptionText)),
|
|
108
|
-
React.createElement(ReturnQuestions, { portalHostName: RETURN_QUESTION_FORM_PORTAL_HOST_NAME, returnQuestions: returnQuestions }),
|
|
109
|
-
React.createElement(View, { style: style.submit },
|
|
110
|
-
React.createElement(Button, { testID: "return-questions-button", onPress: handleOnSubmit }, submitButtonText))))))));
|
|
111
|
-
};
|
|
112
|
-
export { ReturnQuestionsForm };
|
package/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.test.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { renderHook, waitFor } from "@testing-library/react-native";
|
|
2
|
-
import { bootstrap, QueryStatus } from "@lookiero/messaging-react";
|
|
3
|
-
import { CheckoutProjection } from "../../../../projection/checkout/checkout";
|
|
4
|
-
import {
|
|
5
|
-
viewFirstAvailableCheckoutByCustomerIdHandler,
|
|
6
|
-
VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID,
|
|
7
|
-
} from "../../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
|
|
8
|
-
import {
|
|
9
|
-
viewIsCheckoutAccessibleByCustomerIdHandler,
|
|
10
|
-
VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID,
|
|
11
|
-
} from "../../../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
|
|
12
|
-
import {
|
|
13
|
-
viewIsCheckoutEnabledByCustomerIdHandler,
|
|
14
|
-
VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID,
|
|
15
|
-
} from "../../../../projection/checkout/viewIsCheckoutEnabledByCustomerId";
|
|
16
|
-
import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
|
|
17
|
-
import { useViewIsCheckoutAccessibleByCustomerId as sut } from "./useViewIsCheckoutAccessibleByCustomerId";
|
|
18
|
-
|
|
19
|
-
const customerId = "29790d24-b139-4ab8-b618-d796d101e974";
|
|
20
|
-
const checkoutProjection: CheckoutProjection = { id: "75574065-5838-42de-9924-c712f7854347" } as CheckoutProjection;
|
|
21
|
-
const firstAvailableCheckoutByCustomerIdViewMock = jest.fn().mockReturnValue(checkoutProjection);
|
|
22
|
-
const isCheckoutAccessibleByCustomerIdViewMock = jest.fn().mockReturnValue(checkoutProjection);
|
|
23
|
-
|
|
24
|
-
const { Component: Messaging } = bootstrap({ id: MESSAGING_CONTEXT_ID })
|
|
25
|
-
.query(VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID, viewFirstAvailableCheckoutByCustomerIdHandler, {
|
|
26
|
-
view: firstAvailableCheckoutByCustomerIdViewMock,
|
|
27
|
-
})
|
|
28
|
-
.query(VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID, viewIsCheckoutEnabledByCustomerIdHandler, {
|
|
29
|
-
view: isCheckoutAccessibleByCustomerIdViewMock,
|
|
30
|
-
})
|
|
31
|
-
.query(VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, viewIsCheckoutAccessibleByCustomerIdHandler)
|
|
32
|
-
.build();
|
|
33
|
-
|
|
34
|
-
describe("useViewIsCheckoutAccessibleByCustomerId integration hook", () => {
|
|
35
|
-
it("returns success as the query status and the result itself after rendering the hook", async () => {
|
|
36
|
-
const { result } = renderHook(() => sut({ customerId }), { wrapper: Messaging });
|
|
37
|
-
|
|
38
|
-
await waitFor(() => {
|
|
39
|
-
const [projection, status] = result.current;
|
|
40
|
-
|
|
41
|
-
expect(projection).toBe(true);
|
|
42
|
-
expect(status).toBe(QueryStatus.SUCCESS);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
});
|
package/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { useQuery, UseQueryFunctionResult } from "@lookiero/messaging-react";
|
|
2
|
-
import { isCheckoutFeedbackGiven } from "../../../../domain/checkoutFeedback/model/checkoutFeedbackGiven";
|
|
3
|
-
import {
|
|
4
|
-
IsCheckoutAccessibleByCustomerIdProjection,
|
|
5
|
-
viewIsCheckoutAccessibleByCustomerId,
|
|
6
|
-
} from "../../../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
|
|
7
|
-
import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
|
|
8
|
-
|
|
9
|
-
interface UseViewIsCheckoutAccessibleByCustomerIdFunctionArgs {
|
|
10
|
-
readonly customerId: string | undefined;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface UseViewIsCheckoutAccessibleByCustomerIdFunction {
|
|
14
|
-
(
|
|
15
|
-
args: UseViewIsCheckoutAccessibleByCustomerIdFunctionArgs,
|
|
16
|
-
): UseQueryFunctionResult<IsCheckoutAccessibleByCustomerIdProjection>;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const useViewIsCheckoutAccessibleByCustomerId: UseViewIsCheckoutAccessibleByCustomerIdFunction = ({ customerId }) =>
|
|
20
|
-
useQuery({
|
|
21
|
-
query: viewIsCheckoutAccessibleByCustomerId({ customerId }),
|
|
22
|
-
contextId: MESSAGING_CONTEXT_ID,
|
|
23
|
-
invalidation: isCheckoutFeedbackGiven,
|
|
24
|
-
options: {
|
|
25
|
-
refetchOnMount: "always",
|
|
26
|
-
staleTime: Infinity,
|
|
27
|
-
retry: false,
|
|
28
|
-
refetchOnWindowFocus: false,
|
|
29
|
-
cacheTime: 0,
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
export { useViewIsCheckoutAccessibleByCustomerId };
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { render, RenderResult } from "@testing-library/react-native";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { Text } from "react-native";
|
|
4
|
-
import { MemoryRouter, Outlet, Route, Routes } from "react-router-native";
|
|
5
|
-
import { QueryStatus } from "@lookiero/messaging-react";
|
|
6
|
-
import { useViewIsCheckoutAccessibleByCustomerId } from "../../projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId";
|
|
7
|
-
import { CheckoutAccessibilityMiddleware } from "./CheckoutAccessibilityMiddleware";
|
|
8
|
-
|
|
9
|
-
jest.mock("../../projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId", () => ({
|
|
10
|
-
useViewIsCheckoutAccessibleByCustomerId: jest.fn(),
|
|
11
|
-
}));
|
|
12
|
-
|
|
13
|
-
const customerId = "29790d24-b139-4ab8-b618-d796d101e974";
|
|
14
|
-
const checkoutRouteText = "checkout-route-component";
|
|
15
|
-
const loaderText = "loader-component";
|
|
16
|
-
|
|
17
|
-
interface RenderCheckoutAccessibilityMiddlewareArgs {
|
|
18
|
-
readonly onNotAccessible?: () => void;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
interface RenderCheckoutAccessibilityMiddlewareFunction {
|
|
22
|
-
(args?: RenderCheckoutAccessibilityMiddlewareArgs): RenderResult;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const renderCheckoutAccessibilityMiddleware: RenderCheckoutAccessibilityMiddlewareFunction = ({
|
|
26
|
-
onNotAccessible = () => void 0,
|
|
27
|
-
} = {}) =>
|
|
28
|
-
render(
|
|
29
|
-
<MemoryRouter initialEntries={["/"]}>
|
|
30
|
-
<Routes>
|
|
31
|
-
<Route
|
|
32
|
-
path="/"
|
|
33
|
-
element={
|
|
34
|
-
<CheckoutAccessibilityMiddleware
|
|
35
|
-
customerId={customerId}
|
|
36
|
-
loader={<Text>{loaderText}</Text>}
|
|
37
|
-
onNotAccessible={onNotAccessible}
|
|
38
|
-
>
|
|
39
|
-
<Outlet />
|
|
40
|
-
</CheckoutAccessibilityMiddleware>
|
|
41
|
-
}
|
|
42
|
-
>
|
|
43
|
-
<Route element={<Text>{checkoutRouteText}</Text>} path="/" />
|
|
44
|
-
</Route>
|
|
45
|
-
</Routes>
|
|
46
|
-
</MemoryRouter>,
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
describe("CheckoutAccessibilityMiddleware component", () => {
|
|
50
|
-
it("renders a loader while processing viewIsCheckoutAccessibleByCustomerId use-case", async () => {
|
|
51
|
-
(useViewIsCheckoutAccessibleByCustomerId as jest.Mock).mockReturnValue([undefined, QueryStatus.LOADING]);
|
|
52
|
-
const { findByText } = renderCheckoutAccessibilityMiddleware();
|
|
53
|
-
const loader = await findByText(loaderText);
|
|
54
|
-
|
|
55
|
-
expect(loader).toBeTruthy();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("renders its Outlet's content if it is accessible", async () => {
|
|
59
|
-
(useViewIsCheckoutAccessibleByCustomerId as jest.Mock).mockReturnValue([true, QueryStatus.SUCCESS]);
|
|
60
|
-
const { findByText } = renderCheckoutAccessibilityMiddleware();
|
|
61
|
-
const checkoutContent = await findByText(checkoutRouteText);
|
|
62
|
-
|
|
63
|
-
expect(checkoutContent).toBeTruthy();
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it("calls onNotAccessible callback if it is not accessible", async () => {
|
|
67
|
-
(useViewIsCheckoutAccessibleByCustomerId as jest.Mock).mockReturnValue([false, QueryStatus.SUCCESS]);
|
|
68
|
-
const onNotAccessibleFn = jest.fn();
|
|
69
|
-
const { toJSON } = renderCheckoutAccessibilityMiddleware({ onNotAccessible: onNotAccessibleFn });
|
|
70
|
-
|
|
71
|
-
expect(toJSON()).toBeNull();
|
|
72
|
-
expect(onNotAccessibleFn).toHaveBeenCalled();
|
|
73
|
-
});
|
|
74
|
-
});
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React, { FC, useEffect, useRef } from "react";
|
|
2
|
-
import { Spinner } from "@lookiero/aurora";
|
|
3
|
-
import { QueryStatus } from "@lookiero/messaging-react";
|
|
4
|
-
import { useViewIsCheckoutAccessibleByCustomerId } from "../../projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId";
|
|
5
|
-
|
|
6
|
-
interface CheckoutAccessibilityMiddlewareProps {
|
|
7
|
-
readonly customerId: string | undefined;
|
|
8
|
-
readonly onNotAccessible: () => void;
|
|
9
|
-
readonly loader?: JSX.Element;
|
|
10
|
-
readonly children: JSX.Element;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const CheckoutAccessibilityMiddleware: FC<CheckoutAccessibilityMiddlewareProps> = ({
|
|
14
|
-
customerId,
|
|
15
|
-
onNotAccessible,
|
|
16
|
-
loader = <Spinner />,
|
|
17
|
-
children,
|
|
18
|
-
}) => {
|
|
19
|
-
const [accessible, status] = useViewIsCheckoutAccessibleByCustomerId({ customerId });
|
|
20
|
-
|
|
21
|
-
const onNotAccessibleRef = useRef(onNotAccessible);
|
|
22
|
-
onNotAccessibleRef.current = onNotAccessible;
|
|
23
|
-
|
|
24
|
-
const notAccessible = accessible === false || status === QueryStatus.ERROR;
|
|
25
|
-
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
if (notAccessible) {
|
|
28
|
-
onNotAccessibleRef.current();
|
|
29
|
-
}
|
|
30
|
-
}, [notAccessible]);
|
|
31
|
-
|
|
32
|
-
return accessible === undefined && [QueryStatus.IDLE, QueryStatus.LOADING].includes(status)
|
|
33
|
-
? loader
|
|
34
|
-
: accessible
|
|
35
|
-
? children
|
|
36
|
-
: null;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export { CheckoutAccessibilityMiddleware };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
|
|
3
|
-
import { Country } from "@lookiero/sty-psp-locale";
|
|
4
|
-
import { Segment } from "@lookiero/sty-psp-segment";
|
|
5
|
-
import { DummyLayout } from "@lookiero/sty-psp-ui";
|
|
6
|
-
import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
|
|
7
|
-
import { useReturnCheckoutItem } from "../../../domain/checkoutItem/react/useReturnCheckoutItem";
|
|
8
|
-
import { checkout } from "../../../projection/checkout/checkout.mock";
|
|
9
|
-
import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
|
|
10
|
-
import { useListReturnQuestionsByCheckoutItemId } from "../../../projection/returnQuestion/react/useListReturnQuestionsByCheckoutItemId";
|
|
11
|
-
import { returnQuestions as mockReturnQuestions } from "../../../projection/returnQuestion/returnQuestions.mock";
|
|
12
|
-
import { render } from "../../test/render";
|
|
13
|
-
import { Return } from "./Return";
|
|
14
|
-
|
|
15
|
-
const customerId = "a8fff6d7-708c-41a7-b42a-58c5706d33df";
|
|
16
|
-
const country = Country.ES;
|
|
17
|
-
const segment = Segment.WOMEN;
|
|
18
|
-
const mockCheckout = checkout({
|
|
19
|
-
items: [
|
|
20
|
-
{ status: CheckoutItemStatus.KEPT },
|
|
21
|
-
{ status: CheckoutItemStatus.RETURNED },
|
|
22
|
-
{ status: CheckoutItemStatus.REPLACED },
|
|
23
|
-
],
|
|
24
|
-
});
|
|
25
|
-
const mockFirstCheckoutItemId = mockCheckout.items[0]?.id;
|
|
26
|
-
|
|
27
|
-
jest.mock("../../hooks/useStaticInfo", () => ({
|
|
28
|
-
useStaticInfo: () => ({ customer: { customerId, country, segment } }),
|
|
29
|
-
}));
|
|
30
|
-
|
|
31
|
-
jest.mock("react-router-native", () => ({
|
|
32
|
-
...jest.requireActual("react-router-native"),
|
|
33
|
-
useLocation: () => jest.fn(),
|
|
34
|
-
useNavigate: () => jest.fn(),
|
|
35
|
-
useMatch: () => false,
|
|
36
|
-
useParams: () => ({ id: mockFirstCheckoutItemId }),
|
|
37
|
-
}));
|
|
38
|
-
|
|
39
|
-
jest.mock("../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId");
|
|
40
|
-
jest.mock("../../../projection/returnQuestion/react/useListReturnQuestionsByCheckoutItemId");
|
|
41
|
-
jest.mock("../../../domain/checkoutItem/react/useReturnCheckoutItem");
|
|
42
|
-
|
|
43
|
-
describe("Return", () => {
|
|
44
|
-
test("renders correctly", async () => {
|
|
45
|
-
(useViewFirstAvailableCheckoutByCustomerId as jest.Mock).mockReturnValue([mockCheckout, QueryStatus.SUCCESS]);
|
|
46
|
-
(useListReturnQuestionsByCheckoutItemId as jest.Mock).mockReturnValue([mockReturnQuestions, QueryStatus.SUCCESS]);
|
|
47
|
-
const mockReturnCheckoutItem = jest.fn();
|
|
48
|
-
(useReturnCheckoutItem as jest.Mock).mockReturnValue([mockReturnCheckoutItem, CommandStatus.IDLE]);
|
|
49
|
-
|
|
50
|
-
const { findByTestId } = render(<Return layout={DummyLayout} />);
|
|
51
|
-
|
|
52
|
-
expect(await findByTestId("return-questions-form")).toBeTruthy();
|
|
53
|
-
});
|
|
54
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Country } from "@lookiero/sty-psp-locale";
|
|
3
|
-
import { CheckoutItemStatus } from "../../../../../../domain/checkoutItem/model/checkoutItem";
|
|
4
|
-
import { checkoutItem } from "../../../../../projection/checkoutItem/checkoutItem.mock";
|
|
5
|
-
import { I18nMessages } from "../../../../i18n/i18n";
|
|
6
|
-
import { render } from "../../../../test/render";
|
|
7
|
-
import { ProductVariantPreview } from "./ProductVariantPreview";
|
|
8
|
-
|
|
9
|
-
const country = Country.ES;
|
|
10
|
-
const checkoutItemProjection = checkoutItem({ status: CheckoutItemStatus.RETURNED });
|
|
11
|
-
|
|
12
|
-
describe("ProductVariantPreview", () => {
|
|
13
|
-
it("matches the snapshot", async () => {
|
|
14
|
-
const { toJSON } = render(<ProductVariantPreview country={country} item={checkoutItemProjection} />);
|
|
15
|
-
|
|
16
|
-
expect(toJSON()).toMatchSnapshot();
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("renders correctly", async () => {
|
|
20
|
-
const { getByTestId, getByText } = render(
|
|
21
|
-
<ProductVariantPreview country={country} item={checkoutItemProjection} />,
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
expect(getByTestId("product-variant-preview")).toBeTruthy();
|
|
25
|
-
expect(getByTestId("product-variant-image")).toBeTruthy();
|
|
26
|
-
expect(getByTestId("price")).toBeTruthy();
|
|
27
|
-
|
|
28
|
-
expect(getByText(checkoutItemProjection.productVariant.brand)).toBeTruthy();
|
|
29
|
-
expect(getByText(checkoutItemProjection.productVariant.name)).toBeTruthy();
|
|
30
|
-
expect(getByText(`${I18nMessages.ITEM_SIZE} ${checkoutItemProjection.productVariant.size.lookiero}`)).toBeTruthy();
|
|
31
|
-
});
|
|
32
|
-
});
|
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`ProductVariantPreview matches the snapshot 1`] = `
|
|
4
|
-
<View
|
|
5
|
-
style={
|
|
6
|
-
[
|
|
7
|
-
{
|
|
8
|
-
"backgroundColor": "#FFFFFF",
|
|
9
|
-
"flex": 1,
|
|
10
|
-
},
|
|
11
|
-
]
|
|
12
|
-
}
|
|
13
|
-
>
|
|
14
|
-
<View
|
|
15
|
-
style={
|
|
16
|
-
[
|
|
17
|
-
{
|
|
18
|
-
"alignSelf": "center",
|
|
19
|
-
"left": 0,
|
|
20
|
-
"marginHorizontal": "auto",
|
|
21
|
-
"position": "absolute",
|
|
22
|
-
"right": 0,
|
|
23
|
-
"top": 0,
|
|
24
|
-
"width": "100%",
|
|
25
|
-
"zIndex": 5,
|
|
26
|
-
},
|
|
27
|
-
]
|
|
28
|
-
}
|
|
29
|
-
>
|
|
30
|
-
<RCTSafeAreaView />
|
|
31
|
-
</View>
|
|
32
|
-
<View
|
|
33
|
-
style={
|
|
34
|
-
[
|
|
35
|
-
false,
|
|
36
|
-
{
|
|
37
|
-
"backgroundColor": "#FFFFFF",
|
|
38
|
-
"flexDirection": "row",
|
|
39
|
-
"padding": 16,
|
|
40
|
-
},
|
|
41
|
-
]
|
|
42
|
-
}
|
|
43
|
-
testID="product-variant-preview"
|
|
44
|
-
>
|
|
45
|
-
<View
|
|
46
|
-
style={
|
|
47
|
-
[
|
|
48
|
-
{
|
|
49
|
-
"alignItems": "center",
|
|
50
|
-
"flexBasis": "auto",
|
|
51
|
-
"flexWrap": "wrap",
|
|
52
|
-
"justifyContent": "flex-start",
|
|
53
|
-
"width": "100%",
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
"paddingHorizontal": 24,
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
"flex": 1,
|
|
60
|
-
"justifyContent": "center",
|
|
61
|
-
},
|
|
62
|
-
]
|
|
63
|
-
}
|
|
64
|
-
>
|
|
65
|
-
<View
|
|
66
|
-
style={
|
|
67
|
-
[
|
|
68
|
-
{
|
|
69
|
-
"width": "100%",
|
|
70
|
-
},
|
|
71
|
-
undefined,
|
|
72
|
-
{
|
|
73
|
-
"flexDirection": "row",
|
|
74
|
-
},
|
|
75
|
-
]
|
|
76
|
-
}
|
|
77
|
-
>
|
|
78
|
-
<Image
|
|
79
|
-
resizeMode="stretch"
|
|
80
|
-
source={
|
|
81
|
-
{
|
|
82
|
-
"uri": "https://cdn-catalog-back-prod.envs.lookiero.tech/1a/28/1a28f712-a76c-4172-8a11-f15002981dc0.jpg?w=70&f=auto",
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
style={
|
|
86
|
-
{
|
|
87
|
-
"borderRadius": 4,
|
|
88
|
-
"width": 35,
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
testID="product-variant-image"
|
|
92
|
-
/>
|
|
93
|
-
<View
|
|
94
|
-
style={
|
|
95
|
-
[
|
|
96
|
-
{
|
|
97
|
-
"flex": 1,
|
|
98
|
-
"marginLeft": 8,
|
|
99
|
-
},
|
|
100
|
-
]
|
|
101
|
-
}
|
|
102
|
-
>
|
|
103
|
-
<Text
|
|
104
|
-
allowFontScaling={false}
|
|
105
|
-
selectable={false}
|
|
106
|
-
style={
|
|
107
|
-
[
|
|
108
|
-
{
|
|
109
|
-
"color": "#837C7C",
|
|
110
|
-
"fontFamily": "AreaNormal-Semibold",
|
|
111
|
-
"fontSize": 12,
|
|
112
|
-
"letterSpacing": 0.1,
|
|
113
|
-
"lineHeight": 16,
|
|
114
|
-
"paddingBottom": 0,
|
|
115
|
-
"paddingLeft": 0,
|
|
116
|
-
"paddingRight": 0,
|
|
117
|
-
"paddingTop": 0,
|
|
118
|
-
},
|
|
119
|
-
]
|
|
120
|
-
}
|
|
121
|
-
>
|
|
122
|
-
CKS
|
|
123
|
-
</Text>
|
|
124
|
-
<Text
|
|
125
|
-
allowFontScaling={false}
|
|
126
|
-
selectable={false}
|
|
127
|
-
style={
|
|
128
|
-
[
|
|
129
|
-
{
|
|
130
|
-
"color": "#0C0A0A",
|
|
131
|
-
"fontFamily": "AreaNormal-Semibold",
|
|
132
|
-
"fontSize": 12,
|
|
133
|
-
"letterSpacing": 0.1,
|
|
134
|
-
"lineHeight": 16,
|
|
135
|
-
"paddingBottom": 0,
|
|
136
|
-
"paddingLeft": 0,
|
|
137
|
-
"paddingRight": 0,
|
|
138
|
-
"paddingTop": 0,
|
|
139
|
-
},
|
|
140
|
-
]
|
|
141
|
-
}
|
|
142
|
-
>
|
|
143
|
-
Sari Tshirt lines
|
|
144
|
-
</Text>
|
|
145
|
-
<Text
|
|
146
|
-
allowFontScaling={false}
|
|
147
|
-
selectable={false}
|
|
148
|
-
style={
|
|
149
|
-
[
|
|
150
|
-
{
|
|
151
|
-
"color": "#837C7C",
|
|
152
|
-
"fontFamily": "AreaNormal-Semibold",
|
|
153
|
-
"fontSize": 12,
|
|
154
|
-
"letterSpacing": 0.1,
|
|
155
|
-
"lineHeight": 16,
|
|
156
|
-
"paddingBottom": 0,
|
|
157
|
-
"paddingLeft": 0,
|
|
158
|
-
"paddingRight": 0,
|
|
159
|
-
"paddingTop": 0,
|
|
160
|
-
},
|
|
161
|
-
]
|
|
162
|
-
}
|
|
163
|
-
>
|
|
164
|
-
item.size M
|
|
165
|
-
</Text>
|
|
166
|
-
</View>
|
|
167
|
-
<View
|
|
168
|
-
style={
|
|
169
|
-
[
|
|
170
|
-
{
|
|
171
|
-
"justifyContent": "flex-end",
|
|
172
|
-
},
|
|
173
|
-
]
|
|
174
|
-
}
|
|
175
|
-
>
|
|
176
|
-
<View
|
|
177
|
-
style={
|
|
178
|
-
{
|
|
179
|
-
"flexDirection": "row",
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
testID="price"
|
|
183
|
-
>
|
|
184
|
-
<View
|
|
185
|
-
style={
|
|
186
|
-
{
|
|
187
|
-
"alignItems": "flex-end",
|
|
188
|
-
"marginLeft": 8,
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
>
|
|
192
|
-
<Text
|
|
193
|
-
allowFontScaling={false}
|
|
194
|
-
selectable={false}
|
|
195
|
-
style={
|
|
196
|
-
[
|
|
197
|
-
{
|
|
198
|
-
"color": "#0C0A0A",
|
|
199
|
-
"fontFamily": "AreaNormal-Semibold",
|
|
200
|
-
"fontSize": 13,
|
|
201
|
-
"letterSpacing": 0.1,
|
|
202
|
-
"lineHeight": 17,
|
|
203
|
-
"paddingBottom": 0,
|
|
204
|
-
"paddingLeft": 0,
|
|
205
|
-
"paddingRight": 0,
|
|
206
|
-
"paddingTop": 4,
|
|
207
|
-
},
|
|
208
|
-
]
|
|
209
|
-
}
|
|
210
|
-
testID="price-text"
|
|
211
|
-
>
|
|
212
|
-
€39.99
|
|
213
|
-
</Text>
|
|
214
|
-
</View>
|
|
215
|
-
</View>
|
|
216
|
-
</View>
|
|
217
|
-
</View>
|
|
218
|
-
</View>
|
|
219
|
-
</View>
|
|
220
|
-
</View>
|
|
221
|
-
`;
|