@lookiero/checkout 12.2.0 → 12.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) 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/domain/checkoutItem/model/price.d.ts +1 -1
  5. package/dist/src/infrastructure/delivery/baseBootstrap.d.ts +2 -2
  6. package/dist/src/infrastructure/delivery/baseBootstrap.js +4 -4
  7. package/dist/src/infrastructure/delivery/bootstrap.js +2 -2
  8. package/dist/src/infrastructure/delivery/bootstrap.mock.js +3 -3
  9. package/dist/src/infrastructure/projection/checkoutFeedback/checkoutFeedbackDefinition.mock.d.ts +3 -0
  10. package/dist/src/infrastructure/projection/checkoutFeedback/checkoutFeedbackDefinition.mock.js +107 -0
  11. package/dist/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackDefinitionByCheckoutIdView.d.ts +12 -0
  12. package/dist/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackDefinitionByCheckoutIdView.js +10 -0
  13. package/dist/src/infrastructure/projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId.d.ts +10 -0
  14. package/dist/src/infrastructure/projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId.js +9 -0
  15. package/dist/src/infrastructure/projection/checkoutItem/checkoutItem.mock.js +1 -1
  16. package/dist/src/infrastructure/projection/pricing/pricing.mock.js +1 -1
  17. package/dist/src/infrastructure/tracking/tracking.d.ts +1 -1
  18. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestion.d.ts +2 -2
  19. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestion.js +4 -2
  20. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestions.d.ts +2 -2
  21. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem.d.ts +5 -5
  22. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem.js +1 -1
  23. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/CheckoutQuestionItem.d.ts +5 -4
  24. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.d.ts +2 -1
  25. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.js +2 -1
  26. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultCheckoutQuestionItem.d.ts +2 -1
  27. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultCheckoutQuestionItem.js +2 -1
  28. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.d.ts +2 -1
  29. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.js +2 -1
  30. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.d.ts +2 -3
  31. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.js +5 -7
  32. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.d.ts +2 -1
  33. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.js +2 -1
  34. package/dist/src/infrastructure/ui/views/feedback/Feedback.js +10 -9
  35. package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.d.ts +2 -3
  36. package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.js +17 -9
  37. package/dist/src/projection/checkoutFeedback/checkoutFeedback.constants.d.ts +11 -0
  38. package/dist/src/projection/checkoutFeedback/checkoutFeedback.constants.js +10 -0
  39. package/dist/src/projection/checkoutFeedback/checkoutFeedback.d.ts +22 -2
  40. package/dist/src/projection/checkoutFeedback/checkoutFeedback.metadata.d.ts +21 -0
  41. package/dist/src/projection/checkoutFeedback/checkoutFeedback.metadata.js +1 -0
  42. package/dist/src/projection/checkoutFeedback/checkoutFeedback.typeguards.d.ts +3 -0
  43. package/dist/src/projection/checkoutFeedback/checkoutFeedback.typeguards.js +7 -0
  44. package/dist/src/projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId.d.ts +25 -0
  45. package/dist/src/projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId.js +8 -0
  46. package/dist/src/projection/price/price.d.ts +1 -1
  47. package/dist/src/version.d.ts +1 -1
  48. package/dist/src/version.js +1 -1
  49. package/package.json +5 -5
  50. package/src/ExpoRoot.tsx +2 -2
  51. package/src/domain/checkoutItem/model/price.ts +1 -1
  52. package/src/infrastructure/delivery/baseBootstrap.ts +9 -9
  53. package/src/infrastructure/delivery/bootstrap.mock.ts +5 -4
  54. package/src/infrastructure/delivery/bootstrap.ts +2 -2
  55. package/src/infrastructure/projection/checkoutFeedback/checkoutFeedbackDefinition.mock.ts +110 -0
  56. package/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackDefinitionByCheckoutIdView.test.ts +52 -0
  57. package/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackDefinitionByCheckoutIdView.ts +30 -0
  58. package/src/infrastructure/projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId.test.ts +58 -0
  59. package/src/infrastructure/projection/checkoutFeedback/react/useViewCheckoutFeedbackDefinitionByCheckoutId.ts +25 -0
  60. package/src/infrastructure/projection/checkoutItem/checkoutItem.mock.ts +1 -1
  61. package/src/infrastructure/projection/pricing/pricing.mock.ts +1 -1
  62. package/src/infrastructure/tracking/tracking.ts +1 -1
  63. package/src/infrastructure/tracking/useTrackCheckout.test.tsx +1 -2
  64. package/src/infrastructure/tracking/useTrackCheckout.ts +1 -2
  65. package/src/infrastructure/ui/components/atoms/price/Price.test.tsx +1 -1
  66. package/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestion.test.tsx +25 -30
  67. package/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestion.tsx +12 -13
  68. package/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestions.test.tsx +19 -26
  69. package/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestions.tsx +3 -3
  70. package/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem.test.tsx +26 -26
  71. package/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem.tsx +6 -6
  72. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/CheckoutQuestionItem.ts +5 -4
  73. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.test.tsx +7 -11
  74. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.tsx +6 -4
  75. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultCheckoutQuestionItem.tsx +6 -4
  76. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultReturnQuestionItem.test.tsx +16 -10
  77. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.test.tsx +16 -22
  78. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.tsx +6 -4
  79. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.test.tsx +16 -14
  80. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.tsx +13 -14
  81. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.test.tsx +9 -19
  82. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.tsx +7 -5
  83. package/src/infrastructure/ui/views/feedback/Feedback.test.tsx +11 -5
  84. package/src/infrastructure/ui/views/feedback/Feedback.tsx +10 -9
  85. package/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.test.tsx +2 -2
  86. package/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.tsx +20 -13
  87. package/src/infrastructure/ui/views/item/components/productVariantDescription/ProductVariantDescription.test.tsx +1 -2
  88. package/src/infrastructure/ui/views/return/components/price/Price.test.tsx +1 -1
  89. package/src/infrastructure/ui/views/shared/components/productVariant/ProductVariant.test.tsx +1 -2
  90. package/src/projection/checkoutFeedback/checkoutFeedback.constants.ts +16 -0
  91. package/src/projection/checkoutFeedback/checkoutFeedback.metadata.ts +28 -0
  92. package/src/projection/checkoutFeedback/checkoutFeedback.ts +38 -2
  93. package/src/projection/checkoutFeedback/checkoutFeedback.typeguards.ts +13 -0
  94. package/src/projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId.test.ts +52 -0
  95. package/src/projection/checkoutFeedback/viewCheckoutFeedbackDefinitionByCheckoutId.ts +61 -0
  96. package/src/projection/price/price.ts +1 -1
  97. package/cypress/support/interceptListCheckoutQuestionsByCheckoutId.ts +0 -9
  98. package/dist/src/domain/checkoutItem/model/currency.d.ts +0 -6
  99. package/dist/src/domain/checkoutItem/model/currency.js +0 -7
  100. package/dist/src/infrastructure/projection/checkoutQuestion/checkoutQuestions.mock.d.ts +0 -3
  101. package/dist/src/infrastructure/projection/checkoutQuestion/checkoutQuestions.mock.js +0 -103
  102. package/dist/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.d.ts +0 -12
  103. package/dist/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.js +0 -10
  104. package/dist/src/infrastructure/projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId.d.ts +0 -10
  105. package/dist/src/infrastructure/projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId.js +0 -9
  106. package/dist/src/projection/checkoutQuestion/checkoutQuestion.d.ts +0 -18
  107. package/dist/src/projection/checkoutQuestion/checkoutQuestion.js +0 -10
  108. package/dist/src/projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId.d.ts +0 -25
  109. package/dist/src/projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId.js +0 -8
  110. package/src/domain/checkoutItem/model/currency.ts +0 -7
  111. package/src/infrastructure/projection/checkoutQuestion/checkoutQuestions.mock.ts +0 -108
  112. package/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.test.ts +0 -55
  113. package/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.ts +0 -34
  114. package/src/infrastructure/projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId.test.ts +0 -38
  115. package/src/infrastructure/projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId.ts +0 -21
  116. package/src/projection/checkoutQuestion/checkoutQuestion.ts +0 -20
  117. package/src/projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId.test.ts +0 -31
  118. package/src/projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId.ts +0 -61
