@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
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { renderHook, waitFor } from "@testing-library/react-native";
|
|
2
|
+
import { bootstrap, QueryStatus } from "@lookiero/messaging-react";
|
|
3
|
+
import { CheckoutFeedbackQuestionProjection } from "../../../../projection/checkoutFeedback/checkoutFeedback";
|
|
4
|
+
import { CheckoutFeedbackQuestionType } from "../../../../projection/checkoutFeedback/checkoutFeedback.constants";
|
|
5
|
+
import {
|
|
6
|
+
viewCheckoutFeedbackDefinitionByCheckoutIdHandler,
|
|
7
|
+
VIEW_CHECKOUT_FEEDBACK_DEFINITION_BY_CHECKOUT_ID,
|
|
8
|
+
} from "../../../../projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId";
|
|
9
|
+
import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
|
|
10
|
+
import { useViewCheckoutFeedbackDefinitionByCheckoutId as sut } from "./useViewCheckoutFeedbackDefinitionByCheckoutId";
|
|
11
|
+
|
|
12
|
+
const checkoutId = "29790d24-b139-4ab8-b618-d796d101e974";
|
|
13
|
+
const checkoutFeedbackDefinition: CheckoutFeedbackQuestionProjection[] = [
|
|
14
|
+
{
|
|
15
|
+
id: "efe07b97-f6fb-4b6a-ba92-b68519320b2c",
|
|
16
|
+
type: CheckoutFeedbackQuestionType.HOST_DEFAULT,
|
|
17
|
+
translationKey: "checkout.feedback.question.default",
|
|
18
|
+
metadata: {
|
|
19
|
+
showCondition: [],
|
|
20
|
+
},
|
|
21
|
+
children: [
|
|
22
|
+
{
|
|
23
|
+
id: "01975911-d451-7651-b1ae-3f977928e8a2",
|
|
24
|
+
type: CheckoutFeedbackQuestionType.HOST_TEXTAREA,
|
|
25
|
+
metadata: {
|
|
26
|
+
showCondition: [],
|
|
27
|
+
},
|
|
28
|
+
children: [
|
|
29
|
+
{
|
|
30
|
+
id: "01975911-ec6b-768e-9b4a-a6f2645b01b2",
|
|
31
|
+
type: CheckoutFeedbackQuestionType.TEXTAREA,
|
|
32
|
+
translationKey: "checkout.feedback.question.textarea",
|
|
33
|
+
metadata: {
|
|
34
|
+
placeholder: "checkout.feedback.question.textarea.placeholder",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
const view = jest.fn().mockReturnValue(checkoutFeedbackDefinition);
|
|
43
|
+
const { Component: Messaging } = bootstrap({ id: MESSAGING_CONTEXT_ID })
|
|
44
|
+
.query(VIEW_CHECKOUT_FEEDBACK_DEFINITION_BY_CHECKOUT_ID, viewCheckoutFeedbackDefinitionByCheckoutIdHandler, { view })
|
|
45
|
+
.build();
|
|
46
|
+
|
|
47
|
+
describe("useViewCheckoutFeedbackDefinitionByCheckoutId integration hook", () => {
|
|
48
|
+
it("returns success as the query status and the result itself after rendering the hook", async () => {
|
|
49
|
+
const { result } = renderHook(() => sut({ checkoutId }), { wrapper: Messaging });
|
|
50
|
+
|
|
51
|
+
await waitFor(() => {
|
|
52
|
+
const [projection, status] = result.current;
|
|
53
|
+
|
|
54
|
+
expect(projection).toStrictEqual(checkoutFeedbackDefinition);
|
|
55
|
+
expect(status).toBe(QueryStatus.SUCCESS);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useQuery, UseQueryFunctionResult } from "@lookiero/messaging-react";
|
|
2
|
+
import { CheckoutFeedbackQuestionProjection } from "../../../../projection/checkoutFeedback/checkoutFeedback";
|
|
3
|
+
import { viewCheckoutFeedbackDefinitionByCheckoutId } from "../../../../projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId";
|
|
4
|
+
import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
|
|
5
|
+
|
|
6
|
+
interface UseViewCheckoutFeedbackDefinitionByCheckoutIdFunctionArgs {
|
|
7
|
+
readonly checkoutId: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface UseViewCheckoutFeedbackDefinitionByCheckoutIdFunction {
|
|
11
|
+
(
|
|
12
|
+
args: UseViewCheckoutFeedbackDefinitionByCheckoutIdFunctionArgs,
|
|
13
|
+
): UseQueryFunctionResult<CheckoutFeedbackQuestionProjection[]>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const useViewCheckoutFeedbackDefinitionByCheckoutId: UseViewCheckoutFeedbackDefinitionByCheckoutIdFunction = ({
|
|
17
|
+
checkoutId,
|
|
18
|
+
}) =>
|
|
19
|
+
useQuery({
|
|
20
|
+
query: viewCheckoutFeedbackDefinitionByCheckoutId({ checkoutId }),
|
|
21
|
+
contextId: MESSAGING_CONTEXT_ID,
|
|
22
|
+
options: { staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export { useViewCheckoutFeedbackDefinitionByCheckoutId };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { Currency } from "@lookiero/sty-psp-locale";
|
|
1
2
|
import { CheckoutItemStatus } from "../../../domain/checkoutItem/model/checkoutItem";
|
|
2
|
-
import { Currency } from "../../../domain/checkoutItem/model/currency";
|
|
3
3
|
import {
|
|
4
4
|
CheckoutItemProductVariantProjection,
|
|
5
5
|
CheckoutItemProjection,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { Currency } from "@lookiero/sty-psp-locale";
|
|
1
2
|
import { BaseTrackingEvent, TrackingEventCategory } from "@lookiero/sty-psp-tracking";
|
|
2
3
|
import { CheckoutItemStatus } from "../../domain/checkoutItem/model/checkoutItem";
|
|
3
|
-
import { Currency } from "../../domain/checkoutItem/model/currency";
|
|
4
4
|
import { MediaPerspective } from "../../projection/checkoutItem/checkoutItem";
|
|
5
5
|
import { SubscriptionProjection } from "../../projection/subscription/subscription";
|
|
6
6
|
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { renderHook } from "@testing-library/react-native";
|
|
2
|
-
import { Country } from "@lookiero/sty-psp-locale";
|
|
2
|
+
import { Country, Currency } from "@lookiero/sty-psp-locale";
|
|
3
3
|
import { Segment } from "@lookiero/sty-psp-segment";
|
|
4
4
|
import { useEmitUserEvent } from "@lookiero/sty-psp-tracking";
|
|
5
5
|
import { Tradename } from "@lookiero/sty-sp-tradename";
|
|
6
6
|
import { CheckoutStatus } from "../../domain/checkout/model/checkout";
|
|
7
7
|
import { CheckoutItemStatus } from "../../domain/checkoutItem/model/checkoutItem";
|
|
8
|
-
import { Currency } from "../../domain/checkoutItem/model/currency";
|
|
9
8
|
import { CheckoutProjection } from "../../projection/checkout/checkout";
|
|
10
9
|
import { OrderProjection } from "../../projection/order/order";
|
|
11
10
|
import { PricingProjection } from "../../projection/pricing/pricing";
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { useCallback } from "react";
|
|
2
2
|
import invariant from "tiny-invariant";
|
|
3
|
-
import { Country } from "@lookiero/sty-psp-locale";
|
|
3
|
+
import { Country, Currency } from "@lookiero/sty-psp-locale";
|
|
4
4
|
import { Segment } from "@lookiero/sty-psp-segment";
|
|
5
5
|
import { useEmitUserEvent } from "@lookiero/sty-psp-tracking";
|
|
6
6
|
import { Tradename } from "@lookiero/sty-sp-tradename";
|
|
7
7
|
import { CheckoutItemStatus } from "../../domain/checkoutItem/model/checkoutItem";
|
|
8
|
-
import { Currency } from "../../domain/checkoutItem/model/currency";
|
|
9
8
|
import { CheckoutProjection } from "../../projection/checkout/checkout";
|
|
10
9
|
import { OrderProjection } from "../../projection/order/order";
|
|
11
10
|
import { PricingProjection } from "../../projection/pricing/pricing";
|
|
@@ -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/components/organisms/checkoutQuestions/CheckoutQuestion.test.tsx
CHANGED
|
@@ -1,64 +1,59 @@
|
|
|
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 CheckoutQuestion from "./CheckoutQuestion";
|
|
9
8
|
import { CheckoutQuestionItemProvider, CheckoutQuestionItems } from "./behaviors/useCheckoutQuestionItem";
|
|
10
|
-
import { CheckoutQuestionItem
|
|
9
|
+
import { CheckoutQuestionItem } from "./components/CheckoutQuestionItem";
|
|
11
10
|
|
|
12
11
|
const mockOnChange = jest.fn();
|
|
13
12
|
jest.mock("./behaviors/useCheckoutQuestionFeedback", () => ({
|
|
14
13
|
useCheckoutQuestionFeedbackForId: () => ({ onChange: mockOnChange }),
|
|
15
14
|
}));
|
|
16
15
|
|
|
17
|
-
const checkoutQuestion:
|
|
16
|
+
const checkoutQuestion: CheckoutFeedbackQuestionProjection = {
|
|
18
17
|
id: "efe07b97-f6fb-4b6a-ba92-b68519320b2c",
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
translationKey: "checkout.checkout_question.selection.question",
|
|
19
|
+
type: CheckoutFeedbackQuestionType.HOST_SELECT,
|
|
20
|
+
metadata: {
|
|
21
|
+
placeholder: "checkout.checkout_question.selection.placeholder",
|
|
22
|
+
showCondition: [],
|
|
23
|
+
},
|
|
23
24
|
children: [
|
|
24
25
|
{
|
|
25
26
|
id: "68c0bb98-b00a-4b86-af43-528fe903cb69",
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
type: CheckoutQuestionType.ICON,
|
|
29
|
-
showCondition: [],
|
|
27
|
+
translationKey: "checkout.checkout_question.icon.bad",
|
|
28
|
+
type: CheckoutFeedbackQuestionType.ICON,
|
|
30
29
|
},
|
|
31
30
|
{
|
|
32
31
|
id: "85e84a77-461c-41e6-8544-95b5294d0b80",
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
type: CheckoutQuestionType.ICON,
|
|
36
|
-
showCondition: [],
|
|
32
|
+
translationKey: "checkout.checkout_question.icon.regular",
|
|
33
|
+
type: CheckoutFeedbackQuestionType.ICON,
|
|
37
34
|
},
|
|
38
35
|
{
|
|
39
36
|
id: "29441d25-8d9f-471e-a13e-a03f61c88091",
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
type: CheckoutQuestionType.ICON,
|
|
43
|
-
showCondition: [],
|
|
37
|
+
translationKey: "checkout.checkout_question.icon.good",
|
|
38
|
+
type: CheckoutFeedbackQuestionType.ICON,
|
|
44
39
|
},
|
|
45
40
|
],
|
|
46
41
|
};
|
|
47
42
|
|
|
48
|
-
const Item: CheckoutQuestionItem = ({ checkoutQuestion, children }
|
|
43
|
+
const Item: CheckoutQuestionItem<CheckoutFeedbackQuestionType> = ({ checkoutQuestion, children }) => (
|
|
49
44
|
<>
|
|
50
|
-
<Text>{checkoutQuestion.
|
|
45
|
+
<Text>{checkoutQuestion.translationKey}</Text>
|
|
51
46
|
{children}
|
|
52
47
|
</>
|
|
53
48
|
);
|
|
54
49
|
|
|
55
50
|
const checkoutQuestionItems: CheckoutQuestionItems = {
|
|
56
|
-
[
|
|
57
|
-
[
|
|
58
|
-
[
|
|
59
|
-
[
|
|
60
|
-
[
|
|
61
|
-
[
|
|
51
|
+
[CheckoutFeedbackQuestionType.HOST_DEFAULT]: Item,
|
|
52
|
+
[CheckoutFeedbackQuestionType.HOST_TEXTAREA]: Item,
|
|
53
|
+
[CheckoutFeedbackQuestionType.HOST_SELECT]: Item,
|
|
54
|
+
[CheckoutFeedbackQuestionType.TEXTAREA]: Item,
|
|
55
|
+
[CheckoutFeedbackQuestionType.BUTTON]: Item,
|
|
56
|
+
[CheckoutFeedbackQuestionType.ICON]: Item,
|
|
62
57
|
};
|
|
63
58
|
|
|
64
59
|
const Wrapper = ({ children }: { children: ReactNode }) => (
|
|
@@ -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
|
|