@lookiero/checkout 5.1.1 → 5.1.2
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/infrastructure/ui/components/organisms/returnQuestions/ReturnQuestion.d.ts +1 -1
- package/dist/infrastructure/ui/components/organisms/returnQuestions/ReturnQuestion.js +3 -3
- package/dist/infrastructure/ui/components/organisms/returnQuestions/ReturnQuestions.js +1 -1
- package/dist/infrastructure/ui/components/organisms/returnQuestions/behaviors/isChildReturnQuestion.d.ts +10 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/behaviors/isChildReturnQuestion.js +17 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback.d.ts +8 -6
- package/dist/infrastructure/ui/components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback.js +28 -9
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/ReturnQuestionItem.d.ts +1 -1
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.js +3 -2
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.style.d.ts +4 -1
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.style.js +5 -2
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.d.ts +4 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.js +14 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.style.d.ts +11 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.style.js +14 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.js +3 -3
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.style.d.ts +3 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.style.js +3 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/{HostStackReturnQuestionItem.d.ts → form/HostStackReturnQuestionItem.d.ts} +1 -1
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/form/HostStackReturnQuestionItem.js +4 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/modal/HostStackReturnQuestionItem.d.ts +3 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/{HostStackReturnQuestionItem.js → modal/HostStackReturnQuestionItem.js} +4 -4
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/modalOptionReturnQuestionItems/ModalOptionReturnQuestionItems.d.ts +11 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/modalOptionReturnQuestionItems/ModalOptionReturnQuestionItems.js +14 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/modalOptionReturnQuestionItems/ModalOptionReturnQuestionItems.style.d.ts +9 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/modalOptionReturnQuestionItems/ModalOptionReturnQuestionItems.style.js +8 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/optionReturnQuestionItem/OptionReturnQuestionItem.js +4 -4
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/radioReturnQuestionItem/RadioReturnQuestionItem.d.ts +3 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/radioReturnQuestionItem/RadioReturnQuestionItem.js +49 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/radioReturnQuestionItem/RadioReturnQuestionItem.style.d.ts +6 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/radioReturnQuestionItem/RadioReturnQuestionItem.style.js +7 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.js +8 -5
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.style.d.ts +8 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.style.js +11 -0
- package/dist/infrastructure/ui/views/item/Item.js +1 -1
- package/dist/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.js +1 -1
- package/dist/infrastructure/ui/views/return/Return.js +37 -15
- package/dist/infrastructure/ui/views/return/Return.style.d.ts +13 -12
- package/dist/infrastructure/ui/views/return/Return.style.js +13 -12
- package/package.json +1 -1
- /package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/{HostStackReturnQuestionItem.style.d.ts → modal/HostStackReturnQuestionItem.style.d.ts} +0 -0
- /package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/{HostStackReturnQuestionItem.style.js → modal/HostStackReturnQuestionItem.style.js} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { ReturnQuestionProjection } from "../../../../../projection/returnQuestion/returnQuestion";
|
|
3
3
|
interface ReturnQuestionProps {
|
|
4
|
-
readonly
|
|
4
|
+
readonly returnQuestionParent: ReturnQuestionProjection;
|
|
5
5
|
readonly returnQuestion: ReturnQuestionProjection;
|
|
6
6
|
readonly portalHostName?: string;
|
|
7
7
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { memo } from "react";
|
|
2
2
|
import { useReturnQuestionItem } from "./behaviors/useReturnQuestionItem";
|
|
3
|
-
const ReturnQuestion = ({
|
|
3
|
+
const ReturnQuestion = ({ returnQuestionParent, returnQuestion, portalHostName }) => {
|
|
4
4
|
const Item = useReturnQuestionItem({ type: returnQuestion.type });
|
|
5
|
-
return (React.createElement(Item, { portalHostName: portalHostName, returnQuestion: returnQuestion,
|
|
6
|
-
React.createElement(React.Fragment, null, returnQuestion.children?.map((childReturnQuestion) => (React.createElement(ReturnQuestion, { key: childReturnQuestion.id, portalHostName: portalHostName, returnQuestion: childReturnQuestion,
|
|
5
|
+
return (React.createElement(Item, { portalHostName: portalHostName, returnQuestion: returnQuestion, returnQuestionParent: returnQuestionParent, testID: returnQuestion.id },
|
|
6
|
+
React.createElement(React.Fragment, null, returnQuestion.children?.map((childReturnQuestion) => (React.createElement(ReturnQuestion, { key: childReturnQuestion.id, portalHostName: portalHostName, returnQuestion: childReturnQuestion, returnQuestionParent: returnQuestion }))))));
|
|
7
7
|
};
|
|
8
8
|
export default memo(ReturnQuestion);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import ReturnQuestion from "./ReturnQuestion";
|
|
3
|
-
const ReturnQuestions = ({ returnQuestions, portalHostName }) => (React.createElement(React.Fragment, null, returnQuestions.map((returnQuestion) => (React.createElement(ReturnQuestion, { key: returnQuestion.id, portalHostName: portalHostName, returnQuestion: returnQuestion,
|
|
3
|
+
const ReturnQuestions = ({ returnQuestions, portalHostName }) => (React.createElement(React.Fragment, null, returnQuestions.map((returnQuestion) => (React.createElement(ReturnQuestion, { key: returnQuestion.id, portalHostName: portalHostName, returnQuestion: returnQuestion, returnQuestionParent: {} })))));
|
|
4
4
|
export { ReturnQuestions };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReturnQuestionProjection } from "../../../../../../projection/returnQuestion/returnQuestion";
|
|
2
|
+
interface IsChildReturnQuestionFunctionArgs {
|
|
3
|
+
readonly returnQuestionId: string;
|
|
4
|
+
readonly returnQuestion: ReturnQuestionProjection;
|
|
5
|
+
}
|
|
6
|
+
interface IsChildReturnQuestionFunction {
|
|
7
|
+
(args: IsChildReturnQuestionFunctionArgs): boolean;
|
|
8
|
+
}
|
|
9
|
+
declare const isChildReturnQuestion: IsChildReturnQuestionFunction;
|
|
10
|
+
export { isChildReturnQuestion };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const isChildReturnQuestion = ({ returnQuestionId, returnQuestion }) => {
|
|
2
|
+
if (returnQuestionId === returnQuestion.id) {
|
|
3
|
+
return true;
|
|
4
|
+
}
|
|
5
|
+
const children = returnQuestion.children || [];
|
|
6
|
+
for (let index = 0; index < children.length; index++) {
|
|
7
|
+
const isChild = isChildReturnQuestion({
|
|
8
|
+
returnQuestionId,
|
|
9
|
+
returnQuestion: children[index],
|
|
10
|
+
});
|
|
11
|
+
if (isChild) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
};
|
|
17
|
+
export { isChildReturnQuestion };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FC, ReactNode } from "react";
|
|
2
2
|
import { FeedbackProjection } from "../../../../../../projection/feedback/feedback";
|
|
3
|
+
import { ReturnQuestionProjection } from "../../../../../../projection/returnQuestion/returnQuestion";
|
|
3
4
|
interface OnChangeReturnQuestionFeedbackFunctionArgs {
|
|
4
5
|
readonly returnQuestionId: string;
|
|
5
6
|
readonly returnQuestionFeedback: string | undefined;
|
|
@@ -12,18 +13,19 @@ interface ReturnQuestionFeedbackContextProviderProps {
|
|
|
12
13
|
readonly children: ReactNode;
|
|
13
14
|
}
|
|
14
15
|
declare const ReturnQuestionFeedbackProvider: FC<ReturnQuestionFeedbackContextProviderProps>;
|
|
15
|
-
interface
|
|
16
|
-
readonly
|
|
16
|
+
interface UseReturnQuestionFeedbackForReturnQuestionFunctionArgs {
|
|
17
|
+
readonly returnQuestion: ReturnQuestionProjection;
|
|
17
18
|
}
|
|
18
|
-
interface
|
|
19
|
-
(args:
|
|
19
|
+
interface UseReturnQuestionFeedbackForReturnQuestionFunction {
|
|
20
|
+
(args: UseReturnQuestionFeedbackForReturnQuestionFunctionArgs): {
|
|
20
21
|
readonly feedback: string | undefined;
|
|
21
22
|
readonly onChange: OnChangeReturnQuestionFeedbackFunction;
|
|
23
|
+
readonly clear: () => void;
|
|
22
24
|
};
|
|
23
25
|
}
|
|
24
|
-
declare const
|
|
26
|
+
declare const useReturnQuestionFeedbackForReturnQuestion: UseReturnQuestionFeedbackForReturnQuestionFunction;
|
|
25
27
|
interface UseReturnQuestionFeedbackFunction {
|
|
26
28
|
(): FeedbackProjection;
|
|
27
29
|
}
|
|
28
30
|
declare const useReturnQuestionFeedback: UseReturnQuestionFeedbackFunction;
|
|
29
|
-
export {
|
|
31
|
+
export { useReturnQuestionFeedbackForReturnQuestion, useReturnQuestionFeedback, ReturnQuestionFeedbackProvider };
|
|
@@ -1,23 +1,42 @@
|
|
|
1
1
|
import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
2
2
|
import invariant from "tiny-invariant";
|
|
3
|
+
import { isChildReturnQuestion } from "./isChildReturnQuestion";
|
|
3
4
|
const ReturnQuestionFeedbackContext = createContext(null);
|
|
4
5
|
const ReturnQuestionFeedbackProvider = ({ feedback = {}, children, }) => {
|
|
5
6
|
const [contextFeedback, setContextFeedback] = useState(feedback);
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const [contextValues, setContextValues] = useState({});
|
|
8
|
+
const onChange = useCallback(({ returnQuestionId, returnQuestionFeedback }) => {
|
|
9
|
+
setContextFeedback((feedback) => returnQuestionFeedback
|
|
10
|
+
? { ...feedback, [returnQuestionId]: returnQuestionFeedback }
|
|
11
|
+
: Object.entries(feedback).reduce((acc, [id, feedback]) => (id !== returnQuestionId ? { ...acc, [id]: feedback } : acc), {}));
|
|
12
|
+
}, []);
|
|
13
|
+
const clear = useCallback(({ returnQuestion }) => setContextFeedback((feedback) => Object.fromEntries(Object.entries(feedback).filter(([feedbackReturnQuestionId]) => !isChildReturnQuestion({
|
|
14
|
+
returnQuestionId: feedbackReturnQuestionId,
|
|
15
|
+
returnQuestion,
|
|
16
|
+
})))), []);
|
|
17
|
+
const setValues = useCallback((values) => {
|
|
18
|
+
setContextValues(values);
|
|
19
|
+
}, []);
|
|
9
20
|
useEffect(() => setContextFeedback(feedback), [feedback]);
|
|
10
21
|
const value = useMemo(() => ({
|
|
11
22
|
feedback: contextFeedback,
|
|
12
23
|
onChange,
|
|
13
|
-
|
|
24
|
+
clear,
|
|
25
|
+
values: contextValues,
|
|
26
|
+
setValues,
|
|
27
|
+
}), [clear, contextFeedback, contextValues, onChange, setValues]);
|
|
14
28
|
return React.createElement(ReturnQuestionFeedbackContext.Provider, { value: value }, children);
|
|
15
29
|
};
|
|
16
|
-
const
|
|
30
|
+
const useReturnQuestionFeedbackForReturnQuestion = ({ returnQuestion, }) => {
|
|
17
31
|
const returnQuestionFeedbackContext = useContext(ReturnQuestionFeedbackContext);
|
|
18
|
-
invariant(returnQuestionFeedbackContext, "Your are trying to use the
|
|
19
|
-
const { feedback, onChange } = returnQuestionFeedbackContext;
|
|
20
|
-
|
|
32
|
+
invariant(returnQuestionFeedbackContext, "Your are trying to use the useReturnQuestionFeedbackForReturnQuestion hook without wrapping your app with the <ReturnQuestionFeedbackProvider>.");
|
|
33
|
+
const { feedback, onChange, clear } = returnQuestionFeedbackContext;
|
|
34
|
+
const clearReturnQuestionFeedback = useCallback(() => clear({ returnQuestion }), [clear, returnQuestion]);
|
|
35
|
+
return {
|
|
36
|
+
feedback: feedback[returnQuestion.id],
|
|
37
|
+
onChange,
|
|
38
|
+
clear: clearReturnQuestionFeedback,
|
|
39
|
+
};
|
|
21
40
|
};
|
|
22
41
|
const useReturnQuestionFeedback = () => {
|
|
23
42
|
const returnQuestionFeedbackContext = useContext(ReturnQuestionFeedbackContext);
|
|
@@ -25,4 +44,4 @@ const useReturnQuestionFeedback = () => {
|
|
|
25
44
|
const { feedback } = returnQuestionFeedbackContext;
|
|
26
45
|
return feedback;
|
|
27
46
|
};
|
|
28
|
-
export {
|
|
47
|
+
export { useReturnQuestionFeedbackForReturnQuestion, useReturnQuestionFeedback, ReturnQuestionFeedbackProvider };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FC, ReactNode } from "react";
|
|
2
2
|
import { ReturnQuestionProjection } from "../../../../../../projection/returnQuestion/returnQuestion";
|
|
3
3
|
interface ReturnQuestionItemProps {
|
|
4
|
+
readonly returnQuestionParent: ReturnQuestionProjection;
|
|
4
5
|
readonly returnQuestion: ReturnQuestionProjection;
|
|
5
|
-
readonly returnQuestionParentId: string;
|
|
6
6
|
readonly children?: ReactNode;
|
|
7
7
|
readonly portalHostName?: string;
|
|
8
8
|
readonly testID?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Text } from "@lookiero/aurora";
|
|
1
|
+
import { Text, View } from "@lookiero/aurora";
|
|
2
2
|
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { I18nMessages } from "../../../../../i18n/i18n";
|
|
@@ -7,7 +7,8 @@ const HostDefaultReturnQuestionItem = ({ returnQuestion, children }) => {
|
|
|
7
7
|
const titleText = useI18nMessage({ id: returnQuestion.name });
|
|
8
8
|
const isAllOptions = returnQuestion.name === I18nMessages.RETURN_QUESTION_MAIN_ALL_OPINION;
|
|
9
9
|
return (React.createElement(React.Fragment, null,
|
|
10
|
-
titleText && titleText !== " " ? (React.createElement(
|
|
10
|
+
titleText && titleText !== " " ? (React.createElement(View, { style: [style.title, isAllOptions ? style.allOptionsTitle : undefined] },
|
|
11
|
+
React.createElement(Text, { level: 3, action: true }, titleText))) : null,
|
|
11
12
|
children));
|
|
12
13
|
};
|
|
13
14
|
export { HostDefaultReturnQuestionItem };
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { Theme } from "@lookiero/aurora";
|
|
2
2
|
import { StyleSheet } from "react-native";
|
|
3
|
-
const { space4 } = Theme.get();
|
|
3
|
+
const { colorBgBase, space4, space6 } = Theme.get();
|
|
4
4
|
const style = StyleSheet.create({
|
|
5
5
|
allOptionsTitle: {
|
|
6
6
|
display: "none",
|
|
7
7
|
},
|
|
8
8
|
title: {
|
|
9
|
-
|
|
9
|
+
backgroundColor: colorBgBase,
|
|
10
|
+
paddingBottom: space4,
|
|
11
|
+
paddingHorizontal: space6,
|
|
12
|
+
paddingTop: space6,
|
|
10
13
|
},
|
|
11
14
|
});
|
|
12
15
|
export { style };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Text } from "@lookiero/aurora";
|
|
2
|
+
import { useIntl } from "@lookiero/i18n-react";
|
|
3
|
+
import React, { useMemo } from "react";
|
|
4
|
+
import { View } from "react-native";
|
|
5
|
+
import { style } from "./HostRadioGroupReturnQuestionItem.style";
|
|
6
|
+
const HostRadioGroupReturnQuestionItem = ({ returnQuestion, children, testID, }) => {
|
|
7
|
+
const { formatMessage } = useIntl();
|
|
8
|
+
const placeholderText = useMemo(() => (returnQuestion.placeholder ? formatMessage({ id: returnQuestion.placeholder }) : ""), [formatMessage, returnQuestion.placeholder]);
|
|
9
|
+
return (React.createElement(React.Fragment, null,
|
|
10
|
+
React.createElement(View, { style: style.wrapper, testID: testID },
|
|
11
|
+
React.createElement(Text, { level: 3, style: style.title, action: true }, placeholderText),
|
|
12
|
+
children)));
|
|
13
|
+
};
|
|
14
|
+
export { HostRadioGroupReturnQuestionItem, style };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Theme } from "@lookiero/aurora";
|
|
2
|
+
import { StyleSheet } from "react-native";
|
|
3
|
+
const { colorBgBase, space2, space6 } = Theme.get();
|
|
4
|
+
const style = StyleSheet.create({
|
|
5
|
+
title: {
|
|
6
|
+
marginBottom: space2,
|
|
7
|
+
},
|
|
8
|
+
wrapper: {
|
|
9
|
+
backgroundColor: colorBgBase,
|
|
10
|
+
marginBottom: space2,
|
|
11
|
+
padding: space6,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
export { style };
|
|
@@ -4,7 +4,7 @@ import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
|
4
4
|
import { TouchableHighlight, View } from "react-native";
|
|
5
5
|
import { Modal } from "../../../../../../../shared/ui/components/layouts/modal/Modal";
|
|
6
6
|
import { InputField } from "../../../../../../../shared/ui/components/molecules/inputField/InputField";
|
|
7
|
-
import { useReturnQuestionFeedback,
|
|
7
|
+
import { useReturnQuestionFeedback, useReturnQuestionFeedbackForReturnQuestion, } from "../../behaviors/useReturnQuestionFeedback";
|
|
8
8
|
import { deepestReturnQuestionWithFeedbackForReturnQuestion, feedbackForReturnQuestion, } from "../../util/returnQuestionFeedback";
|
|
9
9
|
import { style, containerUnderlayColor } from "./HostSelectReturnQuestionItem.style";
|
|
10
10
|
const HostSelectReturnQuestionItem = ({ returnQuestion, children, portalHostName, testID, }) => {
|
|
@@ -14,7 +14,7 @@ const HostSelectReturnQuestionItem = ({ returnQuestion, children, portalHostName
|
|
|
14
14
|
const handleOnPress = useCallback(() => setModalVisible(true), []);
|
|
15
15
|
const handleOnModalClose = useCallback(() => setModalVisible(false), []);
|
|
16
16
|
const feedback = useReturnQuestionFeedback();
|
|
17
|
-
const { onChange } =
|
|
17
|
+
const { onChange } = useReturnQuestionFeedbackForReturnQuestion({ returnQuestion });
|
|
18
18
|
const intl = useIntl();
|
|
19
19
|
const translate = useCallback((returnQuestionName) => intl.formatMessage({ id: returnQuestionName, defaultMessage: returnQuestionName }), [intl]);
|
|
20
20
|
const inputValue = feedbackForReturnQuestion({ feedback, returnQuestion, translate }).join(" / ");
|
|
@@ -34,7 +34,7 @@ const HostSelectReturnQuestionItem = ({ returnQuestion, children, portalHostName
|
|
|
34
34
|
React.createElement(TouchableHighlight, { accessibilityLabel: testID, style: style.container, testID: testID, underlayColor: containerUnderlayColor, accessible: true, onPress: handleOnPress },
|
|
35
35
|
React.createElement(View, { pointerEvents: "none" },
|
|
36
36
|
React.createElement(InputField, { editable: false, icon: "arrow_down", label: placeholderText, value: inputValue }))),
|
|
37
|
-
React.createElement(Modal, { portalHostName: portalHostName, visible: modalVisible, header: deepestReturnQuestionWithFeedback && (React.createElement(ButtonIcon, { name: "arrow_left", testID: "modal-back-button", onPress: handleOnBackButtonPress })), scroll: true, showCloseButton: true, onClose: handleOnModalClose },
|
|
37
|
+
React.createElement(Modal, { portalHostName: portalHostName, visible: modalVisible, header: deepestReturnQuestionWithFeedback && (React.createElement(ButtonIcon, { name: "arrow_left", style: style.backButton, testID: "modal-back-button", onPress: handleOnBackButtonPress })), scroll: true, showCloseButton: true, onClose: handleOnModalClose },
|
|
38
38
|
React.createElement(View, { style: style.modalContent }, children))));
|
|
39
39
|
};
|
|
40
40
|
export { HostSelectReturnQuestionItem };
|
|
@@ -3,6 +3,9 @@ import { StyleSheet } from "react-native";
|
|
|
3
3
|
const { colorBgPrimaryLight, space4, space6, space8 } = Theme.get();
|
|
4
4
|
const containerUnderlayColor = colorBgPrimaryLight;
|
|
5
5
|
const style = StyleSheet.create({
|
|
6
|
+
backButton: {
|
|
7
|
+
padding: 0,
|
|
8
|
+
},
|
|
6
9
|
container: {
|
|
7
10
|
marginBottom: space4,
|
|
8
11
|
},
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import ReturnQuestion from "../../../ReturnQuestion";
|
|
3
|
+
const HostStackReturnQuestionItem = ({ returnQuestion, portalHostName, }) => (React.createElement(React.Fragment, null, returnQuestion.children?.map((childReturnQuestion) => (React.createElement(ReturnQuestion, { key: childReturnQuestion.id, portalHostName: portalHostName, returnQuestion: childReturnQuestion, returnQuestionParent: returnQuestion })))));
|
|
4
|
+
export { HostStackReturnQuestionItem };
|
|
@@ -3,12 +3,12 @@ import { useIntl } from "@lookiero/i18n-react";
|
|
|
3
3
|
import { animated, useSpring } from "@react-spring/native";
|
|
4
4
|
import React, { useCallback, useMemo, useState } from "react";
|
|
5
5
|
import { View } from "react-native";
|
|
6
|
-
import ReturnQuestion from "
|
|
7
|
-
import {
|
|
6
|
+
import ReturnQuestion from "../../../ReturnQuestion";
|
|
7
|
+
import { useReturnQuestionFeedbackForReturnQuestion } from "../../../behaviors/useReturnQuestionFeedback";
|
|
8
8
|
import { style } from "./HostStackReturnQuestionItem.style";
|
|
9
9
|
const HostStackReturnQuestionItem = ({ returnQuestion, children, portalHostName, }) => {
|
|
10
10
|
const { formatMessage } = useIntl();
|
|
11
|
-
const { feedback } =
|
|
11
|
+
const { feedback } = useReturnQuestionFeedbackForReturnQuestion({ returnQuestion });
|
|
12
12
|
const feedbackReturnQuestion = feedback
|
|
13
13
|
? returnQuestion.children?.find((returnQuestion) => returnQuestion.id === feedback)
|
|
14
14
|
: undefined;
|
|
@@ -22,6 +22,6 @@ const HostStackReturnQuestionItem = ({ returnQuestion, children, portalHostName,
|
|
|
22
22
|
titleText && (React.createElement(Text, { level: 3, style: style.title, heading: true }, titleText)),
|
|
23
23
|
feedbackReturnQuestion ? (React.createElement(React.Fragment, null,
|
|
24
24
|
React.createElement(Text, { color: COLOR.TEXT_MEDIUM, level: 3 }, feedbackText),
|
|
25
|
-
feedbackReturnQuestion.children?.map((childReturnQuestion) => (React.createElement(ReturnQuestion, { key: childReturnQuestion.id, portalHostName: portalHostName, returnQuestion: childReturnQuestion,
|
|
25
|
+
feedbackReturnQuestion.children?.map((childReturnQuestion) => (React.createElement(ReturnQuestion, { key: childReturnQuestion.id, portalHostName: portalHostName, returnQuestion: childReturnQuestion, returnQuestionParent: feedbackReturnQuestion }))))) : (children))));
|
|
26
26
|
};
|
|
27
27
|
export { HostStackReturnQuestionItem };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ReturnQuestionProjection } from "../../../../../../../projection/returnQuestion/returnQuestion";
|
|
3
|
+
interface ModalOptionReturnQuestionItemsProps {
|
|
4
|
+
readonly portalHostName?: string;
|
|
5
|
+
readonly returnQuestion: ReturnQuestionProjection;
|
|
6
|
+
readonly returnQuestionParent: ReturnQuestionProjection;
|
|
7
|
+
readonly visible: boolean;
|
|
8
|
+
readonly onClose: () => void;
|
|
9
|
+
}
|
|
10
|
+
declare const ModalOptionReturnQuestionItems: ({ portalHostName, returnQuestion, visible, onClose, }: ModalOptionReturnQuestionItemsProps) => JSX.Element;
|
|
11
|
+
export { ModalOptionReturnQuestionItems };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { COLOR, Text } from "@lookiero/aurora";
|
|
2
|
+
import { useIntl } from "@lookiero/i18n-react";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { Modal } from "../../../../../../../shared/ui/components/layouts/modal/Modal";
|
|
5
|
+
import ReturnQuestion from "../../ReturnQuestion";
|
|
6
|
+
import { style } from "./ModalOptionReturnQuestionItems.style";
|
|
7
|
+
const ModalOptionReturnQuestionItems = ({ portalHostName, returnQuestion, visible, onClose, }) => {
|
|
8
|
+
const { formatMessage } = useIntl();
|
|
9
|
+
const title = formatMessage({ id: returnQuestion.name });
|
|
10
|
+
return (React.createElement(Modal, { portalHostName: portalHostName, visible: visible, scroll: true, showCloseButton: true, onClose: onClose },
|
|
11
|
+
React.createElement(Text, { color: COLOR.TEXT_MEDIUM, level: 2, style: style.optionText }, title),
|
|
12
|
+
React.createElement(React.Fragment, null, returnQuestion.children?.map((childReturnQuestion) => (React.createElement(ReturnQuestion, { key: childReturnQuestion.id, portalHostName: "", returnQuestion: childReturnQuestion, returnQuestionParent: returnQuestion }))))));
|
|
13
|
+
};
|
|
14
|
+
export { ModalOptionReturnQuestionItems };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Theme } from "@lookiero/aurora";
|
|
2
|
+
import { StyleSheet } from "react-native";
|
|
3
|
+
const { space2, space6 } = Theme.get();
|
|
4
|
+
const style = StyleSheet.create({
|
|
5
|
+
optionText: { marginBottom: space6 },
|
|
6
|
+
wrapper: { marginBottom: space2 },
|
|
7
|
+
});
|
|
8
|
+
export { style };
|
|
@@ -2,12 +2,12 @@ import { Text } from "@lookiero/aurora";
|
|
|
2
2
|
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
3
3
|
import React, { useCallback } from "react";
|
|
4
4
|
import { TouchableHighlight } from "react-native";
|
|
5
|
-
import {
|
|
5
|
+
import { useReturnQuestionFeedbackForReturnQuestion } from "../../behaviors/useReturnQuestionFeedback";
|
|
6
6
|
import { containerUnderlayColor, style } from "./OptionReturnQuestionItem.style";
|
|
7
|
-
const OptionReturnQuestionItem = ({ returnQuestion,
|
|
8
|
-
const { onChange } =
|
|
7
|
+
const OptionReturnQuestionItem = ({ returnQuestion, returnQuestionParent, testID, }) => {
|
|
8
|
+
const { onChange } = useReturnQuestionFeedbackForReturnQuestion({ returnQuestion: returnQuestionParent });
|
|
9
9
|
const optionText = useI18nMessage({ id: returnQuestion.name });
|
|
10
|
-
const handleOnPress = useCallback(() => onChange({ returnQuestionId:
|
|
10
|
+
const handleOnPress = useCallback(() => onChange({ returnQuestionId: returnQuestionParent.id, returnQuestionFeedback: returnQuestion.id }), [onChange, returnQuestion.id, returnQuestionParent.id]);
|
|
11
11
|
return (React.createElement(TouchableHighlight, { accessibilityLabel: testID, style: style.container, testID: testID, underlayColor: containerUnderlayColor, onPress: handleOnPress },
|
|
12
12
|
React.createElement(Text, { level: 3, style: style.text }, optionText)));
|
|
13
13
|
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { View, Option, OPTION_VARIANT } from "@lookiero/aurora";
|
|
2
|
+
import { useIntl } from "@lookiero/i18n-react";
|
|
3
|
+
import React, { useCallback, useEffect, useState } from "react";
|
|
4
|
+
import { useReturnQuestionFeedback, useReturnQuestionFeedbackForReturnQuestion, } from "../../behaviors/useReturnQuestionFeedback";
|
|
5
|
+
import { deepestReturnQuestionWithFeedbackForReturnQuestion, feedbackForReturnQuestion, } from "../../util/returnQuestionFeedback";
|
|
6
|
+
import { ModalOptionReturnQuestionItems } from "../modalOptionReturnQuestionItems/ModalOptionReturnQuestionItems";
|
|
7
|
+
import { style } from "./RadioReturnQuestionItem.style";
|
|
8
|
+
const RadioReturnQuestionItem = ({ returnQuestion, returnQuestionParent, testID, portalHostName, }) => {
|
|
9
|
+
const intl = useIntl();
|
|
10
|
+
const [modalVisible, setModalVisible] = useState(false);
|
|
11
|
+
const { feedback: feedbackId, onChange, clear, } = useReturnQuestionFeedbackForReturnQuestion({ returnQuestion: returnQuestionParent });
|
|
12
|
+
const feedback = useReturnQuestionFeedback();
|
|
13
|
+
const translate = useCallback((returnQuestionName) => intl.formatMessage({ id: returnQuestionName, defaultMessage: returnQuestionName }), [intl]);
|
|
14
|
+
const inputValue = feedbackForReturnQuestion({ feedback, returnQuestion, translate }).join(" / ");
|
|
15
|
+
const optionText = intl.formatMessage({ id: returnQuestion.name });
|
|
16
|
+
const hasChildren = Boolean(returnQuestion.children && returnQuestion.children.length > 0);
|
|
17
|
+
const handleOnModalClose = useCallback(() => {
|
|
18
|
+
// Uncomment if we want to clear current selection (and update callback's dependencies)
|
|
19
|
+
// clear();
|
|
20
|
+
setModalVisible(false);
|
|
21
|
+
}, []);
|
|
22
|
+
const handleOnPress = useCallback(() => {
|
|
23
|
+
clear();
|
|
24
|
+
onChange({ returnQuestionId: returnQuestionParent.id, returnQuestionFeedback: returnQuestion.id });
|
|
25
|
+
if (hasChildren) {
|
|
26
|
+
setModalVisible(true);
|
|
27
|
+
}
|
|
28
|
+
}, [clear, hasChildren, onChange, returnQuestion.id, returnQuestionParent.id]);
|
|
29
|
+
/**
|
|
30
|
+
* This logic is for closing the Modal when its children has been answered.
|
|
31
|
+
*/
|
|
32
|
+
const [deepestReturnQuestionWithFeedback, isLeaf] = deepestReturnQuestionWithFeedbackForReturnQuestion({
|
|
33
|
+
feedback,
|
|
34
|
+
returnQuestion,
|
|
35
|
+
});
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (deepestReturnQuestionWithFeedback && isLeaf) {
|
|
38
|
+
setModalVisible(false);
|
|
39
|
+
}
|
|
40
|
+
}, [deepestReturnQuestionWithFeedback, isLeaf]);
|
|
41
|
+
/**
|
|
42
|
+
* This logic is for closing the Modal when its children has been answered.
|
|
43
|
+
*/
|
|
44
|
+
return (React.createElement(React.Fragment, null,
|
|
45
|
+
React.createElement(View, { style: style.wrapper, testID: testID },
|
|
46
|
+
React.createElement(Option, { checked: returnQuestion.id === feedbackId, name: returnQuestion.id, title: inputValue ? `${optionText} / ${inputValue}` : `${optionText}`, value: returnQuestion.id, variant: OPTION_VARIANT.BUTTON, onChange: handleOnPress })),
|
|
47
|
+
hasChildren ? (React.createElement(ModalOptionReturnQuestionItems, { portalHostName: portalHostName, returnQuestion: returnQuestion, returnQuestionParent: returnQuestion, visible: modalVisible, onClose: handleOnModalClose })) : null));
|
|
48
|
+
};
|
|
49
|
+
export { RadioReturnQuestionItem };
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
import { View } from "@lookiero/aurora";
|
|
1
2
|
import { useIntl } from "@lookiero/i18n-react";
|
|
2
3
|
import React, { useCallback, useMemo } from "react";
|
|
3
4
|
import { InputField } from "../../../../../../../shared/ui/components/molecules/inputField/InputField";
|
|
4
|
-
import {
|
|
5
|
+
import { useReturnQuestionFeedbackForReturnQuestion } from "../../behaviors/useReturnQuestionFeedback";
|
|
6
|
+
import { style } from "./TextareaReturnQuestionItem.style";
|
|
5
7
|
const TEXTAREA_MIN_HEIGHT = 96;
|
|
6
|
-
const TextareaReturnQuestionItem = ({ returnQuestion,
|
|
8
|
+
const TextareaReturnQuestionItem = ({ returnQuestion, returnQuestionParent, testID, }) => {
|
|
7
9
|
const { formatMessage } = useIntl();
|
|
8
10
|
const placeholderText = useMemo(() => (returnQuestion.placeholder ? formatMessage({ id: returnQuestion.placeholder }) : ""), [formatMessage, returnQuestion.placeholder]);
|
|
9
|
-
const { feedback, onChange } =
|
|
10
|
-
const handleOnChange = useCallback((value) => onChange({ returnQuestionId:
|
|
11
|
-
return (React.createElement(
|
|
11
|
+
const { feedback, onChange } = useReturnQuestionFeedbackForReturnQuestion({ returnQuestion: returnQuestionParent });
|
|
12
|
+
const handleOnChange = useCallback((value) => onChange({ returnQuestionId: returnQuestionParent.id, returnQuestionFeedback: value }), [onChange, returnQuestionParent.id]);
|
|
13
|
+
return (React.createElement(View, { style: style.wrapper },
|
|
14
|
+
React.createElement(InputField, { label: placeholderText, minHeight: TEXTAREA_MIN_HEIGHT, placeholder: placeholderText, testID: testID, value: feedback, multiline: true, onChange: handleOnChange })));
|
|
12
15
|
};
|
|
13
16
|
export { TextareaReturnQuestionItem };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Theme } from "@lookiero/aurora";
|
|
2
|
+
import { StyleSheet } from "react-native";
|
|
3
|
+
const { colorBgBase, space6 } = Theme.get();
|
|
4
|
+
const style = StyleSheet.create({
|
|
5
|
+
wrapper: {
|
|
6
|
+
backgroundColor: colorBgBase,
|
|
7
|
+
padding: space6,
|
|
8
|
+
paddingTop: 0,
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
export { style };
|
|
@@ -177,6 +177,6 @@ const Item = ({ customerId, country, layout: Layout }) => {
|
|
|
177
177
|
scrollView: { height: itemWithoutCustomerDecission ? "100%" : "auto" },
|
|
178
178
|
safeAreaView: isDesktopScreen ? style.safeAreaView : null,
|
|
179
179
|
} }, itemWithoutCustomerDecission ? (React.createElement(ItemWithoutCustomerDecission, { bookedProductsVariants: bookedProductsVariants, checkoutId: checkout.id, checkoutItem: checkoutItem, country: country, currentProductVariant: currentProductVariant, onReturn: redirectToReturnPage ? goToReturnPage : showReturnQuestions })) : (React.createElement(ItemWithCustomerDecission, { checkoutId: checkout.id, checkoutItem: checkoutItem, country: country, currentProductVariant: currentProductVariant, returnQuestions: returnQuestions, onEditFeedback: showReturnQuestions }))),
|
|
180
|
-
React.createElement(ReturnQuestionsForm, { returnQuestions: returnQuestions, visible: returnQuestionsVisible, onClose: hideReturnQuestions, onSubmit: returnItem })));
|
|
180
|
+
!redirectToReturnPage ? (React.createElement(ReturnQuestionsForm, { returnQuestions: returnQuestions, visible: returnQuestionsVisible, onClose: hideReturnQuestions, onSubmit: returnItem })) : null));
|
|
181
181
|
};
|
|
182
182
|
export { Item };
|
package/dist/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.js
CHANGED
|
@@ -9,7 +9,7 @@ import { useReturnQuestionFeedback } from "../../../../components/organisms/retu
|
|
|
9
9
|
import { ReturnQuestionItemProvider, } from "../../../../components/organisms/returnQuestions/behaviors/useReturnQuestionItem";
|
|
10
10
|
import { HostDefaultReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem";
|
|
11
11
|
import { HostSelectReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem";
|
|
12
|
-
import { HostStackReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/hostStackReturnQuestionItem/HostStackReturnQuestionItem";
|
|
12
|
+
import { HostStackReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/hostStackReturnQuestionItem/modal/HostStackReturnQuestionItem";
|
|
13
13
|
import { OptionReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/optionReturnQuestionItem/OptionReturnQuestionItem";
|
|
14
14
|
import { TextareaReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem";
|
|
15
15
|
import { I18nMessages } from "../../../../i18n/i18n";
|
|
@@ -3,9 +3,10 @@ import { Button, Text, View, useDevice } from "@lookiero/aurora";
|
|
|
3
3
|
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
4
4
|
import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
|
|
5
5
|
import React, { useCallback } from "react";
|
|
6
|
-
import { useParams } from "react-router-native";
|
|
6
|
+
import { generatePath, useNavigate, useParams } from "react-router-native";
|
|
7
7
|
import { ReturnQuestionType } from "../../../../projection/returnQuestion/returnQuestion";
|
|
8
8
|
import { useLogger } from "../../../../shared/logging/useLogger";
|
|
9
|
+
import { useTrackPressNext } from "../../../../shared/tracking/infrastructure/useTrackPressNext";
|
|
9
10
|
import { useTrackReturnItem } from "../../../../shared/tracking/infrastructure/useTrackReturnItem";
|
|
10
11
|
import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
|
|
11
12
|
import { Column } from "../../../../shared/ui/components/layouts/column/Column";
|
|
@@ -18,23 +19,29 @@ import { ReturnQuestions } from "../../components/organisms/returnQuestions/Retu
|
|
|
18
19
|
import { ReturnQuestionFeedbackProvider, useReturnQuestionFeedback, } from "../../components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback";
|
|
19
20
|
import { ReturnQuestionItemProvider, } from "../../components/organisms/returnQuestions/behaviors/useReturnQuestionItem";
|
|
20
21
|
import { HostDefaultReturnQuestionItem } from "../../components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem";
|
|
21
|
-
import {
|
|
22
|
-
import { HostStackReturnQuestionItem } from "../../components/organisms/returnQuestions/components/hostStackReturnQuestionItem/HostStackReturnQuestionItem";
|
|
23
|
-
import {
|
|
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";
|
|
24
25
|
import { TextareaReturnQuestionItem } from "../../components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem";
|
|
25
26
|
import { I18nMessages } from "../../i18n/i18n";
|
|
27
|
+
import { Routes } from "../../routing/routes";
|
|
28
|
+
import { useBasePath } from "../../routing/useBasePath";
|
|
26
29
|
import { style } from "./Return.style";
|
|
27
30
|
const returnQuestionItems = {
|
|
28
31
|
[ReturnQuestionType.HOST_DEFAULT]: HostDefaultReturnQuestionItem,
|
|
29
32
|
[ReturnQuestionType.HOST_TEXTAREA]: HostDefaultReturnQuestionItem,
|
|
30
|
-
[ReturnQuestionType.HOST_SELECT]:
|
|
33
|
+
[ReturnQuestionType.HOST_SELECT]: HostRadioGroupReturnQuestionItem,
|
|
31
34
|
[ReturnQuestionType.HOST_STACK]: HostStackReturnQuestionItem,
|
|
32
35
|
[ReturnQuestionType.TEXTAREA]: TextareaReturnQuestionItem,
|
|
33
|
-
[ReturnQuestionType.OPTION]:
|
|
36
|
+
[ReturnQuestionType.OPTION]: RadioReturnQuestionItem,
|
|
34
37
|
};
|
|
35
|
-
const ReturnForm = ({
|
|
38
|
+
const ReturnForm = ({ checkout, checkoutItem, country, layout: LocalLayout }) => {
|
|
36
39
|
const { screen } = useDevice();
|
|
40
|
+
const navigate = useNavigate();
|
|
37
41
|
const logger = useLogger();
|
|
42
|
+
const basePath = useBasePath();
|
|
43
|
+
const trackPressNext = useTrackPressNext();
|
|
44
|
+
const checkoutId = checkout.id;
|
|
38
45
|
const titleText = useI18nMessage({ id: I18nMessages.RETURN_QUESTIONS_TITLE });
|
|
39
46
|
const descriptionText = useI18nMessage({ id: I18nMessages.RETURN_QUESTIONS_DESCRIPTION });
|
|
40
47
|
const submitButtonText = useI18nMessage({ id: I18nMessages.RETURN_QUESTIONS_SUBMIT_BUTTON });
|
|
@@ -43,7 +50,6 @@ const ReturnForm = ({ checkoutItem, checkoutId, country, layout: LocalLayout })
|
|
|
43
50
|
const [returnQuestions] = useListReturnQuestionsByCheckoutItemId({
|
|
44
51
|
checkoutItemId: checkoutItem.id,
|
|
45
52
|
});
|
|
46
|
-
const hideReturnQuestions = useCallback(() => void 0, []);
|
|
47
53
|
const [returnCheckoutItem, returnCheckoutItemStatus] = useReturnCheckoutItem({
|
|
48
54
|
checkoutItemId: checkoutItem.id,
|
|
49
55
|
logger,
|
|
@@ -54,11 +60,26 @@ const ReturnForm = ({ checkoutItem, checkoutId, country, layout: LocalLayout })
|
|
|
54
60
|
checkoutId: checkoutId,
|
|
55
61
|
checkoutItemId: checkoutItem.id,
|
|
56
62
|
});
|
|
63
|
+
const navigateToNextItem = useCallback(() => {
|
|
64
|
+
const item = checkoutItem;
|
|
65
|
+
const items = checkout?.items;
|
|
66
|
+
const itemIndex = items.indexOf(item);
|
|
67
|
+
const nextItemIndex = itemIndex === items.length - 1 ? 0 : itemIndex + 1;
|
|
68
|
+
const nextItem = items[nextItemIndex];
|
|
69
|
+
trackPressNext({
|
|
70
|
+
page: TrackingPage.ITEM,
|
|
71
|
+
country,
|
|
72
|
+
checkoutId,
|
|
73
|
+
from: item.id,
|
|
74
|
+
to: nextItem.id,
|
|
75
|
+
});
|
|
76
|
+
navigate(generatePath(`${basePath}/${Routes.ITEM}`, { id: nextItem.id }));
|
|
77
|
+
}, [basePath, checkout?.items, checkoutId, checkoutItem, country, navigate, trackPressNext]);
|
|
57
78
|
const returnItem = useCallback(async (feedbacks) => {
|
|
58
|
-
hideReturnQuestions();
|
|
59
79
|
returnCheckoutItem({ feedbacks });
|
|
60
80
|
trackReturnItem();
|
|
61
|
-
|
|
81
|
+
navigateToNextItem();
|
|
82
|
+
}, [navigateToNextItem, returnCheckoutItem, trackReturnItem]);
|
|
62
83
|
const feedback = useReturnQuestionFeedback();
|
|
63
84
|
const handleOnSubmit = useCallback(() => returnItem(feedback), [feedback, returnItem]);
|
|
64
85
|
/* ReturnCheckoutItem */
|
|
@@ -70,13 +91,14 @@ const ReturnForm = ({ checkoutItem, checkoutId, country, layout: LocalLayout })
|
|
|
70
91
|
React.createElement(PortalHost, { name: "return-question-form-portal" }),
|
|
71
92
|
React.createElement(LocalLayout, { scrollEnabled: true, style: {
|
|
72
93
|
header: style.header,
|
|
73
|
-
|
|
94
|
+
safeAreaView: style.safeAreaView,
|
|
74
95
|
} },
|
|
75
96
|
React.createElement(Row, { style: [style.row, isSmallScreen ? undefined : style.desktopRow] },
|
|
76
97
|
React.createElement(Column, { size: { M: "2/3", L: "2/3" } },
|
|
77
|
-
React.createElement(View,
|
|
78
|
-
React.createElement(
|
|
79
|
-
|
|
98
|
+
React.createElement(View, null,
|
|
99
|
+
React.createElement(View, { style: [style.info, isSmallScreen ? undefined : style.desktopInfo] },
|
|
100
|
+
React.createElement(Text, { level: 3, heading: true }, titleText),
|
|
101
|
+
React.createElement(Text, { level: 1, style: style.description, detail: true }, descriptionText)),
|
|
80
102
|
React.createElement(ReturnQuestions, { portalHostName: "return-question-form-portal", returnQuestions: returnQuestions }),
|
|
81
103
|
React.createElement(View, { style: style.submit },
|
|
82
104
|
React.createElement(Button, { testID: "return-questions-button", onPress: handleOnSubmit }, submitButtonText))))))));
|
|
@@ -90,6 +112,6 @@ const Return = ({ customerId, country, layout: LocalLayout }) => {
|
|
|
90
112
|
return React.createElement(Spinner, null);
|
|
91
113
|
}
|
|
92
114
|
return (React.createElement(ReturnQuestionFeedbackProvider, { key: checkoutItem.id, feedback: checkoutItem.feedbacks || {} },
|
|
93
|
-
React.createElement(ReturnForm, {
|
|
115
|
+
React.createElement(ReturnForm, { checkout: checkout, checkoutItem: checkoutItem, country: country, layout: LocalLayout })));
|
|
94
116
|
};
|
|
95
117
|
export { Return };
|
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
declare const style: {
|
|
2
|
-
container: {
|
|
3
|
-
backgroundColor: string;
|
|
4
|
-
paddingHorizontal: number;
|
|
5
|
-
paddingTop: number;
|
|
6
|
-
};
|
|
7
2
|
description: {
|
|
8
3
|
color: string;
|
|
9
|
-
marginBottom: number;
|
|
10
4
|
};
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
desktopInfo: {
|
|
6
|
+
borderTopLeftRadius: number;
|
|
7
|
+
borderTopRightRadius: number;
|
|
13
8
|
};
|
|
14
9
|
desktopRow: {
|
|
15
|
-
|
|
10
|
+
marginVertical: number;
|
|
16
11
|
};
|
|
17
12
|
header: {
|
|
18
13
|
height: number;
|
|
19
14
|
};
|
|
15
|
+
info: {
|
|
16
|
+
backgroundColor: string;
|
|
17
|
+
paddingBottom: number;
|
|
18
|
+
paddingHorizontal: number;
|
|
19
|
+
paddingTop: number;
|
|
20
|
+
};
|
|
20
21
|
row: {
|
|
21
22
|
flex: number;
|
|
22
23
|
justifyContent: "center";
|
|
23
24
|
};
|
|
24
|
-
|
|
25
|
+
safeAreaView: {
|
|
25
26
|
backgroundColor: string;
|
|
26
27
|
flex: number;
|
|
27
28
|
};
|
|
28
29
|
submit: {
|
|
29
|
-
|
|
30
|
+
backgroundColor: string;
|
|
31
|
+
padding: number;
|
|
30
32
|
};
|
|
31
|
-
title: {};
|
|
32
33
|
};
|
|
33
34
|
export { style };
|
|
@@ -3,35 +3,36 @@ import { StyleSheet } from "react-native";
|
|
|
3
3
|
import { HEADER_HEIGHT } from "../../components/templates/header/Header.style";
|
|
4
4
|
const { borderRadius5, colorBgPrimaryLight, colorBgBase, colorTextMedium, space4, space6, space8 } = Theme.get();
|
|
5
5
|
const style = StyleSheet.create({
|
|
6
|
-
container: {
|
|
7
|
-
backgroundColor: colorBgBase,
|
|
8
|
-
paddingHorizontal: space6,
|
|
9
|
-
paddingTop: space8,
|
|
10
|
-
},
|
|
11
6
|
description: {
|
|
12
7
|
color: colorTextMedium,
|
|
13
|
-
marginBottom: space4,
|
|
14
8
|
},
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
desktopInfo: {
|
|
10
|
+
borderTopLeftRadius: borderRadius5,
|
|
11
|
+
borderTopRightRadius: borderRadius5,
|
|
17
12
|
},
|
|
18
13
|
desktopRow: {
|
|
19
|
-
|
|
14
|
+
marginVertical: space8,
|
|
20
15
|
},
|
|
21
16
|
header: {
|
|
22
17
|
height: HEADER_HEIGHT,
|
|
23
18
|
},
|
|
19
|
+
info: {
|
|
20
|
+
backgroundColor: colorBgBase,
|
|
21
|
+
paddingBottom: space4,
|
|
22
|
+
paddingHorizontal: space6,
|
|
23
|
+
paddingTop: space8,
|
|
24
|
+
},
|
|
24
25
|
row: {
|
|
25
26
|
flex: 1,
|
|
26
27
|
justifyContent: "center",
|
|
27
28
|
},
|
|
28
|
-
|
|
29
|
+
safeAreaView: {
|
|
29
30
|
backgroundColor: colorBgPrimaryLight,
|
|
30
31
|
flex: 1,
|
|
31
32
|
},
|
|
32
33
|
submit: {
|
|
33
|
-
|
|
34
|
+
backgroundColor: colorBgBase,
|
|
35
|
+
padding: space6,
|
|
34
36
|
},
|
|
35
|
-
title: {},
|
|
36
37
|
});
|
|
37
38
|
export { style };
|
package/package.json
CHANGED
|
File without changes
|