@@ -0,0 +1,52 @@
1
+ import { mock } from "jest-mock-extended";
2
+ import { QueryBus } from "@lookiero/messaging";
3
+ import { CheckoutFeedbackQuestionProjection } from "./checkoutFeedback";
4
+ import { CheckoutFeedbackQuestionType } from "./checkoutFeedback.constants";
5
+ import {
6
+ viewCheckoutFeedbackDefinitionByCheckoutId,
7
+ viewCheckoutFeedbackDefinitionByCheckoutIdHandler as sut,
8
+ } from "./viewCheckoutFeedbackDefinitionByCheckoutId";
9
+
10
+ const checkoutId = "29790d24-b139-4ab8-b618-d796d101e974";
11
+ const checkoutFeedbackDefinition: CheckoutFeedbackQuestionProjection[] = [
12
+ {
13
+ id: "efe07b97-f6fb-4b6a-ba92-b68519320b2c",
14
+ type: CheckoutFeedbackQuestionType.HOST_DEFAULT,
15
+ translationKey: "checkout.feedback.question.default",
16
+ metadata: {
17
+ showCondition: [],
18
+ },
19
+ children: [
20
+ {
21
+ id: "01975911-d451-7651-b1ae-3f977928e8a2",
22
+ type: CheckoutFeedbackQuestionType.HOST_TEXTAREA,
23
+ metadata: {
24
+ showCondition: [],
25
+ },
26
+ children: [
27
+ {
28
+ id: "01975911-ec6b-768e-9b4a-a6f2645b01b2",
29
+ type: CheckoutFeedbackQuestionType.TEXTAREA,
30
+ translationKey: "checkout.feedback.question.textarea",
31
+ metadata: {
32
+ placeholder: "checkout.feedback.question.textarea.placeholder",
33
+ },
34
+ },
35
+ ],
36
+ },
37
+ ],
38
+ },
39
+ ];
40
+ const queryBus = mock<QueryBus>();
41
+ const signal = mock<AbortSignal>();
42
+
43
+ describe("viewCheckoutFeedbackDefinitionByCheckoutId", () => {
44
+ it("returns checkout questions by checkout id", async () => {
45
+ const query = viewCheckoutFeedbackDefinitionByCheckoutId({ checkoutId });
46
+ const view = jest.fn(() => Promise.resolve(checkoutFeedbackDefinition));
47
+
48
+ const checkoutFeedbackDefinitionResult = await sut({ view, queryBus, signal })(query);
49
+
50
+ expect(checkoutFeedbackDefinitionResult).toBe(checkoutFeedbackDefinition);
51
+ });
52
+ });
@@ -0,0 +1,61 @@
1
+ import {
2
+ CancelableQueryViewArgs,
3
+ query,
4
+ Query,
5
+ QueryHandlerFunction,
6
+ QueryHandlerFunctionArgs,
7
+ } from "@lookiero/messaging";
8
+ import { CheckoutFeedbackQuestionProjection } from "./checkoutFeedback";
9
+
10
+ const VIEW_CHECKOUT_FEEDBACK_DEFINITION_BY_CHECKOUT_ID = "view_checkout_feedback_definition_by_checkout_id";
11
+
12
+ interface ViewCheckoutFeedbackDefinitionByCheckoutIdPayload {
13
+ readonly checkoutId: string;
14
+ }
15
+
16
+ interface ViewCheckoutFeedbackDefinitionByCheckoutId
17
+ extends Query<typeof VIEW_CHECKOUT_FEEDBACK_DEFINITION_BY_CHECKOUT_ID>,
18
+ ViewCheckoutFeedbackDefinitionByCheckoutIdPayload {}
19
+
20
+ interface ViewCheckoutFeedbackDefinitionByCheckoutIdFunction {
21
+ (payload: ViewCheckoutFeedbackDefinitionByCheckoutIdPayload): ViewCheckoutFeedbackDefinitionByCheckoutId;
22
+ }
23
+
24
+ const viewCheckoutFeedbackDefinitionByCheckoutId: ViewCheckoutFeedbackDefinitionByCheckoutIdFunction = (payload) => ({
25
+ ...query({ name: VIEW_CHECKOUT_FEEDBACK_DEFINITION_BY_CHECKOUT_ID }),
26
+ ...payload,
27
+ });
28
+
29
+ type ViewCheckoutFeedbackDefinitionByCheckoutIdResult = CheckoutFeedbackQuestionProjection[] | null;
30
+
31
+ interface CheckoutFeedbackDefinitionByCheckoutIdViewArgs extends CancelableQueryViewArgs {
32
+ readonly checkoutId: string;
33
+ }
34
+
35
+ interface CheckoutFeedbackDefinitionByCheckoutIdView {
36
+ (args: CheckoutFeedbackDefinitionByCheckoutIdViewArgs): Promise<ViewCheckoutFeedbackDefinitionByCheckoutIdResult>;
37
+ }
38
+
39
+ interface ViewCheckoutFeedbackDefinitionByCheckoutIdHandlerFunctionArgs extends QueryHandlerFunctionArgs {
40
+ readonly view: CheckoutFeedbackDefinitionByCheckoutIdView;
41
+ }
42
+
43
+ const viewCheckoutFeedbackDefinitionByCheckoutIdHandler: QueryHandlerFunction<
44
+ ViewCheckoutFeedbackDefinitionByCheckoutId,
45
+ ViewCheckoutFeedbackDefinitionByCheckoutIdResult,
46
+ ViewCheckoutFeedbackDefinitionByCheckoutIdHandlerFunctionArgs
47
+ > =
48
+ ({ view, signal }) =>
49
+ async ({ checkoutId }) =>
50
+ view({ checkoutId, signal });
51
+
52
+ export type {
53
+ ViewCheckoutFeedbackDefinitionByCheckoutId,
54
+ CheckoutFeedbackDefinitionByCheckoutIdView,
55
+ ViewCheckoutFeedbackDefinitionByCheckoutIdResult,
56
+ };
57
+ export {
58
+ VIEW_CHECKOUT_FEEDBACK_DEFINITION_BY_CHECKOUT_ID,
59
+ viewCheckoutFeedbackDefinitionByCheckoutId,
60
+ viewCheckoutFeedbackDefinitionByCheckoutIdHandler,
61
+ };
@@ -1,4 +1,4 @@
1
- import { Currency } from "../../domain/checkoutItem/model/currency";
1
+ import { Currency } from "@lookiero/sty-psp-locale";
2
2
 
