@lookiero/checkout 6.5.1-beta.0 → 6.6.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/src/ExpoRoot.js +1 -8
- package/dist/src/infrastructure/ab-testing/kameleoonEnvironment.d.ts +2 -6
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.js +1 -10
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.style.d.ts +1 -7
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.style.js +1 -7
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.js +2 -7
- package/dist/src/infrastructure/ui/routing/Routing.js +2 -4
- 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/item/Item.js +4 -33
- package/dist/src/infrastructure/ui/views/return/Return.js +8 -127
- package/dist/src/infrastructure/ui/views/return/components/productVariantPreview/ProductVariantPreview.js +5 -7
- package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.d.ts +15 -0
- package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.js +112 -0
- package/dist/src/infrastructure/ui/views/summary/Summary.js +4 -4
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
- package/src/ExpoRoot.tsx +1 -8
- package/src/infrastructure/ab-testing/kameleoonEnvironment.ts +3 -7
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.style.ts +1 -7
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.test.tsx +0 -5
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.tsx +2 -17
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.test.tsx +0 -5
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.tsx +11 -20
- package/src/infrastructure/ui/routing/Routing.tsx +3 -6
- 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 +6 -62
- package/src/infrastructure/ui/views/item/Item.tsx +5 -48
- package/src/infrastructure/ui/views/return/Return.test.tsx +54 -0
- package/src/infrastructure/ui/views/return/Return.tsx +12 -200
- package/src/infrastructure/ui/views/return/components/productVariantPreview/ProductVariantPreview.test.tsx +32 -0
- package/src/infrastructure/ui/views/return/components/productVariantPreview/ProductVariantPreview.tsx +12 -7
- package/src/infrastructure/ui/views/return/components/productVariantPreview/__snapshots__/ProductVariantPreview.test.tsx.snap +221 -0
- package/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.test.tsx +95 -0
- package/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.tsx +184 -0
- package/src/infrastructure/ui/views/summary/Summary.tsx +6 -6
- 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/infrastructure/ui/components/layouts/layout/Layout.d.ts +0 -21
- package/dist/src/infrastructure/ui/components/layouts/layout/Layout.js +0 -1
- package/dist/src/infrastructure/ui/components/layouts/layout/components/footer/Footer.d.ts +0 -6
- package/dist/src/infrastructure/ui/components/layouts/layout/components/footer/Footer.js +0 -4
- package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.d.ts +0 -6
- package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.js +0 -5
- package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.style.d.ts +0 -4
- package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.style.js +0 -19
- package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.d.ts +0 -3
- package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.js +0 -18
- package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.style.d.ts +0 -12
- package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.style.js +0 -13
- package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.d.ts +0 -6
- package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.js +0 -11
- package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.style.d.ts +0 -8
- package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.style.js +0 -11
- package/dist/src/infrastructure/ui/hooks/useNewFeedbackExperiment.d.ts +0 -11
- package/dist/src/infrastructure/ui/hooks/useNewFeedbackExperiment.js +0 -49
- package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.style.d.ts +0 -7
- package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.style.js +0 -10
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.d.ts +0 -11
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.js +0 -40
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.d.ts +0 -12
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.js +0 -15
- package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.d.ts +0 -13
- package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.js +0 -9
- package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.style.d.ts +0 -7
- package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.style.js +0 -10
- package/src/infrastructure/ui/hooks/useNewFeedbackExperiment.test.tsx +0 -84
- package/src/infrastructure/ui/hooks/useNewFeedbackExperiment.tsx +0 -82
- package/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.ts +0 -18
- package/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.tsx +0 -79
- /package/dist/src/infrastructure/ui/views/return/{Return.style.d.ts → components/returnQuestionsForm/ReturnQuestionsForm.style.d.ts} +0 -0
- /package/dist/src/infrastructure/ui/views/return/{Return.style.js → components/returnQuestionsForm/ReturnQuestionsForm.style.js} +0 -0
- /package/src/infrastructure/ui/views/return/{Return.style.ts → components/returnQuestionsForm/ReturnQuestionsForm.style.ts} +0 -0
|
@@ -1,216 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { Box, Button, Layout, Spinner, Text, View, useDevice } from "@lookiero/aurora";
|
|
6
|
-
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
7
|
-
import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
|
|
8
|
-
import { useLogger } from "@lookiero/sty-psp-logging";
|
|
9
|
-
import { Segment } from "@lookiero/sty-psp-segment";
|
|
1
|
+
import React, { FC } from "react";
|
|
2
|
+
import { useParams } from "react-router-native";
|
|
3
|
+
import { Spinner } from "@lookiero/aurora";
|
|
4
|
+
import { QueryStatus } from "@lookiero/messaging-react";
|
|
10
5
|
import { Layout as UiLayout } from "@lookiero/sty-psp-ui";
|
|
11
|
-
import { CheckoutProjection } from "../../../../projection/checkout/checkout";
|
|
12
6
|
import { CheckoutItemProjection } from "../../../../projection/checkoutItem/checkoutItem";
|
|
13
|
-
import { FeedbackProjection } from "../../../../projection/feedback/feedback";
|
|
14
|
-
import { ReturnQuestionType } from "../../../../projection/returnQuestion/returnQuestion";
|
|
15
|
-
import { Country } from "../../../../projection/shared/country";
|
|
16
|
-
import { useReturnCheckoutItem } from "../../../domain/checkoutItem/react/useReturnCheckoutItem";
|
|
17
7
|
import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
|
|
18
|
-
import {
|
|
19
|
-
import { TrackingPage } from "../../../tracking/tracking";
|
|
20
|
-
import { useTrackPageView } from "../../../tracking/useTrackPageView";
|
|
21
|
-
import { useTrackPressNext } from "../../../tracking/useTrackPressNext";
|
|
22
|
-
import { useTrackPressPrevious } from "../../../tracking/useTrackPressPrevious";
|
|
23
|
-
import { useTrackReturnItem } from "../../../tracking/useTrackReturnItem";
|
|
24
|
-
import { ReturnQuestions } from "../../components/organisms/returnQuestions/ReturnQuestions";
|
|
25
|
-
import {
|
|
26
|
-
ReturnQuestionFeedbackProvider,
|
|
27
|
-
useReturnQuestionFeedback,
|
|
28
|
-
} from "../../components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback";
|
|
29
|
-
import {
|
|
30
|
-
ReturnQuestionItemProvider,
|
|
31
|
-
ReturnQuestionItems,
|
|
32
|
-
} from "../../components/organisms/returnQuestions/behaviors/useReturnQuestionItem";
|
|
33
|
-
import { HostDefaultReturnQuestionItem } from "../../components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem";
|
|
34
|
-
import { HostRadioGroupReturnQuestionItem } from "../../components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem";
|
|
35
|
-
import { HostStackReturnQuestionItem } from "../../components/organisms/returnQuestions/components/hostStackReturnQuestionItem/form/HostStackReturnQuestionItem";
|
|
36
|
-
import { RadioReturnQuestionItem } from "../../components/organisms/returnQuestions/components/radioReturnQuestionItem/RadioReturnQuestionItem";
|
|
37
|
-
import { TextareaReturnQuestionItem } from "../../components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem";
|
|
38
|
-
import { ItemHeader } from "../../components/templates/header/itemHeader/ItemHeader";
|
|
8
|
+
import { ReturnQuestionFeedbackProvider } from "../../components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback";
|
|
39
9
|
import { useStaticInfo } from "../../hooks/useStaticInfo";
|
|
40
|
-
import {
|
|
41
|
-
import { Routes } from "../../routing/routes";
|
|
42
|
-
import { useBasePath } from "../../routing/useBasePath";
|
|
43
|
-
import { style } from "./Return.style";
|
|
44
|
-
import { ProductVariantPreview } from "./components/productVariantPreview/ProductVariantPreview";
|
|
45
|
-
|
|
46
|
-
const returnQuestionItems: ReturnQuestionItems = {
|
|
47
|
-
[ReturnQuestionType.HOST_DEFAULT]: HostDefaultReturnQuestionItem,
|
|
48
|
-
[ReturnQuestionType.HOST_TEXTAREA]: HostDefaultReturnQuestionItem,
|
|
49
|
-
[ReturnQuestionType.HOST_SELECT]: HostRadioGroupReturnQuestionItem,
|
|
50
|
-
[ReturnQuestionType.HOST_STACK]: HostStackReturnQuestionItem,
|
|
51
|
-
[ReturnQuestionType.TEXTAREA]: TextareaReturnQuestionItem,
|
|
52
|
-
[ReturnQuestionType.OPTION]: RadioReturnQuestionItem,
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
interface ReturnFormProps {
|
|
56
|
-
readonly checkoutItem: CheckoutItemProjection;
|
|
57
|
-
readonly country: Country;
|
|
58
|
-
readonly segment: Segment;
|
|
59
|
-
readonly layout: UiLayout;
|
|
60
|
-
readonly checkout: CheckoutProjection;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const ReturnForm: FC<ReturnFormProps> = ({ checkout, checkoutItem, country, segment, layout: UiLayout }) => {
|
|
64
|
-
const { screen } = useDevice();
|
|
65
|
-
const navigate = useNavigate();
|
|
66
|
-
const logger = useLogger();
|
|
67
|
-
const basePath = useBasePath();
|
|
68
|
-
const checkoutId = checkout.id;
|
|
69
|
-
const trackPressNext = useTrackPressNext({
|
|
70
|
-
page: TrackingPage.ITEM,
|
|
71
|
-
country,
|
|
72
|
-
segment,
|
|
73
|
-
checkoutId,
|
|
74
|
-
});
|
|
75
|
-
const trackPressPrevious = useTrackPressPrevious({
|
|
76
|
-
page: TrackingPage.ITEM,
|
|
77
|
-
country,
|
|
78
|
-
segment,
|
|
79
|
-
checkoutId,
|
|
80
|
-
});
|
|
81
|
-
const titleText = useI18nMessage({ id: I18nMessages.RETURN_QUESTIONS_TITLE });
|
|
82
|
-
const descriptionText = useI18nMessage({ id: I18nMessages.RETURN_QUESTIONS_DESCRIPTION });
|
|
83
|
-
const submitButtonText = useI18nMessage({ id: I18nMessages.RETURN_QUESTIONS_SUBMIT_BUTTON });
|
|
84
|
-
const isSmallScreen = screen.S;
|
|
85
|
-
|
|
86
|
-
useTrackPageView({ checkoutId, country, segment, page: TrackingPage.RETURN });
|
|
87
|
-
|
|
88
|
-
/* ReturnCheckoutItem */
|
|
89
|
-
const [returnQuestions] = useListReturnQuestionsByCheckoutItemId({
|
|
90
|
-
checkoutItemId: checkoutItem.id,
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
const [returnCheckoutItem, returnCheckoutItemStatus] = useReturnCheckoutItem({
|
|
94
|
-
checkoutItemId: checkoutItem.id,
|
|
95
|
-
logger,
|
|
96
|
-
});
|
|
97
|
-
const trackReturnItem = useTrackReturnItem({
|
|
98
|
-
page: TrackingPage.RETURN,
|
|
99
|
-
country,
|
|
100
|
-
segment,
|
|
101
|
-
checkoutId: checkoutId,
|
|
102
|
-
checkoutItemId: checkoutItem.id,
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
const navigateToNextItem = useCallback(() => {
|
|
106
|
-
const item = checkoutItem;
|
|
107
|
-
const items = checkout?.items as CheckoutItemProjection[];
|
|
108
|
-
const itemIndex = items.indexOf(item);
|
|
109
|
-
const nextItemIndex = itemIndex === items.length - 1 ? 0 : itemIndex + 1;
|
|
110
|
-
const nextItem = items[nextItemIndex] as CheckoutItemProjection;
|
|
111
|
-
|
|
112
|
-
trackPressNext({ from: item.id, to: nextItem.id });
|
|
113
|
-
navigate(generatePath(`${basePath}/${Routes.ITEM}`, { id: nextItem.id }));
|
|
114
|
-
}, [basePath, checkout?.items, checkoutItem, navigate, trackPressNext]);
|
|
115
|
-
|
|
116
|
-
const navigateToPreviousItem = useCallback(() => {
|
|
117
|
-
const item = checkoutItem;
|
|
118
|
-
const items = checkout?.items as CheckoutItemProjection[];
|
|
119
|
-
const itemIndex = items.indexOf(item);
|
|
120
|
-
const previousItemIndex = itemIndex === 0 ? items.length - 1 : itemIndex - 1;
|
|
121
|
-
const previousItem = items[previousItemIndex] as CheckoutItemProjection;
|
|
122
|
-
|
|
123
|
-
trackPressPrevious({ from: item.id, to: previousItem.id });
|
|
124
|
-
|
|
125
|
-
navigate(generatePath(`${basePath}/${Routes.ITEM}`, { id: previousItem.id }));
|
|
126
|
-
}, [basePath, checkout?.items, checkoutItem, navigate, trackPressPrevious]);
|
|
127
|
-
|
|
128
|
-
const returnItem = useCallback(
|
|
129
|
-
async (feedbacks: FeedbackProjection) => {
|
|
130
|
-
returnCheckoutItem({ feedbacks });
|
|
131
|
-
trackReturnItem();
|
|
132
|
-
navigateToNextItem();
|
|
133
|
-
},
|
|
134
|
-
[navigateToNextItem, returnCheckoutItem, trackReturnItem],
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
const feedback = useReturnQuestionFeedback();
|
|
138
|
-
|
|
139
|
-
const handleOnSubmit = useCallback(() => returnItem(feedback), [feedback, returnItem]);
|
|
140
|
-
|
|
141
|
-
const header = useMemo(
|
|
142
|
-
() => (
|
|
143
|
-
<Box style={style.headerWrapper}>
|
|
144
|
-
<ItemHeader
|
|
145
|
-
item={checkoutItem}
|
|
146
|
-
items={checkout?.items as CheckoutItemProjection[]}
|
|
147
|
-
onNext={navigateToNextItem}
|
|
148
|
-
onPrevious={navigateToPreviousItem}
|
|
149
|
-
/>
|
|
150
|
-
</Box>
|
|
151
|
-
),
|
|
152
|
-
[checkout?.items, checkoutItem, navigateToNextItem, navigateToPreviousItem],
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
/* ReturnCheckoutItem */
|
|
156
|
-
|
|
157
|
-
const dependenciesLoaded = checkoutItem && returnQuestions && returnCheckoutItemStatus !== CommandStatus.LOADING;
|
|
158
|
-
|
|
159
|
-
if (!dependenciesLoaded) {
|
|
160
|
-
return <Spinner />;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return (
|
|
164
|
-
<ReturnQuestionItemProvider returnQuestionItems={returnQuestionItems}>
|
|
165
|
-
<PortalHost name="return-question-form-portal" />
|
|
166
|
-
<UiLayout
|
|
167
|
-
header={header}
|
|
168
|
-
scrollEnabled={false}
|
|
169
|
-
style={{
|
|
170
|
-
safeAreaView: style.safeAreaView,
|
|
171
|
-
scrollView: style.scrollView,
|
|
172
|
-
}}
|
|
173
|
-
>
|
|
174
|
-
<ProductVariantPreview country={country} item={checkoutItem} />
|
|
175
|
-
|
|
176
|
-
<ScrollView showsVerticalScrollIndicator={false}>
|
|
177
|
-
<Layout fullWidth={!screen.L} style={[style.layout, screen.L ? style.desktopLayoutSpacing : undefined]}>
|
|
178
|
-
<Box size={{ L: "2/3" }}>
|
|
179
|
-
<View style={[style.info, isSmallScreen ? undefined : style.desktopInfo]}>
|
|
180
|
-
<Text level={3} heading>
|
|
181
|
-
{titleText}
|
|
182
|
-
</Text>
|
|
183
|
-
<Text level={1} style={style.description} detail>
|
|
184
|
-
{descriptionText}
|
|
185
|
-
</Text>
|
|
186
|
-
</View>
|
|
187
|
-
|
|
188
|
-
<ReturnQuestions portalHostName="return-question-form-portal" returnQuestions={returnQuestions} />
|
|
189
|
-
|
|
190
|
-
<View style={style.submit}>
|
|
191
|
-
<Button testID="return-questions-button" onPress={handleOnSubmit}>
|
|
192
|
-
{submitButtonText}
|
|
193
|
-
</Button>
|
|
194
|
-
</View>
|
|
195
|
-
</Box>
|
|
196
|
-
</Layout>
|
|
197
|
-
</ScrollView>
|
|
198
|
-
</UiLayout>
|
|
199
|
-
</ReturnQuestionItemProvider>
|
|
200
|
-
);
|
|
201
|
-
};
|
|
10
|
+
import { ReturnQuestionsForm } from "./components/returnQuestionsForm/ReturnQuestionsForm";
|
|
202
11
|
|
|
203
12
|
interface ReturnProps {
|
|
204
13
|
readonly layout: UiLayout;
|
|
205
14
|
}
|
|
206
15
|
|
|
207
|
-
const Return: FC<ReturnProps> = ({ layout
|
|
16
|
+
const Return: FC<ReturnProps> = ({ layout }) => {
|
|
208
17
|
const { id } = useParams();
|
|
209
18
|
const {
|
|
210
19
|
customer: { customerId, country, segment },
|
|
211
20
|
} = useStaticInfo();
|
|
21
|
+
|
|
212
22
|
const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
|
|
23
|
+
|
|
213
24
|
const checkoutItem = checkout?.items.find((checkoutItem) => checkoutItem.id === id) as CheckoutItemProjection;
|
|
25
|
+
|
|
214
26
|
const dependenciesLoaded = checkoutStatus !== QueryStatus.LOADING && checkout && checkoutItem;
|
|
215
27
|
|
|
216
28
|
if (!dependenciesLoaded) {
|
|
@@ -219,11 +31,11 @@ const Return: FC<ReturnProps> = ({ layout: UiLayout }) => {
|
|
|
219
31
|
|
|
220
32
|
return (
|
|
221
33
|
<ReturnQuestionFeedbackProvider key={checkoutItem.id} feedback={checkoutItem.feedbacks || {}}>
|
|
222
|
-
<
|
|
34
|
+
<ReturnQuestionsForm
|
|
223
35
|
checkout={checkout}
|
|
224
36
|
checkoutItem={checkoutItem}
|
|
225
37
|
country={country}
|
|
226
|
-
layout={
|
|
38
|
+
layout={layout}
|
|
227
39
|
segment={segment}
|
|
228
40
|
/>
|
|
229
41
|
</ReturnQuestionFeedbackProvider>
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
});
|
|
@@ -19,19 +19,22 @@ interface ProductVariantPreviewProps {
|
|
|
19
19
|
const ProductVariantPreview: FC<ProductVariantPreviewProps> = ({ item, country }) => {
|
|
20
20
|
const cdnImageUrl = useMediaImage();
|
|
21
21
|
const { screen } = useDevice();
|
|
22
|
-
const isSmallScreen = screen.S;
|
|
23
|
-
const { productVariant, price } = item;
|
|
24
|
-
const { media, brand, name, size: sizeProjection } = productVariant;
|
|
25
|
-
const mainImage = media.find((mediaElement) => mediaElement.perspective === "MAIN");
|
|
26
22
|
|
|
27
23
|
const sizeText = useI18nMessage({ id: I18nMessages.ITEM_SIZE });
|
|
28
24
|
const uniqueText = useI18nMessage({ id: I18nMessages.ITEM_UNIQUE });
|
|
29
25
|
|
|
26
|
+
const {
|
|
27
|
+
productVariant: { media, brand, name, size: sizeProjection },
|
|
28
|
+
price,
|
|
29
|
+
} = item;
|
|
30
|
+
|
|
31
|
+
const mainImage = media.find((mediaElement) => mediaElement.perspective === "MAIN");
|
|
32
|
+
|
|
30
33
|
return (
|
|
31
|
-
<View style={[style.wrapper,
|
|
34
|
+
<View style={[style.wrapper, !screen.S && style.mobileWrapper]} testID="product-variant-preview">
|
|
32
35
|
<Row style={style.row}>
|
|
33
36
|
<Column size={{ M: "2/3", L: "2/3" }} style={style.content}>
|
|
34
|
-
{mainImage
|
|
37
|
+
{mainImage && (
|
|
35
38
|
<Image
|
|
36
39
|
resizeMode="stretch"
|
|
37
40
|
style={style.image}
|
|
@@ -43,7 +46,8 @@ const ProductVariantPreview: FC<ProductVariantPreviewProps> = ({ item, country }
|
|
|
43
46
|
}),
|
|
44
47
|
}}
|
|
45
48
|
/>
|
|
46
|
-
)
|
|
49
|
+
)}
|
|
50
|
+
|
|
47
51
|
<View style={style.info}>
|
|
48
52
|
<Text color={COLOR.TEXT_MEDIUM} level={2} detail>
|
|
49
53
|
{brand}
|
|
@@ -55,6 +59,7 @@ const ProductVariantPreview: FC<ProductVariantPreviewProps> = ({ item, country }
|
|
|
55
59
|
{`${sizeText} ${sizeProjection.unique ? uniqueText : size({ size: sizeProjection, country })}`}
|
|
56
60
|
</Text>
|
|
57
61
|
</View>
|
|
62
|
+
|
|
58
63
|
<View style={style.price}>
|
|
59
64
|
<Price price={price} withPercentage />
|
|
60
65
|
</View>
|
|
@@ -0,0 +1,221 @@
|
|
|
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
|
+
`;
|
|
@@ -0,0 +1,95 @@
|
|
|
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
|
+
});
|