@lookiero/checkout 8.14.0 → 8.15.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 (81) hide show
  1. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/ReturnQuestion.js +1 -3
  2. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/behaviors/isChildReturnQuestion.js +1 -2
  3. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/behaviors/useReturnQuestionItem.d.ts +3 -3
  4. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/ReturnQuestionItem.d.ts +3 -4
  5. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionFeedbackItem/HostDefaultReturnQuestionFeedbackItem.d.ts +1 -2
  6. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionFeedbackItem/HostDefaultReturnQuestionFeedbackItem.js +0 -1
  7. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.d.ts +1 -2
  8. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.js +6 -8
  9. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.d.ts +1 -2
  10. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.js +1 -2
  11. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.d.ts +1 -2
  12. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.js +1 -2
  13. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/form/HostStackReturnQuestionItem.d.ts +1 -2
  14. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/form/HostStackReturnQuestionItem.js +0 -1
  15. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/modal/HostStackReturnQuestionItem.d.ts +1 -2
  16. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/modal/HostStackReturnQuestionItem.js +3 -5
  17. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/modalOptionReturnQuestionItems/ModalOptionReturnQuestionItems.js +2 -4
  18. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/optionReturnQuestionItem/OptionReturnQuestionItem.d.ts +1 -2
  19. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/optionReturnQuestionItem/OptionReturnQuestionItem.js +1 -2
  20. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/radioReturnQuestionItem/RadioReturnQuestionItem.d.ts +1 -2
  21. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/radioReturnQuestionItem/RadioReturnQuestionItem.js +1 -2
  22. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem.d.ts +1 -2
  23. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem.js +1 -2
  24. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.d.ts +1 -2
  25. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.js +1 -2
  26. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/util/returnQuestionFeedback.js +9 -18
  27. package/dist/src/infrastructure/ui/views/item/components/returnQuestionsFeedback/ReturnQuestionsFeedback.js +1 -1
  28. package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.js +1 -1
  29. package/dist/src/infrastructure/ui/views/summaryTabs/components/checkoutItemsTabs/CheckoutItemsTabs.js +1 -1
  30. package/dist/src/projection/returnQuestion/returnQuestion.d.ts +16 -23
  31. package/dist/src/projection/returnQuestion/returnQuestion.js +11 -1
  32. package/dist/src/version.d.ts +1 -1
  33. package/dist/src/version.js +1 -1
  34. package/package.json +3 -3
  35. package/src/infrastructure/projection/returnQuestion/react/useListReturnQuestionsByCheckoutItemId.test.ts +9 -4
  36. package/src/infrastructure/projection/returnQuestion/returnQuestions.mock.ts +117 -72
  37. package/src/infrastructure/ui/components/organisms/returnQuestions/ReturnQuestion.test.tsx +12 -10
  38. package/src/infrastructure/ui/components/organisms/returnQuestions/ReturnQuestion.tsx +8 -10
  39. package/src/infrastructure/ui/components/organisms/returnQuestions/ReturnQuestions.test.tsx +9 -10
  40. package/src/infrastructure/ui/components/organisms/returnQuestions/behaviors/isChildReturnQuestion.ts +1 -2
  41. package/src/infrastructure/ui/components/organisms/returnQuestions/behaviors/useReturnQuestionItem.test.tsx +9 -7
  42. package/src/infrastructure/ui/components/organisms/returnQuestions/behaviors/useReturnQuestionItem.tsx +3 -3
  43. package/src/infrastructure/ui/components/organisms/returnQuestions/components/ReturnQuestionItem.ts +3 -4
  44. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionFeedbackItem/HostDefaultReturnQuestionFeedbackItem.test.tsx +13 -7
  45. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionFeedbackItem/HostDefaultReturnQuestionFeedbackItem.tsx +2 -4
  46. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.test.tsx +14 -8
  47. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.tsx +7 -13
  48. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.tsx +5 -7
  49. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.test.tsx +14 -10
  50. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.tsx +5 -7
  51. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/form/HostStackReturnQuestionItem.tsx +3 -5
  52. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/modal/HostStackReturnQuestionItem.test.tsx +36 -43
  53. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/modal/HostStackReturnQuestionItem.tsx +7 -10
  54. package/src/infrastructure/ui/components/organisms/returnQuestions/components/modalOptionReturnQuestionItems/ModalOptionReturnQuestionItems.tsx +9 -11
  55. package/src/infrastructure/ui/components/organisms/returnQuestions/components/optionReturnQuestionItem/OptionReturnQuestionItem.test.tsx +14 -8
  56. package/src/infrastructure/ui/components/organisms/returnQuestions/components/optionReturnQuestionItem/OptionReturnQuestionItem.tsx +4 -6
  57. package/src/infrastructure/ui/components/organisms/returnQuestions/components/radioReturnQuestionItem/RadioReturnQuestionItem.tsx +4 -6
  58. package/src/infrastructure/ui/components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem.test.tsx +25 -23
  59. package/src/infrastructure/ui/components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem.tsx +3 -5
  60. package/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.test.tsx +29 -9
  61. package/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.tsx +5 -7
  62. package/src/infrastructure/ui/components/organisms/returnQuestions/util/__snapshots__/returnQuestionFeedback.test.ts.snap +4 -5
  63. package/src/infrastructure/ui/components/organisms/returnQuestions/util/returnQuestionFeedback.ts +18 -32
  64. package/src/infrastructure/ui/views/item/components/productVariantSlider/__snapshots__/ProductVariantSlider.test.tsx.snap +26 -24
  65. package/src/infrastructure/ui/views/item/components/returnQuestionsFeedback/ReturnQuestionsFeedback.tsx +4 -2
  66. package/src/infrastructure/ui/views/item/views/productVariant/__snapshots__/ProductVariant.test.tsx.snap +78 -72
  67. package/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.tsx +1 -1
  68. package/src/infrastructure/ui/views/shared/components/productVariant/__snapshots__/ProductVariant.test.tsx.snap +4 -4
  69. package/src/infrastructure/ui/views/summaryTabs/components/checkoutItemsTabs/CheckoutItemsTabs.tsx +2 -2
  70. package/src/infrastructure/ui/views/summaryTabs/components/checkoutItemsTabs/__snapshots__/CheckoutItemsTabs.test.tsx.snap +30 -28
  71. package/src/projection/returnQuestion/listReturnQuestionsByCheckoutItemId.test.ts +12 -4
  72. package/src/projection/returnQuestion/returnQuestion.ts +20 -42
  73. package/dist/src/projection/returnQuestion/returnQuestion.constants.d.ts +0 -9
  74. package/dist/src/projection/returnQuestion/returnQuestion.constants.js +0 -10
  75. package/dist/src/projection/returnQuestion/returnQuestion.metadata.d.ts +0 -12
  76. package/dist/src/projection/returnQuestion/returnQuestion.metadata.js +0 -1
  77. package/dist/src/projection/returnQuestion/returnQuestion.typeguard.d.ts +0 -5
  78. package/dist/src/projection/returnQuestion/returnQuestion.typeguard.js +0 -10
  79. package/src/projection/returnQuestion/returnQuestion.constants.ts +0 -10
  80. package/src/projection/returnQuestion/returnQuestion.metadata.ts +0 -17
  81. package/src/projection/returnQuestion/returnQuestion.typeguard.ts +0 -24
