@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
@@ -3,10 +3,10 @@ import { Spinner } from "@lookiero/aurora";
3
3
  import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
4
4
  import { useLogger } from "@lookiero/sty-psp-logging";
5
5
  import { useScreenSize } from "@lookiero/sty-psp-ui";
6
- import { CheckoutQuestionType } from "../../../../projection/checkoutQuestion/checkoutQuestion";
6
+ import { CheckoutFeedbackQuestionType } from "../../../../projection/checkoutFeedback/checkoutFeedback.constants";
7
7
  import { useGiveCheckoutFeedback } from "../../../domain/checkoutFeedback/react/useGiveCheckoutFeedback";
8
8
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
9
- import { useListCheckoutQuestionsByCheckoutId } from "../../../projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId";
9
+ import { useViewCheckoutFeedbackDefinitionByCheckoutId } from "../../../projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId";
10
10
  import { TrackingPage } from "../../../tracking/tracking";
11
11
  import { useTrackChangeFeedback } from "../../../tracking/useTrackChangeFeedback";
12
12
  import { useTrackPageView } from "../../../tracking/useTrackPageView";
@@ -23,7 +23,7 @@ const Feedback = ({ layout: Layout }) => {
23
23
  const { customer: { customerId, country, segment }, tradename, } = useStaticInfo();
24
24
  const style = useMemo(() => feedbackStyle(), []);
25
25
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
26
- const [checkoutQuestions, checkoutQuestionsStatus] = useListCheckoutQuestionsByCheckoutId({
26
+ const [checkoutFeedbackDefinition, checkoutFeedbackDefinitionStatus] = useViewCheckoutFeedbackDefinitionByCheckoutId({
27
27
  checkoutId: checkout?.id,
28
28
  });
29
29
  useTrackPageView({
@@ -41,16 +41,16 @@ const Feedback = ({ layout: Layout }) => {
41
41
  tradename,
42
42
  });
43
43
  const handleOnChangedFeedback = useCallback(({ checkoutQuestionId, checkoutQuestionFeedback, hasFeedback }) => {
44
- const question = checkoutQuestions?.find((question) => question.id === checkoutQuestionId);
45
- if (question?.type === CheckoutQuestionType.HOST_TEXTAREA && hasFeedback) {
44
+ const question = checkoutFeedbackDefinition?.find((question) => question.id === checkoutQuestionId);
45
+ if (question?.type === CheckoutFeedbackQuestionType.HOST_TEXTAREA && hasFeedback) {
46
46
  return;
47
47
  }
48
48
  trackChangeFeedback({
49
49
  questionId: checkoutQuestionId,
50
- questionName: question?.name,
50
+ questionName: question?.translationKey || "",
51
51
  feedback: checkoutQuestionFeedback,
52
52
  });
53
- }, [checkoutQuestions, trackChangeFeedback]);
53
+ }, [checkoutFeedbackDefinition, trackChangeFeedback]);
54
54
  const [giveCheckoutFeedback, giveCheckoutFeedbackStatus] = useGiveCheckoutFeedback({
55
55
  checkoutId: checkout?.id,
56
56
  logger,
@@ -81,12 +81,13 @@ const Feedback = ({ layout: Layout }) => {
81
81
  }
82
82
  }, [giveCheckoutFeedback]);
83
83
  const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
84
- const dependenciesLoaded = dependenciesLoadedStatuses.includes(checkoutStatus) && dependenciesLoadedStatuses.includes(checkoutQuestionsStatus);
84
+ const dependenciesLoaded = dependenciesLoadedStatuses.includes(checkoutStatus) &&
85
+ dependenciesLoadedStatuses.includes(checkoutFeedbackDefinitionStatus);
85
86
  if (!dependenciesLoaded)
86
87
  return React.createElement(Spinner, null);
87
88
  return (React.createElement(CheckoutQuestionFeedbackProvider, { onChanged: handleOnChangedFeedback },
88
89
  React.createElement(Layout, null,
89
90
  React.createElement(Body, { style: { row: [style.container, isDesktop && style.containerDesktop] } },
90
- React.createElement(CheckoutQuestionsForm, { checkoutQuestions: checkoutQuestions || [], submitButtonDisabled: giveCheckoutFeedbackStatus === CommandStatus.LOADING, onSubmit: handleOnSubmit })))));
91
+ React.createElement(CheckoutQuestionsForm, { checkoutQuestions: checkoutFeedbackDefinition || [], submitButtonDisabled: giveCheckoutFeedbackStatus === CommandStatus.LOADING, onSubmit: handleOnSubmit })))));
91
92
  };
92
93
  export { Feedback };
@@ -1,8 +1,7 @@
1
1
  import { FC } from "react";
2
- import { CheckoutFeedbackProjection } from "../../../../../../projection/checkoutFeedback/checkoutFeedback";
3
- import { CheckoutQuestionProjection } from "../../../../../../projection/checkoutQuestion/checkoutQuestion";
2
+ import { CheckoutFeedbackProjection, CheckoutFeedbackQuestionProjection } from "../../../../../../projection/checkoutFeedback/checkoutFeedback";
4
3
  interface CheckoutQuestionsFormProps {
5
- readonly checkoutQuestions: CheckoutQuestionProjection[];
4
+ readonly checkoutQuestions: CheckoutFeedbackQuestionProjection[];
6
5
  readonly submitButtonDisabled: boolean;
7
6
  readonly onSubmit: (feedback: CheckoutFeedbackProjection) => void;
8
7
  }
