@lookiero/checkout 8.18.0 → 8.20.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/cypress/support/interceptListReturnQuestionsByCheckoutItemId.ts +1 -1
- package/dist/src/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.js +1 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/ReturnQuestion.js +3 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/behaviors/isChildReturnQuestion.js +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/behaviors/useReturnQuestionItem.d.ts +3 -3
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/ReturnQuestionItem.d.ts +4 -3
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionFeedbackItem/HostDefaultReturnQuestionFeedbackItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionFeedbackItem/HostDefaultReturnQuestionFeedbackItem.js +1 -0
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.js +8 -6
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.js +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.js +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/form/HostStackReturnQuestionItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/form/HostStackReturnQuestionItem.js +1 -0
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/modal/HostStackReturnQuestionItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/modal/HostStackReturnQuestionItem.js +5 -3
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/modalOptionReturnQuestionItems/ModalOptionReturnQuestionItems.js +4 -2
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/optionReturnQuestionItem/OptionReturnQuestionItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/optionReturnQuestionItem/OptionReturnQuestionItem.js +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/radioReturnQuestionItem/RadioReturnQuestionItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/radioReturnQuestionItem/RadioReturnQuestionItem.js +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem.js +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.js +2 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/util/returnQuestionFeedback.js +18 -9
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsFeedback/ReturnQuestionsFeedback.js +1 -1
- package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.js +1 -1
- package/dist/src/projection/returnQuestion/returnQuestion.constants.d.ts +9 -0
- package/dist/src/projection/returnQuestion/returnQuestion.constants.js +10 -0
- package/dist/src/projection/returnQuestion/returnQuestion.d.ts +23 -16
- package/dist/src/projection/returnQuestion/returnQuestion.js +1 -11
- package/dist/src/projection/returnQuestion/returnQuestion.metadata.d.ts +12 -0
- package/dist/src/projection/returnQuestion/returnQuestion.metadata.js +1 -0
- package/dist/src/projection/returnQuestion/returnQuestion.typeguard.d.ts +5 -0
- package/dist/src/projection/returnQuestion/returnQuestion.typeguard.js +10 -0
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
- package/src/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.ts +1 -1
- package/src/infrastructure/projection/returnQuestion/react/useListReturnQuestionsByCheckoutItemId.test.ts +4 -9
- package/src/infrastructure/projection/returnQuestion/returnQuestions.mock.ts +72 -117
- package/src/infrastructure/ui/components/organisms/returnQuestions/ReturnQuestion.test.tsx +10 -12
- package/src/infrastructure/ui/components/organisms/returnQuestions/ReturnQuestion.tsx +10 -8
- package/src/infrastructure/ui/components/organisms/returnQuestions/ReturnQuestions.test.tsx +10 -9
- package/src/infrastructure/ui/components/organisms/returnQuestions/behaviors/isChildReturnQuestion.ts +2 -1
- package/src/infrastructure/ui/components/organisms/returnQuestions/behaviors/useReturnQuestionItem.test.tsx +7 -9
- package/src/infrastructure/ui/components/organisms/returnQuestions/behaviors/useReturnQuestionItem.tsx +3 -3
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/ReturnQuestionItem.ts +4 -3
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionFeedbackItem/HostDefaultReturnQuestionFeedbackItem.test.tsx +7 -13
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionFeedbackItem/HostDefaultReturnQuestionFeedbackItem.tsx +4 -2
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.test.tsx +8 -14
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.tsx +13 -7
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.tsx +7 -5
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.test.tsx +10 -14
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.tsx +7 -5
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/form/HostStackReturnQuestionItem.tsx +5 -3
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/modal/HostStackReturnQuestionItem.test.tsx +43 -36
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/modal/HostStackReturnQuestionItem.tsx +10 -7
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/modalOptionReturnQuestionItems/ModalOptionReturnQuestionItems.tsx +11 -9
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/optionReturnQuestionItem/OptionReturnQuestionItem.test.tsx +8 -14
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/optionReturnQuestionItem/OptionReturnQuestionItem.tsx +6 -4
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/radioReturnQuestionItem/RadioReturnQuestionItem.tsx +6 -4
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem.test.tsx +23 -25
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem.tsx +5 -3
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.test.tsx +9 -29
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.tsx +7 -5
- package/src/infrastructure/ui/components/organisms/returnQuestions/util/__snapshots__/returnQuestionFeedback.test.ts.snap +5 -4
- package/src/infrastructure/ui/components/organisms/returnQuestions/util/returnQuestionFeedback.ts +32 -18
- package/src/infrastructure/ui/views/item/components/productVariantSlider/__snapshots__/ProductVariantSlider.test.tsx.snap +212 -254
- package/src/infrastructure/ui/views/item/components/returnQuestionsFeedback/ReturnQuestionsFeedback.tsx +2 -4
- package/src/infrastructure/ui/views/item/views/productVariant/__snapshots__/ProductVariant.test.tsx.snap +636 -762
- package/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.tsx +1 -1
- package/src/infrastructure/ui/views/summaryTabs/components/checkoutItemsTabs/__snapshots__/CheckoutItemsTabs.test.tsx.snap +1169 -1211
- package/src/projection/returnQuestion/listReturnQuestionsByCheckoutItemId.test.ts +4 -12
- package/src/projection/returnQuestion/returnQuestion.constants.ts +10 -0
- package/src/projection/returnQuestion/returnQuestion.metadata.ts +17 -0
- package/src/projection/returnQuestion/returnQuestion.ts +42 -20
- package/src/projection/returnQuestion/returnQuestion.typeguard.ts +24 -0
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
ReturnQuestionType,
|
|
5
|
-
} from "../../../../../../../projection/returnQuestion/returnQuestion";
|
|
2
|
+
import { ReturnQuestionProjection } from "../../../../../../../projection/returnQuestion/returnQuestion";
|
|
3
|
+
import { ReturnQuestionType } from "../../../../../../../projection/returnQuestion/returnQuestion.constants";
|
|
6
4
|
import { feedback as mockFeedback } from "../../../../../../projection/feedback/feedback.mock";
|
|
7
5
|
import { I18nMessages } from "../../../../../i18n/i18n";
|
|
8
6
|
import { render } from "../../../../../test/render";
|
|
@@ -12,40 +10,34 @@ jest.mock("../../behaviors/useReturnQuestionFeedback", () => ({
|
|
|
12
10
|
useReturnQuestionFeedback: () => mockFeedback,
|
|
13
11
|
}));
|
|
14
12
|
|
|
15
|
-
const returnQuestion: ReturnQuestionProjection = {
|
|
13
|
+
const returnQuestion: ReturnQuestionProjection<ReturnQuestionType.HOST_DEFAULT> = {
|
|
16
14
|
id: "0ad1dba8-b02c-4121-a1e3-981f1c30800d",
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
type: ReturnQuestionType.HOST_STACK,
|
|
15
|
+
translationKey: "size_title",
|
|
16
|
+
type: ReturnQuestionType.HOST_DEFAULT,
|
|
20
17
|
children: [
|
|
21
18
|
{
|
|
22
19
|
id: "9251dc2c-d76a-484d-9299-346929af932f",
|
|
23
|
-
|
|
24
|
-
placeholder: "",
|
|
20
|
+
translationKey: "size_large",
|
|
25
21
|
type: ReturnQuestionType.OPTION,
|
|
26
22
|
children: [
|
|
27
23
|
{
|
|
28
24
|
id: "542c4d24-e1da-484f-8c3a-7d89ee135adc",
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
type: ReturnQuestionType.HOST_STACK,
|
|
25
|
+
translationKey: "",
|
|
26
|
+
type: ReturnQuestionType.HOST_DEFAULT,
|
|
32
27
|
children: [
|
|
33
28
|
{
|
|
34
29
|
id: "68c0bb98-b00a-4b86-af43-528fe903cb69",
|
|
35
|
-
|
|
36
|
-
placeholder: "",
|
|
30
|
+
translationKey: "size_overall",
|
|
37
31
|
type: ReturnQuestionType.OPTION,
|
|
38
32
|
},
|
|
39
33
|
{
|
|
40
34
|
id: "85e84a77-461c-41e6-8544-95b5294d0b80",
|
|
41
|
-
|
|
42
|
-
placeholder: "",
|
|
35
|
+
translationKey: "size_trousers_too_long",
|
|
43
36
|
type: ReturnQuestionType.OPTION,
|
|
44
37
|
},
|
|
45
38
|
{
|
|
46
39
|
id: "29441d25-8d9f-471e-a13e-a03f61c88091",
|
|
47
|
-
|
|
48
|
-
placeholder: "",
|
|
40
|
+
translationKey: "size_fit_cut_does_not_fit",
|
|
49
41
|
type: ReturnQuestionType.OPTION,
|
|
50
42
|
},
|
|
51
43
|
],
|
|
@@ -54,11 +46,17 @@ const returnQuestion: ReturnQuestionProjection = {
|
|
|
54
46
|
},
|
|
55
47
|
],
|
|
56
48
|
};
|
|
57
|
-
const returnQuestionUnanswered: ReturnQuestionProjection = {
|
|
49
|
+
const returnQuestionUnanswered: ReturnQuestionProjection<ReturnQuestionType.HOST_DEFAULT> = {
|
|
58
50
|
id: "fd7ff4a0-78ed-4c0d-aa4d-64962739c322",
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
51
|
+
translationKey: "style_title",
|
|
52
|
+
type: ReturnQuestionType.HOST_DEFAULT,
|
|
53
|
+
children: [
|
|
54
|
+
{
|
|
55
|
+
id: "68c0bb98-b00a-4b86-af43-528fe903cb69",
|
|
56
|
+
translationKey: "size_overall",
|
|
57
|
+
type: ReturnQuestionType.OPTION,
|
|
58
|
+
},
|
|
59
|
+
],
|
|
62
60
|
};
|
|
63
61
|
|
|
64
62
|
describe("ReturnQuestionFeedbackItem component (ReturnQuestions organism)", () => {
|
|
@@ -70,7 +68,7 @@ describe("ReturnQuestionFeedbackItem component (ReturnQuestions organism)", () =
|
|
|
70
68
|
/>,
|
|
71
69
|
);
|
|
72
70
|
|
|
73
|
-
expect(getByText(returnQuestion.
|
|
71
|
+
expect(getByText(returnQuestion.translationKey)).toBeTruthy();
|
|
74
72
|
expect(getByText("size_large / size_overall")).toBeTruthy();
|
|
75
73
|
});
|
|
76
74
|
|
|
@@ -82,7 +80,7 @@ describe("ReturnQuestionFeedbackItem component (ReturnQuestions organism)", () =
|
|
|
82
80
|
/>,
|
|
83
81
|
);
|
|
84
82
|
|
|
85
|
-
expect(getByText(returnQuestionUnanswered.
|
|
83
|
+
expect(getByText(returnQuestionUnanswered.translationKey)).toBeTruthy();
|
|
86
84
|
expect(getByText(I18nMessages.FEEDBACK_UNANSWERED)).toBeTruthy();
|
|
87
85
|
});
|
|
88
86
|
});
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
1
2
|
import React, { useCallback } from "react";
|
|
2
3
|
import { View } from "react-native";
|
|
3
4
|
import { Text } from "@lookiero/aurora";
|
|
4
5
|
import { useI18nMessage, useIntl } from "@lookiero/i18n-react";
|
|
6
|
+
import { ReturnQuestionType } from "../../../../../../../projection/returnQuestion/returnQuestion.constants";
|
|
5
7
|
import { I18nMessages } from "../../../../../i18n/i18n";
|
|
6
8
|
import { useReturnQuestionFeedback } from "../../behaviors/useReturnQuestionFeedback";
|
|
7
9
|
import { feedbackForReturnQuestion } from "../../util/returnQuestionFeedback";
|
|
8
|
-
import { ReturnQuestionItem
|
|
10
|
+
import { ReturnQuestionItem } from "../ReturnQuestionItem";
|
|
9
11
|
import { style } from "./ReturnQuestionFeedbackItem.style";
|
|
10
12
|
|
|
11
|
-
const ReturnQuestionFeedbackItem: ReturnQuestionItem = ({ returnQuestion }
|
|
12
|
-
const titleText = useI18nMessage({ id: returnQuestion.
|
|
13
|
+
const ReturnQuestionFeedbackItem: ReturnQuestionItem<ReturnQuestionType.HOST_DEFAULT> = ({ returnQuestion }) => {
|
|
14
|
+
const titleText = useI18nMessage({ id: returnQuestion.translationKey });
|
|
13
15
|
const unansweredText = useI18nMessage({ id: I18nMessages.FEEDBACK_UNANSWERED });
|
|
14
16
|
|
|
15
17
|
const returnQuestionFeedback = useReturnQuestionFeedback();
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { fireEvent } from "@testing-library/react-native";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
ReturnQuestionType,
|
|
6
|
-
} from "../../../../../../../projection/returnQuestion/returnQuestion";
|
|
3
|
+
import { ReturnQuestionProjection } from "../../../../../../../projection/returnQuestion/returnQuestion";
|
|
4
|
+
import { ReturnQuestionType } from "../../../../../../../projection/returnQuestion/returnQuestion.constants";
|
|
7
5
|
import { render } from "../../../../../test/render";
|
|
8
6
|
import { TextareaReturnQuestionItem } from "./TextareaReturnQuestionItem";
|
|
9
7
|
|
|
@@ -15,31 +13,13 @@ jest.mock("../../behaviors/useReturnQuestionFeedback", () => ({
|
|
|
15
13
|
const returnQuestionParent = {
|
|
16
14
|
id: "0ad1dba8-b02c-4121-a1e3-981f1c30800d",
|
|
17
15
|
} as ReturnQuestionProjection;
|
|
18
|
-
const returnQuestion: ReturnQuestionProjection = {
|
|
19
|
-
id: "
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
id: "68c0bb98-b00a-4b86-af43-528fe903cb69",
|
|
26
|
-
name: "size_overall",
|
|
27
|
-
placeholder: "",
|
|
28
|
-
type: ReturnQuestionType.OPTION,
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
id: "85e84a77-461c-41e6-8544-95b5294d0b80",
|
|
32
|
-
name: "size_trousers_too_long",
|
|
33
|
-
placeholder: "",
|
|
34
|
-
type: ReturnQuestionType.OPTION,
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
id: "29441d25-8d9f-471e-a13e-a03f61c88091",
|
|
38
|
-
name: "size_fit_cut_does_not_fit",
|
|
39
|
-
placeholder: "",
|
|
40
|
-
type: ReturnQuestionType.OPTION,
|
|
41
|
-
},
|
|
42
|
-
],
|
|
16
|
+
const returnQuestion: ReturnQuestionProjection<ReturnQuestionType.TEXTAREA> = {
|
|
17
|
+
id: "1123a37d-bc00-43a4-9d28-cee1dfaf356c",
|
|
18
|
+
translationKey: "comment_textarea",
|
|
19
|
+
type: ReturnQuestionType.TEXTAREA,
|
|
20
|
+
metadata: {
|
|
21
|
+
placeholder: "comment_textarea_placeholder",
|
|
22
|
+
},
|
|
43
23
|
};
|
|
44
24
|
|
|
45
25
|
describe("TextareaReturnQuestionItem component (ReturnQuestions organism)", () => {
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
1
2
|
import React, { useCallback, useMemo } from "react";
|
|
2
3
|
import { View } from "@lookiero/aurora";
|
|
3
4
|
import { useIntl } from "@lookiero/i18n-react";
|
|
5
|
+
import { ReturnQuestionType } from "../../../../../../../projection/returnQuestion/returnQuestion.constants";
|
|
4
6
|
import { InputField } from "../../../../../../../shared/ui/components/molecules/inputField/InputField";
|
|
5
7
|
import { useReturnQuestionFeedbackForReturnQuestion } from "../../behaviors/useReturnQuestionFeedback";
|
|
6
|
-
import { ReturnQuestionItem
|
|
8
|
+
import { ReturnQuestionItem } from "../ReturnQuestionItem";
|
|
7
9
|
import { style } from "./TextareaReturnQuestionItem.style";
|
|
8
10
|
|
|
9
|
-
const TextareaReturnQuestionItem: ReturnQuestionItem = ({
|
|
11
|
+
const TextareaReturnQuestionItem: ReturnQuestionItem<ReturnQuestionType.TEXTAREA> = ({
|
|
10
12
|
returnQuestion,
|
|
11
13
|
returnQuestionParent,
|
|
12
14
|
testID,
|
|
13
|
-
}
|
|
15
|
+
}) => {
|
|
14
16
|
const { formatMessage } = useIntl();
|
|
15
17
|
|
|
16
18
|
const placeholderText = useMemo(
|
|
17
|
-
() => (returnQuestion.placeholder ? formatMessage({ id: returnQuestion.placeholder }) : ""),
|
|
18
|
-
[formatMessage, returnQuestion.placeholder],
|
|
19
|
+
() => (returnQuestion.metadata.placeholder ? formatMessage({ id: returnQuestion.metadata.placeholder }) : ""),
|
|
20
|
+
[formatMessage, returnQuestion.metadata.placeholder],
|
|
19
21
|
);
|
|
20
22
|
|
|
21
23
|
const { feedback, onChange } = useReturnQuestionFeedbackForReturnQuestion({ returnQuestion: returnQuestionParent });
|
|
@@ -13,14 +13,15 @@ exports[`returnQuestionFeedback utils return the deepest returnQuestion with fee
|
|
|
13
13
|
"children": [
|
|
14
14
|
{
|
|
15
15
|
"id": "1123a37d-bc00-43a4-9d28-cee1dfaf356c",
|
|
16
|
-
"
|
|
17
|
-
|
|
16
|
+
"metadata": {
|
|
17
|
+
"placeholder": "comment_textarea_placeholder",
|
|
18
|
+
},
|
|
19
|
+
"translationKey": "comment_textarea",
|
|
18
20
|
"type": "TEXTAREA",
|
|
19
21
|
},
|
|
20
22
|
],
|
|
21
23
|
"id": "ce3e8d57-5eea-4dd3-bef4-2e811a143612",
|
|
22
|
-
"
|
|
23
|
-
"placeholder": "",
|
|
24
|
+
"translationKey": "comment_title",
|
|
24
25
|
"type": "HOST_TEXTAREA",
|
|
25
26
|
},
|
|
26
27
|
false,
|
package/src/infrastructure/ui/components/organisms/returnQuestions/util/returnQuestionFeedback.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { isUuid } from "@lookiero/sty-psp-uuid";
|
|
2
2
|
import { FeedbackProjection } from "../../../../../../projection/feedback/feedback";
|
|
3
3
|
import { ReturnQuestionProjection } from "../../../../../../projection/returnQuestion/returnQuestion";
|
|
4
|
+
import {
|
|
5
|
+
returnQuestionHasChildren,
|
|
6
|
+
returnQuestionWithTranslationKey,
|
|
7
|
+
} from "../../../../../../projection/returnQuestion/returnQuestion.typeguard";
|
|
4
8
|
|
|
5
9
|
interface RecursiveFeedbackForReturnQuestionFunctionArgs {
|
|
6
10
|
readonly feedback: FeedbackProjection;
|
|
@@ -25,14 +29,16 @@ const feedbackForReturnQuestion: RecursiveFeedbackForReturnQuestionFunction = ({
|
|
|
25
29
|
const returnQuestionFeedback = feedback[returnQuestionId];
|
|
26
30
|
|
|
27
31
|
if (isUuid(returnQuestionFeedback as string)) {
|
|
28
|
-
const feebackReturnQuestionChild =
|
|
29
|
-
(
|
|
30
|
-
|
|
32
|
+
const feebackReturnQuestionChild =
|
|
33
|
+
returnQuestionHasChildren(returnQuestion) &&
|
|
34
|
+
returnQuestion.children?.find((childReturnQuestion) => childReturnQuestion.id === returnQuestionFeedback);
|
|
31
35
|
|
|
32
36
|
if (feebackReturnQuestionChild) {
|
|
33
37
|
return [
|
|
34
38
|
...acc,
|
|
35
|
-
|
|
39
|
+
...(returnQuestionWithTranslationKey(feebackReturnQuestionChild)
|
|
40
|
+
? [translate(feebackReturnQuestionChild.translationKey)]
|
|
41
|
+
: []),
|
|
36
42
|
...feedbackForReturnQuestion({ feedback, returnQuestion: feebackReturnQuestionChild, translate, acc }),
|
|
37
43
|
];
|
|
38
44
|
}
|
|
@@ -44,13 +50,15 @@ const feedbackForReturnQuestion: RecursiveFeedbackForReturnQuestionFunction = ({
|
|
|
44
50
|
}
|
|
45
51
|
|
|
46
52
|
return (
|
|
47
|
-
returnQuestion
|
|
48
|
-
(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
(returnQuestionHasChildren(returnQuestion) &&
|
|
54
|
+
returnQuestion.children?.reduce(
|
|
55
|
+
(acc, childReturnQuestion) => [
|
|
56
|
+
...acc,
|
|
57
|
+
...feedbackForReturnQuestion({ feedback, returnQuestion: childReturnQuestion, translate, acc }),
|
|
58
|
+
],
|
|
59
|
+
[] as string[],
|
|
60
|
+
)) ||
|
|
61
|
+
[]
|
|
54
62
|
);
|
|
55
63
|
};
|
|
56
64
|
|
|
@@ -77,9 +85,9 @@ const deepestReturnQuestionWithFeedbackForReturnQuestion: RecursiveDeepestReturn
|
|
|
77
85
|
const returnQuestionFeedback = feedback[returnQuestionId];
|
|
78
86
|
|
|
79
87
|
if (isUuid(returnQuestionFeedback as string)) {
|
|
80
|
-
const feebackReturnQuestionChild =
|
|
81
|
-
(
|
|
82
|
-
|
|
88
|
+
const feebackReturnQuestionChild =
|
|
89
|
+
returnQuestionHasChildren(returnQuestion) &&
|
|
90
|
+
returnQuestion.children?.find((childReturnQuestion) => childReturnQuestion.id === returnQuestionFeedback);
|
|
83
91
|
|
|
84
92
|
if (feebackReturnQuestionChild) {
|
|
85
93
|
return deepestReturnQuestionWithFeedbackForReturnQuestion({
|
|
@@ -95,9 +103,11 @@ const deepestReturnQuestionWithFeedbackForReturnQuestion: RecursiveDeepestReturn
|
|
|
95
103
|
return [returnQuestion, false];
|
|
96
104
|
}
|
|
97
105
|
|
|
98
|
-
const feebackReturnQuestionChild =
|
|
99
|
-
|
|
100
|
-
|
|
106
|
+
const feebackReturnQuestionChild =
|
|
107
|
+
returnQuestionHasChildren(returnQuestion) &&
|
|
108
|
+
returnQuestion.children?.find((childReturnQuestion) =>
|
|
109
|
+
Object.keys(feedback).find((id) => id === childReturnQuestion.id),
|
|
110
|
+
);
|
|
101
111
|
|
|
102
112
|
if (feebackReturnQuestionChild) {
|
|
103
113
|
return deepestReturnQuestionWithFeedbackForReturnQuestion({
|
|
@@ -107,7 +117,11 @@ const deepestReturnQuestionWithFeedbackForReturnQuestion: RecursiveDeepestReturn
|
|
|
107
117
|
});
|
|
108
118
|
}
|
|
109
119
|
|
|
110
|
-
|
|
120
|
+
const hasChildren = Boolean(
|
|
121
|
+
returnQuestionHasChildren(returnQuestion) && returnQuestion.children && returnQuestion.children.length > 0,
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
return [deepestReturnQuestion, !hasChildren];
|
|
111
125
|
};
|
|
112
126
|
|
|
113
127
|
export { feedbackForReturnQuestion, deepestReturnQuestionWithFeedbackForReturnQuestion };
|