@lookiero/checkout 12.3.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.
Files changed (99) hide show
  1. package/cypress/integration/checkout.spec.ts +14 -9
  2. package/cypress/support/interceptViewCheckoutFeedbackDefinitionByCheckoutId.ts +6 -0
  3. package/dist/src/ExpoRoot.js +2 -2
  4. package/dist/src/infrastructure/delivery/baseBootstrap.d.ts +2 -2
  5. package/dist/src/infrastructure/delivery/baseBootstrap.js +4 -4
  6. package/dist/src/infrastructure/delivery/bootstrap.js +2 -2
  7. package/dist/src/infrastructure/delivery/bootstrap.mock.js +3 -3
  8. package/dist/src/infrastructure/projection/checkoutFeedback/checkoutFeedbackDefinition.mock.d.ts +3 -0
  9. package/dist/src/infrastructure/projection/checkoutFeedback/checkoutFeedbackDefinition.mock.js +107 -0
  10. package/dist/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackDefinitionByCheckoutIdView.d.ts +12 -0
  11. package/dist/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackDefinitionByCheckoutIdView.js +10 -0
  12. package/dist/src/infrastructure/projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId.d.ts +10 -0
  13. package/dist/src/infrastructure/projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId.js +9 -0
  14. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestion.d.ts +2 -2
  15. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestion.js +4 -2
  16. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestions.d.ts +2 -2
  17. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem.d.ts +5 -5
  18. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem.js +1 -1
  19. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/CheckoutQuestionItem.d.ts +5 -4
  20. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.d.ts +2 -1
  21. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.js +2 -1
  22. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultCheckoutQuestionItem.d.ts +2 -1
  23. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultCheckoutQuestionItem.js +2 -1
  24. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.d.ts +2 -1
  25. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.js +2 -1
  26. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.d.ts +2 -3
  27. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.js +5 -7
  28. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.d.ts +2 -1
  29. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.js +2 -1
  30. package/dist/src/infrastructure/ui/views/feedback/Feedback.js +10 -9
  31. package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.d.ts +2 -3
  32. package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.js +17 -9
  33. package/dist/src/projection/checkoutFeedback/checkoutFeedback.constants.d.ts +11 -0
  34. package/dist/src/projection/checkoutFeedback/checkoutFeedback.constants.js +10 -0
  35. package/dist/src/projection/checkoutFeedback/checkoutFeedback.d.ts +22 -2
  36. package/dist/src/projection/checkoutFeedback/checkoutFeedback.metadata.d.ts +21 -0
  37. package/dist/src/projection/checkoutFeedback/checkoutFeedback.metadata.js +1 -0
  38. package/dist/src/projection/checkoutFeedback/checkoutFeedback.typeguards.d.ts +3 -0
  39. package/dist/src/projection/checkoutFeedback/checkoutFeedback.typeguards.js +7 -0
  40. package/dist/src/projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId.d.ts +25 -0
  41. package/dist/src/projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId.js +8 -0
  42. package/dist/src/version.d.ts +1 -1
  43. package/dist/src/version.js +1 -1
  44. package/package.json +1 -1
  45. package/src/ExpoRoot.tsx +2 -2
  46. package/src/infrastructure/delivery/baseBootstrap.ts +9 -9
  47. package/src/infrastructure/delivery/bootstrap.mock.ts +5 -4
  48. package/src/infrastructure/delivery/bootstrap.ts +2 -2
  49. package/src/infrastructure/projection/checkoutFeedback/checkoutFeedbackDefinition.mock.ts +110 -0
  50. package/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackDefinitionByCheckoutIdView.test.ts +52 -0
  51. package/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackDefinitionByCheckoutIdView.ts +30 -0
  52. package/src/infrastructure/projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId.test.ts +58 -0
  53. package/src/infrastructure/projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId.ts +25 -0
  54. package/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestion.test.tsx +25 -30
  55. package/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestion.tsx +12 -13
  56. package/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestions.test.tsx +19 -26
  57. package/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestions.tsx +3 -3
  58. package/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem.test.tsx +26 -26
  59. package/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem.tsx +6 -6
  60. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/CheckoutQuestionItem.ts +5 -4
  61. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.test.tsx +7 -11
  62. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.tsx +6 -4
  63. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultCheckoutQuestionItem.tsx +6 -4
  64. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultReturnQuestionItem.test.tsx +16 -10
  65. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.test.tsx +16 -22
  66. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.tsx +6 -4
  67. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.test.tsx +16 -14
  68. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.tsx +13 -14
  69. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.test.tsx +9 -19
  70. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.tsx +7 -5
  71. package/src/infrastructure/ui/views/feedback/Feedback.test.tsx +11 -5
  72. package/src/infrastructure/ui/views/feedback/Feedback.tsx +10 -9
  73. package/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.test.tsx +2 -2
  74. package/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.tsx +20 -13
  75. package/src/projection/checkoutFeedback/checkoutFeedback.constants.ts +16 -0
  76. package/src/projection/checkoutFeedback/checkoutFeedback.metadata.ts +28 -0
  77. package/src/projection/checkoutFeedback/checkoutFeedback.ts +38 -2
  78. package/src/projection/checkoutFeedback/checkoutFeedback.typeguards.ts +13 -0
  79. package/src/projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId.test.ts +52 -0
  80. package/src/projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId.ts +61 -0
  81. package/cypress/support/interceptListCheckoutQuestionsByCheckoutId.ts +0 -9
  82. package/dist/src/infrastructure/projection/checkoutQuestion/checkoutQuestions.mock.d.ts +0 -3
  83. package/dist/src/infrastructure/projection/checkoutQuestion/checkoutQuestions.mock.js +0 -103
  84. package/dist/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.d.ts +0 -12
  85. package/dist/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.js +0 -10
  86. package/dist/src/infrastructure/projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId.d.ts +0 -10
  87. package/dist/src/infrastructure/projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId.js +0 -9
  88. package/dist/src/projection/checkoutQuestion/checkoutQuestion.d.ts +0 -18
  89. package/dist/src/projection/checkoutQuestion/checkoutQuestion.js +0 -10
  90. package/dist/src/projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId.d.ts +0 -25
  91. package/dist/src/projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId.js +0 -8
  92. package/src/infrastructure/projection/checkoutQuestion/checkoutQuestions.mock.ts +0 -108
  93. package/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.test.ts +0 -55
  94. package/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.ts +0 -34
  95. package/src/infrastructure/projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId.test.ts +0 -38
  96. package/src/infrastructure/projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId.ts +0 -21
  97. package/src/projection/checkoutQuestion/checkoutQuestion.ts +0 -20
  98. package/src/projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId.test.ts +0 -31
  99. 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,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
