@lookiero/checkout 12.3.0 → 12.5.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/public/public/assets/adaptive-icon.png +0 -0
- package/dist/public/public/assets/favicon.png +0 -0
- package/dist/public/public/assets/icon.png +0 -0
- package/dist/public/public/assets/splash.png +0 -0
- package/dist/public/public/images/not-found.png +0 -0
- package/dist/src/ExpoRoot.js +2 -2
- package/dist/src/domain/checkoutItem/model/currency.d.ts +6 -0
- package/dist/src/domain/checkoutItem/model/currency.js +7 -0
- package/dist/src/domain/uiSetting/command/updateUiSetting.d.ts +15 -0
- package/dist/src/domain/uiSetting/command/updateUiSetting.js +10 -0
- package/dist/src/domain/uiSetting/model/uiSetting.d.ts +9 -0
- package/dist/src/domain/uiSetting/model/uiSetting.js +11 -0
- package/dist/src/domain/uiSetting/model/uiSettingUpdated.d.ts +15 -0
- package/dist/src/domain/uiSetting/model/uiSettingUpdated.js +8 -0
- package/dist/src/domain/uiSetting/model/uiSettings.d.ts +7 -0
- package/dist/src/domain/uiSetting/model/uiSettings.js +1 -0
- 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/domain/uiSetting/model/storageUiSettings.d.ts +17 -0
- package/dist/src/infrastructure/domain/uiSetting/model/storageUiSettings.js +20 -0
- package/dist/src/infrastructure/domain/uiSetting/react/useUpdateUiSetting.d.ts +18 -0
- package/dist/src/infrastructure/domain/uiSetting/react/useUpdateUiSetting.js +22 -0
- package/dist/src/infrastructure/integration/useRedirect.d.ts +7 -0
- package/dist/src/infrastructure/integration/useRedirect.js +1 -0
- package/dist/src/infrastructure/persistence/asyncStorageStorage.d.ts +5 -0
- package/dist/src/infrastructure/persistence/asyncStorageStorage.js +7 -0
- package/dist/src/infrastructure/persistence/uiSettingData.d.ts +6 -0
- package/dist/src/infrastructure/persistence/uiSettingData.js +1 -0
- 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/returnQuestion/returnQuestions.mock.js +47 -58
- package/dist/src/infrastructure/projection/uiSetting/react/useViewUiSettingByKey.d.ts +10 -0
- package/dist/src/infrastructure/projection/uiSetting/react/useViewUiSettingByKey.js +11 -0
- package/dist/src/infrastructure/projection/uiSetting/storageUiSettingByKeyView.d.ts +13 -0
- package/dist/src/infrastructure/projection/uiSetting/storageUiSettingByKeyView.js +15 -0
- 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/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.js +1 -2
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostLegacyRadioGroupReturnQuestionItem/HostLegacyRadioGroupReturnQuestionItem.d.ts +4 -0
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostLegacyRadioGroupReturnQuestionItem/HostLegacyRadioGroupReturnQuestionItem.js +17 -0
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostLegacyRadioGroupReturnQuestionItem/HostLegacyRadioGroupReturnQuestionItem.style.d.ts +11 -0
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostLegacyRadioGroupReturnQuestionItem/HostLegacyRadioGroupReturnQuestionItem.style.js +16 -0
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.d.ts +1 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.js +3 -5
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem.js +2 -3
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/util/returnQuestionFeedback.js +2 -4
- package/dist/src/infrastructure/ui/hooks/useSubmitCheckout.d.ts +27 -0
- package/dist/src/infrastructure/ui/hooks/useSubmitCheckout.js +97 -0
- package/dist/src/infrastructure/ui/routing/useBasePath.d.ts +8 -0
- package/dist/src/infrastructure/ui/routing/useBasePath.js +9 -0
- package/dist/src/infrastructure/ui/settings/UISettings.d.ts +3 -0
- package/dist/src/infrastructure/ui/settings/UISettings.js +4 -0
- package/dist/src/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.d.ts +12 -0
- package/dist/src/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.js +90 -0
- 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/infrastructure/ui/views/item/components/returnQuestionsFeedback/ReturnQuestionsFeedback.js +1 -0
- package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.js +3 -1
- 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/returnQuestion/returnQuestion.constants.d.ts +1 -0
- package/dist/src/projection/returnQuestion/returnQuestion.constants.js +1 -0
- package/dist/src/projection/returnQuestion/returnQuestion.d.ts +2 -2
- package/dist/src/projection/returnQuestion/returnQuestion.typeguard.d.ts +2 -4
- package/dist/src/projection/returnQuestion/returnQuestion.typeguard.js +2 -2
- package/dist/src/projection/uiSetting/viewUiSettingByKey.d.ts +29 -0
- package/dist/src/projection/uiSetting/viewUiSettingByKey.js +8 -0
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
- package/src/ExpoRoot.tsx +2 -2
- 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/returnQuestion/returnQuestions.mock.ts +47 -58
- 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/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.tsx +1 -2
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostLegacyRadioGroupReturnQuestionItem/HostLegacyRadioGroupReturnQuestionItem.style.ts +19 -0
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostLegacyRadioGroupReturnQuestionItem/HostLegacyRadioGroupReturnQuestionItem.tsx +36 -0
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.test.tsx +46 -0
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.tsx +7 -12
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem.tsx +6 -5
- package/src/infrastructure/ui/components/organisms/returnQuestions/util/__snapshots__/returnQuestionFeedback.test.ts.snap +22 -2
- package/src/infrastructure/ui/components/organisms/returnQuestions/util/returnQuestionFeedback.ts +2 -7
- 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/returnQuestionsFeedback/ReturnQuestionsFeedback.tsx +1 -0
- package/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.tsx +3 -1
- 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/returnQuestion/returnQuestion.constants.ts +1 -0
- package/src/projection/returnQuestion/returnQuestion.ts +6 -2
- package/src/projection/returnQuestion/returnQuestion.typeguard.ts +3 -11
- package/cypress/support/interceptListCheckoutQuestionsByCheckoutId.ts +0 -9
- 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,16 +1,14 @@
|
|
|
1
1
|
import React, { FC, memo } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { CheckoutFeedbackQuestionProjection } from "../../../../../projection/checkoutFeedback/checkoutFeedback";
|
|
3
|
+
import { checkoutFeedbackQuestionHasChildren } from "../../../../../projection/checkoutFeedback/checkoutFeedback.typeguards";
|
|
3
4
|
import { useCheckoutQuestionItem } from "./behaviors/useCheckoutQuestionItem";
|
|
4
5
|
|
|
5
6
|
interface CheckoutQuestionProps {
|
|
6
7
|
readonly checkoutQuestionParentId: string;
|
|
7
|
-
readonly checkoutQuestion:
|
|
8
|
+
readonly checkoutQuestion: CheckoutFeedbackQuestionProjection;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
const CheckoutQuestion: FC<CheckoutQuestionProps> = ({
|
|
11
|
-
checkoutQuestion,
|
|
12
|
-
checkoutQuestionParentId,
|
|
13
|
-
}: CheckoutQuestionProps) => {
|
|
11
|
+
const CheckoutQuestion: FC<CheckoutQuestionProps> = ({ checkoutQuestion, checkoutQuestionParentId }) => {
|
|
14
12
|
const Item = useCheckoutQuestionItem({ type: checkoutQuestion.type });
|
|
15
13
|
|
|
16
14
|
return (
|
|
@@ -19,13 +17,14 @@ const CheckoutQuestion: FC<CheckoutQuestionProps> = ({
|
|
|
19
17
|
checkoutQuestionParentId={checkoutQuestionParentId}
|
|
20
18
|
testID={checkoutQuestion.id}
|
|
21
19
|
>
|
|
22
|
-
{checkoutQuestion
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
{checkoutFeedbackQuestionHasChildren(checkoutQuestion) &&
|
|
21
|
+
checkoutQuestion.children.map((childCheckoutQuestion) => (
|
|
22
|
+
<CheckoutQuestion
|
|
23
|
+
key={childCheckoutQuestion.id}
|
|
24
|
+
checkoutQuestion={childCheckoutQuestion}
|
|
25
|
+
checkoutQuestionParentId={checkoutQuestion.id}
|
|
26
|
+
/>
|
|
27
|
+
))}
|
|
29
28
|
</Item>
|
|
30
29
|
);
|
|
31
30
|
};
|
package/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestions.test.tsx
CHANGED
|
@@ -1,50 +1,43 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
1
2
|
import { render } from "@testing-library/react-native";
|
|
2
3
|
import React, { ReactNode } from "react";
|
|
3
4
|
import { Text } from "react-native";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
CheckoutQuestionType,
|
|
7
|
-
} from "../../../../../projection/checkoutQuestion/checkoutQuestion";
|
|
5
|
+
import { CheckoutFeedbackQuestionProjection } from "../../../../../projection/checkoutFeedback/checkoutFeedback";
|
|
6
|
+
import { CheckoutFeedbackQuestionType } from "../../../../../projection/checkoutFeedback/checkoutFeedback.constants";
|
|
8
7
|
import { CheckoutQuestions } from "./CheckoutQuestions";
|
|
9
8
|
import { CheckoutQuestionFeedbackProvider } from "./behaviors/useCheckoutQuestionFeedback";
|
|
10
9
|
import { CheckoutQuestionItemProvider, CheckoutQuestionItems } from "./behaviors/useCheckoutQuestionItem";
|
|
11
|
-
import { CheckoutQuestionItem
|
|
10
|
+
import { CheckoutQuestionItem } from "./components/CheckoutQuestionItem";
|
|
12
11
|
|
|
13
|
-
const checkoutQuestions:
|
|
12
|
+
const checkoutQuestions: CheckoutFeedbackQuestionProjection[] = [
|
|
14
13
|
{
|
|
15
14
|
id: "68c0bb98-b00a-4b86-af43-528fe903cb69",
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
type: CheckoutQuestionType.ICON,
|
|
19
|
-
showCondition: [],
|
|
15
|
+
translationKey: "checkout.checkout_question.icon.bad",
|
|
16
|
+
type: CheckoutFeedbackQuestionType.ICON,
|
|
20
17
|
},
|
|
21
18
|
{
|
|
22
19
|
id: "85e84a77-461c-41e6-8544-95b5294d0b80",
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
type: CheckoutQuestionType.ICON,
|
|
26
|
-
showCondition: [],
|
|
20
|
+
translationKey: "checkout.checkout_question.icon.regular",
|
|
21
|
+
type: CheckoutFeedbackQuestionType.ICON,
|
|
27
22
|
},
|
|
28
23
|
{
|
|
29
24
|
id: "29441d25-8d9f-471e-a13e-a03f61c88091",
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
type: CheckoutQuestionType.ICON,
|
|
33
|
-
showCondition: [],
|
|
25
|
+
translationKey: "checkout.checkout_question.icon.good",
|
|
26
|
+
type: CheckoutFeedbackQuestionType.ICON,
|
|
34
27
|
},
|
|
35
28
|
];
|
|
36
29
|
|
|
37
|
-
const Item: CheckoutQuestionItem = ({ checkoutQuestion }
|
|
38
|
-
<Text>{checkoutQuestion.
|
|
30
|
+
const Item: CheckoutQuestionItem<CheckoutFeedbackQuestionType> = ({ checkoutQuestion }) => (
|
|
31
|
+
<Text>{checkoutQuestion.translationKey}</Text>
|
|
39
32
|
);
|
|
40
33
|
|
|
41
34
|
const checkoutQuestionItems: CheckoutQuestionItems = {
|
|
42
|
-
[
|
|
43
|
-
[
|
|
44
|
-
[
|
|
45
|
-
[
|
|
46
|
-
[
|
|
47
|
-
[
|
|
35
|
+
[CheckoutFeedbackQuestionType.HOST_DEFAULT]: Item,
|
|
36
|
+
[CheckoutFeedbackQuestionType.HOST_TEXTAREA]: Item,
|
|
37
|
+
[CheckoutFeedbackQuestionType.HOST_SELECT]: Item,
|
|
38
|
+
[CheckoutFeedbackQuestionType.TEXTAREA]: Item,
|
|
39
|
+
[CheckoutFeedbackQuestionType.BUTTON]: Item,
|
|
40
|
+
[CheckoutFeedbackQuestionType.ICON]: Item,
|
|
48
41
|
};
|
|
49
42
|
|
|
50
43
|
const Wrapper = ({ children }: { children: ReactNode }) => (
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React, { FC } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { CheckoutFeedbackQuestionProjection } from "../../../../../projection/checkoutFeedback/checkoutFeedback";
|
|
3
3
|
import CheckoutQuestion from "./CheckoutQuestion";
|
|
4
4
|
|
|
5
5
|
interface CheckoutQuestionsProps {
|
|
6
|
-
readonly checkoutQuestions:
|
|
6
|
+
readonly checkoutQuestions: CheckoutFeedbackQuestionProjection[];
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
const CheckoutQuestions: FC<CheckoutQuestionsProps> = ({ checkoutQuestions }) => (
|
|
10
10
|
<>
|
|
11
|
-
{checkoutQuestions.map((checkoutQuestion:
|
|
11
|
+
{checkoutQuestions.map((checkoutQuestion: CheckoutFeedbackQuestionProjection) => (
|
|
12
12
|
<CheckoutQuestion key={checkoutQuestion.id} checkoutQuestion={checkoutQuestion} checkoutQuestionParentId="" />
|
|
13
13
|
))}
|
|
14
14
|
</>
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { renderHook } from "@testing-library/react-native";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { Text } from "react-native";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
CheckoutQuestionType,
|
|
7
|
-
} from "../../../../../../projection/checkoutQuestion/checkoutQuestion";
|
|
4
|
+
import { CheckoutFeedbackQuestionProjection } from "../../../../../../projection/checkoutFeedback/checkoutFeedback";
|
|
5
|
+
import { CheckoutFeedbackQuestionType } from "../../../../../../projection/checkoutFeedback/checkoutFeedback.constants";
|
|
8
6
|
import { createWrapper } from "../../../../test/createWrapper";
|
|
9
7
|
import { render } from "../../../../test/render";
|
|
10
8
|
import { CheckoutQuestionItem } from "../components/CheckoutQuestionItem";
|
|
@@ -15,37 +13,39 @@ import {
|
|
|
15
13
|
} from "./useCheckoutQuestionItem";
|
|
16
14
|
|
|
17
15
|
const hostDefaultText = "host default";
|
|
18
|
-
const HostDefault: CheckoutQuestionItem = () =>
|
|
16
|
+
const HostDefault: CheckoutQuestionItem<CheckoutFeedbackQuestionType.HOST_DEFAULT> = () => (
|
|
17
|
+
<Text>{hostDefaultText}</Text>
|
|
18
|
+
);
|
|
19
19
|
const hostSelectText = "host select";
|
|
20
|
-
const HostSelect: CheckoutQuestionItem = () => <Text>{hostSelectText}</Text>;
|
|
20
|
+
const HostSelect: CheckoutQuestionItem<CheckoutFeedbackQuestionType.HOST_SELECT> = () => <Text>{hostSelectText}</Text>;
|
|
21
21
|
const buttonText = "button";
|
|
22
|
-
const Button: CheckoutQuestionItem = () => <Text>{buttonText}</Text>;
|
|
22
|
+
const Button: CheckoutQuestionItem<CheckoutFeedbackQuestionType.BUTTON> = () => <Text>{buttonText}</Text>;
|
|
23
23
|
const iconText = "icon";
|
|
24
|
-
const Icon: CheckoutQuestionItem = () => <Text>{iconText}</Text>;
|
|
24
|
+
const Icon: CheckoutQuestionItem<CheckoutFeedbackQuestionType.ICON> = () => <Text>{iconText}</Text>;
|
|
25
25
|
const textareaText = "textarea";
|
|
26
|
-
const Textarea: CheckoutQuestionItem = () => <Text>{textareaText}</Text>;
|
|
26
|
+
const Textarea: CheckoutQuestionItem<CheckoutFeedbackQuestionType.TEXTAREA> = () => <Text>{textareaText}</Text>;
|
|
27
27
|
|
|
28
28
|
const checkoutQuestionItems: CheckoutQuestionItems = {
|
|
29
|
-
[
|
|
30
|
-
[
|
|
31
|
-
[
|
|
32
|
-
[
|
|
33
|
-
[
|
|
34
|
-
[
|
|
29
|
+
[CheckoutFeedbackQuestionType.HOST_DEFAULT]: HostDefault,
|
|
30
|
+
[CheckoutFeedbackQuestionType.HOST_TEXTAREA]: HostDefault,
|
|
31
|
+
[CheckoutFeedbackQuestionType.HOST_SELECT]: HostSelect,
|
|
32
|
+
[CheckoutFeedbackQuestionType.TEXTAREA]: Textarea,
|
|
33
|
+
[CheckoutFeedbackQuestionType.BUTTON]: Button,
|
|
34
|
+
[CheckoutFeedbackQuestionType.ICON]: Icon,
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
const scenarios: [
|
|
38
|
-
[
|
|
39
|
-
[
|
|
40
|
-
[
|
|
41
|
-
[
|
|
42
|
-
[
|
|
43
|
-
[
|
|
37
|
+
const scenarios: [CheckoutFeedbackQuestionType, string][] = [
|
|
38
|
+
[CheckoutFeedbackQuestionType.HOST_DEFAULT, hostDefaultText],
|
|
39
|
+
[CheckoutFeedbackQuestionType.HOST_TEXTAREA, hostDefaultText],
|
|
40
|
+
[CheckoutFeedbackQuestionType.HOST_SELECT, hostSelectText],
|
|
41
|
+
[CheckoutFeedbackQuestionType.TEXTAREA, textareaText],
|
|
42
|
+
[CheckoutFeedbackQuestionType.BUTTON, buttonText],
|
|
43
|
+
[CheckoutFeedbackQuestionType.ICON, iconText],
|
|
44
44
|
];
|
|
45
45
|
|
|
46
46
|
describe("useCheckoutQuestionItem hook", () => {
|
|
47
47
|
test.each(scenarios)(
|
|
48
|
-
"returns the %s component from the context for
|
|
48
|
+
"returns the %s component from the context for CheckoutFeedbackQuestionType.%s",
|
|
49
49
|
async (type, componentText) => {
|
|
50
50
|
const { result } = renderHook(() => sut({ type }), {
|
|
51
51
|
wrapper: createWrapper({
|
|
@@ -58,7 +58,7 @@ describe("useCheckoutQuestionItem hook", () => {
|
|
|
58
58
|
|
|
59
59
|
const { findByText } = render(
|
|
60
60
|
<Component
|
|
61
|
-
checkoutQuestion={{} as
|
|
61
|
+
checkoutQuestion={{} as CheckoutFeedbackQuestionProjection}
|
|
62
62
|
checkoutQuestionParentId="1d10e62a-27fa-49d0-a89e-b01775dfb4d8"
|
|
63
63
|
/>,
|
|
64
64
|
);
|
|
@@ -69,9 +69,9 @@ describe("useCheckoutQuestionItem hook", () => {
|
|
|
69
69
|
},
|
|
70
70
|
);
|
|
71
71
|
|
|
72
|
-
it("throws if provided
|
|
72
|
+
it("throws if provided CheckoutFeedbackQuestionType is not supported", () => {
|
|
73
73
|
expect(async () =>
|
|
74
|
-
renderHook(() => sut({ type: "NotSupportedType" as
|
|
74
|
+
renderHook(() => sut({ type: "NotSupportedType" as CheckoutFeedbackQuestionType }), {
|
|
75
75
|
wrapper: createWrapper({
|
|
76
76
|
wrapper: CheckoutQuestionItemProvider,
|
|
77
77
|
initialProps: { checkoutQuestionItems, children: null },
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { createContext, FC, ReactNode, useContext, useMemo } from "react";
|
|
2
2
|
import invariant from "tiny-invariant";
|
|
3
|
-
import {
|
|
3
|
+
import { CheckoutFeedbackQuestionType } from "../../../../../../projection/checkoutFeedback/checkoutFeedback.constants";
|
|
4
4
|
import { CheckoutQuestionItem } from "../components/CheckoutQuestionItem";
|
|
5
5
|
|
|
6
|
-
type CheckoutQuestionItems = Record<
|
|
6
|
+
type CheckoutQuestionItems = Record<CheckoutFeedbackQuestionType, CheckoutQuestionItem<CheckoutFeedbackQuestionType>>;
|
|
7
7
|
|
|
8
8
|
const CheckoutQuestionItemContext = createContext<CheckoutQuestionItems>({} as CheckoutQuestionItems);
|
|
9
9
|
|
|
@@ -19,12 +19,12 @@ const CheckoutQuestionItemProvider: FC<CheckoutQuestionItemContextProviderProps>
|
|
|
19
19
|
<CheckoutQuestionItemContext.Provider value={checkoutQuestionItems}>{children}</CheckoutQuestionItemContext.Provider>
|
|
20
20
|
);
|
|
21
21
|
|
|
22
|
-
interface UseCheckoutQuestionItemFunctionArgs {
|
|
23
|
-
readonly type:
|
|
22
|
+
interface UseCheckoutQuestionItemFunctionArgs<QT extends CheckoutFeedbackQuestionType> {
|
|
23
|
+
readonly type: QT;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
interface UseCheckoutQuestionItemFunction {
|
|
27
|
-
(args: UseCheckoutQuestionItemFunctionArgs): CheckoutQuestionItem
|
|
27
|
+
<QT extends CheckoutFeedbackQuestionType>(args: UseCheckoutQuestionItemFunctionArgs<QT>): CheckoutQuestionItem<QT>;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
const useCheckoutQuestionItem: UseCheckoutQuestionItemFunction = ({ type }) => {
|
|
@@ -36,7 +36,7 @@ const useCheckoutQuestionItem: UseCheckoutQuestionItemFunction = ({ type }) => {
|
|
|
36
36
|
"Your are trying to use the useCheckoutQuestionItem hook without wrapping your app with the <CheckoutQuestionItemProvider>.",
|
|
37
37
|
);
|
|
38
38
|
|
|
39
|
-
invariant(item, `The provided
|
|
39
|
+
invariant(item, `The provided CheckoutFeedbackQuestionType (${type}) is NOT SUPPORTED`);
|
|
40
40
|
|
|
41
41
|
return item;
|
|
42
42
|
};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { FC, ReactNode } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { CheckoutFeedbackQuestionProjection } from "../../../../../../projection/checkoutFeedback/checkoutFeedback";
|
|
3
|
+
import { CheckoutFeedbackQuestionType } from "../../../../../../projection/checkoutFeedback/checkoutFeedback.constants";
|
|
3
4
|
|
|
4
|
-
interface CheckoutQuestionItemProps {
|
|
5
|
-
readonly checkoutQuestion:
|
|
5
|
+
interface CheckoutQuestionItemProps<CFQT extends CheckoutFeedbackQuestionType> {
|
|
6
|
+
readonly checkoutQuestion: CheckoutFeedbackQuestionProjection<CFQT>;
|
|
6
7
|
readonly checkoutQuestionParentId: string;
|
|
7
8
|
readonly children?: ReactNode;
|
|
8
9
|
readonly portalHostName?: string;
|
|
9
10
|
readonly testID?: string;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
type CheckoutQuestionItem = FC<CheckoutQuestionItemProps
|
|
13
|
+
type CheckoutQuestionItem<CFQT extends CheckoutFeedbackQuestionType> = FC<CheckoutQuestionItemProps<CFQT>>;
|
|
13
14
|
|
|
14
15
|
export type { CheckoutQuestionItem, CheckoutQuestionItemProps };
|
|
@@ -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 { ButtonCheckoutQuestionItem } from "./ButtonCheckoutQuestionItem";
|
|
9
7
|
|
|
@@ -13,12 +11,10 @@ jest.mock("../../behaviors/useCheckoutQuestionFeedback", () => ({
|
|
|
13
11
|
}));
|
|
14
12
|
|
|
15
13
|
const checkoutQuestionParentId = "0ad1dba8-b02c-4121-a1e3-981f1c30800d";
|
|
16
|
-
const checkoutQuestion:
|
|
14
|
+
const checkoutQuestion: CheckoutFeedbackQuestionProjection = {
|
|
17
15
|
id: "9251dc2c-d76a-484d-9299-346929af932f",
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
type: CheckoutQuestionType.BUTTON,
|
|
21
|
-
showCondition: [],
|
|
16
|
+
translationKey: "checkout.checkout_question.personalshopper.yes",
|
|
17
|
+
type: CheckoutFeedbackQuestionType.BUTTON,
|
|
22
18
|
};
|
|
23
19
|
|
|
24
20
|
describe("ButtonCheckoutQuestionItem component (CheckoutQuestions organism)", () => {
|
|
@@ -30,9 +26,9 @@ describe("ButtonCheckoutQuestionItem component (CheckoutQuestions organism)", ()
|
|
|
30
26
|
/>,
|
|
31
27
|
);
|
|
32
28
|
|
|
33
|
-
expect(getByText(checkoutQuestion.
|
|
29
|
+
expect(getByText(checkoutQuestion.translationKey)).toBeTruthy();
|
|
34
30
|
|
|
35
|
-
fireEvent.press(getByText(checkoutQuestion.
|
|
31
|
+
fireEvent.press(getByText(checkoutQuestion.translationKey));
|
|
36
32
|
|
|
37
33
|
expect(mockOnChange).toHaveBeenCalledWith({
|
|
38
34
|
checkoutQuestionId: checkoutQuestionParentId,
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
1
2
|
import React, { useCallback, useMemo } from "react";
|
|
2
3
|
import { TouchableOpacity } 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
8
|
import { useCheckoutQuestionFeedbackForId } from "../../behaviors/useCheckoutQuestionFeedback";
|
|
7
|
-
import { CheckoutQuestionItem
|
|
9
|
+
import { CheckoutQuestionItem } from "../CheckoutQuestionItem";
|
|
8
10
|
import { style as buttonCheckoutQuestionItemStyle } from "./ButtonCheckoutQuestionItem.style";
|
|
9
11
|
|
|
10
12
|
const ACTIVE_OPACITY = 0.6;
|
|
11
13
|
|
|
12
|
-
const ButtonCheckoutQuestionItem: CheckoutQuestionItem = ({
|
|
14
|
+
const ButtonCheckoutQuestionItem: CheckoutQuestionItem<CheckoutFeedbackQuestionType.BUTTON> = ({
|
|
13
15
|
checkoutQuestion,
|
|
14
16
|
checkoutQuestionParentId,
|
|
15
17
|
testID,
|
|
16
|
-
}
|
|
18
|
+
}) => {
|
|
17
19
|
const { feedback, onChange } = useCheckoutQuestionFeedbackForId({ id: checkoutQuestionParentId });
|
|
18
20
|
|
|
19
|
-
const optionText = useI18nMessage({ domain: DOMAIN, id: checkoutQuestion.
|
|
21
|
+
const optionText = useI18nMessage({ domain: DOMAIN, id: checkoutQuestion.translationKey });
|
|
20
22
|
const handleOnPress = useCallback(
|
|
21
23
|
() => onChange({ checkoutQuestionId: checkoutQuestionParentId, checkoutQuestionFeedback: checkoutQuestion.id }),
|
|
22
24
|
[onChange, checkoutQuestion.id, checkoutQuestionParentId],
|
|
@@ -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 hostDefaultCheckoutQuestionItemStyle } from "./HostDefaultCheckoutQuestionItem.style";
|
|
8
10
|
|
|
9
|
-
const HostDefaultCheckoutQuestionItem: CheckoutQuestionItem = ({
|
|
11
|
+
const HostDefaultCheckoutQuestionItem: CheckoutQuestionItem<CheckoutFeedbackQuestionType.HOST_DEFAULT> = ({
|
|
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(() => hostDefaultCheckoutQuestionItemStyle(), []);
|
|
16
18
|
|
|
@@ -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 };
|