@lookiero/checkout 12.2.0 → 12.4.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/integration/checkout.spec.ts +14 -9
- package/cypress/support/interceptViewCheckoutFeedbackDefinitionByCheckoutId.ts +6 -0
- package/dist/src/ExpoRoot.js +2 -2
- package/dist/src/domain/checkoutItem/model/price.d.ts +1 -1
- package/dist/src/infrastructure/delivery/baseBootstrap.d.ts +2 -2
- package/dist/src/infrastructure/delivery/baseBootstrap.js +4 -4
- package/dist/src/infrastructure/delivery/bootstrap.js +2 -2
- package/dist/src/infrastructure/delivery/bootstrap.mock.js +3 -3
- package/dist/src/infrastructure/projection/checkoutFeedback/checkoutFeedbackDefinition.mock.d.ts +3 -0
- package/dist/src/infrastructure/projection/checkoutFeedback/checkoutFeedbackDefinition.mock.js +107 -0
- package/dist/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackDefinitionByCheckoutIdView.d.ts +12 -0
- package/dist/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackDefinitionByCheckoutIdView.js +10 -0
- package/dist/src/infrastructure/projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId.d.ts +10 -0
- package/dist/src/infrastructure/projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId.js +9 -0
- package/dist/src/infrastructure/projection/checkoutItem/checkoutItem.mock.js +1 -1
- package/dist/src/infrastructure/projection/pricing/pricing.mock.js +1 -1
- package/dist/src/infrastructure/tracking/tracking.d.ts +1 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestion.d.ts +2 -2
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestion.js +4 -2
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestions.d.ts +2 -2
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem.d.ts +5 -5
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem.js +1 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/CheckoutQuestionItem.d.ts +5 -4
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.js +2 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultCheckoutQuestionItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultCheckoutQuestionItem.js +2 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.js +2 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.d.ts +2 -3
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.js +5 -7
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.d.ts +2 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.js +2 -1
- package/dist/src/infrastructure/ui/views/feedback/Feedback.js +10 -9
- package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.d.ts +2 -3
- package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.js +17 -9
- package/dist/src/projection/checkoutFeedback/checkoutFeedback.constants.d.ts +11 -0
- package/dist/src/projection/checkoutFeedback/checkoutFeedback.constants.js +10 -0
- package/dist/src/projection/checkoutFeedback/checkoutFeedback.d.ts +22 -2
- package/dist/src/projection/checkoutFeedback/checkoutFeedback.metadata.d.ts +21 -0
- package/dist/src/projection/checkoutFeedback/checkoutFeedback.metadata.js +1 -0
- package/dist/src/projection/checkoutFeedback/checkoutFeedback.typeguards.d.ts +3 -0
- package/dist/src/projection/checkoutFeedback/checkoutFeedback.typeguards.js +7 -0
- package/dist/src/projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId.d.ts +25 -0
- package/dist/src/projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId.js +8 -0
- package/dist/src/projection/price/price.d.ts +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +5 -5
- package/src/ExpoRoot.tsx +2 -2
- package/src/domain/checkoutItem/model/price.ts +1 -1
- package/src/infrastructure/delivery/baseBootstrap.ts +9 -9
- package/src/infrastructure/delivery/bootstrap.mock.ts +5 -4
- package/src/infrastructure/delivery/bootstrap.ts +2 -2
- package/src/infrastructure/projection/checkoutFeedback/checkoutFeedbackDefinition.mock.ts +110 -0
- package/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackDefinitionByCheckoutIdView.test.ts +52 -0
- package/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackDefinitionByCheckoutIdView.ts +30 -0
- package/src/infrastructure/projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId.test.ts +58 -0
- package/src/infrastructure/projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId.ts +25 -0
- package/src/infrastructure/projection/checkoutItem/checkoutItem.mock.ts +1 -1
- package/src/infrastructure/projection/pricing/pricing.mock.ts +1 -1
- package/src/infrastructure/tracking/tracking.ts +1 -1
- package/src/infrastructure/tracking/useTrackCheckout.test.tsx +1 -2
- package/src/infrastructure/tracking/useTrackCheckout.ts +1 -2
- package/src/infrastructure/ui/components/atoms/price/Price.test.tsx +1 -1
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestion.test.tsx +25 -30
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestion.tsx +12 -13
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestions.test.tsx +19 -26
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestions.tsx +3 -3
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem.test.tsx +26 -26
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem.tsx +6 -6
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/CheckoutQuestionItem.ts +5 -4
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.test.tsx +7 -11
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.tsx +6 -4
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultCheckoutQuestionItem.tsx +6 -4
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultReturnQuestionItem.test.tsx +16 -10
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.test.tsx +16 -22
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.tsx +6 -4
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.test.tsx +16 -14
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.tsx +13 -14
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.test.tsx +9 -19
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.tsx +7 -5
- package/src/infrastructure/ui/views/feedback/Feedback.test.tsx +11 -5
- package/src/infrastructure/ui/views/feedback/Feedback.tsx +10 -9
- package/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.test.tsx +2 -2
- package/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.tsx +20 -13
- package/src/infrastructure/ui/views/item/components/productVariantDescription/ProductVariantDescription.test.tsx +1 -2
- package/src/infrastructure/ui/views/return/components/price/Price.test.tsx +1 -1
- package/src/infrastructure/ui/views/shared/components/productVariant/ProductVariant.test.tsx +1 -2
- package/src/projection/checkoutFeedback/checkoutFeedback.constants.ts +16 -0
- package/src/projection/checkoutFeedback/checkoutFeedback.metadata.ts +28 -0
- package/src/projection/checkoutFeedback/checkoutFeedback.ts +38 -2
- package/src/projection/checkoutFeedback/checkoutFeedback.typeguards.ts +13 -0
- package/src/projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId.test.ts +52 -0
- package/src/projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId.ts +61 -0
- package/src/projection/price/price.ts +1 -1
- package/cypress/support/interceptListCheckoutQuestionsByCheckoutId.ts +0 -9
- package/dist/src/domain/checkoutItem/model/currency.d.ts +0 -6
- package/dist/src/domain/checkoutItem/model/currency.js +0 -7
- package/dist/src/infrastructure/projection/checkoutQuestion/checkoutQuestions.mock.d.ts +0 -3
- package/dist/src/infrastructure/projection/checkoutQuestion/checkoutQuestions.mock.js +0 -103
- package/dist/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.d.ts +0 -12
- package/dist/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.js +0 -10
- package/dist/src/infrastructure/projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId.d.ts +0 -10
- package/dist/src/infrastructure/projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId.js +0 -9
- package/dist/src/projection/checkoutQuestion/checkoutQuestion.d.ts +0 -18
- package/dist/src/projection/checkoutQuestion/checkoutQuestion.js +0 -10
- package/dist/src/projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId.d.ts +0 -25
- package/dist/src/projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId.js +0 -8
- package/src/domain/checkoutItem/model/currency.ts +0 -7
- package/src/infrastructure/projection/checkoutQuestion/checkoutQuestions.mock.ts +0 -108
- package/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.test.ts +0 -55
- package/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.ts +0 -34
- package/src/infrastructure/projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId.test.ts +0 -38
- package/src/infrastructure/projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId.ts +0 -21
- package/src/projection/checkoutQuestion/checkoutQuestion.ts +0 -20
- package/src/projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId.test.ts +0 -31
- package/src/projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId.ts +0 -61
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Text } from "react-native";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
CheckoutQuestionType,
|
|
6
|
-
} from "../../../../../../../projection/checkoutQuestion/checkoutQuestion";
|
|
3
|
+
import { CheckoutFeedbackQuestionProjection } from "../../../../../../../projection/checkoutFeedback/checkoutFeedback";
|
|
4
|
+
import { CheckoutFeedbackQuestionType } from "../../../../../../../projection/checkoutFeedback/checkoutFeedback.constants";
|
|
7
5
|
import { render } from "../../../../../test/render";
|
|
8
6
|
import { HostDefaultCheckoutQuestionItem } from "./HostDefaultCheckoutQuestionItem";
|
|
9
7
|
|
|
10
8
|
const checkoutQuestionParentId = "0ad1dba8-b02c-4121-a1e3-981f1c30800d";
|
|
11
|
-
const checkoutQuestion:
|
|
9
|
+
const checkoutQuestion: CheckoutFeedbackQuestionProjection = {
|
|
12
10
|
id: "9251dc2c-d76a-484d-9299-346929af932f",
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
translationKey: "checkout.checkout_question.selection.question",
|
|
12
|
+
type: CheckoutFeedbackQuestionType.HOST_DEFAULT,
|
|
13
|
+
metadata: {
|
|
14
|
+
showCondition: [],
|
|
15
|
+
},
|
|
16
|
+
children: [
|
|
17
|
+
{
|
|
18
|
+
id: "0197594f-54f3-72bc-aadc-fb079811ad3b",
|
|
19
|
+
type: CheckoutFeedbackQuestionType.BUTTON,
|
|
20
|
+
translationKey: "checkout.checkout_question.personalshopper.yes",
|
|
21
|
+
},
|
|
22
|
+
],
|
|
17
23
|
};
|
|
18
24
|
|
|
19
25
|
describe("HostDefaultCheckoutQuestionItem component (CheckoutQuestions organism)", () => {
|
|
@@ -27,7 +33,7 @@ describe("HostDefaultCheckoutQuestionItem component (CheckoutQuestions organism)
|
|
|
27
33
|
</HostDefaultCheckoutQuestionItem>,
|
|
28
34
|
);
|
|
29
35
|
|
|
30
|
-
expect(getByText(checkoutQuestion.
|
|
36
|
+
expect(getByText(checkoutQuestion.translationKey)).toBeTruthy();
|
|
31
37
|
expect(getByText("HostDefaultCheckoutQuestionItem children")).toBeTruthy();
|
|
32
38
|
});
|
|
33
39
|
});
|
|
@@ -1,40 +1,34 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Text } from "react-native";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
CheckoutQuestionType,
|
|
6
|
-
} from "../../../../../../../projection/checkoutQuestion/checkoutQuestion";
|
|
3
|
+
import { CheckoutFeedbackQuestionProjection } from "../../../../../../../projection/checkoutFeedback/checkoutFeedback";
|
|
4
|
+
import { CheckoutFeedbackQuestionType } from "../../../../../../../projection/checkoutFeedback/checkoutFeedback.constants";
|
|
7
5
|
import { render } from "../../../../../test/render";
|
|
8
6
|
import { HostSelectCheckoutQuestionItem } from "./HostSelectCheckoutQuestionItem";
|
|
9
7
|
|
|
10
8
|
const checkoutQuestionParentId = "0ad1dba8-b02c-4121-a1e3-981f1c30800d";
|
|
11
|
-
const checkoutQuestion:
|
|
9
|
+
const checkoutQuestion: CheckoutFeedbackQuestionProjection = {
|
|
12
10
|
id: "efe07b97-f6fb-4b6a-ba92-b68519320b2c",
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
translationKey: "checkout.checkout_question.selection.question",
|
|
12
|
+
type: CheckoutFeedbackQuestionType.HOST_SELECT,
|
|
13
|
+
metadata: {
|
|
14
|
+
placeholder: "checkout.checkout_question.selection.question_placeholder",
|
|
15
|
+
showCondition: [],
|
|
16
|
+
},
|
|
17
17
|
children: [
|
|
18
18
|
{
|
|
19
19
|
id: "68c0bb98-b00a-4b86-af43-528fe903cb69",
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
type: CheckoutQuestionType.ICON,
|
|
23
|
-
showCondition: [],
|
|
20
|
+
translationKey: "checkout.checkout_question.icon.bad",
|
|
21
|
+
type: CheckoutFeedbackQuestionType.ICON,
|
|
24
22
|
},
|
|
25
23
|
{
|
|
26
24
|
id: "85e84a77-461c-41e6-8544-95b5294d0b80",
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
type: CheckoutQuestionType.ICON,
|
|
30
|
-
showCondition: [],
|
|
25
|
+
translationKey: "checkout.checkout_question.icon.regular",
|
|
26
|
+
type: CheckoutFeedbackQuestionType.ICON,
|
|
31
27
|
},
|
|
32
28
|
{
|
|
33
29
|
id: "29441d25-8d9f-471e-a13e-a03f61c88091",
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
type: CheckoutQuestionType.ICON,
|
|
37
|
-
showCondition: [],
|
|
30
|
+
translationKey: "checkout.checkout_question.icon.good",
|
|
31
|
+
type: CheckoutFeedbackQuestionType.ICON,
|
|
38
32
|
},
|
|
39
33
|
],
|
|
40
34
|
};
|
|
@@ -53,7 +47,7 @@ describe("HostSelectCheckoutQuestionItem component (CheckoutQuestions organism)"
|
|
|
53
47
|
it("renders correctly", async () => {
|
|
54
48
|
const { getByText } = renderHostSelectCheckoutQuestionItem();
|
|
55
49
|
|
|
56
|
-
expect(getByText(checkoutQuestion.
|
|
50
|
+
expect(getByText(checkoutQuestion.translationKey)).toBeTruthy();
|
|
57
51
|
expect(getByText("HostSelectCheckoutQuestionItem children")).toBeTruthy();
|
|
58
52
|
});
|
|
59
53
|
});
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
1
2
|
import React, { useMemo } from "react";
|
|
2
3
|
import { View } from "react-native";
|
|
3
4
|
import { Text } from "@lookiero/aurora";
|
|
4
5
|
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
6
|
+
import { CheckoutFeedbackQuestionType } from "../../../../../../../projection/checkoutFeedback/checkoutFeedback.constants";
|
|
5
7
|
import { DOMAIN } from "../../../../../i18n/i18n";
|
|
6
|
-
import { CheckoutQuestionItem
|
|
8
|
+
import { CheckoutQuestionItem } from "../CheckoutQuestionItem";
|
|
7
9
|
import { style as hostSelectCheckoutQuestionItemStyle } from "./HostSelectCheckoutQuestionItem.style";
|
|
8
10
|
|
|
9
|
-
const HostSelectCheckoutQuestionItem: CheckoutQuestionItem = ({
|
|
11
|
+
const HostSelectCheckoutQuestionItem: CheckoutQuestionItem<CheckoutFeedbackQuestionType.HOST_SELECT> = ({
|
|
10
12
|
checkoutQuestion,
|
|
11
13
|
children,
|
|
12
|
-
}
|
|
13
|
-
const titleText = useI18nMessage({ domain: DOMAIN, id: checkoutQuestion.
|
|
14
|
+
}) => {
|
|
15
|
+
const titleText = useI18nMessage({ domain: DOMAIN, id: checkoutQuestion.translationKey });
|
|
14
16
|
|
|
15
17
|
const style = useMemo(() => hostSelectCheckoutQuestionItemStyle(), []);
|
|
16
18
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { fireEvent } from "@testing-library/react-native";
|
|
2
2
|
import React from "react";
|
|
3
|
+
import { CheckoutFeedbackQuestionProjection } from "../../../../../../../projection/checkoutFeedback/checkoutFeedback";
|
|
3
4
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "../../../../../../../projection/
|
|
5
|
+
CheckoutFeedbackQuestionIcon,
|
|
6
|
+
CheckoutFeedbackQuestionType,
|
|
7
|
+
} from "../../../../../../../projection/checkoutFeedback/checkoutFeedback.constants";
|
|
7
8
|
import { render } from "../../../../../test/render";
|
|
8
|
-
import { IconCheckoutQuestionItem
|
|
9
|
+
import { IconCheckoutQuestionItem } from "./IconCheckoutQuestionItem";
|
|
9
10
|
|
|
10
11
|
const mockOnChange = jest.fn();
|
|
11
12
|
jest.mock("../../behaviors/useCheckoutQuestionFeedback", () => ({
|
|
@@ -13,26 +14,27 @@ jest.mock("../../behaviors/useCheckoutQuestionFeedback", () => ({
|
|
|
13
14
|
}));
|
|
14
15
|
|
|
15
16
|
const checkoutQuestionParentId = "0ad1dba8-b02c-4121-a1e3-981f1c30800d";
|
|
16
|
-
const checkoutQuestion:
|
|
17
|
+
const checkoutQuestion: CheckoutFeedbackQuestionProjection = {
|
|
17
18
|
id: "9251dc2c-d76a-484d-9299-346929af932f",
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
translationKey: "icon",
|
|
20
|
+
type: CheckoutFeedbackQuestionType.ICON,
|
|
21
|
+
metadata: {
|
|
22
|
+
icon: "checkout_feedback.icon.regular",
|
|
23
|
+
},
|
|
22
24
|
};
|
|
23
25
|
|
|
24
|
-
type Scenario = [
|
|
26
|
+
type Scenario = [CheckoutFeedbackQuestionIcon];
|
|
25
27
|
const scenarios: Scenario[] = [
|
|
26
|
-
["
|
|
27
|
-
["
|
|
28
|
-
["
|
|
28
|
+
["checkout_feedback.icon.bad"],
|
|
29
|
+
["checkout_feedback.icon.good"],
|
|
30
|
+
["checkout_feedback.icon.regular"],
|
|
29
31
|
];
|
|
30
32
|
|
|
31
33
|
describe("IconCheckoutQuestionItem component (CheckoutQuestions organism)", () => {
|
|
32
34
|
test.each(scenarios)("renders correctly %s icon", (iconName) => {
|
|
33
35
|
const { getByTestId } = render(
|
|
34
36
|
<IconCheckoutQuestionItem
|
|
35
|
-
checkoutQuestion={{ ...checkoutQuestion,
|
|
37
|
+
checkoutQuestion={{ ...checkoutQuestion, translationKey: iconName }}
|
|
36
38
|
checkoutQuestionParentId={checkoutQuestionParentId}
|
|
37
39
|
testID={iconName}
|
|
38
40
|
/>,
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
1
2
|
import React, { FC, useCallback, useMemo } from "react";
|
|
2
3
|
import { Pressable } from "react-native";
|
|
3
4
|
import { SvgProps } from "react-native-svg";
|
|
4
5
|
import invariant from "tiny-invariant";
|
|
6
|
+
import {
|
|
7
|
+
CheckoutFeedbackQuestionIcon,
|
|
8
|
+
CheckoutFeedbackQuestionType,
|
|
9
|
+
} from "../../../../../../../projection/checkoutFeedback/checkoutFeedback.constants";
|
|
5
10
|
import { useCheckoutQuestionFeedbackForId } from "../../behaviors/useCheckoutQuestionFeedback";
|
|
6
|
-
import { CheckoutQuestionItem
|
|
11
|
+
import { CheckoutQuestionItem } from "../CheckoutQuestionItem";
|
|
7
12
|
import { style as iconCheckoutQuestionItemStyle } from "./IconCheckoutQuestionItem.style";
|
|
8
13
|
import { Happy } from "./icons/Happy";
|
|
9
14
|
import { Normal } from "./icons/Normal";
|
|
10
15
|
import { Sad } from "./icons/Sad";
|
|
11
16
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"checkout_question.icon.bad": Sad,
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
18
|
-
"checkout_question.icon.regular": Normal,
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
20
|
-
"checkout_question.icon.good": Happy,
|
|
17
|
+
const ICON: Record<CheckoutFeedbackQuestionIcon, FC<SvgProps>> = {
|
|
18
|
+
["checkout_feedback.icon.bad"]: Sad,
|
|
19
|
+
["checkout_feedback.icon.regular"]: Normal,
|
|
20
|
+
["checkout_feedback.icon.good"]: Happy,
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
const IconCheckoutQuestionItem: CheckoutQuestionItem = ({
|
|
23
|
+
const IconCheckoutQuestionItem: CheckoutQuestionItem<CheckoutFeedbackQuestionType.ICON> = ({
|
|
24
24
|
checkoutQuestion,
|
|
25
25
|
checkoutQuestionParentId,
|
|
26
26
|
testID,
|
|
27
|
-
}
|
|
28
|
-
const Icon = ICON[checkoutQuestion.
|
|
27
|
+
}) => {
|
|
28
|
+
const Icon = ICON[checkoutQuestion.metadata.icon];
|
|
29
29
|
|
|
30
30
|
const style = useMemo(() => iconCheckoutQuestionItemStyle(), []);
|
|
31
31
|
|
|
@@ -51,5 +51,4 @@ const IconCheckoutQuestionItem: CheckoutQuestionItem = ({
|
|
|
51
51
|
);
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
export type { IconName };
|
|
55
54
|
export { IconCheckoutQuestionItem };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { fireEvent } from "@testing-library/react-native";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
CheckoutQuestionType,
|
|
6
|
-
} from "../../../../../../../projection/checkoutQuestion/checkoutQuestion";
|
|
3
|
+
import { CheckoutFeedbackQuestionProjection } from "../../../../../../../projection/checkoutFeedback/checkoutFeedback";
|
|
4
|
+
import { CheckoutFeedbackQuestionType } from "../../../../../../../projection/checkoutFeedback/checkoutFeedback.constants";
|
|
7
5
|
import { render } from "../../../../../test/render";
|
|
8
6
|
import { TextareaCheckoutQuestionItem } from "./TextareaCheckoutQuestionItem";
|
|
9
7
|
|
|
@@ -13,21 +11,13 @@ jest.mock("../../behaviors/useCheckoutQuestionFeedback", () => ({
|
|
|
13
11
|
}));
|
|
14
12
|
|
|
15
13
|
const checkoutQuestionParentId = "0ad1dba8-b02c-4121-a1e3-981f1c30800d";
|
|
16
|
-
const checkoutQuestion:
|
|
17
|
-
id: "
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
{
|
|
24
|
-
id: "1123a37d-bc00-43a4-9d28-cee1dfaf356c",
|
|
25
|
-
name: "comment_textarea",
|
|
26
|
-
placeholder: "comment_textarea_placeholder",
|
|
27
|
-
type: CheckoutQuestionType.TEXTAREA,
|
|
28
|
-
showCondition: [],
|
|
29
|
-
},
|
|
30
|
-
],
|
|
14
|
+
const checkoutQuestion: CheckoutFeedbackQuestionProjection = {
|
|
15
|
+
id: "1123a37d-bc00-43a4-9d28-cee1dfaf356c",
|
|
16
|
+
translationKey: "comment_textarea",
|
|
17
|
+
type: CheckoutFeedbackQuestionType.TEXTAREA,
|
|
18
|
+
metadata: {
|
|
19
|
+
placeholder: "comment_textarea_placeholder",
|
|
20
|
+
},
|
|
31
21
|
};
|
|
32
22
|
|
|
33
23
|
describe("TextareaCheckoutQuestionItem component (CheckoutQuestions organism)", () => {
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
1
2
|
import React, { useCallback, useMemo } from "react";
|
|
2
3
|
import { useI18n } from "@lookiero/i18n-react";
|
|
3
4
|
import { InputField, TextInput } from "@lookiero/sty-psp-ui";
|
|
5
|
+
import { CheckoutFeedbackQuestionType } from "../../../../../../../projection/checkoutFeedback/checkoutFeedback.constants";
|
|
4
6
|
import { DOMAIN } from "../../../../../i18n/i18n";
|
|
5
7
|
import { useCheckoutQuestionFeedbackForId } from "../../behaviors/useCheckoutQuestionFeedback";
|
|
6
|
-
import { CheckoutQuestionItem
|
|
8
|
+
import { CheckoutQuestionItem } from "../CheckoutQuestionItem";
|
|
7
9
|
import { style as textareaCheckoutQuestionItemStyle } from "./TextareaCheckoutQuestionItem.style";
|
|
8
10
|
|
|
9
|
-
const TextareaCheckoutQuestionItem: CheckoutQuestionItem = ({
|
|
11
|
+
const TextareaCheckoutQuestionItem: CheckoutQuestionItem<CheckoutFeedbackQuestionType.TEXTAREA> = ({
|
|
10
12
|
checkoutQuestion,
|
|
11
13
|
checkoutQuestionParentId,
|
|
12
14
|
testID,
|
|
13
|
-
}
|
|
15
|
+
}) => {
|
|
14
16
|
const { formatMessage } = useI18n({ domain: DOMAIN });
|
|
15
17
|
const placeholderText = useMemo(
|
|
16
|
-
() => (checkoutQuestion.placeholder ? formatMessage({ id: checkoutQuestion.placeholder }) : ""),
|
|
17
|
-
[formatMessage, checkoutQuestion.placeholder],
|
|
18
|
+
() => (checkoutQuestion.metadata.placeholder ? formatMessage({ id: checkoutQuestion.metadata.placeholder }) : ""),
|
|
19
|
+
[formatMessage, checkoutQuestion.metadata.placeholder],
|
|
18
20
|
);
|
|
19
21
|
|
|
20
22
|
const { feedback, onChange } = useCheckoutQuestionFeedbackForId({ id: checkoutQuestionParentId });
|
|
@@ -9,8 +9,8 @@ import { Customer } from "../../../../projection/customer/customer";
|
|
|
9
9
|
import { useGiveCheckoutFeedback } from "../../../domain/checkoutFeedback/react/useGiveCheckoutFeedback";
|
|
10
10
|
import { checkout } from "../../../projection/checkout/checkout.mock";
|
|
11
11
|
import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
12
|
+
import { checkoutFeedbackDefinition as checkoutFeedbackDefinitionMock } from "../../../projection/checkoutFeedback/checkoutFeedbackDefinition.mock";
|
|
13
|
+
import { useViewCheckoutFeedbackDefinitionByCheckoutId } from "../../../projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId";
|
|
14
14
|
import { I18nMessages } from "../../i18n/i18n";
|
|
15
15
|
import { render } from "../../test/render";
|
|
16
16
|
import { Feedback } from "./Feedback";
|
|
@@ -37,7 +37,7 @@ jest.mock("../../hooks/useStaticInfo", () => ({
|
|
|
37
37
|
}));
|
|
38
38
|
|
|
39
39
|
jest.mock("../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId");
|
|
40
|
-
jest.mock("../../../projection/
|
|
40
|
+
jest.mock("../../../projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId");
|
|
41
41
|
jest.mock("../../../domain/checkoutFeedback/react/useGiveCheckoutFeedback");
|
|
42
42
|
|
|
43
43
|
const mockTrackPressContinue = jest.fn();
|
|
@@ -69,7 +69,10 @@ afterAll(() => {
|
|
|
69
69
|
describe("Feedback view", () => {
|
|
70
70
|
test("renders correctly", async () => {
|
|
71
71
|
(useViewFirstAvailableCheckoutByCustomerId as jest.Mock).mockReturnValue([checkoutMock, QueryStatus.SUCCESS]);
|
|
72
|
-
(
|
|
72
|
+
(useViewCheckoutFeedbackDefinitionByCheckoutId as jest.Mock).mockReturnValue([
|
|
73
|
+
checkoutFeedbackDefinitionMock,
|
|
74
|
+
QueryStatus.SUCCESS,
|
|
75
|
+
]);
|
|
73
76
|
(useGiveCheckoutFeedback as jest.Mock).mockReturnValue([mockGiveCheckoutFeedback, CommandStatus.SUCCESS]);
|
|
74
77
|
|
|
75
78
|
const { findByText, getByTestId, getByText } = render(<Feedback layout={DummyLayout} />);
|
|
@@ -116,7 +119,10 @@ describe("Feedback view", () => {
|
|
|
116
119
|
|
|
117
120
|
test("calls giveCheckoutFeedback with an empty feedback when unmounted", async () => {
|
|
118
121
|
(useViewFirstAvailableCheckoutByCustomerId as jest.Mock).mockReturnValue([checkoutMock, QueryStatus.SUCCESS]);
|
|
119
|
-
(
|
|
122
|
+
(useViewCheckoutFeedbackDefinitionByCheckoutId as jest.Mock).mockReturnValue([
|
|
123
|
+
checkoutFeedbackDefinitionMock,
|
|
124
|
+
QueryStatus.SUCCESS,
|
|
125
|
+
]);
|
|
120
126
|
(useGiveCheckoutFeedback as jest.Mock).mockReturnValue([mockGiveCheckoutFeedback, CommandStatus.SUCCESS]);
|
|
121
127
|
|
|
122
128
|
const { unmount } = render(<Feedback layout={DummyLayout} />);
|
|
@@ -4,10 +4,10 @@ import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
|
|
|
4
4
|
import { useLogger } from "@lookiero/sty-psp-logging";
|
|
5
5
|
import { Layout as UiLayout, useScreenSize } from "@lookiero/sty-psp-ui";
|
|
6
6
|
import { CheckoutFeedbackProjection } from "../../../../projection/checkoutFeedback/checkoutFeedback";
|
|
7
|
-
import {
|
|
7
|
+
import { CheckoutFeedbackQuestionType } from "../../../../projection/checkoutFeedback/checkoutFeedback.constants";
|
|
8
8
|
import { useGiveCheckoutFeedback } from "../../../domain/checkoutFeedback/react/useGiveCheckoutFeedback";
|
|
9
9
|
import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
|
|
10
|
-
import {
|
|
10
|
+
import { useViewCheckoutFeedbackDefinitionByCheckoutId } from "../../../projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId";
|
|
11
11
|
import { TrackingPage } from "../../../tracking/tracking";
|
|
12
12
|
import { useTrackChangeFeedback } from "../../../tracking/useTrackChangeFeedback";
|
|
13
13
|
import { useTrackPageView } from "../../../tracking/useTrackPageView";
|
|
@@ -43,7 +43,7 @@ const Feedback: FC<FeedbackProps> = ({ layout: Layout }) => {
|
|
|
43
43
|
const style = useMemo(() => feedbackStyle(), []);
|
|
44
44
|
|
|
45
45
|
const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
|
|
46
|
-
const [
|
|
46
|
+
const [checkoutFeedbackDefinition, checkoutFeedbackDefinitionStatus] = useViewCheckoutFeedbackDefinitionByCheckoutId({
|
|
47
47
|
checkoutId: checkout?.id as string,
|
|
48
48
|
});
|
|
49
49
|
|
|
@@ -64,19 +64,19 @@ const Feedback: FC<FeedbackProps> = ({ layout: Layout }) => {
|
|
|
64
64
|
});
|
|
65
65
|
const handleOnChangedFeedback: HandleOnChangedFeedbackFunction = useCallback(
|
|
66
66
|
({ checkoutQuestionId, checkoutQuestionFeedback, hasFeedback }) => {
|
|
67
|
-
const question =
|
|
67
|
+
const question = checkoutFeedbackDefinition?.find((question) => question.id === checkoutQuestionId);
|
|
68
68
|
|
|
69
|
-
if (question?.type ===
|
|
69
|
+
if (question?.type === CheckoutFeedbackQuestionType.HOST_TEXTAREA && hasFeedback) {
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
trackChangeFeedback({
|
|
74
74
|
questionId: checkoutQuestionId,
|
|
75
|
-
questionName: question?.
|
|
75
|
+
questionName: question?.translationKey || "",
|
|
76
76
|
feedback: checkoutQuestionFeedback,
|
|
77
77
|
});
|
|
78
78
|
},
|
|
79
|
-
[
|
|
79
|
+
[checkoutFeedbackDefinition, trackChangeFeedback],
|
|
80
80
|
);
|
|
81
81
|
|
|
82
82
|
const [giveCheckoutFeedback, giveCheckoutFeedbackStatus] = useGiveCheckoutFeedback({
|
|
@@ -117,7 +117,8 @@ const Feedback: FC<FeedbackProps> = ({ layout: Layout }) => {
|
|
|
117
117
|
|
|
118
118
|
const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
|
|
119
119
|
const dependenciesLoaded =
|
|
120
|
-
dependenciesLoadedStatuses.includes(checkoutStatus) &&
|
|
120
|
+
dependenciesLoadedStatuses.includes(checkoutStatus) &&
|
|
121
|
+
dependenciesLoadedStatuses.includes(checkoutFeedbackDefinitionStatus);
|
|
121
122
|
|
|
122
123
|
if (!dependenciesLoaded) return <Spinner />;
|
|
123
124
|
|
|
@@ -126,7 +127,7 @@ const Feedback: FC<FeedbackProps> = ({ layout: Layout }) => {
|
|
|
126
127
|
<Layout>
|
|
127
128
|
<Body style={{ row: [style.container, isDesktop && style.containerDesktop] }}>
|
|
128
129
|
<CheckoutQuestionsForm
|
|
129
|
-
checkoutQuestions={
|
|
130
|
+
checkoutQuestions={checkoutFeedbackDefinition || []}
|
|
130
131
|
submitButtonDisabled={giveCheckoutFeedbackStatus === CommandStatus.LOADING}
|
|
131
132
|
onSubmit={handleOnSubmit}
|
|
132
133
|
/>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fireEvent } from "@testing-library/react-native";
|
|
2
2
|
import React, { ReactNode } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { checkoutFeedbackDefinition } from "../../../../../projection/checkoutFeedback/checkoutFeedbackDefinition.mock";
|
|
4
4
|
import { CheckoutQuestionFeedbackProvider } from "../../../../components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionFeedback";
|
|
5
5
|
import { I18nMessages } from "../../../../i18n/i18n";
|
|
6
6
|
import { render } from "../../../../test/render";
|
|
@@ -16,7 +16,7 @@ describe("CheckoutQuestionsForm component)", () => {
|
|
|
16
16
|
test("renders correctly", async () => {
|
|
17
17
|
const { getByText, getByTestId, queryByText } = render(
|
|
18
18
|
<CheckoutQuestionsForm
|
|
19
|
-
checkoutQuestions={
|
|
19
|
+
checkoutQuestions={checkoutFeedbackDefinition}
|
|
20
20
|
submitButtonDisabled={false}
|
|
21
21
|
onSubmit={mockOnSubmit}
|
|
22
22
|
/>,
|
|
@@ -2,11 +2,11 @@ import React, { FC, useCallback, useMemo } from "react";
|
|
|
2
2
|
import { View } from "react-native";
|
|
3
3
|
import { Button } from "@lookiero/aurora";
|
|
4
4
|
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
5
|
-
import { CheckoutFeedbackProjection } from "../../../../../../projection/checkoutFeedback/checkoutFeedback";
|
|
6
5
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} from "../../../../../../projection/
|
|
6
|
+
CheckoutFeedbackProjection,
|
|
7
|
+
CheckoutFeedbackQuestionProjection,
|
|
8
|
+
} from "../../../../../../projection/checkoutFeedback/checkoutFeedback";
|
|
9
|
+
import { CheckoutFeedbackQuestionType } from "../../../../../../projection/checkoutFeedback/checkoutFeedback.constants";
|
|
10
10
|
import { CheckoutQuestions } from "../../../../components/organisms/checkoutQuestions/CheckoutQuestions";
|
|
11
11
|
import { useCheckoutQuestionFeedback } from "../../../../components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionFeedback";
|
|
12
12
|
import {
|
|
@@ -21,16 +21,16 @@ import { TextareaCheckoutQuestionItem } from "../../../../components/organisms/c
|
|
|
21
21
|
import { DOMAIN, I18nMessages } from "../../../../i18n/i18n";
|
|
22
22
|
|
|
23
23
|
const checkoutQuestionItems: CheckoutQuestionItems = {
|
|
24
|
-
[
|
|
25
|
-
[
|
|
26
|
-
[
|
|
27
|
-
[
|
|
28
|
-
[
|
|
29
|
-
[
|
|
24
|
+
[CheckoutFeedbackQuestionType.HOST_DEFAULT]: HostDefaultCheckoutQuestionItem,
|
|
25
|
+
[CheckoutFeedbackQuestionType.HOST_TEXTAREA]: HostDefaultCheckoutQuestionItem,
|
|
26
|
+
[CheckoutFeedbackQuestionType.HOST_SELECT]: HostSelectCheckoutQuestionItem,
|
|
27
|
+
[CheckoutFeedbackQuestionType.TEXTAREA]: TextareaCheckoutQuestionItem,
|
|
28
|
+
[CheckoutFeedbackQuestionType.ICON]: IconCheckoutQuestionItem,
|
|
29
|
+
[CheckoutFeedbackQuestionType.BUTTON]: ButtonCheckoutQuestionItem,
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
interface CheckoutQuestionsFormProps {
|
|
33
|
-
readonly checkoutQuestions:
|
|
33
|
+
readonly checkoutQuestions: CheckoutFeedbackQuestionProjection[];
|
|
34
34
|
readonly submitButtonDisabled: boolean;
|
|
35
35
|
readonly onSubmit: (feedback: CheckoutFeedbackProjection) => void;
|
|
36
36
|
}
|
|
@@ -49,8 +49,15 @@ const CheckoutQuestionsForm: FC<CheckoutQuestionsFormProps> = ({
|
|
|
49
49
|
|
|
50
50
|
return checkoutQuestions.filter(
|
|
51
51
|
(checkoutQuestion) =>
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
!checkoutQuestion?.metadata?.showCondition ||
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
56
|
+
// @ts-ignore
|
|
57
|
+
checkoutQuestion?.metadata?.showCondition.length === 0 ||
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
59
|
+
// @ts-ignore
|
|
60
|
+
checkoutQuestion?.metadata?.showCondition.some((condition) => responses.includes(condition)),
|
|
54
61
|
);
|
|
55
62
|
}, [checkoutQuestions, feedback]);
|
|
56
63
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Country } from "@lookiero/sty-psp-locale";
|
|
3
|
-
import { Currency } from "../../../../../../domain/checkoutItem/model/currency";
|
|
2
|
+
import { Country, Currency } from "@lookiero/sty-psp-locale";
|
|
4
3
|
import { I18nMessages } from "../../../../i18n/i18n";
|
|
5
4
|
import { render } from "../../../../test/render";
|
|
6
5
|
import { ProductVariantDescription } from "./ProductVariantDescription";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Currency } from "
|
|
2
|
+
import { Currency } from "@lookiero/sty-psp-locale";
|
|
3
3
|
import { PriceProjection } from "../../../../../../projection/price/price";
|
|
4
4
|
import { render } from "../../../../test/render";
|
|
5
5
|
import { Price } from "./Price";
|
package/src/infrastructure/ui/views/shared/components/productVariant/ProductVariant.test.tsx
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { fireEvent } from "@testing-library/react-native";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { Country } from "@lookiero/sty-psp-locale";
|
|
3
|
+
import { Country, Currency } from "@lookiero/sty-psp-locale";
|
|
4
4
|
import { CheckoutItemStatus } from "../../../../../../domain/checkoutItem/model/checkoutItem";
|
|
5
|
-
import { Currency } from "../../../../../../domain/checkoutItem/model/currency";
|
|
6
5
|
import { ColorProjection, MediaPerspective } from "../../../../../../projection/checkoutItem/checkoutItem";
|
|
7
6
|
import { COLOR_I18N_PREFIX, I18nMessages } from "../../../../i18n/i18n";
|
|
8
7
|
import { render } from "../../../../test/render";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
enum CheckoutFeedbackQuestionType {
|
|
2
|
+
HOST_DEFAULT = "HOST_DEFAULT",
|
|
3
|
+
HOST_TEXTAREA = "HOST_TEXTAREA",
|
|
4
|
+
HOST_SELECT = "HOST_SELECT",
|
|
5
|
+
TEXTAREA = "TEXTAREA",
|
|
6
|
+
ICON = "ICON",
|
|
7
|
+
BUTTON = "BUTTON",
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type CheckoutFeedbackQuestionIcon =
|
|
11
|
+
| "checkout_feedback.icon.bad"
|
|
12
|
+
| "checkout_feedback.icon.regular"
|
|
13
|
+
| "checkout_feedback.icon.good";
|
|
14
|
+
|
|
15
|
+
export type { CheckoutFeedbackQuestionIcon };
|
|
16
|
+
export { CheckoutFeedbackQuestionType };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { EmptyObject } from "@lookiero/sty-psp-typescript";
|
|
2
|
+
import { CheckoutFeedbackQuestionIcon, CheckoutFeedbackQuestionType } from "./checkoutFeedback.constants";
|
|
3
|
+
|
|
4
|
+
type MetadataDictionary = Record<CheckoutFeedbackQuestionType, EmptyObject>;
|
|
5
|
+
|
|
6
|
+
interface ComponentWithPlaceholder {
|
|
7
|
+
readonly placeholder: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface ComponentCondition {
|
|
11
|
+
readonly showCondition: string[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface ComponentIcon {
|
|
15
|
+
readonly icon: CheckoutFeedbackQuestionIcon;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type ComponentMetadata = MetadataDictionary & {
|
|
19
|
+
[CheckoutFeedbackQuestionType.HOST_DEFAULT]: ComponentCondition;
|
|
20
|
+
[CheckoutFeedbackQuestionType.HOST_TEXTAREA]: ComponentCondition;
|
|
21
|
+
[CheckoutFeedbackQuestionType.HOST_SELECT]: ComponentCondition & ComponentWithPlaceholder;
|
|
22
|
+
[CheckoutFeedbackQuestionType.TEXTAREA]: ComponentWithPlaceholder;
|
|
23
|
+
[CheckoutFeedbackQuestionType.ICON]: ComponentIcon;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
type Metadata<CFDT extends CheckoutFeedbackQuestionType> = ComponentMetadata[CFDT];
|
|
27
|
+
|
|
28
|
+
export type { Metadata, ComponentCondition };
|
|
@@ -1,5 +1,41 @@
|
|
|
1
|
+
import { EmptyObject, ExcludePropertyIfOptional, NonEmptyArray } from "@lookiero/sty-psp-typescript";
|
|
1
2
|
import { FeedbackProjection } from "../feedback/feedback";
|
|
3
|
+
import { CheckoutFeedbackQuestionType } from "./checkoutFeedback.constants";
|
|
4
|
+
import { Metadata } from "./checkoutFeedback.metadata";
|
|
2
5
|
|
|
3
|
-
type
|
|
6
|
+
type CheckoutFeedback = FeedbackProjection;
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
type CheckoutFeedbackQuestionTypesWithChildren =
|
|
9
|
+
| CheckoutFeedbackQuestionType.HOST_DEFAULT
|
|
10
|
+
| CheckoutFeedbackQuestionType.HOST_TEXTAREA
|
|
11
|
+
| CheckoutFeedbackQuestionType.HOST_SELECT;
|
|
12
|
+
|
|
13
|
+
type CheckoutFeedbackQuestionTypesWithOptionalTranslationKeys = CheckoutFeedbackQuestionType.ICON;
|
|
14
|
+
|
|
15
|
+
type CheckoutFeedbackQuestionMetadata<CFDT extends CheckoutFeedbackQuestionType> = ExcludePropertyIfOptional<
|
|
16
|
+
"metadata",
|
|
17
|
+
{ readonly metadata: Metadata<CFDT> }
|
|
18
|
+
>;
|
|
19
|
+
|
|
20
|
+
type CheckoutFeedbackQuestionTypeChildren<QT extends CheckoutFeedbackQuestionType> =
|
|
21
|
+
QT extends CheckoutFeedbackQuestionTypesWithChildren
|
|
22
|
+
? { readonly children: NonEmptyArray<CheckoutFeedbackQuestion> }
|
|
23
|
+
: EmptyObject;
|
|
24
|
+
|
|
25
|
+
type CheckoutFeedbackQuestionTypeTranslationKey<QT extends CheckoutFeedbackQuestionType> =
|
|
26
|
+
QT extends CheckoutFeedbackQuestionTypesWithOptionalTranslationKeys
|
|
27
|
+
? { readonly translationKey?: string }
|
|
28
|
+
: { readonly translationKey: string };
|
|
29
|
+
|
|
30
|
+
type CheckoutFeedbackQuestion<CFDT extends CheckoutFeedbackQuestionType = CheckoutFeedbackQuestionType> =
|
|
31
|
+
CFDT extends infer K extends CheckoutFeedbackQuestionType
|
|
32
|
+
? { readonly id: string; readonly type: K } & CheckoutFeedbackQuestionTypeTranslationKey<K> &
|
|
33
|
+
CheckoutFeedbackQuestionTypeChildren<K> &
|
|
34
|
+
CheckoutFeedbackQuestionMetadata<K>
|
|
35
|
+
: never;
|
|
36
|
+
|
|
37
|
+
export type {
|
|
38
|
+
CheckoutFeedback as CheckoutFeedbackProjection,
|
|
39
|
+
CheckoutFeedbackQuestion as CheckoutFeedbackQuestionProjection,
|
|
40
|
+
CheckoutFeedbackQuestionTypesWithChildren,
|
|
41
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CheckoutFeedbackQuestionProjection, CheckoutFeedbackQuestionTypesWithChildren } from "./checkoutFeedback";
|
|
2
|
+
import { CheckoutFeedbackQuestionType } from "./checkoutFeedback.constants";
|
|
3
|
+
|
|
4
|
+
const checkoutFeedbackQuestionHasChildren = (
|
|
5
|
+
question: CheckoutFeedbackQuestionProjection,
|
|
6
|
+
): question is CheckoutFeedbackQuestionProjection<CheckoutFeedbackQuestionTypesWithChildren> =>
|
|
7
|
+
[
|
|
8
|
+
CheckoutFeedbackQuestionType.HOST_DEFAULT,
|
|
9
|
+
CheckoutFeedbackQuestionType.HOST_SELECT,
|
|
10
|
+
CheckoutFeedbackQuestionType.HOST_TEXTAREA,
|
|
11
|
+
].includes(question.type);
|
|
12
|
+
|
|
13
|
+
export { checkoutFeedbackQuestionHasChildren };
|