- CheckoutQuestionProjection,
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, CheckoutQuestionItemProps } from "./components/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: CheckoutQuestionProjection = {
16
+ const checkoutQuestion: CheckoutFeedbackQuestionProjection = {
18
17
  id: "efe07b97-f6fb-4b6a-ba92-b68519320b2c",
19
- name: "checkout.checkout_question.selection.question",
20
- placeholder: "checkout.checkout_question.selection.placeholder",
21
- type: CheckoutQuestionType.HOST_SELECT,
22
- showCondition: [],
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
- name: "checkout.checkout_question.icon.bad",
27
- placeholder: "",
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
- name: "checkout.checkout_question.icon.regular",
34
- placeholder: "",
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
- name: "checkout.checkout_question.icon.good",
41
- placeholder: "",
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 }: CheckoutQuestionItemProps) => (
43
+ const Item: CheckoutQuestionItem<CheckoutFeedbackQuestionType> = ({ checkoutQuestion, children }) => (
49
44
  <>
50
- <Text>{checkoutQuestion.name}</Text>
45
+ <Text>{checkoutQuestion.translationKey}</Text>
51
46
  {children}
52
47
  </>
53
48
  );
54
49
 
55
50
  const checkoutQuestionItems: CheckoutQuestionItems = {
56
- [CheckoutQuestionType.HOST_DEFAULT]: Item,
57
- [CheckoutQuestionType.HOST_TEXTAREA]: Item,
58
- [CheckoutQuestionType.HOST_SELECT]: Item,
59
- [CheckoutQuestionType.TEXTAREA]: Item,
60
- [CheckoutQuestionType.BUTTON]: Item,
61
- [CheckoutQuestionType.ICON]: Item,
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 { CheckoutQuestionProjection } from "../../../../../projection/checkoutQuestion/checkoutQuestion";
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: CheckoutQuestionProjection;
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.children?.map((childCheckoutQuestion) => (
23
- <CheckoutQuestion
24
- key={childCheckoutQuestion.id}
25
- checkoutQuestion={childCheckoutQuestion}
26
- checkoutQuestionParentId={checkoutQuestion.id}
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
  };
@@ -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
- CheckoutQuestionProjection,
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, CheckoutQuestionItemProps } from "./components/CheckoutQuestionItem";
10
+ import { CheckoutQuestionItem } from "./components/CheckoutQuestionItem";
12
11
 
13
- const checkoutQuestions: CheckoutQuestionProjection[] = [
12
+ const checkoutQuestions: CheckoutFeedbackQuestionProjection[] = [
14
13
  {
15
14
  id: "68c0bb98-b00a-4b86-af43-528fe903cb69",
16
- name: "checkout.checkout_question.icon.bad",
17
- placeholder: "",
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
- name: "checkout.checkout_question.icon.regular",
24
- placeholder: "",
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
- name: "checkout.checkout_question.icon.good",
31
- placeholder: "",
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 }: CheckoutQuestionItemProps) => (
38
- <Text>{checkoutQuestion.name}</Text>
30
+ const Item: CheckoutQuestionItem<CheckoutFeedbackQuestionType> = ({ checkoutQuestion }) => (
31
+ <Text>{checkoutQuestion.translationKey}</Text>
39
32
  );
40
33
 
41
34
  const checkoutQuestionItems: CheckoutQuestionItems = {
42
- [CheckoutQuestionType.HOST_DEFAULT]: Item,
43
- [CheckoutQuestionType.HOST_TEXTAREA]: Item,
44
- [CheckoutQuestionType.HOST_SELECT]: Item,
45
- [CheckoutQuestionType.TEXTAREA]: Item,
46
- [CheckoutQuestionType.BUTTON]: Item,
47
- [CheckoutQuestionType.ICON]: Item,
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 { CheckoutQuestionProjection } from "../../../../../projection/checkoutQuestion/checkoutQuestion";
2
+ import { CheckoutFeedbackQuestionProjection } from "../../../../../projection/checkoutFeedback/checkoutFeedback";
3
3
  import CheckoutQuestion from "./CheckoutQuestion";
4
4
 
5
5
  interface CheckoutQuestionsProps {
6
- readonly checkoutQuestions: CheckoutQuestionProjection[];
6
+ readonly checkoutQuestions: CheckoutFeedbackQuestionProjection[];
7
7
  }
8
8
 
9
9
  const CheckoutQuestions: FC<CheckoutQuestionsProps> = ({ checkoutQuestions }) => (
10
10
  <>
11
- {checkoutQuestions.map((checkoutQuestion: CheckoutQuestionProjection) => (
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
- CheckoutQuestionProjection,
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 = () => <Text>{hostDefaultText}</Text>;
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
- [CheckoutQuestionType.HOST_DEFAULT]: HostDefault,
30
- [CheckoutQuestionType.HOST_TEXTAREA]: HostDefault,
31
- [CheckoutQuestionType.HOST_SELECT]: HostSelect,
32
- [CheckoutQuestionType.TEXTAREA]: Textarea,
33
- [CheckoutQuestionType.BUTTON]: Button,
34
- [CheckoutQuestionType.ICON]: Icon,
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: [CheckoutQuestionType, string][] = [
38
- [CheckoutQuestionType.HOST_DEFAULT, hostDefaultText],
39
- [CheckoutQuestionType.HOST_TEXTAREA, hostDefaultText],
40
- [CheckoutQuestionType.HOST_SELECT, hostSelectText],
41
- [CheckoutQuestionType.TEXTAREA, textareaText],
42
- [CheckoutQuestionType.BUTTON, buttonText],
43
- [CheckoutQuestionType.ICON, iconText],
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 CheckoutQuestionType.%s",
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 CheckoutQuestionProjection}
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 CheckoutQuestionType is not supported", () => {
72
+ it("throws if provided CheckoutFeedbackQuestionType is not supported", () => {
73
73
  expect(async () =>
74
- renderHook(() => sut({ type: "NotSupportedType" as CheckoutQuestionType }), {
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 { CheckoutQuestionType } from "../../../../../../projection/checkoutQuestion/checkoutQuestion";
3
+ import { CheckoutFeedbackQuestionType } from "../../../../../../projection/checkoutFeedback/checkoutFeedback.constants";
4
4
  import { CheckoutQuestionItem } from "../components/CheckoutQuestionItem";
5
5
 
6
- type CheckoutQuestionItems = Record<CheckoutQuestionType, CheckoutQuestionItem>;
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: CheckoutQuestionType;
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 CheckoutQuestionType (${type}) is NOT SUPPORTED`);
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 { CheckoutQuestionProjection } from "../../../../../../projection/checkoutQuestion/checkoutQuestion";
2
+ import { CheckoutFeedbackQuestionProjection } from "../../../../../../projection/checkoutFeedback/checkoutFeedback";
3
+ import { CheckoutFeedbackQuestionType } from "../../../../../../projection/checkoutFeedback/checkoutFeedback.constants";
3
4
 
4
- interface CheckoutQuestionItemProps {
5
- readonly checkoutQuestion: CheckoutQuestionProjection;
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
- CheckoutQuestionProjection,
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: CheckoutQuestionProjection = {
14
+ const checkoutQuestion: CheckoutFeedbackQuestionProjection = {
17
15
  id: "9251dc2c-d76a-484d-9299-346929af932f",
18
- name: "checkout.checkout_question.personalshopper.yes",
19
- placeholder: "",
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.name)).toBeTruthy();
29
+ expect(getByText(checkoutQuestion.translationKey)).toBeTruthy();
34
30
 
35
- fireEvent.press(getByText(checkoutQuestion.name));
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, CheckoutQuestionItemProps } from "../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
- }: CheckoutQuestionItemProps) => {
18
+ }) => {
17
19
  const { feedback, onChange } = useCheckoutQuestionFeedbackForId({ id: checkoutQuestionParentId });
18
20
 
19
- const optionText = useI18nMessage({ domain: DOMAIN, id: checkoutQuestion.name });
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, CheckoutQuestionItemProps } from "../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
- }: CheckoutQuestionItemProps) => {
13
- const titleText = useI18nMessage({ domain: DOMAIN, id: checkoutQuestion.name });
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
- CheckoutQuestionProjection,
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: CheckoutQuestionProjection = {
9
+ const checkoutQuestion: CheckoutFeedbackQuestionProjection = {
12
10
  id: "9251dc2c-d76a-484d-9299-346929af932f",
13
- name: "checkout.checkout_question.selection.question",
14
- placeholder: "",
15
- type: CheckoutQuestionType.HOST_DEFAULT,
16
- showCondition: [],
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.name)).toBeTruthy();
36
+ expect(getByText(checkoutQuestion.translationKey)).toBeTruthy();
31
37
  expect(getByText("HostDefaultCheckoutQuestionItem children")).toBeTruthy();
32
38
  });
33
39
  });