@lookiero/checkout 12.3.0 → 12.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/cypress/integration/checkout.spec.ts +14 -9
  2. package/cypress/support/interceptViewCheckoutFeedbackDefinitionByCheckoutId.ts +6 -0
  3. package/dist/public/public/assets/adaptive-icon.png +0 -0
  4. package/dist/public/public/assets/favicon.png +0 -0
  5. package/dist/public/public/assets/icon.png +0 -0
  6. package/dist/public/public/assets/splash.png +0 -0
  7. package/dist/public/public/images/not-found.png +0 -0
  8. package/dist/src/ExpoRoot.js +2 -2
  9. package/dist/src/domain/checkoutItem/model/currency.d.ts +6 -0
  10. package/dist/src/domain/checkoutItem/model/currency.js +7 -0
  11. package/dist/src/domain/uiSetting/command/updateUiSetting.d.ts +15 -0
  12. package/dist/src/domain/uiSetting/command/updateUiSetting.js +10 -0
  13. package/dist/src/domain/uiSetting/model/uiSetting.d.ts +9 -0
  14. package/dist/src/domain/uiSetting/model/uiSetting.js +11 -0
  15. package/dist/src/domain/uiSetting/model/uiSettingUpdated.d.ts +15 -0
  16. package/dist/src/domain/uiSetting/model/uiSettingUpdated.js +8 -0
  17. package/dist/src/domain/uiSetting/model/uiSettings.d.ts +7 -0
  18. package/dist/src/domain/uiSetting/model/uiSettings.js +1 -0
  19. package/dist/src/infrastructure/delivery/baseBootstrap.d.ts +2 -2
  20. package/dist/src/infrastructure/delivery/baseBootstrap.js +4 -4
  21. package/dist/src/infrastructure/delivery/bootstrap.js +2 -2
  22. package/dist/src/infrastructure/delivery/bootstrap.mock.js +3 -3
  23. package/dist/src/infrastructure/domain/uiSetting/model/storageUiSettings.d.ts +17 -0
  24. package/dist/src/infrastructure/domain/uiSetting/model/storageUiSettings.js +20 -0
  25. package/dist/src/infrastructure/domain/uiSetting/react/useUpdateUiSetting.d.ts +18 -0
  26. package/dist/src/infrastructure/domain/uiSetting/react/useUpdateUiSetting.js +22 -0
  27. package/dist/src/infrastructure/integration/useRedirect.d.ts +7 -0
  28. package/dist/src/infrastructure/integration/useRedirect.js +1 -0
  29. package/dist/src/infrastructure/persistence/asyncStorageStorage.d.ts +5 -0
  30. package/dist/src/infrastructure/persistence/asyncStorageStorage.js +7 -0
  31. package/dist/src/infrastructure/persistence/uiSettingData.d.ts +6 -0
  32. package/dist/src/infrastructure/persistence/uiSettingData.js +1 -0
  33. package/dist/src/infrastructure/projection/checkoutFeedback/checkoutFeedbackDefinition.mock.d.ts +3 -0
  34. package/dist/src/infrastructure/projection/checkoutFeedback/checkoutFeedbackDefinition.mock.js +107 -0
  35. package/dist/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackDefinitionByCheckoutIdView.d.ts +12 -0
  36. package/dist/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackDefinitionByCheckoutIdView.js +10 -0
  37. package/dist/src/infrastructure/projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId.d.ts +10 -0
  38. package/dist/src/infrastructure/projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId.js +9 -0
  39. package/dist/src/infrastructure/projection/returnQuestion/returnQuestions.mock.js +47 -58
  40. package/dist/src/infrastructure/projection/uiSetting/react/useViewUiSettingByKey.d.ts +10 -0
  41. package/dist/src/infrastructure/projection/uiSetting/react/useViewUiSettingByKey.js +11 -0
  42. package/dist/src/infrastructure/projection/uiSetting/storageUiSettingByKeyView.d.ts +13 -0
  43. package/dist/src/infrastructure/projection/uiSetting/storageUiSettingByKeyView.js +15 -0
  44. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestion.d.ts +2 -2
  45. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestion.js +4 -2
  46. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestions.d.ts +2 -2
  47. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem.d.ts +5 -5
  48. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem.js +1 -1
  49. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/CheckoutQuestionItem.d.ts +5 -4
  50. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.d.ts +2 -1
  51. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.js +2 -1
  52. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultCheckoutQuestionItem.d.ts +2 -1
  53. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultCheckoutQuestionItem.js +2 -1
  54. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.d.ts +2 -1
  55. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.js +2 -1
  56. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.d.ts +2 -3
  57. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.js +5 -7
  58. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.d.ts +2 -1
  59. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.js +2 -1
  60. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.js +1 -2
  61. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostLegacyRadioGroupReturnQuestionItem/HostLegacyRadioGroupReturnQuestionItem.d.ts +4 -0
  62. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostLegacyRadioGroupReturnQuestionItem/HostLegacyRadioGroupReturnQuestionItem.js +17 -0
  63. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostLegacyRadioGroupReturnQuestionItem/HostLegacyRadioGroupReturnQuestionItem.style.d.ts +11 -0
  64. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostLegacyRadioGroupReturnQuestionItem/HostLegacyRadioGroupReturnQuestionItem.style.js +16 -0
  65. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.d.ts +1 -1
  66. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.js +3 -5
  67. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem.js +2 -3
  68. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/util/returnQuestionFeedback.js +2 -4
  69. package/dist/src/infrastructure/ui/hooks/useSubmitCheckout.d.ts +27 -0
  70. package/dist/src/infrastructure/ui/hooks/useSubmitCheckout.js +97 -0
  71. package/dist/src/infrastructure/ui/routing/useBasePath.d.ts +8 -0
  72. package/dist/src/infrastructure/ui/routing/useBasePath.js +9 -0
  73. package/dist/src/infrastructure/ui/settings/UISettings.d.ts +3 -0
  74. package/dist/src/infrastructure/ui/settings/UISettings.js +4 -0
  75. package/dist/src/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.d.ts +12 -0
  76. package/dist/src/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.js +90 -0
  77. package/dist/src/infrastructure/ui/views/feedback/Feedback.js +10 -9
  78. package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.d.ts +2 -3
  79. package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.js +17 -9
  80. package/dist/src/infrastructure/ui/views/item/components/returnQuestionsFeedback/ReturnQuestionsFeedback.js +1 -0
  81. package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.js +3 -1
  82. package/dist/src/projection/checkoutFeedback/checkoutFeedback.constants.d.ts +11 -0
  83. package/dist/src/projection/checkoutFeedback/checkoutFeedback.constants.js +10 -0
  84. package/dist/src/projection/checkoutFeedback/checkoutFeedback.d.ts +22 -2
  85. package/dist/src/projection/checkoutFeedback/checkoutFeedback.metadata.d.ts +21 -0
  86. package/dist/src/projection/checkoutFeedback/checkoutFeedback.metadata.js +1 -0
  87. package/dist/src/projection/checkoutFeedback/checkoutFeedback.typeguards.d.ts +3 -0
  88. package/dist/src/projection/checkoutFeedback/checkoutFeedback.typeguards.js +7 -0
  89. package/dist/src/projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId.d.ts +25 -0
  90. package/dist/src/projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId.js +8 -0
  91. package/dist/src/projection/returnQuestion/returnQuestion.constants.d.ts +1 -0
  92. package/dist/src/projection/returnQuestion/returnQuestion.constants.js +1 -0
  93. package/dist/src/projection/returnQuestion/returnQuestion.d.ts +2 -2
  94. package/dist/src/projection/returnQuestion/returnQuestion.typeguard.d.ts +2 -4
  95. package/dist/src/projection/returnQuestion/returnQuestion.typeguard.js +2 -2
  96. package/dist/src/projection/uiSetting/viewUiSettingByKey.d.ts +29 -0
  97. package/dist/src/projection/uiSetting/viewUiSettingByKey.js +8 -0
  98. package/dist/src/version.d.ts +1 -1
  99. package/dist/src/version.js +1 -1
  100. package/package.json +1 -1
  101. package/src/ExpoRoot.tsx +2 -2
  102. package/src/infrastructure/delivery/baseBootstrap.ts +9 -9
  103. package/src/infrastructure/delivery/bootstrap.mock.ts +5 -4
  104. package/src/infrastructure/delivery/bootstrap.ts +2 -2
  105. package/src/infrastructure/projection/checkoutFeedback/checkoutFeedbackDefinition.mock.ts +110 -0
  106. package/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackDefinitionByCheckoutIdView.test.ts +52 -0
  107. package/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackDefinitionByCheckoutIdView.ts +30 -0
  108. package/src/infrastructure/projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId.test.ts +58 -0
  109. package/src/infrastructure/projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId.ts +25 -0
  110. package/src/infrastructure/projection/returnQuestion/returnQuestions.mock.ts +47 -58
  111. package/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestion.test.tsx +25 -30
  112. package/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestion.tsx +12 -13
  113. package/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestions.test.tsx +19 -26
  114. package/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestions.tsx +3 -3
  115. package/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem.test.tsx +26 -26
  116. package/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem.tsx +6 -6
  117. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/CheckoutQuestionItem.ts +5 -4
  118. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.test.tsx +7 -11
  119. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.tsx +6 -4
  120. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultCheckoutQuestionItem.tsx +6 -4
  121. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultReturnQuestionItem.test.tsx +16 -10
  122. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.test.tsx +16 -22
  123. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.tsx +6 -4
  124. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.test.tsx +16 -14
  125. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.tsx +13 -14
  126. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.test.tsx +9 -19
  127. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.tsx +7 -5
  128. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.tsx +1 -2
  129. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostLegacyRadioGroupReturnQuestionItem/HostLegacyRadioGroupReturnQuestionItem.style.ts +19 -0
  130. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostLegacyRadioGroupReturnQuestionItem/HostLegacyRadioGroupReturnQuestionItem.tsx +36 -0
  131. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.test.tsx +46 -0
  132. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.tsx +7 -12
  133. package/src/infrastructure/ui/components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem.tsx +6 -5
  134. package/src/infrastructure/ui/components/organisms/returnQuestions/util/__snapshots__/returnQuestionFeedback.test.ts.snap +22 -2
  135. package/src/infrastructure/ui/components/organisms/returnQuestions/util/returnQuestionFeedback.ts +2 -7
  136. package/src/infrastructure/ui/views/feedback/Feedback.test.tsx +11 -5
  137. package/src/infrastructure/ui/views/feedback/Feedback.tsx +10 -9
  138. package/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.test.tsx +2 -2
  139. package/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.tsx +20 -13
  140. package/src/infrastructure/ui/views/item/components/returnQuestionsFeedback/ReturnQuestionsFeedback.tsx +1 -0
  141. package/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.tsx +3 -1
  142. package/src/projection/checkoutFeedback/checkoutFeedback.constants.ts +16 -0
  143. package/src/projection/checkoutFeedback/checkoutFeedback.metadata.ts +28 -0
  144. package/src/projection/checkoutFeedback/checkoutFeedback.ts +38 -2
  145. package/src/projection/checkoutFeedback/checkoutFeedback.typeguards.ts +13 -0
  146. package/src/projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId.test.ts +52 -0
  147. package/src/projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId.ts +61 -0
  148. package/src/projection/returnQuestion/returnQuestion.constants.ts +1 -0
  149. package/src/projection/returnQuestion/returnQuestion.ts +6 -2
  150. package/src/projection/returnQuestion/returnQuestion.typeguard.ts +3 -11
  151. package/cypress/support/interceptListCheckoutQuestionsByCheckoutId.ts +0 -9
  152. package/src/infrastructure/projection/checkoutQuestion/checkoutQuestions.mock.ts +0 -108
  153. package/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.test.ts +0 -55
  154. package/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.ts +0 -34
  155. package/src/infrastructure/projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId.test.ts +0 -38
  156. package/src/infrastructure/projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId.ts +0 -21
  157. package/src/projection/checkoutQuestion/checkoutQuestion.ts +0 -20
  158. package/src/projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId.test.ts +0 -31
  159. package/src/projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId.ts +0 -61
