@lookiero/checkout 1.0.0 → 1.1.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/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.js +8 -2
- package/dist/infrastructure/ui/components/organisms/returnQuestions/util/returnQuestionFeedback.d.ts +6 -3
- package/dist/infrastructure/ui/components/organisms/returnQuestions/util/returnQuestionFeedback.js +3 -9
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useI18nMessage, useIntl } from "@lookiero/i18n-react";
|
|
2
|
-
import React, { useCallback, useState } from "react";
|
|
2
|
+
import React, { useCallback, useEffect, useState } from "react";
|
|
3
3
|
import { TouchableHighlight, View } from "react-native";
|
|
4
4
|
import { Modal } from "../../../../../../../shared/ui/components/layouts/modal/Modal";
|
|
5
5
|
import { ButtonIcon } from "../../../../../../../shared/ui/components/molecules/buttonIcon/ButtonIcon";
|
|
@@ -17,12 +17,18 @@ const HostSelectReturnQuestionItem = ({ returnQuestion, children, portalHostName
|
|
|
17
17
|
const intl = useIntl();
|
|
18
18
|
const translate = useCallback((returnQuestionName) => intl.formatMessage({ id: returnQuestionName, defaultMessage: returnQuestionName }), [intl]);
|
|
19
19
|
const inputValue = feedbackForReturnQuestion({ feedback, returnQuestion, translate }).join(" / ");
|
|
20
|
-
const deepestReturnQuestionWithFeedback = deepestReturnQuestionWithFeedbackForReturnQuestion({
|
|
20
|
+
const [deepestReturnQuestionWithFeedback, isLeaf] = deepestReturnQuestionWithFeedbackForReturnQuestion({
|
|
21
21
|
feedback,
|
|
22
22
|
returnQuestion,
|
|
23
23
|
});
|
|
24
24
|
const handleOnBackButtonPress = useCallback(() => deepestReturnQuestionWithFeedback &&
|
|
25
25
|
onChange({ returnQuestionId: deepestReturnQuestionWithFeedback.id, returnQuestionFeedback: undefined }), [deepestReturnQuestionWithFeedback, onChange]);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (isLeaf) {
|
|
28
|
+
handleOnModalClose();
|
|
29
|
+
}
|
|
30
|
+
// deepestReturnQuestionWithFeedback needs to be as a dependency in order to be re-evaluated whenever it changes
|
|
31
|
+
}, [handleOnModalClose, deepestReturnQuestionWithFeedback, isLeaf]);
|
|
26
32
|
return (React.createElement(React.Fragment, null,
|
|
27
33
|
React.createElement(TouchableHighlight, { style: style.container, underlayColor: containerUnderlayColor, onPress: handleOnPress },
|
|
28
34
|
React.createElement(View, { pointerEvents: "none" },
|
package/dist/infrastructure/ui/components/organisms/returnQuestions/util/returnQuestionFeedback.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FeedbackProjection } from "../../../../../../projection/feedback/feedback";
|
|
2
2
|
import { ReturnQuestionProjection } from "../../../../../../projection/returnQuestion/returnQuestion";
|
|
3
3
|
interface RecursiveFeedbackForReturnQuestionFunctionArgs {
|
|
4
|
-
readonly feedback: FeedbackProjection
|
|
4
|
+
readonly feedback: FeedbackProjection;
|
|
5
5
|
readonly returnQuestion: ReturnQuestionProjection;
|
|
6
6
|
readonly translate: (i18nString: string) => string;
|
|
7
7
|
readonly acc?: string[];
|
|
@@ -11,12 +11,15 @@ interface RecursiveFeedbackForReturnQuestionFunction {
|
|
|
11
11
|
}
|
|
12
12
|
declare const feedbackForReturnQuestion: RecursiveFeedbackForReturnQuestionFunction;
|
|
13
13
|
interface RecursiveDeepestReturnQuestionWithFeedbackFunctionArgs {
|
|
14
|
-
readonly feedback: FeedbackProjection
|
|
14
|
+
readonly feedback: FeedbackProjection;
|
|
15
15
|
readonly returnQuestion: ReturnQuestionProjection;
|
|
16
16
|
readonly deepestReturnQuestion?: ReturnQuestionProjection;
|
|
17
17
|
}
|
|
18
18
|
interface RecursiveDeepestReturnQuestionWithFeedbackFunction {
|
|
19
|
-
(args: RecursiveDeepestReturnQuestionWithFeedbackFunctionArgs):
|
|
19
|
+
(args: RecursiveDeepestReturnQuestionWithFeedbackFunctionArgs): [
|
|
20
|
+
question: ReturnQuestionProjection | undefined,
|
|
21
|
+
isLeaf: boolean
|
|
22
|
+
];
|
|
20
23
|
}
|
|
21
24
|
declare const deepestReturnQuestionWithFeedbackForReturnQuestion: RecursiveDeepestReturnQuestionWithFeedbackFunction;
|
|
22
25
|
export { feedbackForReturnQuestion, deepestReturnQuestionWithFeedbackForReturnQuestion };
|
package/dist/infrastructure/ui/components/organisms/returnQuestions/util/returnQuestionFeedback.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { validate } from "uuid";
|
|
2
2
|
const isUuid = (value) => validate(value);
|
|
3
3
|
const feedbackForReturnQuestion = ({ feedback, returnQuestion, translate, acc = [], }) => {
|
|
4
|
-
if (!feedback) {
|
|
5
|
-
return [];
|
|
6
|
-
}
|
|
7
4
|
const returnQuestionId = Object.keys(feedback).find((id) => id === returnQuestion.id);
|
|
8
5
|
if (returnQuestionId) {
|
|
9
6
|
const returnQuestionFeedback = feedback[returnQuestionId];
|
|
@@ -26,9 +23,6 @@ const feedbackForReturnQuestion = ({ feedback, returnQuestion, translate, acc =
|
|
|
26
23
|
], []) || []);
|
|
27
24
|
};
|
|
28
25
|
const deepestReturnQuestionWithFeedbackForReturnQuestion = ({ feedback, returnQuestion, deepestReturnQuestion, }) => {
|
|
29
|
-
if (!feedback) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
26
|
const returnQuestionId = Object.keys(feedback).find((id) => id === returnQuestion.id);
|
|
33
27
|
if (returnQuestionId) {
|
|
34
28
|
const returnQuestionFeedback = feedback[returnQuestionId];
|
|
@@ -41,9 +35,9 @@ const deepestReturnQuestionWithFeedbackForReturnQuestion = ({ feedback, returnQu
|
|
|
41
35
|
deepestReturnQuestion: returnQuestion,
|
|
42
36
|
});
|
|
43
37
|
}
|
|
44
|
-
return returnQuestion;
|
|
38
|
+
return [returnQuestion, false];
|
|
45
39
|
}
|
|
46
|
-
return returnQuestion;
|
|
40
|
+
return [returnQuestion, false];
|
|
47
41
|
}
|
|
48
42
|
const feebackReturnQuestionChild = returnQuestion.children?.find((childReturnQuestion) => Object.keys(feedback).find((id) => id === childReturnQuestion.id));
|
|
49
43
|
if (feebackReturnQuestionChild) {
|
|
@@ -53,6 +47,6 @@ const deepestReturnQuestionWithFeedbackForReturnQuestion = ({ feedback, returnQu
|
|
|
53
47
|
deepestReturnQuestion: feebackReturnQuestionChild,
|
|
54
48
|
});
|
|
55
49
|
}
|
|
56
|
-
return deepestReturnQuestion;
|
|
50
|
+
return [deepestReturnQuestion, !returnQuestion.children || returnQuestion.children.length === 0];
|
|
57
51
|
};
|
|
58
52
|
export { feedbackForReturnQuestion, deepestReturnQuestionWithFeedbackForReturnQuestion };
|