@@ -2,7 +2,7 @@ import React, { 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 { CheckoutQuestionType, } from "../../../../../../projection/checkoutQuestion/checkoutQuestion";
5
+ import { CheckoutFeedbackQuestionType } from "../../../../../../projection/checkoutFeedback/checkoutFeedback.constants";
6
6
  import { CheckoutQuestions } from "../../../../components/organisms/checkoutQuestions/CheckoutQuestions";
7
7
  import { useCheckoutQuestionFeedback } from "../../../../components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionFeedback";
8
8
  import { CheckoutQuestionItemProvider, } from "../../../../components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem";
@@ -13,12 +13,12 @@ import { IconCheckoutQuestionItem } from "../../../../components/organisms/check
13
13
  import { TextareaCheckoutQuestionItem } from "../../../../components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem";
14
14
  import { DOMAIN, I18nMessages } from "../../../../i18n/i18n";
15
15
  const checkoutQuestionItems = {
16
- [CheckoutQuestionType.HOST_DEFAULT]: HostDefaultCheckoutQuestionItem,
17
- [CheckoutQuestionType.HOST_TEXTAREA]: HostDefaultCheckoutQuestionItem,
18
- [CheckoutQuestionType.HOST_SELECT]: HostSelectCheckoutQuestionItem,
19
- [CheckoutQuestionType.TEXTAREA]: TextareaCheckoutQuestionItem,
20
- [CheckoutQuestionType.ICON]: IconCheckoutQuestionItem,
21
- [CheckoutQuestionType.BUTTON]: ButtonCheckoutQuestionItem,
16
+ [CheckoutFeedbackQuestionType.HOST_DEFAULT]: HostDefaultCheckoutQuestionItem,
17
+ [CheckoutFeedbackQuestionType.HOST_TEXTAREA]: HostDefaultCheckoutQuestionItem,
18
+ [CheckoutFeedbackQuestionType.HOST_SELECT]: HostSelectCheckoutQuestionItem,
19
+ [CheckoutFeedbackQuestionType.TEXTAREA]: TextareaCheckoutQuestionItem,
20
+ [CheckoutFeedbackQuestionType.ICON]: IconCheckoutQuestionItem,
21
+ [CheckoutFeedbackQuestionType.BUTTON]: ButtonCheckoutQuestionItem,
22
22
  };
23
23
  const CheckoutQuestionsForm = ({ checkoutQuestions, submitButtonDisabled, onSubmit, }) => {
24
24
  const buttonText = useI18nMessage({ domain: DOMAIN, id: I18nMessages.FEEDBACK_BUTTON });
@@ -26,8 +26,16 @@ const CheckoutQuestionsForm = ({ checkoutQuestions, submitButtonDisabled, onSubm
26
26
  const handlePress = useCallback(() => onSubmit(feedback), [feedback, onSubmit]);
27
27
  const filteredCheckoutQuestions = useMemo(() => {
28
28
  const responses = Object.values(feedback);
29
- return checkoutQuestions.filter((checkoutQuestion) => checkoutQuestion.showCondition.length === 0 ||
30
- checkoutQuestion.showCondition.some((condition) => responses.includes(condition)));
29
+ return checkoutQuestions.filter((checkoutQuestion) =>
30
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
31
+ // @ts-ignore
32
+ !checkoutQuestion?.metadata?.showCondition ||
33
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
34
+ // @ts-ignore
35
+ checkoutQuestion?.metadata?.showCondition.length === 0 ||
36
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
37
+ // @ts-ignore
38
+ checkoutQuestion?.metadata?.showCondition.some((condition) => responses.includes(condition)));
31
39
  }, [checkoutQuestions, feedback]);
32
40
  return (React.createElement(View, { testID: "checkout-questions-form" },
33
41
  React.createElement(CheckoutQuestionItemProvider, { checkoutQuestionItems: checkoutQuestionItems },
@@ -0,0 +1,11 @@
1
+ declare 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
+ type CheckoutFeedbackQuestionIcon = "checkout_feedback.icon.bad" | "checkout_feedback.icon.regular" | "checkout_feedback.icon.good";
10
+ export type { CheckoutFeedbackQuestionIcon };
11
+ export { CheckoutFeedbackQuestionType };
@@ -0,0 +1,10 @@
1
+ var CheckoutFeedbackQuestionType;
2
+ (function (CheckoutFeedbackQuestionType) {
3
+ CheckoutFeedbackQuestionType["HOST_DEFAULT"] = "HOST_DEFAULT";
4
+ CheckoutFeedbackQuestionType["HOST_TEXTAREA"] = "HOST_TEXTAREA";
5
+ CheckoutFeedbackQuestionType["HOST_SELECT"] = "HOST_SELECT";
6
+ CheckoutFeedbackQuestionType["TEXTAREA"] = "TEXTAREA";
7
+ CheckoutFeedbackQuestionType["ICON"] = "ICON";
8
+ CheckoutFeedbackQuestionType["BUTTON"] = "BUTTON";
9
+ })(CheckoutFeedbackQuestionType || (CheckoutFeedbackQuestionType = {}));
10
+ export { CheckoutFeedbackQuestionType };
@@ -1,3 +1,23 @@
1
+ import { EmptyObject, ExcludePropertyIfOptional, NonEmptyArray } from "@lookiero/sty-psp-typescript";
1
2
  import { FeedbackProjection } from "../feedback/feedback";
2
- type CheckoutFeedbackProjection = FeedbackProjection;
3
- export type { CheckoutFeedbackProjection };
3
+ import { CheckoutFeedbackQuestionType } from "./checkoutFeedback.constants";
4
+ import { Metadata } from "./checkoutFeedback.metadata";
5
+ type CheckoutFeedback = FeedbackProjection;
6
+ type CheckoutFeedbackQuestionTypesWithChildren = CheckoutFeedbackQuestionType.HOST_DEFAULT | CheckoutFeedbackQuestionType.HOST_TEXTAREA | CheckoutFeedbackQuestionType.HOST_SELECT;
7
+ type CheckoutFeedbackQuestionTypesWithOptionalTranslationKeys = CheckoutFeedbackQuestionType.ICON;
8
+ type CheckoutFeedbackQuestionMetadata<CFDT extends CheckoutFeedbackQuestionType> = ExcludePropertyIfOptional<"metadata", {
9
+ readonly metadata: Metadata<CFDT>;
10
+ }>;
11
+ type CheckoutFeedbackQuestionTypeChildren<QT extends CheckoutFeedbackQuestionType> = QT extends CheckoutFeedbackQuestionTypesWithChildren ? {
12
+ readonly children: NonEmptyArray<CheckoutFeedbackQuestion>;
13
+ } : EmptyObject;
14
+ type CheckoutFeedbackQuestionTypeTranslationKey<QT extends CheckoutFeedbackQuestionType> = QT extends CheckoutFeedbackQuestionTypesWithOptionalTranslationKeys ? {
15
+ readonly translationKey?: string;
16
+ } : {
17
+ readonly translationKey: string;
18
+ };
19
+ type CheckoutFeedbackQuestion<CFDT extends CheckoutFeedbackQuestionType = CheckoutFeedbackQuestionType> = CFDT extends infer K extends CheckoutFeedbackQuestionType ? {
20
+ readonly id: string;
21
+ readonly type: K;
22
+ } & CheckoutFeedbackQuestionTypeTranslationKey<K> & CheckoutFeedbackQuestionTypeChildren<K> & CheckoutFeedbackQuestionMetadata<K> : never;
23
+ export type { CheckoutFeedback as CheckoutFeedbackProjection, CheckoutFeedbackQuestion as CheckoutFeedbackQuestionProjection, CheckoutFeedbackQuestionTypesWithChildren, };
@@ -0,0 +1,21 @@
1
+ import { EmptyObject } from "@lookiero/sty-psp-typescript";
2
+ import { CheckoutFeedbackQuestionIcon, CheckoutFeedbackQuestionType } from "./checkoutFeedback.constants";
3
+ type MetadataDictionary = Record<CheckoutFeedbackQuestionType, EmptyObject>;
4
+ interface ComponentWithPlaceholder {
5
+ readonly placeholder: string;
6
+ }
7
+ interface ComponentCondition {
8
+ readonly showCondition: string[];
9
+ }
10
+ interface ComponentIcon {
11
+ readonly icon: CheckoutFeedbackQuestionIcon;
12
+ }
13
+ type ComponentMetadata = MetadataDictionary & {
14
+ [CheckoutFeedbackQuestionType.HOST_DEFAULT]: ComponentCondition;
15
+ [CheckoutFeedbackQuestionType.HOST_TEXTAREA]: ComponentCondition;
16
+ [CheckoutFeedbackQuestionType.HOST_SELECT]: ComponentCondition & ComponentWithPlaceholder;
17
+ [CheckoutFeedbackQuestionType.TEXTAREA]: ComponentWithPlaceholder;
18
+ [CheckoutFeedbackQuestionType.ICON]: ComponentIcon;
19
+ };
20
+ type Metadata<CFDT extends CheckoutFeedbackQuestionType> = ComponentMetadata[CFDT];
21
+ export type { Metadata, ComponentCondition };
@@ -0,0 +1 @@
1
+ import { CheckoutFeedbackQuestionType } from "./checkoutFeedback.constants";
@@ -0,0 +1,3 @@
1
+ import { CheckoutFeedbackQuestionProjection, CheckoutFeedbackQuestionTypesWithChildren } from "./checkoutFeedback";
2
+ declare const checkoutFeedbackQuestionHasChildren: (question: CheckoutFeedbackQuestionProjection) => question is CheckoutFeedbackQuestionProjection<CheckoutFeedbackQuestionTypesWithChildren>;
3
+ export { checkoutFeedbackQuestionHasChildren };
@@ -0,0 +1,7 @@
1
+ import { CheckoutFeedbackQuestionType } from "./checkoutFeedback.constants";
2
+ const checkoutFeedbackQuestionHasChildren = (question) => [
3
+ CheckoutFeedbackQuestionType.HOST_DEFAULT,
4
+ CheckoutFeedbackQuestionType.HOST_SELECT,
5
+ CheckoutFeedbackQuestionType.HOST_TEXTAREA,
6
+ ].includes(question.type);
7
+ export { checkoutFeedbackQuestionHasChildren };
@@ -0,0 +1,25 @@
1
+ import { CancelableQueryViewArgs, Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
2
+ import { CheckoutFeedbackQuestionProjection } from "./checkoutFeedback";
3
+ declare const VIEW_CHECKOUT_FEEDBACK_DEFINITION_BY_CHECKOUT_ID = "view_checkout_feedback_definition_by_checkout_id";
4
+ interface ViewCheckoutFeedbackDefinitionByCheckoutIdPayload {
5
+ readonly checkoutId: string;
6
+ }
7
+ interface ViewCheckoutFeedbackDefinitionByCheckoutId extends Query<typeof VIEW_CHECKOUT_FEEDBACK_DEFINITION_BY_CHECKOUT_ID>, ViewCheckoutFeedbackDefinitionByCheckoutIdPayload {
8
+ }
9
+ interface ViewCheckoutFeedbackDefinitionByCheckoutIdFunction {
10
+ (payload: ViewCheckoutFeedbackDefinitionByCheckoutIdPayload): ViewCheckoutFeedbackDefinitionByCheckoutId;
11
+ }
12
+ declare const viewCheckoutFeedbackDefinitionByCheckoutId: ViewCheckoutFeedbackDefinitionByCheckoutIdFunction;
13
+ type ViewCheckoutFeedbackDefinitionByCheckoutIdResult = CheckoutFeedbackQuestionProjection[] | null;
14
+ interface CheckoutFeedbackDefinitionByCheckoutIdViewArgs extends CancelableQueryViewArgs {
15
+ readonly checkoutId: string;
16
+ }
17
+ interface CheckoutFeedbackDefinitionByCheckoutIdView {
18
+ (args: CheckoutFeedbackDefinitionByCheckoutIdViewArgs): Promise<ViewCheckoutFeedbackDefinitionByCheckoutIdResult>;
19
+ }
20
+ interface ViewCheckoutFeedbackDefinitionByCheckoutIdHandlerFunctionArgs extends QueryHandlerFunctionArgs {
21
+ readonly view: CheckoutFeedbackDefinitionByCheckoutIdView;
22
+ }
23
+ declare const viewCheckoutFeedbackDefinitionByCheckoutIdHandler: QueryHandlerFunction<ViewCheckoutFeedbackDefinitionByCheckoutId, ViewCheckoutFeedbackDefinitionByCheckoutIdResult, ViewCheckoutFeedbackDefinitionByCheckoutIdHandlerFunctionArgs>;
24
+ export type { ViewCheckoutFeedbackDefinitionByCheckoutId, CheckoutFeedbackDefinitionByCheckoutIdView, ViewCheckoutFeedbackDefinitionByCheckoutIdResult, };
25
+ export { VIEW_CHECKOUT_FEEDBACK_DEFINITION_BY_CHECKOUT_ID, viewCheckoutFeedbackDefinitionByCheckoutId, viewCheckoutFeedbackDefinitionByCheckoutIdHandler, };
@@ -0,0 +1,8 @@
1
+ import { query, } from "@lookiero/messaging";
2
+ const VIEW_CHECKOUT_FEEDBACK_DEFINITION_BY_CHECKOUT_ID = "view_checkout_feedback_definition_by_checkout_id";
3
+ const viewCheckoutFeedbackDefinitionByCheckoutId = (payload) => ({
4
+ ...query({ name: VIEW_CHECKOUT_FEEDBACK_DEFINITION_BY_CHECKOUT_ID }),
5
+ ...payload,
6
+ });
7
+ const viewCheckoutFeedbackDefinitionByCheckoutIdHandler = ({ view, signal }) => async ({ checkoutId }) => view({ checkoutId, signal });
8
+ export { VIEW_CHECKOUT_FEEDBACK_DEFINITION_BY_CHECKOUT_ID, viewCheckoutFeedbackDefinitionByCheckoutId, viewCheckoutFeedbackDefinitionByCheckoutIdHandler, };
@@ -1 +1 @@
1
- export declare const VERSION = "12.3.0";
1
+ export declare const VERSION = "12.4.0";
@@ -1 +1 @@
1
- export const VERSION = "12.3.0";
1
+ export const VERSION = "12.4.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "12.3.0",
3
+ "version": "12.4.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "sideEffects": "false",
package/src/ExpoRoot.tsx CHANGED
@@ -37,7 +37,7 @@ const order: OrderProjection = {
37
37
  };
38
38
 
39
39
  const customer: Customer = {
40
- customerId: "5c38e826-3d01-4a4b-a3d1-8a4166dc2a31",
40
+ customerId: "8fc50dda-26b8-4a14-b2bf-7f4f9541f9bd",
41
41
  country: Country.NL,
42
42
  segment: Segment.WOMEN,
43
43
  email: "email@example.com",
@@ -58,7 +58,7 @@ const apiUrl =
58
58
  ? "/local-to-dev"
59
59
  : "/checkout/api";
60
60
  const authToken =
61
- "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjU3MDEwMTIsImV4cCI6MTc1MDMyMTgwOSwiZGlzcGxheU5hbWUiOiJUZXN0aW5nIiwiY291bnRyeV9jb2RlIjoiRVMiLCJhY2Nlc3NWaWEiOiJlbWFpbCIsInN1YnNjcmlwdGlvblN0YXJ0aW5nRGF0ZSI6IjIwMjUtMDUtMTkiLCJpbXBlcnNvbmF0ZWQiOmZhbHNlLCJ1dWlkIjoiNWMzOGU4MjYtM2QwMS00YTRiLWEzZDEtOGE0MTY2ZGMyYTMxIiwidHJhZGVuYW1lIjoiTE9PS0lFUk8iLCJpYXQiOjE3NDc2NDM0MDl9.-amqZAXKy9KKeo9a7bOQigWw1flM99OBlddxbMBA_PU";
61
+ "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjU5OTQwMTcsImV4cCI6MTc1MjE0NDQ2MywiZGlzcGxheU5hbWUiOiJUZXN0aW5nIiwiY291bnRyeV9jb2RlIjoiRVMiLCJhY2Nlc3NWaWEiOiJlbWFpbCIsInN1YnNjcmlwdGlvblN0YXJ0aW5nRGF0ZSI6IjIwMjUtMDYtMTAiLCJpbXBlcnNvbmF0ZWQiOmZhbHNlLCJ1dWlkIjoiOGZjNTBkZGEtMjZiOC00YTE0LWIyYmYtN2Y0Zjk1NDFmOWJkIiwidHJhZGVuYW1lIjoiTE9PS0lFUk8iLCJpYXQiOjE3NDk1NTI0NjN9.xFDOdP0an_ki8_JsvTANVDxPXWs0iWpTs1EFMqCrbO8";
62
62
  const getAuthToken = () => Promise.resolve(authToken);
63
63
 
64
64
  const externalTranslationsUrl =
@@ -85,16 +85,16 @@ import {
85
85
  viewCheckoutBookingByIdHandler,
86
86
  VIEW_CHECKOUT_BOOKING_BY_ID,
87
87
  } from "../../projection/checkoutBooking/viewCheckoutBookingById";
88
+ import {
89
+ viewCheckoutFeedbackDefinitionByCheckoutIdHandler,
90
+ VIEW_CHECKOUT_FEEDBACK_DEFINITION_BY_CHECKOUT_ID,
91
+ CheckoutFeedbackDefinitionByCheckoutIdView,
92
+ } from "../../projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId";
88
93
  import {
89
94
  viewCheckoutItemByIdHandler,
90
95
  VIEW_CHECKOUT_ITEM_BY_ID,
91
96
  CheckoutItemByIdView,
92
97
  } from "../../projection/checkoutItem/viewCheckoutItemById";
93
- import {
94
- CheckoutQuestionsByCheckoutIdView,
95
- listCheckoutQuestionsByCheckoutIdHandler,
96
- LIST_CHECKOUT_QUESTIONS_BY_CHECKOUT_ID,
97
- } from "../../projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId";
98
98
  import {
99
99
  PaymentFlowPayloadByCheckoutIdView,
100
100
  viewPaymentFlowPayloadByCheckoutIdHandler,
@@ -145,7 +145,7 @@ interface BaseBootstrapFunctionArgs<
145
145
  readonly bookedProductsVariantsForCheckoutItemView: BookedProductsVariantsForCheckoutItemView;
146
146
  readonly pricingByCheckoutIdView: PricingByCheckoutIdView;
147
147
  readonly paymentFlowPayloadByCheckoutIdView: PaymentFlowPayloadByCheckoutIdView;
148
- readonly checkoutQuestionsByCheckoutIdView: CheckoutQuestionsByCheckoutIdView;
148
+ readonly checkoutFeedbackDefinitionByCheckoutIdView: CheckoutFeedbackDefinitionByCheckoutIdView;
149
149
  readonly getCheckout: CheckoutsGetFunction<CheckoutGetFunctionArgs>;
150
150
  readonly saveCheckout: CheckoutsSaveFunction<CheckoutSaveFunctionArgs>;
151
151
  readonly checkoutsDependencies: NeverWhenEmptyRecord<
@@ -204,7 +204,7 @@ const baseBootstrap: BaseBootstrapFunction = ({
204
204
  checkoutBookingByIdView,
205
205
  pricingByCheckoutIdView,
206
206
  paymentFlowPayloadByCheckoutIdView,
207
- checkoutQuestionsByCheckoutIdView,
207
+ checkoutFeedbackDefinitionByCheckoutIdView,
208
208
  getCheckout,
209
209
  saveCheckout,
210
210
  checkoutsDependencies,
@@ -268,8 +268,8 @@ const baseBootstrap: BaseBootstrapFunction = ({
268
268
  .query(VIEW_PAYMENT_FLOW_PAYLOAD_BY_CHECKOUT_ID, viewPaymentFlowPayloadByCheckoutIdHandler, {
269
269
  view: paymentFlowPayloadByCheckoutIdView,
270
270
  })
271
- .query(LIST_CHECKOUT_QUESTIONS_BY_CHECKOUT_ID, listCheckoutQuestionsByCheckoutIdHandler, {
272
- view: checkoutQuestionsByCheckoutIdView,
271
+ .query(VIEW_CHECKOUT_FEEDBACK_DEFINITION_BY_CHECKOUT_ID, viewCheckoutFeedbackDefinitionByCheckoutIdHandler, {
272
+ view: checkoutFeedbackDefinitionByCheckoutIdView,
273
273
  })
274
274
  .query(VIEW_CHECKOUT_BOOKING_BY_ID, viewCheckoutBookingByIdHandler, {
275
275
  view: checkoutBookingByIdView,
@@ -7,8 +7,8 @@ import { FiveItemsDiscountByCustomerIdView } from "../../projection/checkout/vie
7
7
  import { IsCheckoutEnabledByCustomerIdView } from "../../projection/checkout/viewIsCheckoutEnabledByCustomerId";
8
8
  import { IsSizeChangeEnabledByCheckoutIdView } from "../../projection/checkout/viewIsSizeChangeEnabledByCheckoutId";
9
9
  import { CheckoutBookingByIdView } from "../../projection/checkoutBooking/viewCheckoutBookingById";
10
+ import { CheckoutFeedbackDefinitionByCheckoutIdView } from "../../projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId";
10
11
  import { CheckoutItemByIdView } from "../../projection/checkoutItem/viewCheckoutItemById";
11
- import { CheckoutQuestionsByCheckoutIdView } from "../../projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId";
12
12
  import { PaymentFlowPayloadByCheckoutIdView } from "../../projection/payment/viewPaymentFlowPayloadByCheckoutId";
13
13
  import { PricingByCheckoutIdView } from "../../projection/pricing/viewPricingByCheckoutId";
14
14
  import { ReturnQuestionsByCheckoutItemIdView } from "../../projection/returnQuestion/listReturnQuestionsByCheckoutItemId";
@@ -16,7 +16,7 @@ import { bookedProductsVariants } from "../projection/bookedProductsVariants/boo
16
16
  import { checkout } from "../projection/checkout/checkout.mock";
17
17
  import { checkoutBooking as checkoutBookingMock } from "../projection/checkoutBooking/checkoutBooking.mock";
18
18
  import { checkoutFeedback as checkoutFeedbackMock } from "../projection/checkoutFeedback/checkoutFeedback.mock";
19
- import { checkoutQuestions as checkoutQuestionsMock } from "../projection/checkoutQuestion/checkoutQuestions.mock";
19
+ import { checkoutFeedbackDefinition as checkoutFeedbackDefinitionMock } from "../projection/checkoutFeedback/checkoutFeedbackDefinition.mock";
20
20
  import { feedback as feedbackMock } from "../projection/feedback/feedback.mock";
21
21
  import { paymentFlowPayload as paymentFlowPayloadMock } from "../projection/payment/paymentFlowPayload.mock";
22
22
  import { pricing as pricingMock } from "../projection/pricing/pricing.mock";
@@ -73,7 +73,8 @@ const bookedProductsVariantsForCheckoutItemView: BookedProductsVariantsForChecko
73
73
  bookedProductsVariants;
74
74
  const pricingByCheckoutIdView: PricingByCheckoutIdView = async () => pricingMock();
75
75
  const paymentFlowPayloadByCheckoutIdView: PaymentFlowPayloadByCheckoutIdView = async () => paymentFlowPayloadMock;
76
- const checkoutQuestionsByCheckoutIdView: CheckoutQuestionsByCheckoutIdView = async () => checkoutQuestionsMock;
76
+ const checkoutFeedbackDefinitionByCheckoutIdView: CheckoutFeedbackDefinitionByCheckoutIdView = async () =>
77
+ checkoutFeedbackDefinitionMock;
77
78
 
78
79
  const bootstrap: () => BuildBootstrapFunctionReturn = () =>
79
80
  baseBootstrap({
@@ -88,7 +89,7 @@ const bootstrap: () => BuildBootstrapFunctionReturn = () =>
88
89
  bookedProductsVariantsForCheckoutItemView,
89
90
  pricingByCheckoutIdView,
90
91
  paymentFlowPayloadByCheckoutIdView,
91
- checkoutQuestionsByCheckoutIdView,
92
+ checkoutFeedbackDefinitionByCheckoutIdView,
92
93
  getCheckout,
93
94
  saveCheckout,
94
95
  checkoutsDependencies: [{ dataSource }],
@@ -13,8 +13,8 @@ import { httpFiveItemsDiscountByCustomerIdView } from "../projection/checkout/ht
13
13
  import { httpIsCheckoutEnabledByCustomerIdView } from "../projection/checkout/httpIsCheckoutEnabledByCustomerIdView";
14
14
  import { httpIsSizeChangeEnabledByCheckoutIdView } from "../projection/checkout/httpIsSizeChangeEnabledByCheckoutIdView";
15
15
  import { httpCheckoutBookingByIdView } from "../projection/checkoutBooking/httpCheckoutBookingByIdView";
16
+ import { httpCheckoutFeedbackDefinitionByCheckoutIdView } from "../projection/checkoutFeedback/httpCheckoutFeedbackDefinitionByCheckoutIdView";
16
17
  import { httpCheckoutItemByIdView } from "../projection/checkoutItem/httpCheckoutItemByIdView";
17
- import { httpCheckoutQuestionsByCheckoutIdView } from "../projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView";
18
18
  import { httpPaymentFlowPayloadByCheckoutIdView } from "../projection/payment/httpPaymentFlowPayloadByCheckoutIdView";
19
19
  import { httpPricingByCheckoutIdView } from "../projection/pricing/httpPricingByCheckoutIdView";
20
20
  import { httpReturnQuestionsByCheckoutItemIdView } from "../projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView";
@@ -55,7 +55,7 @@ const bootstrap: BootstrapFunction = ({ apiUrl, getAuthToken }) => {
55
55
  paymentFlowPayloadByCheckoutIdView: httpPaymentFlowPayloadByCheckoutIdView({
56
56
  httpPost,
57
57
  }),
58
- checkoutQuestionsByCheckoutIdView: httpCheckoutQuestionsByCheckoutIdView({
58
+ checkoutFeedbackDefinitionByCheckoutIdView: httpCheckoutFeedbackDefinitionByCheckoutIdView({
59
59
  httpPost,
60
60
  }),
61
61
  getCheckout,
@@ -0,0 +1,110 @@
1
+ import { CheckoutFeedbackQuestionProjection } from "../../../projection/checkoutFeedback/checkoutFeedback";
2
+ import { CheckoutFeedbackQuestionType } from "../../../projection/checkoutFeedback/checkoutFeedback.constants";
3
+
4
+ const checkoutFeedbackDefinition: CheckoutFeedbackQuestionProjection[] = [
5
+ {
6
+ id: "efe07b97-f6fb-4b6a-ba92-b68519320b2c",
7
+ translationKey: "checkout_question.selection.question",
8
+ type: CheckoutFeedbackQuestionType.HOST_SELECT,
9
+ metadata: {
10
+ placeholder: "checkout_question.selection.placeholder",
11
+ showCondition: [],
12
+ },
13
+ children: [
14
+ {
15
+ id: "68c0bb98-b00a-4b86-af43-528fe903cb69",
16
+ type: CheckoutFeedbackQuestionType.ICON,
17
+ metadata: {
18
+ icon: "checkout_feedback.icon.bad",
19
+ },
20
+ },
21
+ {
22
+ id: "85e84a77-461c-41e6-8544-95b5294d0b80",
23
+ type: CheckoutFeedbackQuestionType.ICON,
24
+ metadata: {
25
+ icon: "checkout_feedback.icon.regular",
26
+ },
27
+ },
28
+ {
29
+ id: "29441d25-8d9f-471e-a13e-a03f61c88091",
30
+ type: CheckoutFeedbackQuestionType.ICON,
31
+ metadata: {
32
+ icon: "checkout_feedback.icon.good",
33
+ },
34
+ },
35
+ ],
36
+ },
37
+ {
38
+ id: "6a6d3878-5561-412c-96f3-7ed79ee587bb",
39
+ translationKey: "checkout_question.experience.question",
40
+ type: CheckoutFeedbackQuestionType.HOST_SELECT,
41
+ metadata: {
42
+ placeholder: "checkout_question.experience.placeholder",
43
+ showCondition: [],
44
+ },
45
+ children: [
46
+ {
47
+ id: "a3d937b6-7499-4a3c-86bf-5c0af9ab2e23",
48
+ type: CheckoutFeedbackQuestionType.ICON,
49
+ metadata: {
50
+ icon: "checkout_feedback.icon.bad",
51
+ },
52
+ },
53
+ {
54
+ id: "7970edd3-fb5c-42d3-afe3-ce31bcbb856c",
55
+ type: CheckoutFeedbackQuestionType.ICON,
56
+ metadata: {
57
+ icon: "checkout_feedback.icon.regular",
58
+ },
59
+ },
60
+ {
61
+ id: "bab3d4f9-0227-4550-a53f-3c125d68429c",
62
+ type: CheckoutFeedbackQuestionType.ICON,
63
+ metadata: {
64
+ icon: "checkout_feedback.icon.good",
65
+ },
66
+ },
67
+ ],
68
+ },
69
+ {
70
+ id: "a1acdb2d-62c8-467f-b7cc-dc24d967290c",
71
+ translationKey: "checkout_question.personalshopper.question",
72
+ type: CheckoutFeedbackQuestionType.HOST_SELECT,
73
+ metadata: {
74
+ showCondition: ["68c0bb98-b00a-4b86-af43-528fe903cb69"],
75
+ placeholder: "checkout_question.personalshopper.placeholder",
76
+ },
77
+ children: [
78
+ {
79
+ id: "cce7851c-92c7-461b-8dcb-903c5de59ed1",
80
+ translationKey: "checkout_question.personalshopper.yes",
81
+ type: CheckoutFeedbackQuestionType.BUTTON,
82
+ },
83
+ {
84
+ id: "4bf8f27d-669b-4d36-8d39-b5599c671816",
85
+ translationKey: "checkout_question.personalshopper.no",
86
+ type: CheckoutFeedbackQuestionType.BUTTON,
87
+ },
88
+ ],
89
+ },
90
+ {
91
+ id: "ce3e8d57-5eea-4dd3-bef4-2e811a143612",
92
+ translationKey: "checkout_question.comment.question",
93
+ type: CheckoutFeedbackQuestionType.HOST_TEXTAREA,
94
+ metadata: {
95
+ showCondition: [],
96
+ },
97
+ children: [
98
+ {
99
+ id: "1123a37d-bc00-43a4-9d28-cee1dfaf356c",
100
+ translationKey: "checkout_question.comment.question",
101
+ type: CheckoutFeedbackQuestionType.TEXTAREA,
102
+ metadata: {
103
+ placeholder: "checkout_question.comment.placeholder",
104
+ },
105
+ },
106
+ ],
107
+ },
108
+ ];
109
+
110
+ export { checkoutFeedbackDefinition };
@@ -0,0 +1,52 @@
1
+ import { mock } from "jest-mock-extended";
2
+ import { fetchHttpPost } from "@lookiero/sty-psp-http";
3
+ import { checkoutFeedbackDefinition } from "./checkoutFeedbackDefinition.mock";
4
+ import { httpCheckoutFeedbackDefinitionByCheckoutIdView as sut } from "./httpCheckoutFeedbackDefinitionByCheckoutIdView";
5
+
6
+ const fetchMock = jest.fn();
7
+ global.fetch = fetchMock;
8
+ const apiUrl = "/api";
9
+ const getAuthToken = () => Promise.resolve("token");
10
+ const view = sut({ httpPost: fetchHttpPost({ apiUrl: () => apiUrl, getAuthToken, device: "web", version: "1.0.0" }) });
11
+ const signal = mock<AbortSignal>();
12
+
13
+ const checkoutId = "29790d24-b139-4ab8-b618-d796d101e974";
14
+
15
+ const checkoutFeedbackDefinitionResponseOk: Response = {
16
+ ok: true,
17
+ status: 200,
18
+ text: () => Promise.resolve(JSON.stringify(checkoutFeedbackDefinition)),
19
+ } as Response;
20
+ const checkoutFeedbackDefinitionResponseNotFound: Response = {
21
+ ok: false,
22
+ status: 404,
23
+ } as Response;
24
+ const checkoutFeedbackDefinitionResponseError: Response = {
25
+ ok: false,
26
+ } as Response;
27
+
28
+ describe("httpCheckoutFeedbackDefinitionByCheckoutIdView", () => {
29
+ it("returns a checkoutFeedbackDefinition projection for a 200 response", async () => {
30
+ fetchMock.mockReturnValue(Promise.resolve(checkoutFeedbackDefinitionResponseOk));
31
+
32
+ const returnedCheckoutFeedbackDefinition = await view({ checkoutId, signal });
33
+
34
+ expect(returnedCheckoutFeedbackDefinition).toStrictEqual(checkoutFeedbackDefinition);
35
+ });
36
+
37
+ it("returns null for a 404 response", async () => {
38
+ fetchMock.mockReturnValue(Promise.resolve(checkoutFeedbackDefinitionResponseNotFound));
39
+
40
+ const returnedCheckoutFeedbackDefinition = await view({ checkoutId, signal });
41
+
42
+ expect(returnedCheckoutFeedbackDefinition).toBeNull();
43
+ });
44
+
45
+ it("returns null for a non successfull response", async () => {
46
+ fetchMock.mockReturnValue(Promise.resolve(checkoutFeedbackDefinitionResponseError));
47
+
48
+ const returnedCheckoutFeedbackDefinition = await view({ checkoutId, signal });
49
+
50
+ expect(returnedCheckoutFeedbackDefinition).toBeNull();
51
+ });
52
+ });
@@ -0,0 +1,30 @@
1
+ import { HttpPostFunction } from "@lookiero/sty-psp-http";
2
+ import {
3
+ CheckoutFeedbackDefinitionByCheckoutIdView,
4
+ ViewCheckoutFeedbackDefinitionByCheckoutIdResult,
5
+ } from "../../../projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId";
6
+
7
+ interface HttpCheckoutFeedbackDefinitionByCheckoutIdView extends CheckoutFeedbackDefinitionByCheckoutIdView {}
8
+
9
+ interface HttpCheckoutFeedbackDefinitionByCheckoutIdViewFunctionArgs {
10
+ readonly httpPost: HttpPostFunction;
11
+ }
12
+
13
+ interface HttpCheckoutFeedbackDefinitionByCheckoutIdViewFunction {
14
+ (args: HttpCheckoutFeedbackDefinitionByCheckoutIdViewFunctionArgs): HttpCheckoutFeedbackDefinitionByCheckoutIdView;
15
+ }
16
+
17
+ const httpCheckoutFeedbackDefinitionByCheckoutIdView: HttpCheckoutFeedbackDefinitionByCheckoutIdViewFunction =
18
+ ({ httpPost }) =>
19
+ async ({ checkoutId, signal }) =>
20
+ await httpPost<ViewCheckoutFeedbackDefinitionByCheckoutIdResult>({
21
+ endpoint: "/view-checkout-feedback-definition-by-checkout-id",
22
+ body: { checkoutId },
23
+ signal,
24
+ result: {
25
+ error: null,
26
+ success: (response) => response,
27
+ },
28
+ });
29
+
30
+ export { httpCheckoutFeedbackDefinitionByCheckoutIdView };