@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,95 +0,0 @@
|
|
|
1
|
-
import { fireEvent } from "@testing-library/react-native";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { generatePath } from "react-router-native";
|
|
4
|
-
import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
|
|
5
|
-
import { Country } from "@lookiero/sty-psp-locale";
|
|
6
|
-
import { Segment } from "@lookiero/sty-psp-segment";
|
|
7
|
-
import { DummyLayout } from "@lookiero/sty-psp-ui";
|
|
8
|
-
import { CheckoutItemStatus } from "../../../../../../domain/checkoutItem/model/checkoutItem";
|
|
9
|
-
import { CheckoutItemProjection } from "../../../../../../projection/checkoutItem/checkoutItem";
|
|
10
|
-
import { useReturnCheckoutItem } from "../../../../../domain/checkoutItem/react/useReturnCheckoutItem";
|
|
11
|
-
import { checkout } from "../../../../../projection/checkout/checkout.mock";
|
|
12
|
-
import { useListReturnQuestionsByCheckoutItemId } from "../../../../../projection/returnQuestion/react/useListReturnQuestionsByCheckoutItemId";
|
|
13
|
-
import { returnQuestions as mockReturnQuestions } from "../../../../../projection/returnQuestion/returnQuestions.mock";
|
|
14
|
-
import { ReturnQuestionFeedbackProvider } from "../../../../components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback";
|
|
15
|
-
import { I18nMessages } from "../../../../i18n/i18n";
|
|
16
|
-
import { Routes } from "../../../../routing/routes";
|
|
17
|
-
import { render } from "../../../../test/render";
|
|
18
|
-
import { ReturnQuestionsForm } from "./ReturnQuestionsForm";
|
|
19
|
-
|
|
20
|
-
const country = Country.ES;
|
|
21
|
-
const segment = Segment.WOMEN;
|
|
22
|
-
const mockCheckout = checkout({
|
|
23
|
-
items: [
|
|
24
|
-
{ status: CheckoutItemStatus.KEPT },
|
|
25
|
-
{ status: CheckoutItemStatus.RETURNED },
|
|
26
|
-
{ status: CheckoutItemStatus.REPLACED },
|
|
27
|
-
],
|
|
28
|
-
});
|
|
29
|
-
const checkoutItem = mockCheckout.items[1] as CheckoutItemProjection;
|
|
30
|
-
|
|
31
|
-
const mockNavigate = jest.fn();
|
|
32
|
-
jest.mock("react-router-native", () => ({
|
|
33
|
-
...jest.requireActual("react-router-native"),
|
|
34
|
-
useNavigate: () => mockNavigate,
|
|
35
|
-
}));
|
|
36
|
-
|
|
37
|
-
jest.mock("../../../../../projection/returnQuestion/react/useListReturnQuestionsByCheckoutItemId");
|
|
38
|
-
jest.mock("../../../../../domain/checkoutItem/react/useReturnCheckoutItem");
|
|
39
|
-
|
|
40
|
-
const mockPressNext = jest.fn();
|
|
41
|
-
jest.mock("../../../../../tracking/useTrackPressNext", () => ({
|
|
42
|
-
useTrackPressNext: () => mockPressNext,
|
|
43
|
-
}));
|
|
44
|
-
|
|
45
|
-
const mockPressBack = jest.fn();
|
|
46
|
-
jest.mock("../../../../../tracking/useTrackPressBack", () => ({
|
|
47
|
-
useTrackPressBack: () => mockPressBack,
|
|
48
|
-
}));
|
|
49
|
-
|
|
50
|
-
const mockReturnItem = jest.fn();
|
|
51
|
-
jest.mock("../../../../../tracking/useTrackReturnItem", () => ({
|
|
52
|
-
useTrackReturnItem: () => mockReturnItem,
|
|
53
|
-
}));
|
|
54
|
-
|
|
55
|
-
describe("Return", () => {
|
|
56
|
-
test("renders correctly", async () => {
|
|
57
|
-
(useListReturnQuestionsByCheckoutItemId as jest.Mock).mockReturnValue([mockReturnQuestions, QueryStatus.SUCCESS]);
|
|
58
|
-
const mockReturnCheckoutItem = jest.fn();
|
|
59
|
-
(useReturnCheckoutItem as jest.Mock).mockReturnValue([mockReturnCheckoutItem, CommandStatus.IDLE]);
|
|
60
|
-
|
|
61
|
-
const { findByTestId, getByTestId, getByText } = render(
|
|
62
|
-
<ReturnQuestionFeedbackProvider feedback={{}}>
|
|
63
|
-
<ReturnQuestionsForm
|
|
64
|
-
checkout={mockCheckout}
|
|
65
|
-
checkoutItem={checkoutItem}
|
|
66
|
-
country={country}
|
|
67
|
-
layout={DummyLayout}
|
|
68
|
-
segment={segment}
|
|
69
|
-
/>
|
|
70
|
-
,
|
|
71
|
-
</ReturnQuestionFeedbackProvider>,
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
expect(await findByTestId("return-questions-form")).toBeTruthy();
|
|
75
|
-
|
|
76
|
-
expect(getByTestId("product-variant-preview")).toBeTruthy();
|
|
77
|
-
|
|
78
|
-
expect(getByText(I18nMessages.RETURN_QUESTIONS_TITLE)).toBeTruthy();
|
|
79
|
-
expect(getByText(I18nMessages.RETURN_QUESTIONS_DESCRIPTION)).toBeTruthy();
|
|
80
|
-
|
|
81
|
-
expect(getByTestId("item-detail-header")).toBeTruthy();
|
|
82
|
-
|
|
83
|
-
fireEvent.press(getByTestId("close-button-icon"));
|
|
84
|
-
expect(mockPressBack).toHaveBeenCalled();
|
|
85
|
-
expect(mockNavigate).toHaveBeenLastCalledWith(-1);
|
|
86
|
-
|
|
87
|
-
fireEvent.press(getByTestId("return-questions-button"));
|
|
88
|
-
expect(mockReturnCheckoutItem).toHaveBeenCalled();
|
|
89
|
-
expect(mockReturnItem).toHaveBeenCalled();
|
|
90
|
-
expect(mockPressNext).toHaveBeenCalled();
|
|
91
|
-
expect(mockNavigate).toHaveBeenLastCalledWith(
|
|
92
|
-
generatePath(`/${Routes.ITEM}`, { id: mockCheckout.items[2]?.id as string }),
|
|
93
|
-
);
|
|
94
|
-
});
|
|
95
|
-
});
|
package/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.tsx
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { PortalHost } from "@gorhom/portal";
|
|
2
|
-
import React, { FC, 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 { Segment } from "@lookiero/sty-psp-segment";
|
|
10
|
-
import { Layout as UiLayout } from "@lookiero/sty-psp-ui";
|
|
11
|
-
import { CheckoutProjection } from "../../../../../../projection/checkout/checkout";
|
|
12
|
-
import { CheckoutItemProjection } from "../../../../../../projection/checkoutItem/checkoutItem";
|
|
13
|
-
import { ReturnQuestionType } from "../../../../../../projection/returnQuestion/returnQuestion";
|
|
14
|
-
import { Country } from "../../../../../../projection/shared/country";
|
|
15
|
-
import { useReturnCheckoutItem } from "../../../../../domain/checkoutItem/react/useReturnCheckoutItem";
|
|
16
|
-
import { useListReturnQuestionsByCheckoutItemId } from "../../../../../projection/returnQuestion/react/useListReturnQuestionsByCheckoutItemId";
|
|
17
|
-
import { TrackingPage } from "../../../../../tracking/tracking";
|
|
18
|
-
import { useTrackPageView } from "../../../../../tracking/useTrackPageView";
|
|
19
|
-
import { useTrackPressBack } from "../../../../../tracking/useTrackPressBack";
|
|
20
|
-
import { useTrackPressNext } from "../../../../../tracking/useTrackPressNext";
|
|
21
|
-
import { useTrackReturnItem } from "../../../../../tracking/useTrackReturnItem";
|
|
22
|
-
import { ReturnQuestions } from "../../../../components/organisms/returnQuestions/ReturnQuestions";
|
|
23
|
-
import { useReturnQuestionFeedback } from "../../../../components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback";
|
|
24
|
-
import {
|
|
25
|
-
ReturnQuestionItemProvider,
|
|
26
|
-
ReturnQuestionItems,
|
|
27
|
-
} from "../../../../components/organisms/returnQuestions/behaviors/useReturnQuestionItem";
|
|
28
|
-
import { HostDefaultReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem";
|
|
29
|
-
import { HostRadioGroupReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem";
|
|
30
|
-
import { HostStackReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/hostStackReturnQuestionItem/form/HostStackReturnQuestionItem";
|
|
31
|
-
import { RadioReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/radioReturnQuestionItem/RadioReturnQuestionItem";
|
|
32
|
-
import { TextareaReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem";
|
|
33
|
-
import { ItemDetailHeader } from "../../../../components/templates/header/itemDetailHeader/ItemDetailHeader";
|
|
34
|
-
import { I18nMessages } from "../../../../i18n/i18n";
|
|
35
|
-
import { Routes } from "../../../../routing/routes";
|
|
36
|
-
import { useBasePath } from "../../../../routing/useBasePath";
|
|
37
|
-
import { ProductVariantPreview } from "../productVariantPreview/ProductVariantPreview";
|
|
38
|
-
import { style } from "./ReturnQuestionsForm.style";
|
|
39
|
-
|
|
40
|
-
const RETURN_QUESTION_FORM_PORTAL_HOST_NAME = "return-question-form-portal";
|
|
41
|
-
|
|
42
|
-
const returnQuestionItems: ReturnQuestionItems = {
|
|
43
|
-
[ReturnQuestionType.HOST_DEFAULT]: HostDefaultReturnQuestionItem,
|
|
44
|
-
[ReturnQuestionType.HOST_TEXTAREA]: HostDefaultReturnQuestionItem,
|
|
45
|
-
[ReturnQuestionType.HOST_SELECT]: HostRadioGroupReturnQuestionItem,
|
|
46
|
-
[ReturnQuestionType.HOST_STACK]: HostStackReturnQuestionItem,
|
|
47
|
-
[ReturnQuestionType.TEXTAREA]: TextareaReturnQuestionItem,
|
|
48
|
-
[ReturnQuestionType.OPTION]: RadioReturnQuestionItem,
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
interface ReturnQuestionsFormProps {
|
|
52
|
-
readonly checkout: CheckoutProjection;
|
|
53
|
-
readonly checkoutItem: CheckoutItemProjection;
|
|
54
|
-
readonly country: Country;
|
|
55
|
-
readonly layout: UiLayout;
|
|
56
|
-
readonly segment: Segment;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const ReturnQuestionsForm: FC<ReturnQuestionsFormProps> = ({
|
|
60
|
-
checkout,
|
|
61
|
-
checkoutItem,
|
|
62
|
-
country,
|
|
63
|
-
layout: Layout,
|
|
64
|
-
segment,
|
|
65
|
-
}) => {
|
|
66
|
-
const navigate = useNavigate();
|
|
67
|
-
const basePath = useBasePath();
|
|
68
|
-
const logger = useLogger();
|
|
69
|
-
|
|
70
|
-
const { screen } = useDevice();
|
|
71
|
-
|
|
72
|
-
const titleText = useI18nMessage({ id: I18nMessages.RETURN_QUESTIONS_TITLE });
|
|
73
|
-
const descriptionText = useI18nMessage({ id: I18nMessages.RETURN_QUESTIONS_DESCRIPTION });
|
|
74
|
-
const submitButtonText = useI18nMessage({ id: I18nMessages.RETURN_QUESTIONS_SUBMIT_BUTTON });
|
|
75
|
-
|
|
76
|
-
const feedback = useReturnQuestionFeedback();
|
|
77
|
-
const [returnQuestions] = useListReturnQuestionsByCheckoutItemId({
|
|
78
|
-
checkoutItemId: checkoutItem.id,
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
const [returnCheckoutItem, returnCheckoutItemStatus] = useReturnCheckoutItem({
|
|
82
|
-
checkoutItemId: checkoutItem.id,
|
|
83
|
-
logger,
|
|
84
|
-
});
|
|
85
|
-
const trackReturnItem = useTrackReturnItem({
|
|
86
|
-
page: TrackingPage.RETURN,
|
|
87
|
-
country,
|
|
88
|
-
segment,
|
|
89
|
-
checkoutId: checkout.id,
|
|
90
|
-
checkoutItemId: checkoutItem.id,
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
useTrackPageView({ checkoutId: checkout.id, country, segment, page: TrackingPage.RETURN });
|
|
94
|
-
|
|
95
|
-
const trackPressBack = useTrackPressBack({
|
|
96
|
-
page: TrackingPage.ITEM,
|
|
97
|
-
country,
|
|
98
|
-
segment,
|
|
99
|
-
checkoutId: checkout?.id,
|
|
100
|
-
});
|
|
101
|
-
const handleOnBack = useCallback(() => {
|
|
102
|
-
trackPressBack();
|
|
103
|
-
navigate(-1);
|
|
104
|
-
}, [navigate, trackPressBack]);
|
|
105
|
-
|
|
106
|
-
const trackPressNext = useTrackPressNext({
|
|
107
|
-
page: TrackingPage.ITEM,
|
|
108
|
-
country,
|
|
109
|
-
segment,
|
|
110
|
-
checkoutId: checkout.id,
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
const handleOnSubmit = useCallback(async () => {
|
|
114
|
-
returnCheckoutItem({ feedbacks: feedback });
|
|
115
|
-
trackReturnItem();
|
|
116
|
-
|
|
117
|
-
const itemIndex = checkout.items.indexOf(checkoutItem);
|
|
118
|
-
const nextItemIndex = itemIndex === checkout.items.length - 1 ? 0 : itemIndex + 1;
|
|
119
|
-
const nextItem = checkout.items[nextItemIndex] as CheckoutItemProjection;
|
|
120
|
-
|
|
121
|
-
trackPressNext({ from: checkoutItem.id, to: nextItem.id });
|
|
122
|
-
navigate(generatePath(`${basePath}/${Routes.ITEM}`, { id: nextItem.id }));
|
|
123
|
-
}, [basePath, checkout.items, checkoutItem, feedback, navigate, returnCheckoutItem, trackPressNext, trackReturnItem]);
|
|
124
|
-
|
|
125
|
-
const header = useMemo(
|
|
126
|
-
() => (
|
|
127
|
-
<Box style={style.headerWrapper}>
|
|
128
|
-
<ItemDetailHeader onBack={handleOnBack} />
|
|
129
|
-
</Box>
|
|
130
|
-
),
|
|
131
|
-
[handleOnBack],
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
const dependenciesLoaded = checkoutItem && returnQuestions && returnCheckoutItemStatus !== CommandStatus.LOADING;
|
|
135
|
-
|
|
136
|
-
if (!dependenciesLoaded) {
|
|
137
|
-
return <Spinner />;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return (
|
|
141
|
-
<ReturnQuestionItemProvider returnQuestionItems={returnQuestionItems}>
|
|
142
|
-
<PortalHost name={RETURN_QUESTION_FORM_PORTAL_HOST_NAME} />
|
|
143
|
-
|
|
144
|
-
<Layout
|
|
145
|
-
header={header}
|
|
146
|
-
scrollEnabled={false}
|
|
147
|
-
style={{
|
|
148
|
-
safeAreaView: style.safeAreaView,
|
|
149
|
-
scrollView: style.scrollView,
|
|
150
|
-
}}
|
|
151
|
-
>
|
|
152
|
-
<ProductVariantPreview country={country} item={checkoutItem} />
|
|
153
|
-
|
|
154
|
-
<ScrollView showsVerticalScrollIndicator={false} testID="return-questions-form">
|
|
155
|
-
<AuroraLayout fullWidth={!screen.L} style={[style.layout, screen.L ? style.desktopLayoutSpacing : undefined]}>
|
|
156
|
-
<Box size={{ L: "2/3" }}>
|
|
157
|
-
<View style={[style.info, !screen.S && style.desktopInfo]}>
|
|
158
|
-
<Text level={3} heading>
|
|
159
|
-
{titleText}
|
|
160
|
-
</Text>
|
|
161
|
-
<Text level={1} style={style.description} detail>
|
|
162
|
-
{descriptionText}
|
|
163
|
-
</Text>
|
|
164
|
-
</View>
|
|
165
|
-
|
|
166
|
-
<ReturnQuestions
|
|
167
|
-
portalHostName={RETURN_QUESTION_FORM_PORTAL_HOST_NAME}
|
|
168
|
-
returnQuestions={returnQuestions}
|
|
169
|
-
/>
|
|
170
|
-
|
|
171
|
-
<View style={style.submit}>
|
|
172
|
-
<Button testID="return-questions-button" onPress={handleOnSubmit}>
|
|
173
|
-
{submitButtonText}
|
|
174
|
-
</Button>
|
|
175
|
-
</View>
|
|
176
|
-
</Box>
|
|
177
|
-
</AuroraLayout>
|
|
178
|
-
</ScrollView>
|
|
179
|
-
</Layout>
|
|
180
|
-
</ReturnQuestionItemProvider>
|
|
181
|
-
);
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
export { ReturnQuestionsForm };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { bootstrap } from "@lookiero/messaging";
|
|
2
|
-
import { CheckoutProjection } from "./checkout";
|
|
3
|
-
import {
|
|
4
|
-
viewFirstAvailableCheckoutByCustomerIdHandler,
|
|
5
|
-
VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID,
|
|
6
|
-
} from "./viewFirstAvailableCheckoutByCustomerId";
|
|
7
|
-
import {
|
|
8
|
-
viewIsCheckoutAccessibleByCustomerId,
|
|
9
|
-
viewIsCheckoutAccessibleByCustomerIdHandler,
|
|
10
|
-
VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID,
|
|
11
|
-
} from "./viewIsCheckoutAccessibleByCustomerId";
|
|
12
|
-
import {
|
|
13
|
-
viewIsCheckoutEnabledByCustomerIdHandler,
|
|
14
|
-
VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID,
|
|
15
|
-
} from "./viewIsCheckoutEnabledByCustomerId";
|
|
16
|
-
|
|
17
|
-
const customerId = "29790d24-b139-4ab8-b618-d796d101e974";
|
|
18
|
-
const checkoutProjection: CheckoutProjection = { id: "75574065-5838-42de-9924-c712f7854347" } as CheckoutProjection;
|
|
19
|
-
const firstAvailableCheckoutByCustomerIdViewMock = jest.fn();
|
|
20
|
-
const isCheckoutEnabledByCustomerIdViewMock = jest.fn();
|
|
21
|
-
|
|
22
|
-
const { queryBus } = bootstrap()
|
|
23
|
-
.query(VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID, viewFirstAvailableCheckoutByCustomerIdHandler, {
|
|
24
|
-
view: firstAvailableCheckoutByCustomerIdViewMock,
|
|
25
|
-
})
|
|
26
|
-
.query(VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID, viewIsCheckoutEnabledByCustomerIdHandler, {
|
|
27
|
-
view: isCheckoutEnabledByCustomerIdViewMock,
|
|
28
|
-
})
|
|
29
|
-
.query(VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, viewIsCheckoutAccessibleByCustomerIdHandler)
|
|
30
|
-
.build();
|
|
31
|
-
|
|
32
|
-
// expectedResult, customerId, CheckoutProjection, isCheckoutEnabled
|
|
33
|
-
type Scenarios = [boolean, string | undefined, CheckoutProjection | undefined, boolean][];
|
|
34
|
-
const scenarios: Scenarios = [
|
|
35
|
-
[false, undefined, checkoutProjection, true],
|
|
36
|
-
[false, customerId, undefined, true],
|
|
37
|
-
[false, customerId, checkoutProjection, false],
|
|
38
|
-
[true, customerId, checkoutProjection, true],
|
|
39
|
-
];
|
|
40
|
-
|
|
41
|
-
describe("viewIsCheckoutAccessibleByCustomerId", () => {
|
|
42
|
-
test.each(scenarios)(
|
|
43
|
-
"Returns %s when customer is %s, checkout projection is %s and the checkout is enabled: %s",
|
|
44
|
-
async (expectedResult, customerId, checkout, isEnabled) => {
|
|
45
|
-
firstAvailableCheckoutByCustomerIdViewMock.mockReturnValue(checkout);
|
|
46
|
-
isCheckoutEnabledByCustomerIdViewMock.mockReturnValue(isEnabled);
|
|
47
|
-
const query = viewIsCheckoutAccessibleByCustomerId({ customerId });
|
|
48
|
-
|
|
49
|
-
const result = await queryBus(query);
|
|
50
|
-
|
|
51
|
-
expect(result).toBe(expectedResult);
|
|
52
|
-
},
|
|
53
|
-
);
|
|
54
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { query, Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
|
|
2
|
-
import { viewFirstAvailableCheckoutByCustomerId } from "./viewFirstAvailableCheckoutByCustomerId";
|
|
3
|
-
import { viewIsCheckoutEnabledByCustomerId } from "./viewIsCheckoutEnabledByCustomerId";
|
|
4
|
-
|
|
5
|
-
type IsCheckoutAccessibleByCustomerIdProjection = boolean;
|
|
6
|
-
|
|
7
|
-
const VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID = "view_is_checkout_accessible_by_customer_id";
|
|
8
|
-
|
|
9
|
-
interface ViewIsCheckoutAccessibleByCustomerIdPayload {
|
|
10
|
-
readonly customerId: string | undefined;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface ViewIsCheckoutAccessibleByCustomerId
|
|
14
|
-
extends Query<typeof VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID>,
|
|
15
|
-
ViewIsCheckoutAccessibleByCustomerIdPayload {}
|
|
16
|
-
|
|
17
|
-
interface ViewIsCheckoutAccessibleByCustomerIdFunction {
|
|
18
|
-
(payload: ViewIsCheckoutAccessibleByCustomerIdPayload): ViewIsCheckoutAccessibleByCustomerId;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const viewIsCheckoutAccessibleByCustomerId: ViewIsCheckoutAccessibleByCustomerIdFunction = (payload) => ({
|
|
22
|
-
...query({ name: VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID }),
|
|
23
|
-
...payload,
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
interface ViewIsCheckoutAccessibleByCustomerIdHandlerFunctionArgs extends QueryHandlerFunctionArgs {}
|
|
27
|
-
|
|
28
|
-
const isNonEmptyCustomerId = (customerId: string | undefined): customerId is string => Boolean(customerId);
|
|
29
|
-
|
|
30
|
-
const viewIsCheckoutAccessibleByCustomerIdHandler: QueryHandlerFunction<
|
|
31
|
-
ViewIsCheckoutAccessibleByCustomerId,
|
|
32
|
-
IsCheckoutAccessibleByCustomerIdProjection,
|
|
33
|
-
ViewIsCheckoutAccessibleByCustomerIdHandlerFunctionArgs
|
|
34
|
-
> =
|
|
35
|
-
({ queryBus }) =>
|
|
36
|
-
async ({ customerId }) =>
|
|
37
|
-
isNonEmptyCustomerId(customerId) &&
|
|
38
|
-
Boolean(await queryBus(viewFirstAvailableCheckoutByCustomerId({ customerId }))) &&
|
|
39
|
-
Boolean(await queryBus(viewIsCheckoutEnabledByCustomerId({ customerId })));
|
|
40
|
-
|
|
41
|
-
export type { IsCheckoutAccessibleByCustomerIdProjection };
|
|
42
|
-
export {
|
|
43
|
-
VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID,
|
|
44
|
-
viewIsCheckoutAccessibleByCustomerId,
|
|
45
|
-
viewIsCheckoutAccessibleByCustomerIdHandler,
|
|
46
|
-
};
|
|
File without changes
|
|
File without changes
|