3
3
  interface PriceProjection {
4
4
  readonly amount: number;
@@ -1,9 +0,0 @@
1
- import { CheckoutQuestionProjection } from "../../src/projection/checkoutQuestion/checkoutQuestion";
2
-
3
- const interceptListCheckoutQuestionsByCheckoutId = (response: CheckoutQuestionProjection[]) =>
4
- cy.intercept(
5
- { method: "POST", url: "/local-to-dev/list-checkout-questions-by-checkout-id" },
6
- { body: { result: response } },
7
- );
8
-
9
- export { interceptListCheckoutQuestionsByCheckoutId };
@@ -1,6 +0,0 @@
1
- declare enum Currency {
2
- EUR = "EUR",
3
- GBP = "GBP",
4
- SEK = "SEK"
5
- }
6
- export { Currency };
@@ -1,7 +0,0 @@
1
- var Currency;
2
- (function (Currency) {
3
- Currency["EUR"] = "EUR";
4
- Currency["GBP"] = "GBP";
5
- Currency["SEK"] = "SEK";
6
- })(Currency || (Currency = {}));
7
- export { Currency };
@@ -1,3 +0,0 @@
1
- import { CheckoutQuestionProjection } from "../../../projection/checkoutQuestion/checkoutQuestion";
2
- declare const checkoutQuestions: CheckoutQuestionProjection[];
3
- export { checkoutQuestions };
@@ -1,103 +0,0 @@
1
- import { CheckoutQuestionType, } from "../../../projection/checkoutQuestion/checkoutQuestion";
2
- const checkoutQuestions = [
3
- {
4
- id: "efe07b97-f6fb-4b6a-ba92-b68519320b2c",
5
- name: "checkout_question.selection.question",
6
- placeholder: "checkout_question.selection.placeholder",
7
- type: CheckoutQuestionType.HOST_SELECT,
8
- showCondition: [],
9
- children: [
10
- {
11
- id: "68c0bb98-b00a-4b86-af43-528fe903cb69",
12
- name: "checkout_question.icon.bad",
13
- placeholder: "",
14
- type: CheckoutQuestionType.ICON,
15
- showCondition: [],
16
- },
17
- {
18
- id: "85e84a77-461c-41e6-8544-95b5294d0b80",
19
- name: "checkout_question.icon.regular",
20
- placeholder: "",
21
- type: CheckoutQuestionType.ICON,
22
- showCondition: [],
23
- },
24
- {
25
- id: "29441d25-8d9f-471e-a13e-a03f61c88091",
26
- name: "checkout_question.icon.good",
27
- placeholder: "",
28
- type: CheckoutQuestionType.ICON,
29
- showCondition: [],
30
- },
31
- ],
32
- },
33
- {
34
- id: "6a6d3878-5561-412c-96f3-7ed79ee587bb",
35
- name: "checkout_question.experience.question",
36
- placeholder: "checkout_question.experience.placeholder",
37
- type: CheckoutQuestionType.HOST_SELECT,
38
- showCondition: [],
39
- children: [
40
- {
41
- id: "a3d937b6-7499-4a3c-86bf-5c0af9ab2e23",
42
- name: "checkout_question.icon.bad",
43
- placeholder: "",
44
- type: CheckoutQuestionType.ICON,
45
- showCondition: [],
46
- },
47
- {
48
- id: "7970edd3-fb5c-42d3-afe3-ce31bcbb856c",
49
- name: "checkout_question.icon.regular",
50
- placeholder: "",
51
- type: CheckoutQuestionType.ICON,
52
- showCondition: [],
53
- },
54
- {
55
- id: "bab3d4f9-0227-4550-a53f-3c125d68429c",
56
- name: "checkout_question.icon.good",
57
- placeholder: "",
58
- type: CheckoutQuestionType.ICON,
59
- showCondition: [],
60
- },
61
- ],
62
- },
63
- {
64
- id: "a1acdb2d-62c8-467f-b7cc-dc24d967290c",
65
- name: "checkout_question.personalshopper.question",
66
- placeholder: "checkout_question.personalshopper.placeholder",
67
- type: CheckoutQuestionType.HOST_SELECT,
68
- showCondition: ["68c0bb98-b00a-4b86-af43-528fe903cb69"],
69
- children: [
70
- {
71
- id: "cce7851c-92c7-461b-8dcb-903c5de59ed1",
72
- name: "checkout_question.personalshopper.yes",
73
- placeholder: "",
74
- type: CheckoutQuestionType.BUTTON,
75
- showCondition: [],
76
- },
77
- {
78
- id: "4bf8f27d-669b-4d36-8d39-b5599c671816",
79
- name: "checkout_question.personalshopper.no",
80
- placeholder: "",
81
- type: CheckoutQuestionType.BUTTON,
82
- showCondition: [],
83
- },
84
- ],
85
- },
86
- {
87
- id: "ce3e8d57-5eea-4dd3-bef4-2e811a143612",
88
- name: "checkout_question.comment.question",
89
- placeholder: "",
90
- type: CheckoutQuestionType.HOST_TEXTAREA,
91
- showCondition: [],
92
- children: [
93
- {
94
- id: "1123a37d-bc00-43a4-9d28-cee1dfaf356c",
95
- name: "checkout_question.comment.question",
96
- placeholder: "checkout_question.comment.placeholder",
97
- type: CheckoutQuestionType.TEXTAREA,
98
- showCondition: [],
99
- },
100
- ],
101
- },
102
- ];
103
- export { checkoutQuestions };
@@ -1,12 +0,0 @@
1
- import { HttpPostFunction } from "@lookiero/sty-psp-http";
2
- import { CheckoutQuestionsByCheckoutIdView } from "../../../projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId";
3
- interface HttpCheckoutQuestionsByCheckoutIdView extends CheckoutQuestionsByCheckoutIdView {
4
- }
5
- interface HttpCheckoutQuestionsByCheckoutIdViewFunctionArgs {
6
- readonly httpPost: HttpPostFunction;
7
- }
8
- interface HttpCheckoutQuestionsByCheckoutIdViewFunction {
9
- (args: HttpCheckoutQuestionsByCheckoutIdViewFunctionArgs): HttpCheckoutQuestionsByCheckoutIdView;
10
- }
11
- declare const httpCheckoutQuestionsByCheckoutIdView: HttpCheckoutQuestionsByCheckoutIdViewFunction;
12
- export { httpCheckoutQuestionsByCheckoutIdView };
@@ -1,10 +0,0 @@
1
- const httpCheckoutQuestionsByCheckoutIdView = ({ httpPost }) => async ({ checkoutId, signal }) => await httpPost({
2
- endpoint: "/list-checkout-questions-by-checkout-id",
3
- body: { checkoutId },
4
- signal,
5
- result: {
6
- error: null,
7
- success: (response) => response.result,
8
- },
9
- });
10
- export { httpCheckoutQuestionsByCheckoutIdView };
@@ -1,10 +0,0 @@
1
- import { UseQueryFunctionResult } from "@lookiero/messaging-react";
2
- import { CheckoutQuestionProjection } from "../../../../projection/checkoutQuestion/checkoutQuestion";
3
- interface UseListChckoutQuestionsByCheckoutIdFunctionArgs {
4
- readonly checkoutId: string;
5
- }
6
- interface UseListChckoutQuestionsByCheckoutIdFunction {
7
- (args: UseListChckoutQuestionsByCheckoutIdFunctionArgs): UseQueryFunctionResult<CheckoutQuestionProjection[]>;
8
- }
9
- declare const useListCheckoutQuestionsByCheckoutId: UseListChckoutQuestionsByCheckoutIdFunction;
10
- export { useListCheckoutQuestionsByCheckoutId };
@@ -1,9 +0,0 @@
1
- import { useQuery } from "@lookiero/messaging-react";
2
- import { listCheckoutQuestionsByCheckoutId } from "../../../../projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId";
3
- import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
4
- const useListCheckoutQuestionsByCheckoutId = ({ checkoutId }) => useQuery({
5
- query: listCheckoutQuestionsByCheckoutId({ checkoutId }),
6
- contextId: MESSAGING_CONTEXT_ID,
7
- options: { staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
8
- });
9
- export { useListCheckoutQuestionsByCheckoutId };
@@ -1,18 +0,0 @@
1
- declare enum CheckoutQuestionType {
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
- interface CheckoutQuestionProjection {
10
- readonly id: string;
11
- readonly name: string;
12
- readonly placeholder: string;
13
- readonly type: CheckoutQuestionType;
14
- readonly children?: CheckoutQuestionProjection[];
15
- readonly showCondition: string[];
16
- }
17
- export { CheckoutQuestionType };
18
- export type { CheckoutQuestionProjection };
@@ -1,10 +0,0 @@
1
- var CheckoutQuestionType;
2
- (function (CheckoutQuestionType) {
3
- CheckoutQuestionType["HOST_DEFAULT"] = "HOST_DEFAULT";
4
- CheckoutQuestionType["HOST_TEXTAREA"] = "HOST_TEXTAREA";
5
- CheckoutQuestionType["HOST_SELECT"] = "HOST_SELECT";
6
- CheckoutQuestionType["TEXTAREA"] = "TEXTAREA";
7
- CheckoutQuestionType["ICON"] = "ICON";
8
- CheckoutQuestionType["BUTTON"] = "BUTTON";
9
- })(CheckoutQuestionType || (CheckoutQuestionType = {}));
10
- export { CheckoutQuestionType };
@@ -1,25 +0,0 @@
1
- import { CancelableQueryViewArgs, Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
2
- import { CheckoutQuestionProjection } from "./checkoutQuestion";
3
- declare const LIST_CHECKOUT_QUESTIONS_BY_CHECKOUT_ID = "list_checkout_questions_by_checkout_id";
4
- interface ListCheckoutQuestionsByCheckoutIdPayload {
5
- readonly checkoutId: string;
6
- }
7
- interface ListCheckoutQuestionsByCheckoutId extends Query<typeof LIST_CHECKOUT_QUESTIONS_BY_CHECKOUT_ID>, ListCheckoutQuestionsByCheckoutIdPayload {
8
- }
9
- interface ListCheckoutQuestionsByCheckoutIdFunction {
10
- (payload: ListCheckoutQuestionsByCheckoutIdPayload): ListCheckoutQuestionsByCheckoutId;
11
- }
12
- declare const listCheckoutQuestionsByCheckoutId: ListCheckoutQuestionsByCheckoutIdFunction;
13
- type ListCheckoutQuestionsByCheckoutIdResult = CheckoutQuestionProjection[] | null;
14
- interface CheckoutQuestionsByCheckoutIdViewArgs extends CancelableQueryViewArgs {
15
- readonly checkoutId: string;
16
- }
17
- interface CheckoutQuestionsByCheckoutIdView {
18
- (args: CheckoutQuestionsByCheckoutIdViewArgs): Promise<ListCheckoutQuestionsByCheckoutIdResult>;
19
- }
20
- interface ListCheckoutQuestionsByCheckoutIdHandlerFunctionArgs extends QueryHandlerFunctionArgs {
21
- readonly view: CheckoutQuestionsByCheckoutIdView;
22
- }
23
- declare const listCheckoutQuestionsByCheckoutIdHandler: QueryHandlerFunction<ListCheckoutQuestionsByCheckoutId, ListCheckoutQuestionsByCheckoutIdResult, ListCheckoutQuestionsByCheckoutIdHandlerFunctionArgs>;
24
- export type { ListCheckoutQuestionsByCheckoutId, CheckoutQuestionsByCheckoutIdView, ListCheckoutQuestionsByCheckoutIdResult, };
25
- export { LIST_CHECKOUT_QUESTIONS_BY_CHECKOUT_ID, listCheckoutQuestionsByCheckoutId, listCheckoutQuestionsByCheckoutIdHandler, };
@@ -1,8 +0,0 @@
1
- import { query, } from "@lookiero/messaging";
2
- const LIST_CHECKOUT_QUESTIONS_BY_CHECKOUT_ID = "list_checkout_questions_by_checkout_id";
3
- const listCheckoutQuestionsByCheckoutId = (payload) => ({
4
- ...query({ name: LIST_CHECKOUT_QUESTIONS_BY_CHECKOUT_ID }),
5
- ...payload,
6
- });
7
- const listCheckoutQuestionsByCheckoutIdHandler = ({ view, signal }) => async ({ checkoutId }) => view({ checkoutId, signal });
8
- export { LIST_CHECKOUT_QUESTIONS_BY_CHECKOUT_ID, listCheckoutQuestionsByCheckoutId, listCheckoutQuestionsByCheckoutIdHandler, };
@@ -1,7 +0,0 @@
1
- enum Currency {
2
- EUR = "EUR",
3
- GBP = "GBP",
4
- SEK = "SEK",
5
- }
6
-
7
- export { Currency };
@@ -1,108 +0,0 @@
1
- import {
2
- CheckoutQuestionProjection,
3
- CheckoutQuestionType,
4
- } from "../../../projection/checkoutQuestion/checkoutQuestion";
5
-
6
- const checkoutQuestions: CheckoutQuestionProjection[] = [
7
- {
8
- id: "efe07b97-f6fb-4b6a-ba92-b68519320b2c",
9
- name: "checkout_question.selection.question",
10
- placeholder: "checkout_question.selection.placeholder",
11
- type: CheckoutQuestionType.HOST_SELECT,
12
- showCondition: [],
13
- children: [
14
- {
15
- id: "68c0bb98-b00a-4b86-af43-528fe903cb69",
16
- name: "checkout_question.icon.bad",
17
- placeholder: "",
18
- type: CheckoutQuestionType.ICON,
19
- showCondition: [],
20
- },
21
- {
22
- id: "85e84a77-461c-41e6-8544-95b5294d0b80",
23
- name: "checkout_question.icon.regular",
24
- placeholder: "",
25
- type: CheckoutQuestionType.ICON,
26
- showCondition: [],
27
- },
28
- {
29
- id: "29441d25-8d9f-471e-a13e-a03f61c88091",
30
- name: "checkout_question.icon.good",
31
- placeholder: "",
32
- type: CheckoutQuestionType.ICON,
33
- showCondition: [],
34
- },
35
- ],
36
- },
37
- {
38
- id: "6a6d3878-5561-412c-96f3-7ed79ee587bb",
39
- name: "checkout_question.experience.question",
40
- placeholder: "checkout_question.experience.placeholder",
41
- type: CheckoutQuestionType.HOST_SELECT,
42
- showCondition: [],
43
- children: [
44
- {
45
- id: "a3d937b6-7499-4a3c-86bf-5c0af9ab2e23",
46
- name: "checkout_question.icon.bad",
47
- placeholder: "",
48
- type: CheckoutQuestionType.ICON,
49
- showCondition: [],
50
- },
51
- {
52
- id: "7970edd3-fb5c-42d3-afe3-ce31bcbb856c",
53
- name: "checkout_question.icon.regular",
54
- placeholder: "",
55
- type: CheckoutQuestionType.ICON,
56
- showCondition: [],
57
- },
58
- {
59
- id: "bab3d4f9-0227-4550-a53f-3c125d68429c",
60
- name: "checkout_question.icon.good",
61
- placeholder: "",
62
- type: CheckoutQuestionType.ICON,
63
- showCondition: [],
64
- },
65
- ],
66
- },
67
- {
68
- id: "a1acdb2d-62c8-467f-b7cc-dc24d967290c",
69
- name: "checkout_question.personalshopper.question",
70
- placeholder: "checkout_question.personalshopper.placeholder",
71
- type: CheckoutQuestionType.HOST_SELECT,
72
- showCondition: ["68c0bb98-b00a-4b86-af43-528fe903cb69"],
73
- children: [
74
- {
75
- id: "cce7851c-92c7-461b-8dcb-903c5de59ed1",
76
- name: "checkout_question.personalshopper.yes",
77
- placeholder: "",
78
- type: CheckoutQuestionType.BUTTON,
79
- showCondition: [],
80
- },
81
- {
82
- id: "4bf8f27d-669b-4d36-8d39-b5599c671816",
83
- name: "checkout_question.personalshopper.no",
84
- placeholder: "",
85
- type: CheckoutQuestionType.BUTTON,
86
- showCondition: [],
87
- },
88
- ],
89
- },
90
- {
91
- id: "ce3e8d57-5eea-4dd3-bef4-2e811a143612",
92
- name: "checkout_question.comment.question",
93
- placeholder: "",
94
- type: CheckoutQuestionType.HOST_TEXTAREA,
95
- showCondition: [],
96
- children: [
97
- {
98
- id: "1123a37d-bc00-43a4-9d28-cee1dfaf356c",
99
- name: "checkout_question.comment.question",
100
- placeholder: "checkout_question.comment.placeholder",
101
- type: CheckoutQuestionType.TEXTAREA,
102
- showCondition: [],
103
- },
104
- ],
105
- },
106
- ];
107
-
108
- export { checkoutQuestions };
@@ -1,55 +0,0 @@
1
- import { mock } from "jest-mock-extended";
2
- import { fetchHttpPost } from "@lookiero/sty-psp-http";
3
- import { CheckoutQuestionProjection } from "../../../projection/checkoutQuestion/checkoutQuestion";
4
- import { checkoutQuestions } from "./checkoutQuestions.mock";
5
- import { httpCheckoutQuestionsByCheckoutIdView as sut } from "./httpCheckoutQuestionsByCheckoutIdView";
6
-
7
- const fetchMock = jest.fn();
8
- global.fetch = fetchMock;
9
- const apiUrl = "/api";
10
- const getAuthToken = () => Promise.resolve("token");
11
- const view = sut({ httpPost: fetchHttpPost({ apiUrl: () => apiUrl, getAuthToken, device: "web", version: "1.0.0" }) });
12
- const signal = mock<AbortSignal>();
13
-
14
- const checkoutId = "29790d24-b139-4ab8-b618-d796d101e974";
15
- const checkoutQuestionsResponse: { result: CheckoutQuestionProjection[] } = {
16
- result: checkoutQuestions,
17
- };
18
- const checkoutQuestionsResponseOk: Response = {
19
- ok: true,
20
- status: 200,
21
- text: () => Promise.resolve(JSON.stringify(checkoutQuestionsResponse)),
22
- } as Response;
23
- const checkoutQuestionsResponseNotFound: Response = {
24
- ok: false,
25
- status: 404,
26
- } as Response;
27
- const checkoutQuestionsResponseError: Response = {
28
- ok: false,
29
- } as Response;
30
-
31
- describe("httpCheckoutQuestionsByCheckoutIdView", () => {
32
- it("returns a CheckoutQuestions projection for a 200 response", async () => {
33
- fetchMock.mockReturnValue(Promise.resolve(checkoutQuestionsResponseOk));
34
-
35
- const returnedCheckoutQuestions = await view({ checkoutId, signal });
36
-
37
- expect(returnedCheckoutQuestions).toStrictEqual(checkoutQuestionsResponse.result);
38
- });
39
-
40
- it("returns null for a 404 response", async () => {
41
- fetchMock.mockReturnValue(Promise.resolve(checkoutQuestionsResponseNotFound));
42
-
43
- const returnedCheckoutQuestions = await view({ checkoutId, signal });
44
-
45
- expect(returnedCheckoutQuestions).toBeNull();
46
- });
47
-
48
- it("returns null for a non successfull response", async () => {
49
- fetchMock.mockReturnValue(Promise.resolve(checkoutQuestionsResponseError));
50
-
51
- const returnedCheckoutQuestions = await view({ checkoutId, signal });
52
-
53
- expect(returnedCheckoutQuestions).toBeNull();
54
- });
55
- });
@@ -1,34 +0,0 @@
1
- import { HttpPostFunction } from "@lookiero/sty-psp-http";
2
- import {
3
- CheckoutQuestionsByCheckoutIdView,
4
- ListCheckoutQuestionsByCheckoutIdResult,
5
- } from "../../../projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId";
6
-
7
- interface HttpCheckoutQuestionsByCheckoutIdView extends CheckoutQuestionsByCheckoutIdView {}
8
-
9
- interface HttpCheckoutQuestionsByCheckoutIdViewFunctionArgs {
10
- readonly httpPost: HttpPostFunction;
11
- }
12
-
13
- interface HttpCheckoutQuestionsByCheckoutIdViewFunction {
14
- (args: HttpCheckoutQuestionsByCheckoutIdViewFunctionArgs): HttpCheckoutQuestionsByCheckoutIdView;
15
- }
16
-
17
- interface ListCheckoutQuestionsByCheckoutIdResponse {
18
- readonly result: ListCheckoutQuestionsByCheckoutIdResult;
19
- }
20
-
21
- const httpCheckoutQuestionsByCheckoutIdView: HttpCheckoutQuestionsByCheckoutIdViewFunction =
22
- ({ httpPost }) =>
23
- async ({ checkoutId, signal }) =>
24
- await httpPost<ListCheckoutQuestionsByCheckoutIdResponse, ListCheckoutQuestionsByCheckoutIdResult>({
25
- endpoint: "/list-checkout-questions-by-checkout-id",
26
- body: { checkoutId },
27
- signal,
28
- result: {
29
- error: null,
30
- success: (response) => response.result,
31
- },
32
- });
33
-
34
- export { httpCheckoutQuestionsByCheckoutIdView };
@@ -1,38 +0,0 @@
1
- import { renderHook, waitFor } from "@testing-library/react-native";
2
- import { bootstrap, QueryStatus } from "@lookiero/messaging-react";
3
- import {
4
- CheckoutQuestionProjection,
5
- CheckoutQuestionType,
6
- } from "../../../../projection/checkoutQuestion/checkoutQuestion";
7
- import {
8
- listCheckoutQuestionsByCheckoutIdHandler,
9
- LIST_CHECKOUT_QUESTIONS_BY_CHECKOUT_ID,
10
- } from "../../../../projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId";
11
- import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
12
- import { useListCheckoutQuestionsByCheckoutId as sut } from "./useListCheckoutQuestionsByCheckoutId";
13
-
14
- const checkoutId = "29790d24-b139-4ab8-b618-d796d101e974";
15
- const checkoutQuestionProjection: CheckoutQuestionProjection = {
16
- id: "efe07b97-f6fb-4b6a-ba92-b68519320b2c",
17
- name: "main_title",
18
- placeholder: "",
19
- type: CheckoutQuestionType.HOST_DEFAULT,
20
- showCondition: [],
21
- };
22
- const view = jest.fn().mockReturnValue(checkoutQuestionProjection);
23
- const { Component: Messaging } = bootstrap({ id: MESSAGING_CONTEXT_ID })
24
- .query(LIST_CHECKOUT_QUESTIONS_BY_CHECKOUT_ID, listCheckoutQuestionsByCheckoutIdHandler, { view })
25
- .build();
26
-
27
- describe("useListCheckoutQuestionsByCheckoutId integration hook", () => {
28
- it("returns success as the query status and the result itself after rendering the hook", async () => {
29
- const { result } = renderHook(() => sut({ checkoutId }), { wrapper: Messaging });
30
-
31
- await waitFor(() => {
32
- const [projection, status] = result.current;
33
-
34
- expect(projection).toStrictEqual(checkoutQuestionProjection);
35
- expect(status).toBe(QueryStatus.SUCCESS);
36
- });
37
- });
38
- });
@@ -1,21 +0,0 @@
1
- import { useQuery, UseQueryFunctionResult } from "@lookiero/messaging-react";
2
- import { CheckoutQuestionProjection } from "../../../../projection/checkoutQuestion/checkoutQuestion";
3
- import { listCheckoutQuestionsByCheckoutId } from "../../../../projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId";
4
- import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
5
-
6
- interface UseListChckoutQuestionsByCheckoutIdFunctionArgs {
7
- readonly checkoutId: string;
8
- }
9
-
10
- interface UseListChckoutQuestionsByCheckoutIdFunction {
11
- (args: UseListChckoutQuestionsByCheckoutIdFunctionArgs): UseQueryFunctionResult<CheckoutQuestionProjection[]>;
12
- }
13
-
14
- const useListCheckoutQuestionsByCheckoutId: UseListChckoutQuestionsByCheckoutIdFunction = ({ checkoutId }) =>
15
- useQuery({
16
- query: listCheckoutQuestionsByCheckoutId({ checkoutId }),
17
- contextId: MESSAGING_CONTEXT_ID,
18
- options: { staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
19
- });
20
-
21
- export { useListCheckoutQuestionsByCheckoutId };
@@ -1,20 +0,0 @@
1
- enum CheckoutQuestionType {
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
- interface CheckoutQuestionProjection {
11
- readonly id: string;
12
- readonly name: string;
13
- readonly placeholder: string; // required for CheckoutQuestionType.SELECT | CheckoutQuestionType.TEXTAREA
14
- readonly type: CheckoutQuestionType;
15
- readonly children?: CheckoutQuestionProjection[];
16
- readonly showCondition: string[];
17
- }
18
-
19
- export { CheckoutQuestionType };
20
- export type { CheckoutQuestionProjection };