@@ -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 { TextareaCheckoutQuestionItem } from "./TextareaCheckoutQuestionItem";
9
7
 
@@ -13,21 +11,13 @@ jest.mock("../../behaviors/useCheckoutQuestionFeedback", () => ({
13
11
  }));
14
12
 
15
13
  const checkoutQuestionParentId = "0ad1dba8-b02c-4121-a1e3-981f1c30800d";
16
- const checkoutQuestion: CheckoutQuestionProjection = {
17
- id: "ce3e8d57-5eea-4dd3-bef4-2e811a143612",
18
- name: "comment_title",
19
- placeholder: "",
20
- type: CheckoutQuestionType.HOST_TEXTAREA,
21
- showCondition: [],
22
- children: [
23
- {
24
- id: "1123a37d-bc00-43a4-9d28-cee1dfaf356c",
25
- name: "comment_textarea",
26
- placeholder: "comment_textarea_placeholder",
27
- type: CheckoutQuestionType.TEXTAREA,
28
- showCondition: [],
29
- },
30
- ],
14
+ const checkoutQuestion: CheckoutFeedbackQuestionProjection = {
15
+ id: "1123a37d-bc00-43a4-9d28-cee1dfaf356c",
16
+ translationKey: "comment_textarea",
17
+ type: CheckoutFeedbackQuestionType.TEXTAREA,
18
+ metadata: {
19
+ placeholder: "comment_textarea_placeholder",
20
+ },
31
21
  };
32
22
 
33
23
  describe("TextareaCheckoutQuestionItem component (CheckoutQuestions organism)", () => {
@@ -1,20 +1,22 @@
1
+ /* eslint-disable react/prop-types */
1
2
  import React, { useCallback, useMemo } from "react";
2
3
  import { useI18n } from "@lookiero/i18n-react";
3
4
  import { InputField, TextInput } from "@lookiero/sty-psp-ui";
5
+ import { CheckoutFeedbackQuestionType } from "../../../../../../../projection/checkoutFeedback/checkoutFeedback.constants";
4
6
  import { DOMAIN } from "../../../../../i18n/i18n";
5
7
  import { useCheckoutQuestionFeedbackForId } from "../../behaviors/useCheckoutQuestionFeedback";
6
- import { CheckoutQuestionItem, CheckoutQuestionItemProps } from "../CheckoutQuestionItem";
8
+ import { CheckoutQuestionItem } from "../CheckoutQuestionItem";
7
9
  import { style as textareaCheckoutQuestionItemStyle } from "./TextareaCheckoutQuestionItem.style";
8
10
 
9
- const TextareaCheckoutQuestionItem: CheckoutQuestionItem = ({
11
+ const TextareaCheckoutQuestionItem: CheckoutQuestionItem<CheckoutFeedbackQuestionType.TEXTAREA> = ({
10
12
  checkoutQuestion,
11
13
  checkoutQuestionParentId,
12
14
  testID,
13
- }: CheckoutQuestionItemProps) => {
15
+ }) => {
14
16
  const { formatMessage } = useI18n({ domain: DOMAIN });
15
17
  const placeholderText = useMemo(
16
- () => (checkoutQuestion.placeholder ? formatMessage({ id: checkoutQuestion.placeholder }) : ""),
17
- [formatMessage, checkoutQuestion.placeholder],
18
+ () => (checkoutQuestion.metadata.placeholder ? formatMessage({ id: checkoutQuestion.metadata.placeholder }) : ""),
19
+ [formatMessage, checkoutQuestion.metadata.placeholder],
18
20
  );
19
21
 
20
22
  const { feedback, onChange } = useCheckoutQuestionFeedbackForId({ id: checkoutQuestionParentId });
@@ -4,7 +4,6 @@ import { View } from "react-native";
4
4
  import { Text } from "@lookiero/aurora";
5
5
  import { useI18n } from "@lookiero/i18n-react";
6
6
  import { ReturnQuestionType } from "../../../../../../../projection/returnQuestion/returnQuestion.constants";
7
- import { returnQuestionWithTranslationKey } from "../../../../../../../projection/returnQuestion/returnQuestion.typeguard";
8
7
  import { DOMAIN, I18nMessages } from "../../../../../i18n/i18n";
9
8
  import { ReturnQuestionItem } from "../ReturnQuestionItem";
10
9
  import { style as hostDefaultReturnQuestionItemStyle } from "./HostDefaultReturnQuestionItem.style";
@@ -20,7 +19,7 @@ const HostDefaultReturnQuestionItem: ReturnQuestionItem<ReturnQuestionType.HOST_
20
19
 
21
20
  return (
22
21
  <>
23
- {returnQuestionWithTranslationKey(returnQuestion) && returnQuestion.translationKey !== " " && !isAllOptions ? (
22
+ {returnQuestion.translationKey && returnQuestion.translationKey !== " " && !isAllOptions ? (
24
23
  <View style={style.title}>
25
24
  <Text level={3} action>
26
25
  {formatMessage({ id: returnQuestion.translationKey })}
@@ -0,0 +1,19 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { theme } from "@lookiero/sty-psp-ui";
3
+
4
+ const style = () => {
5
+ const { colorBgBase, space2, space6 } = theme();
6
+
7
+ return StyleSheet.create({
8
+ title: {
9
+ marginBottom: space2,
10
+ },
11
+ wrapper: {
12
+ backgroundColor: colorBgBase,
13
+ marginBottom: space2,
14
+ padding: space6,
15
+ },
16
+ });
17
+ };
18
+
19
+ export { style };
@@ -0,0 +1,36 @@
1
+ /* eslint-disable react/prop-types */
2
+ import React, { useMemo } from "react";
3
+ import { View } from "react-native";
4
+ import { Text } from "@lookiero/aurora";
5
+ import { useI18n } from "@lookiero/i18n-react";
6
+ import { ReturnQuestionType } from "../../../../../../../projection/returnQuestion/returnQuestion.constants";
7
+ import { DOMAIN } from "../../../../../i18n/i18n";
8
+ import { ReturnQuestionItem } from "../ReturnQuestionItem";
9
+ import { style as hostLegacyRadioGroupReturnQuestionItemStyle } from "./HostLegacyRadioGroupReturnQuestionItem.style";
10
+
11
+ const HostLegacyRadioGroupReturnQuestionItem: ReturnQuestionItem<ReturnQuestionType.HOST_SELECT> = ({
12
+ returnQuestion,
13
+ children,
14
+ testID,
15
+ }) => {
16
+ const { formatMessage } = useI18n({ domain: DOMAIN });
17
+ const placeholderText = useMemo(
18
+ () => (returnQuestion.metadata.placeholder ? formatMessage({ id: returnQuestion.metadata.placeholder }) : ""),
19
+ [formatMessage, returnQuestion.metadata.placeholder],
20
+ );
21
+
22
+ const style = useMemo(() => hostLegacyRadioGroupReturnQuestionItemStyle(), []);
23
+
24
+ return (
25
+ <>
26
+ <View style={style.wrapper} testID={testID}>
27
+ <Text level={3} style={style.title} action>
28
+ {placeholderText}
29
+ </Text>
30
+ {children}
31
+ </View>
32
+ </>
33
+ );
34
+ };
35
+
36
+ export { HostLegacyRadioGroupReturnQuestionItem };
@@ -0,0 +1,46 @@
1
+ import React from "react";
2
+ import { Text } from "react-native";
3
+ import { ReturnQuestionProjection } from "../../../../../../../projection/returnQuestion/returnQuestion";
4
+ import { ReturnQuestionType } from "../../../../../../../projection/returnQuestion/returnQuestion.constants";
5
+ import { render } from "../../../../../test/render";
6
+ import { HostRadioGroupReturnQuestionItem } from "./HostRadioGroupReturnQuestionItem";
7
+
8
+ const returnQuestion: ReturnQuestionProjection<ReturnQuestionType.HOST_RADIO_GROUP> = {
9
+ id: "9251dc2c-d76a-484d-9299-346929af932f",
10
+ translationKey: "size_large",
11
+ type: ReturnQuestionType.HOST_RADIO_GROUP,
12
+ children: [
13
+ {
14
+ id: "68c0bb98-b00a-4b86-af43-528fe903cb69",
15
+ translationKey: "size_overall",
16
+ type: ReturnQuestionType.OPTION,
17
+ },
18
+ {
19
+ id: "85e84a77-461c-41e6-8544-95b5294d0b80",
20
+ translationKey: "size_trousers_too_long",
21
+ type: ReturnQuestionType.OPTION,
22
+ },
23
+ {
24
+ id: "29441d25-8d9f-471e-a13e-a03f61c88091",
25
+ translationKey: "size_fit_cut_does_not_fit",
26
+ type: ReturnQuestionType.OPTION,
27
+ },
28
+ ],
29
+ };
30
+
31
+ describe("HostRadioGroupReturnQuestionItem component (ReturnQuestions organism)", () => {
32
+ it("renders correctly", () => {
33
+ const childrenText = "HostRadioGroupReturnQuestionItem children";
34
+ const { getByText } = render(
35
+ <HostRadioGroupReturnQuestionItem
36
+ returnQuestion={returnQuestion}
37
+ returnQuestionParent={{} as ReturnQuestionProjection}
38
+ >
39
+ <Text>{childrenText}</Text>
40
+ </HostRadioGroupReturnQuestionItem>,
41
+ );
42
+
43
+ expect(getByText(returnQuestion.translationKey as string)).toBeTruthy();
44
+ expect(getByText(childrenText)).toBeTruthy();
45
+ });
46
+ });
@@ -8,28 +8,23 @@ import { DOMAIN } from "../../../../../i18n/i18n";
8
8
  import { ReturnQuestionItem } from "../ReturnQuestionItem";
9
9
  import { style as hostRadioGroupReturnQuestionItemStyle } from "./HostRadioGroupReturnQuestionItem.style";
10
10
 
11
- const HostRadioGroupReturnQuestionItem: ReturnQuestionItem<ReturnQuestionType.HOST_SELECT> = ({
11
+ const HostRadioGroupReturnQuestionItem: ReturnQuestionItem<ReturnQuestionType.HOST_RADIO_GROUP> = ({
12
12
  returnQuestion,
13
13
  children,
14
14
  testID,
15
15
  }) => {
16
16
  const { formatMessage } = useI18n({ domain: DOMAIN });
17
- const placeholderText = useMemo(
18
- () => (returnQuestion.metadata.placeholder ? formatMessage({ id: returnQuestion.metadata.placeholder }) : ""),
19
- [formatMessage, returnQuestion.metadata.placeholder],
20
- );
21
-
22
17
  const style = useMemo(() => hostRadioGroupReturnQuestionItemStyle(), []);
23
18
 
24
19
  return (
25
- <>
26
- <View style={style.wrapper} testID={testID}>
20
+ <View style={style.wrapper} testID={testID}>
21
+ {returnQuestion.translationKey && (
27
22
  <Text level={3} style={style.title} action>
28
- {placeholderText}
23
+ {formatMessage({ id: returnQuestion.translationKey })}
29
24
  </Text>
30
- {children}
31
- </View>
32
- </>
25
+ )}
26
+ {children}
27
+ </View>
33
28
  );
34
29
  };
35
30
 
@@ -11,12 +11,11 @@ import { ReturnQuestionItem } from "../ReturnQuestionItem";
11
11
  import { style as returnQuestionFeedbackItemStyle } from "./ReturnQuestionFeedbackItem.style";
12
12
 
13
13
  const ReturnQuestionFeedbackItem: ReturnQuestionItem<ReturnQuestionType.HOST_DEFAULT> = ({ returnQuestion }) => {
14
- const titleText = useI18nMessage({ domain: DOMAIN, id: returnQuestion.translationKey });
14
+ const { formatMessage } = useI18n({ domain: DOMAIN });
15
15
  const unansweredText = useI18nMessage({ domain: DOMAIN, id: I18nMessages.FEEDBACK_UNANSWERED });
16
16
 
17
17
  const returnQuestionFeedback = useReturnQuestionFeedback();
18
18
 
19
- const { formatMessage } = useI18n({ domain: DOMAIN });
20
19
  const translate = useCallback(
21
20
  (returnQuestionName: string) => formatMessage({ id: returnQuestionName, defaultMessage: returnQuestionName }),
22
21
  [formatMessage],
@@ -29,9 +28,11 @@ const ReturnQuestionFeedbackItem: ReturnQuestionItem<ReturnQuestionType.HOST_DEF
29
28
 
30
29
  return (
31
30
  <View style={style.container}>
32
- <Text level={2} style={style.title} detailBold>
33
- {titleText}
34
- </Text>
31
+ {returnQuestion.translationKey && (
32
+ <Text level={2} style={style.title} detailBold>
33
+ {formatMessage({ id: returnQuestion.translationKey })}
34
+ </Text>
35
+ )}
35
36
  <Text level={1} detail>
36
37
  {feedback || unansweredText}
37
38
  </Text>
@@ -2,8 +2,28 @@
2
2
 
3
3
  exports[`returnQuestionFeedback utils return the deepest returnQuestion with feedback recursively 1`] = `
4
4
  [
5
- undefined,
6
- false,
5
+ {
6
+ "children": [
7
+ {
8
+ "id": "68c0bb98-b00a-4b86-af43-528fe903cb69",
9
+ "translationKey": "size_overall",
10
+ "type": "OPTION",
11
+ },
12
+ {
13
+ "id": "85e84a77-461c-41e6-8544-95b5294d0b80",
14
+ "translationKey": "size_trousers_too_long",
15
+ "type": "OPTION",
16
+ },
17
+ {
18
+ "id": "29441d25-8d9f-471e-a13e-a03f61c88091",
19
+ "translationKey": "size_fit_cut_does_not_fit",
20
+ "type": "OPTION",
21
+ },
22
+ ],
23
+ "id": "542c4d24-e1da-484f-8c3a-7d89ee135adc",
24
+ "type": "HOST_STACK",
25
+ },
26
+ true,
7
27
  ]
8
28
  `;
9
29
 
@@ -1,10 +1,7 @@
1
1
  import { isUuid } from "@lookiero/sty-psp-uuid";
2
2
  import { FeedbackProjection } from "../../../../../../projection/feedback/feedback";
3
3
  import { ReturnQuestionProjection } from "../../../../../../projection/returnQuestion/returnQuestion";
4
- import {
5
- returnQuestionHasChildren,
6
- returnQuestionWithTranslationKey,
7
- } from "../../../../../../projection/returnQuestion/returnQuestion.typeguard";
4
+ import { returnQuestionHasChildren } from "../../../../../../projection/returnQuestion/returnQuestion.typeguard";
8
5
 
9
6
  interface RecursiveFeedbackForReturnQuestionFunctionArgs {
10
7
  readonly feedback: FeedbackProjection;
@@ -36,9 +33,7 @@ const feedbackForReturnQuestion: RecursiveFeedbackForReturnQuestionFunction = ({
36
33
  if (feebackReturnQuestionChild) {
37
34
  return [
38
35
  ...acc,
39
- ...(returnQuestionWithTranslationKey(feebackReturnQuestionChild)
40
- ? [translate(feebackReturnQuestionChild.translationKey)]
41
- : []),
36
+ ...(feebackReturnQuestionChild.translationKey ? [translate(feebackReturnQuestionChild.translationKey)] : []),
42
37
  ...feedbackForReturnQuestion({ feedback, returnQuestion: feebackReturnQuestionChild, translate, acc }),
43
38
  ];
44
39
  }
@@ -9,8 +9,8 @@ import { Customer } from "../../../../projection/customer/customer";
9
9
  import { useGiveCheckoutFeedback } from "../../../domain/checkoutFeedback/react/useGiveCheckoutFeedback";
10
10
  import { checkout } from "../../../projection/checkout/checkout.mock";
11
11
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
12
- import { checkoutQuestions as checkoutQuestionsMock } from "../../../projection/checkoutQuestion/checkoutQuestions.mock";
13
- import { useListCheckoutQuestionsByCheckoutId } from "../../../projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId";
12
+ import { checkoutFeedbackDefinition as checkoutFeedbackDefinitionMock } from "../../../projection/checkoutFeedback/checkoutFeedbackDefinition.mock";
13
+ import { useViewCheckoutFeedbackDefinitionByCheckoutId } from "../../../projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId";
14
14
  import { I18nMessages } from "../../i18n/i18n";
15
15
  import { render } from "../../test/render";
16
16
  import { Feedback } from "./Feedback";
@@ -37,7 +37,7 @@ jest.mock("../../hooks/useStaticInfo", () => ({
37
37
  }));
38
38
 
39
39
  jest.mock("../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId");
40
- jest.mock("../../../projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId");
40
+ jest.mock("../../../projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId");
41
41
  jest.mock("../../../domain/checkoutFeedback/react/useGiveCheckoutFeedback");
42
42
 
43
43
  const mockTrackPressContinue = jest.fn();
@@ -69,7 +69,10 @@ afterAll(() => {
69
69
  describe("Feedback view", () => {
70
70
  test("renders correctly", async () => {
71
71
  (useViewFirstAvailableCheckoutByCustomerId as jest.Mock).mockReturnValue([checkoutMock, QueryStatus.SUCCESS]);
72
- (useListCheckoutQuestionsByCheckoutId as jest.Mock).mockReturnValue([checkoutQuestionsMock, QueryStatus.SUCCESS]);
72
+ (useViewCheckoutFeedbackDefinitionByCheckoutId as jest.Mock).mockReturnValue([
73
+ checkoutFeedbackDefinitionMock,
74
+ QueryStatus.SUCCESS,
75
+ ]);
73
76
  (useGiveCheckoutFeedback as jest.Mock).mockReturnValue([mockGiveCheckoutFeedback, CommandStatus.SUCCESS]);
74
77
 
75
78
  const { findByText, getByTestId, getByText } = render(<Feedback layout={DummyLayout} />);
@@ -116,7 +119,10 @@ describe("Feedback view", () => {
116
119
 
117
120
  test("calls giveCheckoutFeedback with an empty feedback when unmounted", async () => {
118
121
  (useViewFirstAvailableCheckoutByCustomerId as jest.Mock).mockReturnValue([checkoutMock, QueryStatus.SUCCESS]);
119
- (useListCheckoutQuestionsByCheckoutId as jest.Mock).mockReturnValue([checkoutQuestionsMock, QueryStatus.SUCCESS]);
122
+ (useViewCheckoutFeedbackDefinitionByCheckoutId as jest.Mock).mockReturnValue([
123
+ checkoutFeedbackDefinitionMock,
124
+ QueryStatus.SUCCESS,
125
+ ]);
120
126
  (useGiveCheckoutFeedback as jest.Mock).mockReturnValue([mockGiveCheckoutFeedback, CommandStatus.SUCCESS]);
121
127
 
122
128
  const { unmount } = render(<Feedback layout={DummyLayout} />);
@@ -4,10 +4,10 @@ import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
4
4
  import { useLogger } from "@lookiero/sty-psp-logging";
5
5
  import { Layout as UiLayout, useScreenSize } from "@lookiero/sty-psp-ui";
6
6
  import { CheckoutFeedbackProjection } from "../../../../projection/checkoutFeedback/checkoutFeedback";
7
- import { CheckoutQuestionType } from "../../../../projection/checkoutQuestion/checkoutQuestion";
7
+ import { CheckoutFeedbackQuestionType } from "../../../../projection/checkoutFeedback/checkoutFeedback.constants";
8
8
  import { useGiveCheckoutFeedback } from "../../../domain/checkoutFeedback/react/useGiveCheckoutFeedback";
9
9
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
10
- import { useListCheckoutQuestionsByCheckoutId } from "../../../projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId";
10
+ import { useViewCheckoutFeedbackDefinitionByCheckoutId } from "../../../projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId";
11
11
  import { TrackingPage } from "../../../tracking/tracking";
12
12
  import { useTrackChangeFeedback } from "../../../tracking/useTrackChangeFeedback";
13
13
  import { useTrackPageView } from "../../../tracking/useTrackPageView";
@@ -43,7 +43,7 @@ const Feedback: FC<FeedbackProps> = ({ layout: Layout }) => {
43
43
  const style = useMemo(() => feedbackStyle(), []);
44
44
 
45
45
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
46
- const [checkoutQuestions, checkoutQuestionsStatus] = useListCheckoutQuestionsByCheckoutId({
46
+ const [checkoutFeedbackDefinition, checkoutFeedbackDefinitionStatus] = useViewCheckoutFeedbackDefinitionByCheckoutId({
47
47
  checkoutId: checkout?.id as string,
48
48
  });
49
49
 
@@ -64,19 +64,19 @@ const Feedback: FC<FeedbackProps> = ({ layout: Layout }) => {
64
64
  });
65
65
  const handleOnChangedFeedback: HandleOnChangedFeedbackFunction = useCallback(
66
66
  ({ checkoutQuestionId, checkoutQuestionFeedback, hasFeedback }) => {
67
- const question = checkoutQuestions?.find((question) => question.id === checkoutQuestionId);
67
+ const question = checkoutFeedbackDefinition?.find((question) => question.id === checkoutQuestionId);
68
68
 
69
- if (question?.type === CheckoutQuestionType.HOST_TEXTAREA && hasFeedback) {
69
+ if (question?.type === CheckoutFeedbackQuestionType.HOST_TEXTAREA && hasFeedback) {
70
70
  return;
71
71
  }
72
72
 
73
73
  trackChangeFeedback({
74
74
  questionId: checkoutQuestionId,
75
- questionName: question?.name as string,
75
+ questionName: question?.translationKey || "",
76
76
  feedback: checkoutQuestionFeedback,
77
77
  });
78
78
  },
79
- [checkoutQuestions, trackChangeFeedback],
79
+ [checkoutFeedbackDefinition, trackChangeFeedback],
80
80
  );
81
81
 
82
82
  const [giveCheckoutFeedback, giveCheckoutFeedbackStatus] = useGiveCheckoutFeedback({
@@ -117,7 +117,8 @@ const Feedback: FC<FeedbackProps> = ({ layout: Layout }) => {
117
117
 
118
118
  const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
119
119
  const dependenciesLoaded =
120
- dependenciesLoadedStatuses.includes(checkoutStatus) && dependenciesLoadedStatuses.includes(checkoutQuestionsStatus);
120
+ dependenciesLoadedStatuses.includes(checkoutStatus) &&
121
+ dependenciesLoadedStatuses.includes(checkoutFeedbackDefinitionStatus);
121
122
 
122
123
  if (!dependenciesLoaded) return <Spinner />;
123
124
 
@@ -126,7 +127,7 @@ const Feedback: FC<FeedbackProps> = ({ layout: Layout }) => {
126
127
  <Layout>
127
128
  <Body style={{ row: [style.container, isDesktop && style.containerDesktop] }}>
128
129
  <CheckoutQuestionsForm
129
- checkoutQuestions={checkoutQuestions || []}
130
+ checkoutQuestions={checkoutFeedbackDefinition || []}
130
131
  submitButtonDisabled={giveCheckoutFeedbackStatus === CommandStatus.LOADING}
131
132
  onSubmit={handleOnSubmit}
132
133
  />
@@ -1,6 +1,6 @@
1
1
  import { fireEvent } from "@testing-library/react-native";
2
2
  import React, { ReactNode } from "react";
3
- import { checkoutQuestions } from "../../../../../projection/checkoutQuestion/checkoutQuestions.mock";
3
+ import { checkoutFeedbackDefinition } from "../../../../../projection/checkoutFeedback/checkoutFeedbackDefinition.mock";
4
4
  import { CheckoutQuestionFeedbackProvider } from "../../../../components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionFeedback";
5
5
  import { I18nMessages } from "../../../../i18n/i18n";
6
6
  import { render } from "../../../../test/render";
@@ -16,7 +16,7 @@ describe("CheckoutQuestionsForm component)", () => {
16
16
  test("renders correctly", async () => {
17
17
  const { getByText, getByTestId, queryByText } = render(
18
18
  <CheckoutQuestionsForm
19
- checkoutQuestions={checkoutQuestions}
19
+ checkoutQuestions={checkoutFeedbackDefinition}
20
20
  submitButtonDisabled={false}
21
21
  onSubmit={mockOnSubmit}
22
22
  />,
@@ -2,11 +2,11 @@ import React, { FC, useCallback, useMemo } from "react";
2
2
  import { View } from "react-native";
3
3
  import { Button } from "@lookiero/aurora";
4
4
  import { useI18nMessage } from "@lookiero/i18n-react";
5
- import { CheckoutFeedbackProjection } from "../../../../../../projection/checkoutFeedback/checkoutFeedback";
6
5
  import {
7
- CheckoutQuestionProjection,
8
- CheckoutQuestionType,
9
- } from "../../../../../../projection/checkoutQuestion/checkoutQuestion";
6
+ CheckoutFeedbackProjection,
7
+ CheckoutFeedbackQuestionProjection,
8
+ } from "../../../../../../projection/checkoutFeedback/checkoutFeedback";
9
+ import { CheckoutFeedbackQuestionType } from "../../../../../../projection/checkoutFeedback/checkoutFeedback.constants";
10
10
  import { CheckoutQuestions } from "../../../../components/organisms/checkoutQuestions/CheckoutQuestions";
11
11
  import { useCheckoutQuestionFeedback } from "../../../../components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionFeedback";
12
12
  import {
@@ -21,16 +21,16 @@ import { TextareaCheckoutQuestionItem } from "../../../../components/organisms/c
21
21
  import { DOMAIN, I18nMessages } from "../../../../i18n/i18n";
22
22
 
23
23
  const checkoutQuestionItems: CheckoutQuestionItems = {
24
- [CheckoutQuestionType.HOST_DEFAULT]: HostDefaultCheckoutQuestionItem,
25
- [CheckoutQuestionType.HOST_TEXTAREA]: HostDefaultCheckoutQuestionItem,
26
- [CheckoutQuestionType.HOST_SELECT]: HostSelectCheckoutQuestionItem,
27
- [CheckoutQuestionType.TEXTAREA]: TextareaCheckoutQuestionItem,
28
- [CheckoutQuestionType.ICON]: IconCheckoutQuestionItem,
29
- [CheckoutQuestionType.BUTTON]: ButtonCheckoutQuestionItem,
24
+ [CheckoutFeedbackQuestionType.HOST_DEFAULT]: HostDefaultCheckoutQuestionItem,
25
+ [CheckoutFeedbackQuestionType.HOST_TEXTAREA]: HostDefaultCheckoutQuestionItem,
26
+ [CheckoutFeedbackQuestionType.HOST_SELECT]: HostSelectCheckoutQuestionItem,
27
+ [CheckoutFeedbackQuestionType.TEXTAREA]: TextareaCheckoutQuestionItem,
28
+ [CheckoutFeedbackQuestionType.ICON]: IconCheckoutQuestionItem,
29
+ [CheckoutFeedbackQuestionType.BUTTON]: ButtonCheckoutQuestionItem,
30
30
  };
31
31
 
32
32
  interface CheckoutQuestionsFormProps {
33
- readonly checkoutQuestions: CheckoutQuestionProjection[];
33
+ readonly checkoutQuestions: CheckoutFeedbackQuestionProjection[];
34
34
  readonly submitButtonDisabled: boolean;
35
35
  readonly onSubmit: (feedback: CheckoutFeedbackProjection) => void;
36
36
  }
@@ -49,8 +49,15 @@ const CheckoutQuestionsForm: FC<CheckoutQuestionsFormProps> = ({
49
49
 
50
50
  return checkoutQuestions.filter(
51
51
  (checkoutQuestion) =>
52
- checkoutQuestion.showCondition.length === 0 ||
53
- checkoutQuestion.showCondition.some((condition) => responses.includes(condition)),
52
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
53
+ // @ts-ignore
54
+ !checkoutQuestion?.metadata?.showCondition ||
55
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
56
+ // @ts-ignore
57
+ checkoutQuestion?.metadata?.showCondition.length === 0 ||
58
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
59
+ // @ts-ignore
60
+ checkoutQuestion?.metadata?.showCondition.some((condition) => responses.includes(condition)),
54
61
  );
55
62
  }, [checkoutQuestions, feedback]);
56
63
 
@@ -22,6 +22,7 @@ const returnQuestionItems: ReturnQuestionItems = {
22
22
  [ReturnQuestionType.HOST_STACK]: ReturnQuestionFeedbackItem,
23
23
  [ReturnQuestionType.TEXTAREA]: ReturnQuestionFeedbackItem,
24
24
  [ReturnQuestionType.OPTION]: ReturnQuestionFeedbackItem,
25
+ [ReturnQuestionType.HOST_RADIO_GROUP]: ReturnQuestionFeedbackItem,
25
26
  };
26
27
 
27
28
  interface ReturnQuestionsFeedbackProps {
@@ -27,6 +27,7 @@ import {
27
27
  ReturnQuestionItems,
28
28
  } from "../../../../components/organisms/returnQuestions/behaviors/useReturnQuestionItem";
29
29
  import { HostDefaultReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem";
30
+ import { HostLegacyRadioGroupReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/hostLegacyRadioGroupReturnQuestionItem/HostLegacyRadioGroupReturnQuestionItem";
30
31
  import { HostRadioGroupReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem";
31
32
  import { HostStackReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/hostStackReturnQuestionItem/form/HostStackReturnQuestionItem";
32
33
  import { RadioReturnQuestionItem } from "../../../../components/organisms/returnQuestions/components/radioReturnQuestionItem/RadioReturnQuestionItem";
@@ -43,7 +44,8 @@ const RETURN_QUESTION_FORM_PORTAL_HOST_NAME = "return-question-form-portal";
43
44
  const returnQuestionItems: ReturnQuestionItems = {
44
45
  [ReturnQuestionType.HOST_DEFAULT]: HostDefaultReturnQuestionItem,
45
46
  [ReturnQuestionType.HOST_TEXTAREA]: HostDefaultReturnQuestionItem,
46
- [ReturnQuestionType.HOST_SELECT]: HostRadioGroupReturnQuestionItem,
47
+ [ReturnQuestionType.HOST_SELECT]: HostLegacyRadioGroupReturnQuestionItem,
48
+ [ReturnQuestionType.HOST_RADIO_GROUP]: HostRadioGroupReturnQuestionItem,
47
49
  [ReturnQuestionType.HOST_STACK]: HostStackReturnQuestionItem,
48
50
  [ReturnQuestionType.TEXTAREA]: TextareaReturnQuestionItem,
49
51
  [ReturnQuestionType.OPTION]: RadioReturnQuestionItem,
@@ -0,0 +1,16 @@
1
+ enum CheckoutFeedbackQuestionType {
2
+ HOST_DEFAULT = "HOST_DEFAULT",
3
+ HOST_TEXTAREA = "HOST_TEXTAREA",
4
+ HOST_SELECT = "HOST_SELECT",
5
+ TEXTAREA = "TEXTAREA",
6
+ ICON = "ICON",
7
+ BUTTON = "BUTTON",
8
+ }
9
+
10
+ type CheckoutFeedbackQuestionIcon =
11
+ | "checkout_feedback.icon.bad"
12
+ | "checkout_feedback.icon.regular"
13
+ | "checkout_feedback.icon.good";
14
+
15
+ export type { CheckoutFeedbackQuestionIcon };
16
+ export { CheckoutFeedbackQuestionType };
@@ -0,0 +1,28 @@
1
+ import { EmptyObject } from "@lookiero/sty-psp-typescript";
2
+ import { CheckoutFeedbackQuestionIcon, CheckoutFeedbackQuestionType } from "./checkoutFeedback.constants";
3
+
4
+ type MetadataDictionary = Record<CheckoutFeedbackQuestionType, EmptyObject>;
5
+
6
+ interface ComponentWithPlaceholder {
7
+ readonly placeholder: string;
8
+ }
9
+
10
+ interface ComponentCondition {
11
+ readonly showCondition: string[];
12
+ }
13
+
14
+ interface ComponentIcon {
15
+ readonly icon: CheckoutFeedbackQuestionIcon;
16
+ }
17
+
18
+ type ComponentMetadata = MetadataDictionary & {
19
+ [CheckoutFeedbackQuestionType.HOST_DEFAULT]: ComponentCondition;
20
+ [CheckoutFeedbackQuestionType.HOST_TEXTAREA]: ComponentCondition;
21
+ [CheckoutFeedbackQuestionType.HOST_SELECT]: ComponentCondition & ComponentWithPlaceholder;
22
+ [CheckoutFeedbackQuestionType.TEXTAREA]: ComponentWithPlaceholder;
23
+ [CheckoutFeedbackQuestionType.ICON]: ComponentIcon;
24
+ };
25
+
26
+ type Metadata<CFDT extends CheckoutFeedbackQuestionType> = ComponentMetadata[CFDT];
27
+
28
+ export type { Metadata, ComponentCondition };
@@ -1,5 +1,41 @@
1
+ import { EmptyObject, ExcludePropertyIfOptional, NonEmptyArray } from "@lookiero/sty-psp-typescript";
1
2
  import { FeedbackProjection } from "../feedback/feedback";
3
+ import { CheckoutFeedbackQuestionType } from "./checkoutFeedback.constants";
4
+ import { Metadata } from "./checkoutFeedback.metadata";
2
5
 
3
- type CheckoutFeedbackProjection = FeedbackProjection;
6
+ type CheckoutFeedback = FeedbackProjection;
4
7
 
5
- export type { CheckoutFeedbackProjection };
8
+ type CheckoutFeedbackQuestionTypesWithChildren =
9
+ | CheckoutFeedbackQuestionType.HOST_DEFAULT
10
+ | CheckoutFeedbackQuestionType.HOST_TEXTAREA
11
+ | CheckoutFeedbackQuestionType.HOST_SELECT;
12
+
13
+ type CheckoutFeedbackQuestionTypesWithOptionalTranslationKeys = CheckoutFeedbackQuestionType.ICON;
14
+
15
+ type CheckoutFeedbackQuestionMetadata<CFDT extends CheckoutFeedbackQuestionType> = ExcludePropertyIfOptional<
16
+ "metadata",
17
+ { readonly metadata: Metadata<CFDT> }
18
+ >;
19
+
20
+ type CheckoutFeedbackQuestionTypeChildren<QT extends CheckoutFeedbackQuestionType> =
21
+ QT extends CheckoutFeedbackQuestionTypesWithChildren
22
+ ? { readonly children: NonEmptyArray<CheckoutFeedbackQuestion> }
23
+ : EmptyObject;
24
+
25
+ type CheckoutFeedbackQuestionTypeTranslationKey<QT extends CheckoutFeedbackQuestionType> =
26
+ QT extends CheckoutFeedbackQuestionTypesWithOptionalTranslationKeys
27
+ ? { readonly translationKey?: string }
28
+ : { readonly translationKey: string };
29
+
30
+ type CheckoutFeedbackQuestion<CFDT extends CheckoutFeedbackQuestionType = CheckoutFeedbackQuestionType> =
31
+ CFDT extends infer K extends CheckoutFeedbackQuestionType
32
+ ? { readonly id: string; readonly type: K } & CheckoutFeedbackQuestionTypeTranslationKey<K> &
33
+ CheckoutFeedbackQuestionTypeChildren<K> &
34
+ CheckoutFeedbackQuestionMetadata<K>
35
+ : never;
36
+
37
+ export type {
38
+ CheckoutFeedback as CheckoutFeedbackProjection,
39
+ CheckoutFeedbackQuestion as CheckoutFeedbackQuestionProjection,
40
+ CheckoutFeedbackQuestionTypesWithChildren,
41
+ };
@@ -0,0 +1,13 @@
1
+ import { CheckoutFeedbackQuestionProjection, CheckoutFeedbackQuestionTypesWithChildren } from "./checkoutFeedback";
2
+ import { CheckoutFeedbackQuestionType } from "./checkoutFeedback.constants";
3
+
4
+ const checkoutFeedbackQuestionHasChildren = (
5
+ question: CheckoutFeedbackQuestionProjection,
6
+ ): question is CheckoutFeedbackQuestionProjection<CheckoutFeedbackQuestionTypesWithChildren> =>
7
+ [
8
+ CheckoutFeedbackQuestionType.HOST_DEFAULT,
9
+ CheckoutFeedbackQuestionType.HOST_SELECT,
10
+ CheckoutFeedbackQuestionType.HOST_TEXTAREA,
11
+ ].includes(question.type);
12
+
13
+ export { checkoutFeedbackQuestionHasChildren };