@@ -1,15 +1,14 @@
1
1
  import { FC, ReactNode } from "react";
2
2
  import { ReturnQuestionProjection } from "../../../../../../projection/returnQuestion/returnQuestion";
3
- import { ReturnQuestionType } from "../../../../../../projection/returnQuestion/returnQuestion.constants";
4
3
 
5
- interface ReturnQuestionItemProps<RQT extends ReturnQuestionType> {
4
+ interface ReturnQuestionItemProps {
6
5
  readonly returnQuestionParent: ReturnQuestionProjection;
7
- readonly returnQuestion: ReturnQuestionProjection<RQT>;
6
+ readonly returnQuestion: ReturnQuestionProjection;
8
7
  readonly children?: ReactNode;
9
8
  readonly portalHostName?: string;
10
9
  readonly testID?: string;
11
10
  }
12
11
 
13
- type ReturnQuestionItem<QT extends ReturnQuestionType> = FC<ReturnQuestionItemProps<QT>>;
12
+ type ReturnQuestionItem = FC<ReturnQuestionItemProps>;
14
13
 
15
14
  export type { ReturnQuestionItem, ReturnQuestionItemProps };
@@ -1,28 +1,34 @@
1
1
  import React from "react";
2
2
  import { Text } from "react-native";
3
- import { ReturnQuestionProjection } from "../../../../../../../projection/returnQuestion/returnQuestion";
4
- import { ReturnQuestionType } from "../../../../../../../projection/returnQuestion/returnQuestion.constants";
3
+ import {
4
+ ReturnQuestionProjection,
5
+ ReturnQuestionType,
6
+ } from "../../../../../../../projection/returnQuestion/returnQuestion";
5
7
  import { render } from "../../../../../test/render";
6
8
  import { HostDefaultReturnQuestionFeedbackItem } from "./HostDefaultReturnQuestionFeedbackItem";
7
9
 
8
10
  const returnQuestion: ReturnQuestionProjection = {
9
11
  id: "9251dc2c-d76a-484d-9299-346929af932f",
10
- translationKey: "size_large",
11
- type: ReturnQuestionType.HOST_DEFAULT,
12
+ name: "size_large",
13
+ placeholder: "",
14
+ type: ReturnQuestionType.OPTION,
12
15
  children: [
13
16
  {
14
17
  id: "68c0bb98-b00a-4b86-af43-528fe903cb69",
15
- translationKey: "size_overall",
18
+ name: "size_overall",
19
+ placeholder: "",
16
20
  type: ReturnQuestionType.OPTION,
17
21
  },
18
22
  {
19
23
  id: "85e84a77-461c-41e6-8544-95b5294d0b80",
20
- translationKey: "size_trousers_too_long",
24
+ name: "size_trousers_too_long",
25
+ placeholder: "",
21
26
  type: ReturnQuestionType.OPTION,
22
27
  },
23
28
  {
24
29
  id: "29441d25-8d9f-471e-a13e-a03f61c88091",
25
- translationKey: "size_fit_cut_does_not_fit",
30
+ name: "size_fit_cut_does_not_fit",
31
+ placeholder: "",
26
32
  type: ReturnQuestionType.OPTION,
27
33
  },
28
34
  ],
@@ -1,9 +1,7 @@
1
- /* eslint-disable react/prop-types */
2
1
  import React from "react";
3
- import { ReturnQuestionType } from "../../../../../../../projection/returnQuestion/returnQuestion.constants";
4
- import { ReturnQuestionItem } from "../ReturnQuestionItem";
2
+ import { ReturnQuestionItem, ReturnQuestionItemProps } from "../ReturnQuestionItem";
5
3
 
6
- const HostDefaultReturnQuestionFeedbackItem: ReturnQuestionItem<ReturnQuestionType.HOST_DEFAULT> = ({ children }) => (
4
+ const HostDefaultReturnQuestionFeedbackItem: ReturnQuestionItem = ({ children }: ReturnQuestionItemProps) => (
7
5
  <>{children}</>
8
6
  );
9
7
 
@@ -1,7 +1,9 @@
1
1
  import React from "react";
2
2
  import { Text } from "react-native";
3
- import { ReturnQuestionProjection } from "../../../../../../../projection/returnQuestion/returnQuestion";
4
- import { ReturnQuestionType } from "../../../../../../../projection/returnQuestion/returnQuestion.constants";
3
+ import {
4
+ ReturnQuestionProjection,
5
+ ReturnQuestionType,
6
+ } from "../../../../../../../projection/returnQuestion/returnQuestion";
5
7
  import { render } from "../../../../../test/render";
6
8
  import { HostDefaultReturnQuestionItem } from "./HostDefaultReturnQuestionItem";
7
9
 
@@ -12,22 +14,26 @@ jest.mock("../../behaviors/useReturnQuestionFeedback", () => ({
12
14
 
13
15
  const returnQuestion: ReturnQuestionProjection = {
14
16
  id: "9251dc2c-d76a-484d-9299-346929af932f",
15
- translationKey: "size_large",
16
- type: ReturnQuestionType.HOST_DEFAULT,
17
+ name: "size_large",
18
+ placeholder: "",
19
+ type: ReturnQuestionType.OPTION,
17
20
  children: [
18
21
  {
19
22
  id: "68c0bb98-b00a-4b86-af43-528fe903cb69",
20
- translationKey: "size_overall",
23
+ name: "size_overall",
24
+ placeholder: "",
21
25
  type: ReturnQuestionType.OPTION,
22
26
  },
23
27
  {
24
28
  id: "85e84a77-461c-41e6-8544-95b5294d0b80",
25
- translationKey: "size_trousers_too_long",
29
+ name: "size_trousers_too_long",
30
+ placeholder: "",
26
31
  type: ReturnQuestionType.OPTION,
27
32
  },
28
33
  {
29
34
  id: "29441d25-8d9f-471e-a13e-a03f61c88091",
30
- translationKey: "size_fit_cut_does_not_fit",
35
+ name: "size_fit_cut_does_not_fit",
36
+ placeholder: "",
31
37
  type: ReturnQuestionType.OPTION,
32
38
  },
33
39
  ],
@@ -44,7 +50,7 @@ describe("HostDefaultReturnQuestionItem component (ReturnQuestions organism)", (
44
50
  </HostDefaultReturnQuestionItem>,
45
51
  );
46
52
 
47
- expect(getByText(returnQuestion.translationKey)).toBeTruthy();
53
+ expect(getByText(returnQuestion.name)).toBeTruthy();
48
54
  expect(getByText("HostDefaultReturnQuestionItem children")).toBeTruthy();
49
55
  });
50
56
  });
@@ -1,26 +1,20 @@
1
- /* eslint-disable react/prop-types */
2
1
  import React from "react";
3
2
  import { Text, View } from "@lookiero/aurora";
4
- import { useIntl } from "@lookiero/i18n-react";
5
- import { ReturnQuestionType } from "../../../../../../../projection/returnQuestion/returnQuestion.constants";
6
- import { returnQuestionWithTranslationKey } from "../../../../../../../projection/returnQuestion/returnQuestion.typeguard";
3
+ import { useI18nMessage } from "@lookiero/i18n-react";
7
4
  import { I18nMessages } from "../../../../../i18n/i18n";
8
- import { ReturnQuestionItem } from "../ReturnQuestionItem";
5
+ import { ReturnQuestionItem, ReturnQuestionItemProps } from "../ReturnQuestionItem";
9
6
  import { style } from "./HostDefaultReturnQuestionItem.style";
10
7
 
11
- const HostDefaultReturnQuestionItem: ReturnQuestionItem<ReturnQuestionType.HOST_DEFAULT> = ({
12
- returnQuestion,
13
- children,
14
- }) => {
15
- const { formatMessage } = useIntl();
16
- const isAllOptions = returnQuestion.translationKey === I18nMessages.RETURN_QUESTION_MAIN_ALL_OPINION;
8
+ const HostDefaultReturnQuestionItem: ReturnQuestionItem = ({ returnQuestion, children }: ReturnQuestionItemProps) => {
9
+ const titleText = useI18nMessage({ id: returnQuestion.name });
10
+ const isAllOptions = returnQuestion.name === I18nMessages.RETURN_QUESTION_MAIN_ALL_OPINION;
17
11
 
18
12
  return (
19
13
  <>
20
- {returnQuestionWithTranslationKey(returnQuestion) && returnQuestion.translationKey !== " " && !isAllOptions ? (
14
+ {titleText && titleText !== " " && !isAllOptions ? (
21
15
  <View style={style.title}>
22
16
  <Text level={3} action>
23
- {formatMessage({ id: returnQuestion.translationKey })}
17
+ {titleText}
24
18
  </Text>
25
19
  </View>
26
20
  ) : null}
@@ -1,21 +1,19 @@
1
- /* eslint-disable react/prop-types */
2
1
  import React, { useMemo } from "react";
3
2
  import { View } from "react-native";
4
3
  import { Text } from "@lookiero/aurora";
5
4
  import { useIntl } from "@lookiero/i18n-react";
6
- import { ReturnQuestionType } from "../../../../../../../projection/returnQuestion/returnQuestion.constants";
7
- import { ReturnQuestionItem } from "../ReturnQuestionItem";
5
+ import { ReturnQuestionItem, ReturnQuestionItemProps } from "../ReturnQuestionItem";
8
6
  import { style } from "./HostRadioGroupReturnQuestionItem.style";
9
7
 
10
- const HostRadioGroupReturnQuestionItem: ReturnQuestionItem<ReturnQuestionType.HOST_SELECT> = ({
8
+ const HostRadioGroupReturnQuestionItem: ReturnQuestionItem = ({
11
9
  returnQuestion,
12
10
  children,
13
11
  testID,
14
- }) => {
12
+ }: ReturnQuestionItemProps) => {
15
13
  const { formatMessage } = useIntl();
16
14
  const placeholderText = useMemo(
17
- () => (returnQuestion.metadata.placeholder ? formatMessage({ id: returnQuestion.metadata.placeholder }) : ""),
18
- [formatMessage, returnQuestion.metadata.placeholder],
15
+ () => (returnQuestion.placeholder ? formatMessage({ id: returnQuestion.placeholder }) : ""),
16
+ [formatMessage, returnQuestion.placeholder],
19
17
  );
20
18
 
21
19
  return (
@@ -1,8 +1,10 @@
1
1
  import { fireEvent, within } from "@testing-library/react-native";
2
2
  import React from "react";
3
3
  import { Text } from "react-native";
4
- import { ReturnQuestionProjection } from "../../../../../../../projection/returnQuestion/returnQuestion";
5
- import { ReturnQuestionType } from "../../../../../../../projection/returnQuestion/returnQuestion.constants";
4
+ import {
5
+ ReturnQuestionProjection,
6
+ ReturnQuestionType,
7
+ } from "../../../../../../../projection/returnQuestion/returnQuestion";
6
8
  import { render } from "../../../../../test/render";
7
9
  import { HostSelectReturnQuestionItem } from "./HostSelectReturnQuestionItem";
8
10
 
@@ -16,30 +18,32 @@ jest.mock("../../behaviors/useReturnQuestionFeedback", () => ({
16
18
 
17
19
  const returnQuestion: ReturnQuestionProjection = {
18
20
  id: "9251dc2c-d76a-484d-9299-346929af932f",
19
- translationKey: "size_large",
21
+ name: "size_large",
22
+ placeholder: "",
20
23
  type: ReturnQuestionType.HOST_SELECT,
21
- metadata: {
22
- placeholder: "",
23
- },
24
24
  children: [
25
25
  {
26
26
  id: "542c4d24-e1da-484f-8c3a-7d89ee135adc",
27
- translationKey: "",
27
+ name: "",
28
+ placeholder: "",
28
29
  type: ReturnQuestionType.HOST_STACK,
29
30
  children: [
30
31
  {
31
32
  id: "68c0bb98-b00a-4b86-af43-528fe903cb69",
32
- translationKey: "size_overall",
33
+ name: "size_overall",
34
+ placeholder: "",
33
35
  type: ReturnQuestionType.OPTION,
34
36
  },
35
37
  {
36
38
  id: "85e84a77-461c-41e6-8544-95b5294d0b80",
37
- translationKey: "size_trousers_too_long",
39
+ name: "size_trousers_too_long",
40
+ placeholder: "",
38
41
  type: ReturnQuestionType.OPTION,
39
42
  },
40
43
  {
41
44
  id: "29441d25-8d9f-471e-a13e-a03f61c88091",
42
- translationKey: "size_fit_cut_does_not_fit",
45
+ name: "size_fit_cut_does_not_fit",
46
+ placeholder: "",
43
47
  type: ReturnQuestionType.OPTION,
44
48
  },
45
49
  ],
@@ -1,10 +1,8 @@
1
- /* eslint-disable react/prop-types */
2
1
  import React, { useCallback, useEffect, useMemo, useState } from "react";
3
2
  import { TouchableHighlight, View } from "react-native";
4
3
  import { ButtonIcon } from "@lookiero/aurora";
5
4
  import { useIntl } from "@lookiero/i18n-react";
6
5
  import { Modal } from "@lookiero/sty-psp-ui";
7
- import { ReturnQuestionType } from "../../../../../../../projection/returnQuestion/returnQuestion.constants";
8
6
  import { InputField } from "../../../../../../../shared/ui/components/molecules/inputField/InputField";
9
7
  import {
10
8
  useReturnQuestionFeedback,
@@ -14,19 +12,19 @@ import {
14
12
  deepestReturnQuestionWithFeedbackForReturnQuestion,
15
13
  feedbackForReturnQuestion,
16
14
  } from "../../util/returnQuestionFeedback";
17
- import { ReturnQuestionItem } from "../ReturnQuestionItem";
15
+ import { ReturnQuestionItem, ReturnQuestionItemProps } from "../ReturnQuestionItem";
18
16
  import { style, containerUnderlayColor } from "./HostSelectReturnQuestionItem.style";
19
17
 
20
- const HostSelectReturnQuestionItem: ReturnQuestionItem<ReturnQuestionType.HOST_SELECT> = ({
18
+ const HostSelectReturnQuestionItem: ReturnQuestionItem = ({
21
19
  returnQuestion,
22
20
  children,
23
21
  portalHostName,
24
22
  testID,
25
- }) => {
23
+ }: ReturnQuestionItemProps) => {
26
24
  const { formatMessage } = useIntl();
27
25
  const placeholderText = useMemo(
28
- () => (returnQuestion.metadata.placeholder ? formatMessage({ id: returnQuestion.metadata.placeholder }) : ""),
29
- [formatMessage, returnQuestion.metadata.placeholder],
26
+ () => (returnQuestion.placeholder ? formatMessage({ id: returnQuestion.placeholder }) : ""),
27
+ [formatMessage, returnQuestion.placeholder],
30
28
  );
31
29
 
32
30
  const [modalVisible, setModalVisible] = useState(false);
@@ -1,13 +1,11 @@
1
- /* eslint-disable react/prop-types */
2
1
  import React from "react";
3
- import { ReturnQuestionType } from "../../../../../../../../projection/returnQuestion/returnQuestion.constants";
4
2
  import ReturnQuestion from "../../../ReturnQuestion";
5
- import { ReturnQuestionItem } from "../../ReturnQuestionItem";
3
+ import { ReturnQuestionItem, ReturnQuestionItemProps } from "../../ReturnQuestionItem";
6
4
 
7
- const HostStackReturnQuestionItem: ReturnQuestionItem<ReturnQuestionType.HOST_STACK> = ({
5
+ const HostStackReturnQuestionItem: ReturnQuestionItem = ({
8
6
  returnQuestion,
9
7
  portalHostName,
10
- }) => (
8
+ }: ReturnQuestionItemProps) => (
11
9
  <>
12
10
  {returnQuestion.children?.map((childReturnQuestion) => (
13
11
  <ReturnQuestion
@@ -1,7 +1,9 @@
1
1
  import React from "react";
2
2
  import { Text } from "react-native";
3
- import { ReturnQuestionProjection } from "../../../../../../../../projection/returnQuestion/returnQuestion";
4
- import { ReturnQuestionType } from "../../../../../../../../projection/returnQuestion/returnQuestion.constants";
3
+ import {
4
+ ReturnQuestionProjection,
5
+ ReturnQuestionType,
6
+ } from "../../../../../../../../projection/returnQuestion/returnQuestion";
5
7
  import { render } from "../../../../../../test/render";
6
8
  import * as useReturnQuestionFeedback from "../../../behaviors/useReturnQuestionFeedback";
7
9
  import { HostStackReturnQuestionItem } from "./HostStackReturnQuestionItem";
@@ -13,54 +15,45 @@ const mockedUseReturnQuestionFeedbackForReturnQuestion = (
13
15
  useReturnQuestionFeedback as jest.Mocked<typeof useReturnQuestionFeedback>
14
16
  ).useReturnQuestionFeedbackForReturnQuestion;
15
17
 
16
- const withTitle: ReturnQuestionProjection<ReturnQuestionType.HOST_STACK> = {
18
+ const returnQuestionChildren: ReturnQuestionProjection[] = [
19
+ {
20
+ id: "68c0bb98-b00a-4b86-af43-528fe903cb69",
21
+ name: "size_overall",
22
+ placeholder: "",
23
+ type: ReturnQuestionType.OPTION,
24
+ },
25
+ {
26
+ id: "85e84a77-461c-41e6-8544-95b5294d0b80",
27
+ name: "size_trousers_too_long",
28
+ placeholder: "",
29
+ type: ReturnQuestionType.OPTION,
30
+ },
31
+ {
32
+ id: "29441d25-8d9f-471e-a13e-a03f61c88091",
33
+ name: "size_fit_cut_does_not_fit",
34
+ placeholder: "",
35
+ type: ReturnQuestionType.OPTION,
36
+ },
37
+ ];
38
+
39
+ const withTitle: ReturnQuestionProjection = {
17
40
  id: "542c4d24-e1da-484f-8c3a-7d89ee135adc",
18
- translationKey: "return question title",
41
+ name: "return question title",
42
+ placeholder: "",
19
43
  type: ReturnQuestionType.HOST_STACK,
20
- children: [
21
- {
22
- id: "68c0bb98-b00a-4b86-af43-528fe903cb69",
23
- translationKey: "size_overall",
24
- type: ReturnQuestionType.OPTION,
25
- },
26
- {
27
- id: "85e84a77-461c-41e6-8544-95b5294d0b80",
28
- translationKey: "size_trousers_too_long",
29
- type: ReturnQuestionType.OPTION,
30
- },
31
- {
32
- id: "29441d25-8d9f-471e-a13e-a03f61c88091",
33
- translationKey: "size_fit_cut_does_not_fit",
34
- type: ReturnQuestionType.OPTION,
35
- },
36
- ],
44
+ children: returnQuestionChildren,
37
45
  };
38
46
 
39
- const withoutTitle: ReturnQuestionProjection<ReturnQuestionType.HOST_STACK> = {
47
+ const withoutTitle: ReturnQuestionProjection = {
40
48
  id: "542c4d24-e1da-484f-8c3a-7d89ee135adc",
41
- translationKey: "",
49
+ name: "",
50
+ placeholder: "",
42
51
  type: ReturnQuestionType.HOST_STACK,
43
- children: [
44
- {
45
- id: "68c0bb98-b00a-4b86-af43-528fe903cb69",
46
- translationKey: "size_overall",
47
- type: ReturnQuestionType.OPTION,
48
- },
49
- {
50
- id: "85e84a77-461c-41e6-8544-95b5294d0b80",
51
- translationKey: "size_trousers_too_long",
52
- type: ReturnQuestionType.OPTION,
53
- },
54
- {
55
- id: "29441d25-8d9f-471e-a13e-a03f61c88091",
56
- translationKey: "size_fit_cut_does_not_fit",
57
- type: ReturnQuestionType.OPTION,
58
- },
59
- ],
52
+ children: returnQuestionChildren,
60
53
  };
61
54
 
62
55
  interface RenderHostStackReturnQuestionItemParameters {
63
- readonly returnQuestion: ReturnQuestionProjection<ReturnQuestionType.HOST_STACK>;
56
+ readonly returnQuestion: ReturnQuestionProjection;
64
57
  }
65
58
 
66
59
  const renderHostStackReturnQuestionItem = ({ returnQuestion }: RenderHostStackReturnQuestionItemParameters) =>
@@ -79,7 +72,7 @@ describe("HostStackReturnQuestionItem component (ReturnQuestions organism)", ()
79
72
  });
80
73
  const { findByText } = renderHostStackReturnQuestionItem({ returnQuestion: withTitle });
81
74
 
82
- expect(await findByText(withTitle.translationKey as string)).toBeDefined();
75
+ expect(await findByText(withTitle.name)).toBeDefined();
83
76
  });
84
77
 
85
78
  it("does not render a title for the returnQuestion (when returnQuestion's name is not provided)", async () => {
@@ -90,7 +83,7 @@ describe("HostStackReturnQuestionItem component (ReturnQuestions organism)", ()
90
83
  });
91
84
  const { queryByText } = renderHostStackReturnQuestionItem({ returnQuestion: withoutTitle });
92
85
 
93
- expect(await queryByText(withTitle.translationKey as string)).toBeNull();
86
+ expect(await queryByText(withTitle.name)).toBeNull();
94
87
  });
95
88
 
96
89
  it("renders the feedback and a ReturnQuestion for its returnQuestion.children when there is feedback", async () => {
@@ -1,21 +1,18 @@
1
- /* eslint-disable react/prop-types */
2
1
  import { animated, useSpring } from "@react-spring/native";
3
2
  import React, { useCallback, useMemo, useState } from "react";
4
3
  import { LayoutChangeEvent, View } from "react-native";
5
4
  import { COLOR, Text } from "@lookiero/aurora";
6
5
  import { useIntl } from "@lookiero/i18n-react";
7
- import { ReturnQuestionType } from "../../../../../../../../projection/returnQuestion/returnQuestion.constants";
8
- import { returnQuestionHasChildren } from "../../../../../../../../projection/returnQuestion/returnQuestion.typeguard";
9
6
  import ReturnQuestion from "../../../ReturnQuestion";
10
7
  import { useReturnQuestionFeedbackForReturnQuestion } from "../../../behaviors/useReturnQuestionFeedback";
11
- import { ReturnQuestionItem } from "../../ReturnQuestionItem";
8
+ import { ReturnQuestionItem, ReturnQuestionItemProps } from "../../ReturnQuestionItem";
12
9
  import { style } from "./HostStackReturnQuestionItem.style";
13
10
 
14
- const HostStackReturnQuestionItem: ReturnQuestionItem<ReturnQuestionType.HOST_STACK> = ({
11
+ const HostStackReturnQuestionItem: ReturnQuestionItem = ({
15
12
  returnQuestion,
16
13
  children,
17
14
  portalHostName,
18
- }) => {
15
+ }: ReturnQuestionItemProps) => {
19
16
  const { formatMessage } = useIntl();
20
17
  const { feedback } = useReturnQuestionFeedbackForReturnQuestion({ returnQuestion });
21
18
  const feedbackReturnQuestion = feedback
@@ -23,11 +20,11 @@ const HostStackReturnQuestionItem: ReturnQuestionItem<ReturnQuestionType.HOST_ST
23
20
  : undefined;
24
21
 
25
22
  const titleText = useMemo(
26
- () => (returnQuestion.translationKey ? formatMessage({ id: returnQuestion.translationKey }) : undefined),
27
- [formatMessage, returnQuestion.translationKey],
23
+ () => (returnQuestion.name ? formatMessage({ id: returnQuestion.name }) : undefined),
24
+ [formatMessage, returnQuestion.name],
28
25
  );
29
26
  const feedbackText = useMemo(
30
- () => (feedbackReturnQuestion ? formatMessage({ id: feedbackReturnQuestion.translationKey }) : undefined),
27
+ () => (feedbackReturnQuestion ? formatMessage({ id: feedbackReturnQuestion.name }) : undefined),
31
28
  [feedbackReturnQuestion, formatMessage],
32
29
  );
33
30
 
@@ -51,7 +48,7 @@ const HostStackReturnQuestionItem: ReturnQuestionItem<ReturnQuestionType.HOST_ST
51
48
  {titleText}
52
49
  </Text>
53
50
  )}
54
- {feedbackReturnQuestion && returnQuestionHasChildren(feedbackReturnQuestion) ? (
51
+ {feedbackReturnQuestion ? (
55
52
  <>
56
53
  <Text color={COLOR.TEXT_MEDIUM} level={3}>
57
54
  {feedbackText}
@@ -4,7 +4,6 @@ import { COLOR, Text } from "@lookiero/aurora";
4
4
  import { useIntl } from "@lookiero/i18n-react";
5
5
  import { Modal } from "@lookiero/sty-psp-ui";
6
6
  import { ReturnQuestionProjection } from "../../../../../../../projection/returnQuestion/returnQuestion";
7
- import { returnQuestionHasChildren } from "../../../../../../../projection/returnQuestion/returnQuestion.typeguard";
8
7
  import ReturnQuestion from "../../ReturnQuestion";
9
8
  import { style } from "./ModalOptionReturnQuestionItems.style";
10
9
 
@@ -23,7 +22,7 @@ const ModalOptionReturnQuestionItems = ({
23
22
  onClose,
24
23
  }: ModalOptionReturnQuestionItemsProps) => {
25
24
  const { formatMessage } = useIntl();
26
- const title = formatMessage({ id: returnQuestion.translationKey });
25
+ const title = formatMessage({ id: returnQuestion.name });
27
26
 
28
27
  return (
29
28
  <Modal portalHostName={portalHostName} visible={visible} scroll showCloseButton onClose={onClose}>
@@ -32,15 +31,14 @@ const ModalOptionReturnQuestionItems = ({
32
31
  {title}
33
32
  </Text>
34
33
  <>
35
- {returnQuestionHasChildren(returnQuestion) &&
36
- returnQuestion.children?.map((childReturnQuestion) => (
37
- <ReturnQuestion
38
- key={childReturnQuestion.id}
39
- portalHostName=""
40
- returnQuestion={childReturnQuestion}
41
- returnQuestionParent={returnQuestion}
42
- />
43
- ))}
34
+ {returnQuestion.children?.map((childReturnQuestion) => (
35
+ <ReturnQuestion
36
+ key={childReturnQuestion.id}
37
+ portalHostName=""
38
+ returnQuestion={childReturnQuestion}
39
+ returnQuestionParent={returnQuestion}
40
+ />
41
+ ))}
44
42
  </>
45
43
  </View>
46
44
  </Modal>
@@ -1,7 +1,9 @@
1
1
  import { fireEvent } from "@testing-library/react-native";
2
2
  import React from "react";
3
- import { ReturnQuestionProjection } from "../../../../../../../projection/returnQuestion/returnQuestion";
4
- import { ReturnQuestionType } from "../../../../../../../projection/returnQuestion/returnQuestion.constants";
3
+ import {
4
+ ReturnQuestionProjection,
5
+ ReturnQuestionType,
6
+ } from "../../../../../../../projection/returnQuestion/returnQuestion";
5
7
  import { render } from "../../../../../test/render";
6
8
  import { OptionReturnQuestionItem } from "./OptionReturnQuestionItem";
7
9
 
@@ -15,22 +17,26 @@ const returnQuestionParent = {
15
17
  } as ReturnQuestionProjection;
16
18
  const returnQuestion: ReturnQuestionProjection = {
17
19
  id: "9251dc2c-d76a-484d-9299-346929af932f",
18
- translationKey: "size_large",
20
+ name: "size_large",
21
+ placeholder: "",
19
22
  type: ReturnQuestionType.OPTION,
20
23
  children: [
21
24
  {
22
25
  id: "68c0bb98-b00a-4b86-af43-528fe903cb69",
23
- translationKey: "size_overall",
26
+ name: "size_overall",
27
+ placeholder: "",
24
28
  type: ReturnQuestionType.OPTION,
25
29
  },
26
30
  {
27
31
  id: "85e84a77-461c-41e6-8544-95b5294d0b80",
28
- translationKey: "size_trousers_too_long",
32
+ name: "size_trousers_too_long",
33
+ placeholder: "",
29
34
  type: ReturnQuestionType.OPTION,
30
35
  },
31
36
  {
32
37
  id: "29441d25-8d9f-471e-a13e-a03f61c88091",
33
- translationKey: "size_fit_cut_does_not_fit",
38
+ name: "size_fit_cut_does_not_fit",
39
+ placeholder: "",
34
40
  type: ReturnQuestionType.OPTION,
35
41
  },
36
42
  ],
@@ -42,9 +48,9 @@ describe("OptionReturnQuestionItem component (ReturnQuestions organism)", () =>
42
48
  <OptionReturnQuestionItem returnQuestion={returnQuestion} returnQuestionParent={returnQuestionParent} />,
43
49
  );
44
50
 
45
- expect(getByText(returnQuestion.translationKey)).toBeTruthy();
51
+ expect(getByText(returnQuestion.name)).toBeTruthy();
46
52
 
47
- fireEvent.press(getByText(returnQuestion.translationKey));
53
+ fireEvent.press(getByText(returnQuestion.name));
48
54
 
49
55
  expect(mockOnChange).toHaveBeenCalledWith({
50
56
  returnQuestionId: returnQuestionParent.id,
@@ -1,21 +1,19 @@
1
- /* eslint-disable react/prop-types */
2
1
  import React, { useCallback } from "react";
3
2
  import { TouchableHighlight, ViewStyle } from "react-native";
4
3
  import { Text } from "@lookiero/aurora";
5
4
  import { useI18nMessage } from "@lookiero/i18n-react";
6
- import { ReturnQuestionType } from "../../../../../../../projection/returnQuestion/returnQuestion.constants";
7
5
  import { useReturnQuestionFeedbackForReturnQuestion } from "../../behaviors/useReturnQuestionFeedback";
8
- import { ReturnQuestionItem } from "../ReturnQuestionItem";
6
+ import { ReturnQuestionItem, ReturnQuestionItemProps } from "../ReturnQuestionItem";
9
7
  import { containerUnderlayColor, style } from "./OptionReturnQuestionItem.style";
10
8
 
11
- const OptionReturnQuestionItem: ReturnQuestionItem<ReturnQuestionType.OPTION> = ({
9
+ const OptionReturnQuestionItem: ReturnQuestionItem = ({
12
10
  returnQuestion,
13
11
  returnQuestionParent,
14
12
  testID,
15
- }) => {
13
+ }: ReturnQuestionItemProps) => {
16
14
  const { onChange } = useReturnQuestionFeedbackForReturnQuestion({ returnQuestion: returnQuestionParent });
17
15
 
18
- const optionText = useI18nMessage({ id: returnQuestion.translationKey });
16
+ const optionText = useI18nMessage({ id: returnQuestion.name });
19
17
  const handleOnPress = useCallback(
20
18
  () => onChange({ returnQuestionId: returnQuestionParent.id, returnQuestionFeedback: returnQuestion.id }),
21
19
  [onChange, returnQuestion.id, returnQuestionParent.id],
@@ -1,8 +1,6 @@
1
- /* eslint-disable react/prop-types */
2
1
  import React, { useCallback, useEffect, useState } from "react";
3
2
  import { View, Option, OPTION_VARIANT, SIZE } from "@lookiero/aurora";
4
3
  import { useIntl } from "@lookiero/i18n-react";
5
- import { ReturnQuestionType } from "../../../../../../../projection/returnQuestion/returnQuestion.constants";
6
4
  import {
7
5
  useReturnQuestionFeedback,
8
6
  useReturnQuestionFeedbackForReturnQuestion,
@@ -11,16 +9,16 @@ import {
11
9
  deepestReturnQuestionWithFeedbackForReturnQuestion,
12
10
  feedbackForReturnQuestion,
13
11
  } from "../../util/returnQuestionFeedback";
14
- import { ReturnQuestionItem } from "../ReturnQuestionItem";
12
+ import { ReturnQuestionItem, ReturnQuestionItemProps } from "../ReturnQuestionItem";
15
13
  import { ModalOptionReturnQuestionItems } from "../modalOptionReturnQuestionItems/ModalOptionReturnQuestionItems";
16
14
  import { style } from "./RadioReturnQuestionItem.style";
17
15
 
18
- const RadioReturnQuestionItem: ReturnQuestionItem<ReturnQuestionType.OPTION> = ({
16
+ const RadioReturnQuestionItem: ReturnQuestionItem = ({
19
17
  returnQuestion,
20
18
  returnQuestionParent,
21
19
  testID,
22
20
  portalHostName,
23
- }) => {
21
+ }: ReturnQuestionItemProps) => {
24
22
  const intl = useIntl();
25
23
  const [modalVisible, setModalVisible] = useState(false);
26
24
  const {
@@ -35,7 +33,7 @@ const RadioReturnQuestionItem: ReturnQuestionItem<ReturnQuestionType.OPTION> = (
35
33
  );
36
34
 
37
35
  const inputValue = feedbackForReturnQuestion({ feedback, returnQuestion, translate }).join(" / ");
38
- const optionText = intl.formatMessage({ id: returnQuestion.translationKey });
36
+ const optionText = intl.formatMessage({ id: returnQuestion.name });
39
37
 
40
38
  const hasChildren = Boolean(returnQuestion.children && returnQuestion.children.length > 0);
41
39