@lookiero/checkout 7.0.0-beta.0 → 7.0.1-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/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/CheckoutMiddleware.js +5 -1
- 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/return/components/returnQuestionsForm/ReturnQuestionsForm.style.d.ts +40 -0
- package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.style.js +43 -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/CheckoutMiddleware.test.tsx +10 -0
- package/src/infrastructure/ui/routing/CheckoutMiddleware.tsx +7 -1
- 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/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/src/infrastructure/ui/views/return/{Return.style.ts → components/returnQuestionsForm/ReturnQuestionsForm.style.ts} +0 -0
package/dist/src/ExpoRoot.js
CHANGED
|
@@ -100,14 +100,7 @@ setPaymentsBridge({
|
|
|
100
100
|
});
|
|
101
101
|
const kameleoonConfig = {
|
|
102
102
|
siteCode: "aplm4v3ckn",
|
|
103
|
-
experiments: {
|
|
104
|
-
newFeedback: {
|
|
105
|
-
id: "245000",
|
|
106
|
-
variations: {
|
|
107
|
-
v1: "964072",
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
},
|
|
103
|
+
experiments: {},
|
|
111
104
|
};
|
|
112
105
|
// const { Component: Messaging } = checkoutMockBootstrap();
|
|
113
106
|
const { Component: Messaging } = checkoutBootstrap({ apiUrl: () => apiUrl, getAuthToken });
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
interface
|
|
2
|
-
readonly id: string;
|
|
3
|
-
readonly variations: Record<string, string>;
|
|
1
|
+
interface Experiments {
|
|
4
2
|
}
|
|
5
3
|
interface KameleoonEnvironment {
|
|
6
4
|
readonly siteCode: string;
|
|
7
|
-
readonly experiments:
|
|
8
|
-
readonly newFeedback: Experiment;
|
|
9
|
-
};
|
|
5
|
+
readonly experiments: Experiments;
|
|
10
6
|
}
|
|
11
7
|
export type { KameleoonEnvironment };
|
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Text, View } from "@lookiero/aurora";
|
|
3
3
|
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
4
|
-
import { NewFeedbackExperimentVariation, useNewFeedbackExperiment, } from "../../../../../hooks/useNewFeedbackExperiment";
|
|
5
4
|
import { I18nMessages } from "../../../../../i18n/i18n";
|
|
6
5
|
import { style } from "./HostDefaultReturnQuestionItem.style";
|
|
7
6
|
const HostDefaultReturnQuestionItem = ({ returnQuestion, children }) => {
|
|
8
7
|
const titleText = useI18nMessage({ id: returnQuestion.name });
|
|
9
8
|
const isAllOptions = returnQuestion.name === I18nMessages.RETURN_QUESTION_MAIN_ALL_OPINION;
|
|
10
|
-
/* Kameleoon experiment */
|
|
11
|
-
const newFeedbackVariation = useNewFeedbackExperiment();
|
|
12
|
-
const isReturnPage = newFeedbackVariation === NewFeedbackExperimentVariation.RETURN_PAGE;
|
|
13
|
-
/* Kameleoon experiment */
|
|
14
9
|
return (React.createElement(React.Fragment, null,
|
|
15
|
-
titleText && titleText !== " " ? (React.createElement(View, { style:
|
|
16
|
-
style.title,
|
|
17
|
-
isAllOptions ? style.allOptionsTitle : undefined,
|
|
18
|
-
isReturnPage ? style.formTitle : undefined,
|
|
19
|
-
] },
|
|
10
|
+
titleText && titleText !== " " && !isAllOptions ? (React.createElement(View, { style: style.title },
|
|
20
11
|
React.createElement(Text, { level: 3, action: true }, titleText))) : null,
|
|
21
12
|
children));
|
|
22
13
|
};
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
declare const style: {
|
|
2
|
-
allOptionsTitle: {
|
|
3
|
-
display: "none";
|
|
4
|
-
};
|
|
5
|
-
formTitle: {
|
|
6
|
-
paddingLeft: number;
|
|
7
|
-
};
|
|
8
2
|
title: {
|
|
9
3
|
backgroundColor: string;
|
|
10
4
|
paddingBottom: number;
|
|
11
|
-
|
|
5
|
+
paddingHorizontal: number;
|
|
12
6
|
paddingTop: number;
|
|
13
7
|
};
|
|
14
8
|
};
|
|
@@ -2,16 +2,10 @@ import { StyleSheet } from "react-native";
|
|
|
2
2
|
import { theme } from "@lookiero/sty-psp-ui";
|
|
3
3
|
const { colorBgBase, space4, space6 } = theme();
|
|
4
4
|
const style = StyleSheet.create({
|
|
5
|
-
allOptionsTitle: {
|
|
6
|
-
display: "none",
|
|
7
|
-
},
|
|
8
|
-
formTitle: {
|
|
9
|
-
paddingLeft: space6,
|
|
10
|
-
},
|
|
11
5
|
title: {
|
|
12
6
|
backgroundColor: colorBgBase,
|
|
13
7
|
paddingBottom: space4,
|
|
14
|
-
|
|
8
|
+
paddingHorizontal: space6,
|
|
15
9
|
paddingTop: space6,
|
|
16
10
|
},
|
|
17
11
|
});
|
|
@@ -2,19 +2,14 @@ import React, { useCallback, useMemo } from "react";
|
|
|
2
2
|
import { View } from "@lookiero/aurora";
|
|
3
3
|
import { useIntl } from "@lookiero/i18n-react";
|
|
4
4
|
import { InputField } from "../../../../../../../shared/ui/components/molecules/inputField/InputField";
|
|
5
|
-
import { NewFeedbackExperimentVariation, useNewFeedbackExperiment, } from "../../../../../hooks/useNewFeedbackExperiment";
|
|
6
5
|
import { useReturnQuestionFeedbackForReturnQuestion } from "../../behaviors/useReturnQuestionFeedback";
|
|
7
6
|
import { style } from "./TextareaReturnQuestionItem.style";
|
|
8
7
|
const TextareaReturnQuestionItem = ({ returnQuestion, returnQuestionParent, testID, }) => {
|
|
9
8
|
const { formatMessage } = useIntl();
|
|
10
|
-
/* Kameleoon experiment */
|
|
11
|
-
const newFeedbackVariation = useNewFeedbackExperiment();
|
|
12
|
-
const isReturnPage = newFeedbackVariation === NewFeedbackExperimentVariation.RETURN_PAGE;
|
|
13
|
-
/* Kameleoon experiment */
|
|
14
9
|
const placeholderText = useMemo(() => (returnQuestion.placeholder ? formatMessage({ id: returnQuestion.placeholder }) : ""), [formatMessage, returnQuestion.placeholder]);
|
|
15
10
|
const { feedback, onChange } = useReturnQuestionFeedbackForReturnQuestion({ returnQuestion: returnQuestionParent });
|
|
16
11
|
const handleOnChange = useCallback((value) => onChange({ returnQuestionId: returnQuestionParent.id, returnQuestionFeedback: value }), [onChange, returnQuestionParent.id]);
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
return (React.createElement(View, { style: style.wrapper },
|
|
13
|
+
React.createElement(InputField, { label: placeholderText, placeholder: placeholderText, testID: testID, value: feedback, multiline: true, onChange: handleOnChange })));
|
|
19
14
|
};
|
|
20
15
|
export { TextareaReturnQuestionItem };
|
|
@@ -78,9 +78,13 @@ const CheckoutMiddleware = ({ customerId, onNotAccessible, loader = React.create
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
}, [basePath, checkout?.status, checkout?.items]);
|
|
81
|
-
if (
|
|
81
|
+
if (checkout === undefined) {
|
|
82
82
|
return loader;
|
|
83
83
|
}
|
|
84
|
+
if (checkout === null) {
|
|
85
|
+
onNotAccessible();
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
84
88
|
/* Prevent direct payment access */
|
|
85
89
|
if (checkoutPaymentRouteMatch && !checkoutShown.current) {
|
|
86
90
|
onNotAccessible();
|
|
@@ -2,7 +2,6 @@ import React, { memo, Suspense } from "react";
|
|
|
2
2
|
import { Navigate, Outlet, useRoutes as reactRouterUseRoutes } from "react-router-native";
|
|
3
3
|
import { Spinner } from "@lookiero/aurora";
|
|
4
4
|
import { Kameleoon } from "@lookiero/sty-psp-ab-testing";
|
|
5
|
-
import { NewFeedbackExperimentProvider } from "../hooks/useNewFeedbackExperiment";
|
|
6
5
|
import { StaticInfoProvider } from "../hooks/useStaticInfo";
|
|
7
6
|
import { App } from "../views/App";
|
|
8
7
|
import { Checkout } from "../views/checkout/Checkout";
|
|
@@ -24,9 +23,8 @@ const Routing = ({ basePath = "", customer, order, subscription, locale, I18n, k
|
|
|
24
23
|
React.createElement(I18n, { loader: React.createElement(Spinner, null), locale: locale, onError: onI18nError },
|
|
25
24
|
React.createElement(Kameleoon, { loader: React.createElement(Spinner, null), siteCode: kameleoon.siteCode },
|
|
26
25
|
React.createElement(CheckoutMiddleware, { customerId: customer?.customerId, onNotAccessible: onNotAccessible },
|
|
27
|
-
React.createElement(
|
|
28
|
-
React.createElement(
|
|
29
|
-
React.createElement(Outlet, null))))))))),
|
|
26
|
+
React.createElement(App, null,
|
|
27
|
+
React.createElement(Outlet, null)))))))),
|
|
30
28
|
children: [
|
|
31
29
|
{
|
|
32
30
|
path: Routes.ITEM,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useCallback, useMemo, useState } from "react";
|
|
2
2
|
import { Platform, ScrollView, View } from "react-native";
|
|
3
3
|
import { useNavigate } from "react-router-native";
|
|
4
|
-
import { Box, Button, Layout, Spinner, Text, useDevice } from "@lookiero/aurora";
|
|
4
|
+
import { Box, Button, Layout as AuroraLayout, Spinner, Text, useDevice } from "@lookiero/aurora";
|
|
5
5
|
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
6
6
|
import { QueryStatus } from "@lookiero/messaging-react";
|
|
7
7
|
import { Sticky } from "@lookiero/sty-psp-ui";
|
|
@@ -23,7 +23,7 @@ import { Pricing } from "../summary/components/pricing/Pricing";
|
|
|
23
23
|
import { style } from "./Checkout.style";
|
|
24
24
|
import { DeliveryBanner } from "./components/deliveryBanner/DeliveryBanner";
|
|
25
25
|
import { PaymentInstrument } from "./components/paymentInstrument/PaymentInstrument";
|
|
26
|
-
const Checkout = ({ children, layout:
|
|
26
|
+
const Checkout = ({ children, layout: Layout, useRedirect }) => {
|
|
27
27
|
const { customer: { customerId, country, segment }, } = useStaticInfo();
|
|
28
28
|
const titleText = useI18nMessage({ id: I18nMessages.CHECKOUT_TITLE });
|
|
29
29
|
const submitButtonText = useI18nMessage({ id: I18nMessages.CHECKOUT_PAY_BUTTON });
|
|
@@ -68,13 +68,13 @@ const Checkout = ({ children, layout: UiLayout, useRedirect }) => {
|
|
|
68
68
|
if (!dependenciesLoaded) {
|
|
69
69
|
return React.createElement(Spinner, null);
|
|
70
70
|
}
|
|
71
|
-
return (React.createElement(
|
|
71
|
+
return (React.createElement(Layout, { header: React.createElement(CheckoutHeader, { onBack: handleOnBack }), scrollEnabled: false, style: {
|
|
72
72
|
header: style.header,
|
|
73
73
|
scrollView: style.scrollView,
|
|
74
74
|
} },
|
|
75
75
|
React.createElement(ScrollView, { showsVerticalScrollIndicator: false },
|
|
76
76
|
hasReplacedCheckoutItem && React.createElement(DeliveryBanner, null),
|
|
77
|
-
React.createElement(
|
|
77
|
+
React.createElement(AuroraLayout, { fullWidth: !screen.L, style: [screen.L && style.desktopLayoutSpacing, !screen.L && { paddingBottom: pricingHeight }] },
|
|
78
78
|
React.createElement(Box, { size: { L: "2/3" }, style: screen.L && style.desktopListSpacing },
|
|
79
79
|
React.createElement(View, { style: [style.contentWrapper, screen.L && style.desktopContentWrapper] },
|
|
80
80
|
React.createElement(Text, { level: 3, style: style.title, heading: true }, titleText),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
|
-
import { Layout } from "@lookiero/sty-psp-ui";
|
|
2
|
+
import { Layout as UiLayout } from "@lookiero/sty-psp-ui";
|
|
3
3
|
interface FeedbackProps {
|
|
4
|
-
readonly layout:
|
|
4
|
+
readonly layout: UiLayout;
|
|
5
5
|
}
|
|
6
6
|
declare const Feedback: FC<FeedbackProps>;
|
|
7
7
|
export { Feedback };
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useMemo, useRef
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useRef } from "react";
|
|
2
2
|
import { generatePath, useMatch, useNavigate, useParams } from "react-router-native";
|
|
3
3
|
import { Box, Spinner } from "@lookiero/aurora";
|
|
4
|
-
import {
|
|
4
|
+
import { QueryStatus } from "@lookiero/messaging-react";
|
|
5
5
|
import { useLogger } from "@lookiero/sty-psp-logging";
|
|
6
6
|
import { useScreenSize } from "@lookiero/sty-psp-ui";
|
|
7
7
|
import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
|
|
8
8
|
import { useBookCheckoutBookingForCheckoutItem } from "../../../domain/checkoutBooking/react/useBookCheckoutBookingForCheckoutItem";
|
|
9
|
-
import { useReturnCheckoutItem } from "../../../domain/checkoutItem/react/useReturnCheckoutItem";
|
|
10
9
|
import { useViewBookedProductsVariantsForCheckoutItem } from "../../../projection/bookedProductsVariants/react/useViewBookedProductsVariantsForCheckoutItem";
|
|
11
10
|
import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
|
|
12
11
|
import { useViewFiveItemsDiscountByCustomerId } from "../../../projection/checkout/react/useViewFiveItemsDiscountByCustomerId";
|
|
@@ -17,17 +16,14 @@ import { useTrackItemPageView } from "../../../tracking/useTrackItemPageView";
|
|
|
17
16
|
import { useTrackPressBack } from "../../../tracking/useTrackPressBack";
|
|
18
17
|
import { useTrackPressNext } from "../../../tracking/useTrackPressNext";
|
|
19
18
|
import { useTrackPressPrevious } from "../../../tracking/useTrackPressPrevious";
|
|
20
|
-
import { useTrackReturnItem } from "../../../tracking/useTrackReturnItem";
|
|
21
19
|
import { FiveItemsDiscountBanner } from "../../components/atoms/fiveItemsDiscountBanner/FiveItemsDiscountBanner";
|
|
22
20
|
import { ReturnQuestionFeedbackProvider } from "../../components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback";
|
|
23
21
|
import { ItemDetailHeader } from "../../components/templates/header/itemDetailHeader/ItemDetailHeader";
|
|
24
22
|
import { ItemHeader } from "../../components/templates/header/itemHeader/ItemHeader";
|
|
25
|
-
import { NewFeedbackExperimentVariation, useNewFeedbackExperiment } from "../../hooks/useNewFeedbackExperiment";
|
|
26
23
|
import { useStaticInfo } from "../../hooks/useStaticInfo";
|
|
27
24
|
import { Routes } from "../../routing/routes";
|
|
28
25
|
import { useBasePath } from "../../routing/useBasePath";
|
|
29
26
|
import { style } from "./Item.style";
|
|
30
|
-
import { ReturnQuestionsForm } from "./components/returnQuestionsForm/ReturnQuestionsForm";
|
|
31
27
|
import { ItemWithCustomerDecission, } from "./views/itemWithCustomerDecission/ItemWithCustomerDecission";
|
|
32
28
|
import { ItemWithoutCustomerDecission, } from "./views/itemWithoutCustomerDecission/ItemWithoutCustomerDecission";
|
|
33
29
|
const Item = ({ layout: Layout }) => {
|
|
@@ -41,10 +37,6 @@ const Item = ({ layout: Layout }) => {
|
|
|
41
37
|
const [fiveItemsDiscount = 0, fiveItemsDiscountStatus] = useViewFiveItemsDiscountByCustomerId({ customerId });
|
|
42
38
|
const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
|
|
43
39
|
const checkoutItem = checkout?.items.find((checkoutItem) => checkoutItem.id === id);
|
|
44
|
-
/* Kameleoon experiment */
|
|
45
|
-
const newFeedbackVariation = useNewFeedbackExperiment();
|
|
46
|
-
const redirectToReturnPage = newFeedbackVariation === NewFeedbackExperimentVariation.RETURN_PAGE;
|
|
47
|
-
/* Kameleoon experiment */
|
|
48
40
|
/* SizeChange and Booking */
|
|
49
41
|
const [isSizeChangeEnabled, sizeChangeEnabledStatus] = useViewIsSizeChangeEnabledByCheckoutId({
|
|
50
42
|
checkoutId: checkout?.id,
|
|
@@ -72,28 +64,9 @@ const Item = ({ layout: Layout }) => {
|
|
|
72
64
|
const [returnQuestions] = useListReturnQuestionsByCheckoutItemId({
|
|
73
65
|
checkoutItemId: checkoutItem.id,
|
|
74
66
|
});
|
|
75
|
-
const [returnQuestionsVisible, setReturnQuestionsVisible] = useState(false);
|
|
76
|
-
const showReturnQuestions = useCallback(() => setReturnQuestionsVisible(true), []);
|
|
77
|
-
const hideReturnQuestions = useCallback(() => setReturnQuestionsVisible(false), []);
|
|
78
67
|
const goToReturnPage = useCallback(() => {
|
|
79
68
|
navigate(`${basePath}/${generatePath(Routes.RETURN, { id: checkoutItem.id })}`);
|
|
80
69
|
}, [basePath, checkoutItem.id, navigate]);
|
|
81
|
-
const [returnCheckoutItem, returnCheckoutItemStatus] = useReturnCheckoutItem({
|
|
82
|
-
checkoutItemId: checkoutItem.id,
|
|
83
|
-
logger,
|
|
84
|
-
});
|
|
85
|
-
const trackReturnItem = useTrackReturnItem({
|
|
86
|
-
page: TrackingPage.ITEM,
|
|
87
|
-
country,
|
|
88
|
-
segment,
|
|
89
|
-
checkoutId: checkout?.id,
|
|
90
|
-
checkoutItemId: checkoutItem.id,
|
|
91
|
-
});
|
|
92
|
-
const returnItem = useCallback(async (feedbacks) => {
|
|
93
|
-
hideReturnQuestions();
|
|
94
|
-
returnCheckoutItem({ feedbacks });
|
|
95
|
-
trackReturnItem();
|
|
96
|
-
}, [hideReturnQuestions, returnCheckoutItem, trackReturnItem]);
|
|
97
70
|
/* ReturnCheckoutItem */
|
|
98
71
|
const currentProductVariant = useMemo(() => checkoutItem.status === CheckoutItemStatus.REPLACED && checkoutItem.replacedFor
|
|
99
72
|
? { id: checkoutItem.replacedFor.id, size: checkoutItem.replacedFor.size }
|
|
@@ -163,8 +136,7 @@ const Item = ({ layout: Layout }) => {
|
|
|
163
136
|
bookedProductsVariantsStatus !== QueryStatus.LOADING &&
|
|
164
137
|
fiveItemsDiscountStatus !== QueryStatus.LOADING &&
|
|
165
138
|
sizeChangeEnabledStatus !== QueryStatus.LOADING &&
|
|
166
|
-
(isBookingRequired ? checkout.checkoutBookingId && bookedProductsVariants : true)
|
|
167
|
-
returnCheckoutItemStatus !== CommandStatus.LOADING;
|
|
139
|
+
(isBookingRequired ? checkout.checkoutBookingId && bookedProductsVariants : true);
|
|
168
140
|
if (!dependenciesLoaded) {
|
|
169
141
|
return React.createElement(Spinner, { testID: "spinner" });
|
|
170
142
|
}
|
|
@@ -173,7 +145,6 @@ const Item = ({ layout: Layout }) => {
|
|
|
173
145
|
header: fiveItemsDiscount !== 0 ? style.headerWithDoubleHeight : style.header,
|
|
174
146
|
scrollView: { height: itemWithoutCustomerDecission ? "100%" : "auto" },
|
|
175
147
|
safeAreaView: isDesktopScreen ? style.safeAreaView : null,
|
|
176
|
-
} }, itemWithoutCustomerDecission ? (React.createElement(ItemWithoutCustomerDecission, { bookedProductsVariants: bookedProductsVariants, checkoutId: checkout.id, checkoutItem: checkoutItem, currentProductVariant: currentProductVariant, onReturn:
|
|
177
|
-
!redirectToReturnPage ? (React.createElement(ReturnQuestionsForm, { returnQuestions: returnQuestions, visible: returnQuestionsVisible, onClose: hideReturnQuestions, onSubmit: returnItem })) : null));
|
|
148
|
+
} }, itemWithoutCustomerDecission ? (React.createElement(ItemWithoutCustomerDecission, { bookedProductsVariants: bookedProductsVariants, checkoutId: checkout.id, checkoutItem: checkoutItem, currentProductVariant: currentProductVariant, onReturn: goToReturnPage })) : (React.createElement(ItemWithCustomerDecission, { checkoutId: checkout.id, checkoutItem: checkoutItem, currentProductVariant: currentProductVariant, returnQuestions: returnQuestions, onEditFeedback: goToReturnPage })))));
|
|
178
149
|
};
|
|
179
150
|
export { Item };
|
|
@@ -1,131 +1,12 @@
|
|
|
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 { ReturnQuestionType } from "../../../../projection/returnQuestion/returnQuestion";
|
|
10
|
-
import { useReturnCheckoutItem } from "../../../domain/checkoutItem/react/useReturnCheckoutItem";
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { useParams } from "react-router-native";
|
|
3
|
+
import { Spinner } from "@lookiero/aurora";
|
|
4
|
+
import { QueryStatus } from "@lookiero/messaging-react";
|
|
11
5
|
import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
|
|
12
|
-
import {
|
|
13
|
-
import { TrackingPage } from "../../../tracking/tracking";
|
|
14
|
-
import { useTrackPageView } from "../../../tracking/useTrackPageView";
|
|
15
|
-
import { useTrackPressNext } from "../../../tracking/useTrackPressNext";
|
|
16
|
-
import { useTrackPressPrevious } from "../../../tracking/useTrackPressPrevious";
|
|
17
|
-
import { useTrackReturnItem } from "../../../tracking/useTrackReturnItem";
|
|
18
|
-
import { ReturnQuestions } from "../../components/organisms/returnQuestions/ReturnQuestions";
|
|
19
|
-
import { ReturnQuestionFeedbackProvider, useReturnQuestionFeedback, } from "../../components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback";
|
|
20
|
-
import { ReturnQuestionItemProvider, } from "../../components/organisms/returnQuestions/behaviors/useReturnQuestionItem";
|
|
21
|
-
import { HostDefaultReturnQuestionItem } from "../../components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem";
|
|
22
|
-
import { HostRadioGroupReturnQuestionItem } from "../../components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem";
|
|
23
|
-
import { HostStackReturnQuestionItem } from "../../components/organisms/returnQuestions/components/hostStackReturnQuestionItem/form/HostStackReturnQuestionItem";
|
|
24
|
-
import { RadioReturnQuestionItem } from "../../components/organisms/returnQuestions/components/radioReturnQuestionItem/RadioReturnQuestionItem";
|
|
25
|
-
import { TextareaReturnQuestionItem } from "../../components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem";
|
|
26
|
-
import { ItemHeader } from "../../components/templates/header/itemHeader/ItemHeader";
|
|
6
|
+
import { ReturnQuestionFeedbackProvider } from "../../components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback";
|
|
27
7
|
import { useStaticInfo } from "../../hooks/useStaticInfo";
|
|
28
|
-
import {
|
|
29
|
-
|
|
30
|
-
import { useBasePath } from "../../routing/useBasePath";
|
|
31
|
-
import { style } from "./Return.style";
|
|
32
|
-
import { ProductVariantPreview } from "./components/productVariantPreview/ProductVariantPreview";
|
|
33
|
-
const returnQuestionItems = {
|
|
34
|
-
[ReturnQuestionType.HOST_DEFAULT]: HostDefaultReturnQuestionItem,
|
|
35
|
-
[ReturnQuestionType.HOST_TEXTAREA]: HostDefaultReturnQuestionItem,
|
|
36
|
-
[ReturnQuestionType.HOST_SELECT]: HostRadioGroupReturnQuestionItem,
|
|
37
|
-
[ReturnQuestionType.HOST_STACK]: HostStackReturnQuestionItem,
|
|
38
|
-
[ReturnQuestionType.TEXTAREA]: TextareaReturnQuestionItem,
|
|
39
|
-
[ReturnQuestionType.OPTION]: RadioReturnQuestionItem,
|
|
40
|
-
};
|
|
41
|
-
const ReturnForm = ({ checkout, checkoutItem, country, segment, layout: UiLayout }) => {
|
|
42
|
-
const { screen } = useDevice();
|
|
43
|
-
const navigate = useNavigate();
|
|
44
|
-
const logger = useLogger();
|
|
45
|
-
const basePath = useBasePath();
|
|
46
|
-
const checkoutId = checkout.id;
|
|
47
|
-
const trackPressNext = useTrackPressNext({
|
|
48
|
-
page: TrackingPage.ITEM,
|
|
49
|
-
country,
|
|
50
|
-
segment,
|
|
51
|
-
checkoutId,
|
|
52
|
-
});
|
|
53
|
-
const trackPressPrevious = useTrackPressPrevious({
|
|
54
|
-
page: TrackingPage.ITEM,
|
|
55
|
-
country,
|
|
56
|
-
segment,
|
|
57
|
-
checkoutId,
|
|
58
|
-
});
|
|
59
|
-
const titleText = useI18nMessage({ id: I18nMessages.RETURN_QUESTIONS_TITLE });
|
|
60
|
-
const descriptionText = useI18nMessage({ id: I18nMessages.RETURN_QUESTIONS_DESCRIPTION });
|
|
61
|
-
const submitButtonText = useI18nMessage({ id: I18nMessages.RETURN_QUESTIONS_SUBMIT_BUTTON });
|
|
62
|
-
const isSmallScreen = screen.S;
|
|
63
|
-
useTrackPageView({ checkoutId, country, segment, page: TrackingPage.RETURN });
|
|
64
|
-
/* ReturnCheckoutItem */
|
|
65
|
-
const [returnQuestions] = useListReturnQuestionsByCheckoutItemId({
|
|
66
|
-
checkoutItemId: checkoutItem.id,
|
|
67
|
-
});
|
|
68
|
-
const [returnCheckoutItem, returnCheckoutItemStatus] = useReturnCheckoutItem({
|
|
69
|
-
checkoutItemId: checkoutItem.id,
|
|
70
|
-
logger,
|
|
71
|
-
});
|
|
72
|
-
const trackReturnItem = useTrackReturnItem({
|
|
73
|
-
page: TrackingPage.RETURN,
|
|
74
|
-
country,
|
|
75
|
-
segment,
|
|
76
|
-
checkoutId: checkoutId,
|
|
77
|
-
checkoutItemId: checkoutItem.id,
|
|
78
|
-
});
|
|
79
|
-
const navigateToNextItem = useCallback(() => {
|
|
80
|
-
const item = checkoutItem;
|
|
81
|
-
const items = checkout?.items;
|
|
82
|
-
const itemIndex = items.indexOf(item);
|
|
83
|
-
const nextItemIndex = itemIndex === items.length - 1 ? 0 : itemIndex + 1;
|
|
84
|
-
const nextItem = items[nextItemIndex];
|
|
85
|
-
trackPressNext({ from: item.id, to: nextItem.id });
|
|
86
|
-
navigate(generatePath(`${basePath}/${Routes.ITEM}`, { id: nextItem.id }));
|
|
87
|
-
}, [basePath, checkout?.items, checkoutItem, navigate, trackPressNext]);
|
|
88
|
-
const navigateToPreviousItem = useCallback(() => {
|
|
89
|
-
const item = checkoutItem;
|
|
90
|
-
const items = checkout?.items;
|
|
91
|
-
const itemIndex = items.indexOf(item);
|
|
92
|
-
const previousItemIndex = itemIndex === 0 ? items.length - 1 : itemIndex - 1;
|
|
93
|
-
const previousItem = items[previousItemIndex];
|
|
94
|
-
trackPressPrevious({ from: item.id, to: previousItem.id });
|
|
95
|
-
navigate(generatePath(`${basePath}/${Routes.ITEM}`, { id: previousItem.id }));
|
|
96
|
-
}, [basePath, checkout?.items, checkoutItem, navigate, trackPressPrevious]);
|
|
97
|
-
const returnItem = useCallback(async (feedbacks) => {
|
|
98
|
-
returnCheckoutItem({ feedbacks });
|
|
99
|
-
trackReturnItem();
|
|
100
|
-
navigateToNextItem();
|
|
101
|
-
}, [navigateToNextItem, returnCheckoutItem, trackReturnItem]);
|
|
102
|
-
const feedback = useReturnQuestionFeedback();
|
|
103
|
-
const handleOnSubmit = useCallback(() => returnItem(feedback), [feedback, returnItem]);
|
|
104
|
-
const header = useMemo(() => (React.createElement(Box, { style: style.headerWrapper },
|
|
105
|
-
React.createElement(ItemHeader, { item: checkoutItem, items: checkout?.items, onNext: navigateToNextItem, onPrevious: navigateToPreviousItem }))), [checkout?.items, checkoutItem, navigateToNextItem, navigateToPreviousItem]);
|
|
106
|
-
/* ReturnCheckoutItem */
|
|
107
|
-
const dependenciesLoaded = checkoutItem && returnQuestions && returnCheckoutItemStatus !== CommandStatus.LOADING;
|
|
108
|
-
if (!dependenciesLoaded) {
|
|
109
|
-
return React.createElement(Spinner, null);
|
|
110
|
-
}
|
|
111
|
-
return (React.createElement(ReturnQuestionItemProvider, { returnQuestionItems: returnQuestionItems },
|
|
112
|
-
React.createElement(PortalHost, { name: "return-question-form-portal" }),
|
|
113
|
-
React.createElement(UiLayout, { header: header, scrollEnabled: false, style: {
|
|
114
|
-
safeAreaView: style.safeAreaView,
|
|
115
|
-
scrollView: style.scrollView,
|
|
116
|
-
} },
|
|
117
|
-
React.createElement(ProductVariantPreview, { country: country, item: checkoutItem }),
|
|
118
|
-
React.createElement(ScrollView, { showsVerticalScrollIndicator: false },
|
|
119
|
-
React.createElement(Layout, { fullWidth: !screen.L, style: [style.layout, screen.L ? style.desktopLayoutSpacing : undefined] },
|
|
120
|
-
React.createElement(Box, { size: { L: "2/3" } },
|
|
121
|
-
React.createElement(View, { style: [style.info, isSmallScreen ? undefined : style.desktopInfo] },
|
|
122
|
-
React.createElement(Text, { level: 3, heading: true }, titleText),
|
|
123
|
-
React.createElement(Text, { level: 1, style: style.description, detail: true }, descriptionText)),
|
|
124
|
-
React.createElement(ReturnQuestions, { portalHostName: "return-question-form-portal", returnQuestions: returnQuestions }),
|
|
125
|
-
React.createElement(View, { style: style.submit },
|
|
126
|
-
React.createElement(Button, { testID: "return-questions-button", onPress: handleOnSubmit }, submitButtonText))))))));
|
|
127
|
-
};
|
|
128
|
-
const Return = ({ layout: UiLayout }) => {
|
|
8
|
+
import { ReturnQuestionsForm } from "./components/returnQuestionsForm/ReturnQuestionsForm";
|
|
9
|
+
const Return = ({ layout }) => {
|
|
129
10
|
const { id } = useParams();
|
|
130
11
|
const { customer: { customerId, country, segment }, } = useStaticInfo();
|
|
131
12
|
const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
|
|
@@ -135,6 +16,6 @@ const Return = ({ layout: UiLayout }) => {
|
|
|
135
16
|
return React.createElement(Spinner, null);
|
|
136
17
|
}
|
|
137
18
|
return (React.createElement(ReturnQuestionFeedbackProvider, { key: checkoutItem.id, feedback: checkoutItem.feedbacks || {} },
|
|
138
|
-
React.createElement(
|
|
19
|
+
React.createElement(ReturnQuestionsForm, { checkout: checkout, checkoutItem: checkoutItem, country: country, layout: layout, segment: segment })));
|
|
139
20
|
};
|
|
140
21
|
export { Return };
|
|
@@ -11,21 +11,19 @@ import { IMAGE_SIZE, style } from "./ProductVariantPreview.style";
|
|
|
11
11
|
const ProductVariantPreview = ({ item, country }) => {
|
|
12
12
|
const cdnImageUrl = useMediaImage();
|
|
13
13
|
const { screen } = useDevice();
|
|
14
|
-
const isSmallScreen = screen.S;
|
|
15
|
-
const { productVariant, price } = item;
|
|
16
|
-
const { media, brand, name, size: sizeProjection } = productVariant;
|
|
17
|
-
const mainImage = media.find((mediaElement) => mediaElement.perspective === "MAIN");
|
|
18
14
|
const sizeText = useI18nMessage({ id: I18nMessages.ITEM_SIZE });
|
|
19
15
|
const uniqueText = useI18nMessage({ id: I18nMessages.ITEM_UNIQUE });
|
|
20
|
-
|
|
16
|
+
const { productVariant: { media, brand, name, size: sizeProjection }, price, } = item;
|
|
17
|
+
const mainImage = media.find((mediaElement) => mediaElement.perspective === "MAIN");
|
|
18
|
+
return (React.createElement(View, { style: [style.wrapper, !screen.S && style.mobileWrapper], testID: "product-variant-preview" },
|
|
21
19
|
React.createElement(Row, { style: style.row },
|
|
22
20
|
React.createElement(Column, { size: { M: "2/3", L: "2/3" }, style: style.content },
|
|
23
|
-
mainImage
|
|
21
|
+
mainImage && (React.createElement(Image, { resizeMode: "stretch", style: style.image, testID: "product-variant-image", source: {
|
|
24
22
|
uri: cdnImageUrl({
|
|
25
23
|
url: mainImage.url,
|
|
26
24
|
width: IMAGE_SIZE,
|
|
27
25
|
}),
|
|
28
|
-
} }))
|
|
26
|
+
} })),
|
|
29
27
|
React.createElement(View, { style: style.info },
|
|
30
28
|
React.createElement(Text, { color: COLOR.TEXT_MEDIUM, level: 2, detail: true }, brand),
|
|
31
29
|
React.createElement(Text, { level: 2, detail: true }, name),
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { Segment } from "@lookiero/sty-psp-segment";
|
|
3
|
+
import { Layout as UiLayout } from "@lookiero/sty-psp-ui";
|
|
4
|
+
import { CheckoutProjection } from "../../../../../../projection/checkout/checkout";
|
|
5
|
+
import { CheckoutItemProjection } from "../../../../../../projection/checkoutItem/checkoutItem";
|
|
6
|
+
import { Country } from "../../../../../../projection/shared/country";
|
|
7
|
+
interface ReturnQuestionsFormProps {
|
|
8
|
+
readonly checkout: CheckoutProjection;
|
|
9
|
+
readonly checkoutItem: CheckoutItemProjection;
|
|
10
|
+
readonly country: Country;
|
|
11
|
+
readonly layout: UiLayout;
|
|
12
|
+
readonly segment: Segment;
|
|
13
|
+
}
|
|
14
|
+
declare const ReturnQuestionsForm: FC<ReturnQuestionsFormProps>;
|
|
15
|
+
export { ReturnQuestionsForm };
|
|
@@ -0,0 +1,112 @@
|
|
|
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 };
|