@lookiero/checkout 0.3.18 → 0.3.20

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 (46) hide show
  1. package/dist/package.json +1 -1
  2. package/dist/src/domain/checkoutFeedback/command/giveCheckoutFeedback.d.ts +15 -0
  3. package/dist/src/domain/checkoutFeedback/command/giveCheckoutFeedback.js +7 -0
  4. package/dist/src/domain/checkoutFeedback/model/checkoutFeedback.d.ts +9 -0
  5. package/dist/src/domain/checkoutFeedback/model/checkoutFeedback.js +10 -0
  6. package/dist/src/domain/checkoutFeedback/model/checkoutFeedbackGiven.d.ts +13 -0
  7. package/dist/src/domain/checkoutFeedback/model/checkoutFeedbackGiven.js +4 -0
  8. package/dist/src/domain/checkoutFeedback/model/checkoutFeedbacks.d.ts +7 -0
  9. package/dist/src/domain/checkoutFeedback/model/checkoutFeedbacks.js +1 -0
  10. package/dist/src/domain/checkoutFeedback/model/feedbacks.d.ts +3 -0
  11. package/dist/src/domain/checkoutFeedback/model/feedbacks.js +1 -0
  12. package/dist/src/infrastructure/delivery/baseBootstrap.d.ts +9 -2
  13. package/dist/src/infrastructure/delivery/baseBootstrap.js +4 -1
  14. package/dist/src/infrastructure/delivery/bootstrap.js +4 -0
  15. package/dist/src/infrastructure/delivery/mock/checkoutFeedbackDataSource.d.ts +14 -0
  16. package/dist/src/infrastructure/delivery/mock/checkoutFeedbackDataSource.js +12 -0
  17. package/dist/src/infrastructure/delivery/mock/dataSourceCheckoutFeedbacks.d.ts +14 -0
  18. package/dist/src/infrastructure/delivery/mock/dataSourceCheckoutFeedbacks.js +19 -0
  19. package/dist/src/infrastructure/domain/checkoutFeedback/model/httpCheckoutFeedbacks.d.ts +16 -0
  20. package/dist/src/infrastructure/domain/checkoutFeedback/model/httpCheckoutFeedbacks.js +14 -0
  21. package/dist/src/infrastructure/domain/checkoutFeedback/model/httpCheckoutFeedbacksGive.d.ts +5 -0
  22. package/dist/src/infrastructure/domain/checkoutFeedback/model/httpCheckoutFeedbacksGive.js +13 -0
  23. package/dist/src/infrastructure/domain/checkoutFeedback/react/useGiveCheckoutFeedback.d.ts +17 -0
  24. package/dist/src/infrastructure/domain/checkoutFeedback/react/useGiveCheckoutFeedback.js +13 -0
  25. package/dist/src/infrastructure/projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId.js +9 -1
  26. package/dist/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackByIdView.d.ts +12 -0
  27. package/dist/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackByIdView.js +9 -0
  28. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionFeedback.d.ts +29 -0
  29. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionFeedback.js +28 -0
  30. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.js +7 -3
  31. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.js +7 -3
  32. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.js +6 -5
  33. package/dist/src/infrastructure/ui/views/feedback/Feedback.js +11 -16
  34. package/dist/src/infrastructure/ui/views/feedback/Feedback.style.d.ts +0 -3
  35. package/dist/src/infrastructure/ui/views/feedback/Feedback.style.js +0 -3
  36. package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.d.ts +3 -0
  37. package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.js +18 -3
  38. package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.style.d.ts +6 -0
  39. package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.style.js +7 -0
  40. package/dist/src/projection/checkoutFeedback/checkoutFeedback.d.ts +6 -0
  41. package/dist/src/projection/checkoutFeedback/checkoutFeedback.js +1 -0
  42. package/dist/src/projection/checkoutFeedback/feedback.d.ts +3 -0
  43. package/dist/src/projection/checkoutFeedback/feedback.js +1 -0
  44. package/dist/src/projection/checkoutFeedback/viewCheckoutFeedbackById.d.ts +25 -0
  45. package/dist/src/projection/checkoutFeedback/viewCheckoutFeedbackById.js +8 -0
  46. package/package.json +1 -1
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.3.18",
3
+ "version": "0.3.20",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -0,0 +1,15 @@
1
+ import { Command } from "@lookiero/messaging";
2
+ import { Feedbacks } from "../model/feedbacks";
3
+ declare const GIVE_CHECKOUT_FEEDBACK = "give_checkout_feedback";
4
+ interface GiveCheckoutFeedbackPayload {
5
+ readonly aggregateId: string;
6
+ readonly feedbacks: Feedbacks;
7
+ }
8
+ interface GiveCheckoutFeedback extends Command<typeof GIVE_CHECKOUT_FEEDBACK>, GiveCheckoutFeedbackPayload {
9
+ }
10
+ interface GiveCheckoutFeedbackFunction {
11
+ (payload: GiveCheckoutFeedbackPayload): GiveCheckoutFeedback;
12
+ }
13
+ declare const giveCheckoutFeedback: GiveCheckoutFeedbackFunction;
14
+ export type { GiveCheckoutFeedback };
15
+ export { GIVE_CHECKOUT_FEEDBACK, giveCheckoutFeedback };
@@ -0,0 +1,7 @@
1
+ import { command } from "@lookiero/messaging";
2
+ const GIVE_CHECKOUT_FEEDBACK = "give_checkout_feedback";
3
+ const giveCheckoutFeedback = ({ aggregateId, ...payload }) => ({
4
+ ...command({ aggregateId, name: GIVE_CHECKOUT_FEEDBACK }),
5
+ ...payload,
6
+ });
7
+ export { GIVE_CHECKOUT_FEEDBACK, giveCheckoutFeedback };
@@ -0,0 +1,9 @@
1
+ import { AggregateRoot, CommandHandlerFunction } from "@lookiero/messaging";
2
+ import { GiveCheckoutFeedback } from "../command/giveCheckoutFeedback";
3
+ import { Feedbacks } from "./feedbacks";
4
+ interface CheckoutFeedback extends AggregateRoot {
5
+ readonly feedbacks: Feedbacks;
6
+ }
7
+ declare const giveCheckoutFeedbackHandler: CommandHandlerFunction<GiveCheckoutFeedback, CheckoutFeedback>;
8
+ export type { CheckoutFeedback };
9
+ export { giveCheckoutFeedbackHandler };
@@ -0,0 +1,10 @@
1
+ import { checkoutFeedbackGiven } from "./checkoutFeedbackGiven";
2
+ const giveCheckoutFeedbackHandler = () => async ({ aggregateRoot, command }) => {
3
+ const { aggregateId, feedbacks } = command;
4
+ return {
5
+ ...aggregateRoot,
6
+ feedbacks,
7
+ domainEvents: [checkoutFeedbackGiven({ aggregateId })],
8
+ };
9
+ };
10
+ export { giveCheckoutFeedbackHandler };
@@ -0,0 +1,13 @@
1
+ import { DomainEvent } from "@lookiero/messaging";
2
+ declare const CHECKOUT_FEEDBACK_GIVEN = "checkout_feedback_given";
3
+ interface CheckoutFeedbackGivenPayload {
4
+ readonly aggregateId: string;
5
+ }
6
+ interface CheckoutFeedbackGiven extends DomainEvent<typeof CHECKOUT_FEEDBACK_GIVEN>, CheckoutFeedbackGivenPayload {
7
+ }
8
+ interface CheckoutFeedbackGivenFunction {
9
+ (payload: CheckoutFeedbackGivenPayload): CheckoutFeedbackGiven;
10
+ }
11
+ declare const checkoutFeedbackGiven: CheckoutFeedbackGivenFunction;
12
+ export type { CheckoutFeedbackGiven };
13
+ export { CHECKOUT_FEEDBACK_GIVEN, checkoutFeedbackGiven };
@@ -0,0 +1,4 @@
1
+ import { domainEvent } from "@lookiero/messaging";
2
+ const CHECKOUT_FEEDBACK_GIVEN = "checkout_feedback_given";
3
+ const checkoutFeedbackGiven = ({ aggregateId }) => domainEvent({ aggregateId, name: CHECKOUT_FEEDBACK_GIVEN });
4
+ export { CHECKOUT_FEEDBACK_GIVEN, checkoutFeedbackGiven };
@@ -0,0 +1,7 @@
1
+ import { RepositoryGetFunction, RepositoryGetFunctionArgs, RepositorySaveFunction, RepositorySaveFunctionArgs } from "@lookiero/messaging";
2
+ import { CheckoutFeedback } from "./checkoutFeedback";
3
+ interface CheckoutFeedbacksGetFunction<CheckoutFeedbacksGetFunctionArgs extends RepositoryGetFunctionArgs> extends RepositoryGetFunction<CheckoutFeedback, CheckoutFeedbacksGetFunctionArgs> {
4
+ }
5
+ interface CheckoutFeedbacksSaveFunction<CheckoutFeedbacksSaveFunctionArgs extends RepositorySaveFunctionArgs> extends RepositorySaveFunction<CheckoutFeedback, CheckoutFeedbacksSaveFunctionArgs> {
6
+ }
7
+ export type { CheckoutFeedbacksGetFunction, CheckoutFeedbacksSaveFunction };
@@ -0,0 +1,3 @@
1
+ type CheckoutQuestionId = string;
2
+ type Feedbacks = Record<CheckoutQuestionId, CheckoutQuestionId | string>;
3
+ export type { Feedbacks };
@@ -4,6 +4,8 @@ import { Checkout } from "../../domain/checkout/model/checkout";
4
4
  import { CheckoutsGetFunction, CheckoutsSaveFunction } from "../../domain/checkout/model/checkouts";
5
5
  import { CheckoutBooking } from "../../domain/checkoutBooking/model/checkoutBooking";
6
6
  import { CheckoutBookingsGetFunction, CheckoutBookingsSaveFunction } from "../../domain/checkoutBooking/model/checkoutBookings";
7
+ import { CheckoutFeedback } from "../../domain/checkoutFeedback/model/checkoutFeedback";
8
+ import { CheckoutFeedbacksGetFunction, CheckoutFeedbacksSaveFunction } from "../../domain/checkoutFeedback/model/checkoutFeedbacks";
7
9
  import { CheckoutItem } from "../../domain/checkoutItem/model/checkoutItem";
8
10
  import { CheckoutItemsGetFunction, CheckoutItemsSaveFunction } from "../../domain/checkoutItem/model/checkoutItems";
9
11
  import { UiSetting } from "../../domain/uiSetting/model/uiSetting";
@@ -22,7 +24,7 @@ import { UiSettingByKeyView } from "../../projection/uiSetting/viewUiSettingByKe
22
24
  declare const MESSAGING_CONTEXT_ID = "Checkout";
23
25
  type NeverWhenEmptyRecord<K extends [Record<string, unknown>]> = K extends [Record<string, never>] ? [never?] : K;
24
26
  type RepositoryDependencies<A extends AggregateRoot, GetFunctionArgs extends RepositoryGetFunctionArgs, SaveFunctionArgs extends RepositorySaveFunctionArgs> = Omit<Parameters<RepositoryGetFunction<A, GetFunctionArgs>>[0] & Parameters<RepositorySaveFunction<A, SaveFunctionArgs>>[0], keyof RepositoryGetFunctionArgs>;
25
- interface BaseBootstrapFunctionArgs<UiSettingGetFunctionArgs extends RepositoryGetFunctionArgs, UiSettingSaveFunctionArgs extends RepositorySaveFunctionArgs, CheckoutGetFunctionArgs extends RepositoryGetFunctionArgs, CheckoutSaveFunctionArgs extends RepositorySaveFunctionArgs, CheckoutItemGetFunctionArgs extends RepositoryGetFunctionArgs, CheckoutItemSaveFunctionArgs extends RepositorySaveFunctionArgs, CheckoutBookingGetFunctionArgs extends RepositoryGetFunctionArgs, CheckoutBookingSaveFunctionArgs extends RepositorySaveFunctionArgs> {
27
+ interface BaseBootstrapFunctionArgs<UiSettingGetFunctionArgs extends RepositoryGetFunctionArgs, UiSettingSaveFunctionArgs extends RepositorySaveFunctionArgs, CheckoutGetFunctionArgs extends RepositoryGetFunctionArgs, CheckoutSaveFunctionArgs extends RepositorySaveFunctionArgs, CheckoutItemGetFunctionArgs extends RepositoryGetFunctionArgs, CheckoutItemSaveFunctionArgs extends RepositorySaveFunctionArgs, CheckoutBookingGetFunctionArgs extends RepositoryGetFunctionArgs, CheckoutBookingSaveFunctionArgs extends RepositorySaveFunctionArgs, CheckoutFeedbackGetFunctionArgs extends RepositoryGetFunctionArgs, CheckoutFeedbackSaveFunctionArgs extends RepositorySaveFunctionArgs> {
26
28
  readonly checkoutByIdView: CheckoutByIdView;
27
29
  readonly firstAvailableCheckoutByCustomerIdView: FirstAvailableCheckoutByCustomerIdView;
28
30
  readonly isCheckoutEnabledByCustomerIdView: IsCheckoutEnabledByCustomerIdView;
@@ -54,9 +56,14 @@ interface BaseBootstrapFunctionArgs<UiSettingGetFunctionArgs extends RepositoryG
54
56
  readonly checkoutBookingsDependencies: NeverWhenEmptyRecord<[
55
57
  RepositoryDependencies<CheckoutBooking, CheckoutBookingGetFunctionArgs, CheckoutBookingSaveFunctionArgs>
56
58
  ]>;
59
+ readonly getCheckoutFeedback: CheckoutFeedbacksGetFunction<CheckoutFeedbackGetFunctionArgs>;
60
+ readonly saveCheckoutFeedback: CheckoutFeedbacksSaveFunction<CheckoutFeedbackSaveFunctionArgs>;
61
+ readonly checkoutFeedbacksDependencies: NeverWhenEmptyRecord<[
62
+ RepositoryDependencies<CheckoutFeedback, CheckoutFeedbackGetFunctionArgs, CheckoutFeedbackSaveFunctionArgs>
63
+ ]>;
57
64
  }
58
65
  interface BaseBootstrapFunction {
59
- <UiSettingGetArgs extends RepositoryGetFunctionArgs, UiSettingSaveArgs extends RepositorySaveFunctionArgs, CheckoutGetFunctionArgs extends RepositoryGetFunctionArgs, CheckoutSaveFunctionArgs extends RepositorySaveFunctionArgs, CheckoutItemGetFunctionArgs extends RepositoryGetFunctionArgs, CheckoutItemSaveFunctionArgs extends RepositorySaveFunctionArgs, CheckoutBookingGetFunctionArgs extends RepositoryGetFunctionArgs, CheckoutBookingSaveFunctionArgs extends RepositorySaveFunctionArgs>(args: BaseBootstrapFunctionArgs<UiSettingGetArgs, UiSettingSaveArgs, CheckoutGetFunctionArgs, CheckoutSaveFunctionArgs, CheckoutItemGetFunctionArgs, CheckoutItemSaveFunctionArgs, CheckoutBookingGetFunctionArgs, CheckoutBookingSaveFunctionArgs>): BuildBootstrapFunctionReturn;
66
+ <UiSettingGetArgs extends RepositoryGetFunctionArgs, UiSettingSaveArgs extends RepositorySaveFunctionArgs, CheckoutGetFunctionArgs extends RepositoryGetFunctionArgs, CheckoutSaveFunctionArgs extends RepositorySaveFunctionArgs, CheckoutItemGetFunctionArgs extends RepositoryGetFunctionArgs, CheckoutItemSaveFunctionArgs extends RepositorySaveFunctionArgs, CheckoutBookingGetFunctionArgs extends RepositoryGetFunctionArgs, CheckoutBookingSaveFunctionArgs extends RepositorySaveFunctionArgs, CheckoutFeedbackGetFunctionArgs extends RepositoryGetFunctionArgs, CheckoutFeedbackSaveFunctionArgs extends RepositorySaveFunctionArgs>(args: BaseBootstrapFunctionArgs<UiSettingGetArgs, UiSettingSaveArgs, CheckoutGetFunctionArgs, CheckoutSaveFunctionArgs, CheckoutItemGetFunctionArgs, CheckoutItemSaveFunctionArgs, CheckoutBookingGetFunctionArgs, CheckoutBookingSaveFunctionArgs, CheckoutFeedbackGetFunctionArgs, CheckoutFeedbackSaveFunctionArgs>): BuildBootstrapFunctionReturn;
60
67
  }
61
68
  declare const baseBootstrap: BaseBootstrapFunction;
62
69
  export { baseBootstrap, MESSAGING_CONTEXT_ID };
@@ -4,6 +4,8 @@ import { START_CHECKOUT } from "../../domain/checkout/command/startCheckout";
4
4
  import { markCheckoutAsPaidHandler, startCheckoutHandler } from "../../domain/checkout/model/checkout";
5
5
  import { BOOK_CHECKOUT_BOOKING_FOR_CHECKOUT_ITEM } from "../../domain/checkoutBooking/command/bookCheckoutBookingForCheckoutItem";
6
6
  import { bookCheckoutBookingForCheckoutItemHandler, } from "../../domain/checkoutBooking/model/checkoutBooking";
7
+ import { GIVE_CHECKOUT_FEEDBACK } from "../../domain/checkoutFeedback/command/giveCheckoutFeedback";
8
+ import { giveCheckoutFeedbackHandler } from "../../domain/checkoutFeedback/model/checkoutFeedback";
7
9
  import { KEEP_CHECKOUT_ITEM } from "../../domain/checkoutItem/command/keepCheckoutItem";
8
10
  import { REPLACE_CHECKOUT_ITEM } from "../../domain/checkoutItem/command/replaceCheckoutItem";
9
11
  import { RETURN_CHECKOUT_ITEM } from "../../domain/checkoutItem/command/returnCheckoutItem";
@@ -23,7 +25,7 @@ import { viewPricingByCheckoutIdHandler, VIEW_PRICING_BY_CHECKOUT_ID, } from "..
23
25
  import { listReturnQuestionsByCheckoutItemIdHandler, LIST_RETURN_QUESTIONS_BY_CHECKOUT_ITEM_ID, } from "../../projection/returnQuestion/listReturnQuestionsByCheckoutItemId";
24
26
  import { viewUiSettingByKeyHandler, VIEW_UI_SETTING_BY_KEY, } from "../../projection/uiSetting/viewUiSettingByKey";
25
27
  const MESSAGING_CONTEXT_ID = "Checkout";
26
- const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdView, isCheckoutEnabledByCustomerIdView, fiveItemsDiscountByCustomerIdView, uiSettingByKeyView, checkoutItemByIdView, returnQuestionsByCheckoutItemIdView, bookedSizeChangeProductsVariantsForCheckoutItemView, pricingByCheckoutIdView, paymentFlowPayloadByCheckoutIdView, checkoutQuestionsByCheckoutIdView, getUiSetting, saveUiSetting, uiSettingsDependencies, getCheckout, saveCheckout, checkoutsDependencies, getCheckoutItem, saveCheckoutItem, checkoutItemsDependencies, getCheckoutBooking, saveCheckoutBooking, checkoutBookingsDependencies, }) => messagingBootstrap({ id: MESSAGING_CONTEXT_ID })
28
+ const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdView, isCheckoutEnabledByCustomerIdView, fiveItemsDiscountByCustomerIdView, uiSettingByKeyView, checkoutItemByIdView, returnQuestionsByCheckoutItemIdView, bookedSizeChangeProductsVariantsForCheckoutItemView, pricingByCheckoutIdView, paymentFlowPayloadByCheckoutIdView, checkoutQuestionsByCheckoutIdView, getUiSetting, saveUiSetting, uiSettingsDependencies, getCheckout, saveCheckout, checkoutsDependencies, getCheckoutItem, saveCheckoutItem, checkoutItemsDependencies, getCheckoutBooking, saveCheckoutBooking, checkoutBookingsDependencies, getCheckoutFeedback, saveCheckoutFeedback, checkoutFeedbacksDependencies, }) => messagingBootstrap({ id: MESSAGING_CONTEXT_ID })
27
29
  .query(VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID, viewFiveItemsDiscountByCustomerIdHandler, {
28
30
  view: fiveItemsDiscountByCustomerIdView,
29
31
  })
@@ -61,6 +63,7 @@ const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdVie
61
63
  view: bookedSizeChangeProductsVariantsForCheckoutItemView,
62
64
  })
63
65
  .command(BOOK_CHECKOUT_BOOKING_FOR_CHECKOUT_ITEM, bookCheckoutBookingForCheckoutItemHandler)(getCheckoutBooking, saveCheckoutBooking, ...checkoutBookingsDependencies)
66
+ .command(GIVE_CHECKOUT_FEEDBACK, giveCheckoutFeedbackHandler)(getCheckoutFeedback, saveCheckoutFeedback, ...checkoutFeedbacksDependencies)
64
67
  .query(VIEW_UI_SETTING_BY_KEY, viewUiSettingByKeyHandler, {
65
68
  view: uiSettingByKeyView,
66
69
  })
@@ -1,5 +1,6 @@
1
1
  import { getCheckout, saveCheckout } from "../domain/checkout/model/httpCheckouts";
2
2
  import { getCheckoutBooking, saveCheckoutBooking } from "../domain/checkoutBooking/model/httpCheckoutBookings";
3
+ import { getCheckoutFeedback, saveCheckoutFeedback } from "../domain/checkoutFeedback/model/httpCheckoutFeedbacks";
3
4
  import { getCheckoutItem, saveCheckoutItem } from "../domain/checkoutItem/model/httpCheckoutItems";
4
5
  import { getUiSetting, saveUiSetting } from "../domain/uiSetting/model/storageUiSettings";
5
6
  import { read, write } from "../persistence/asyncStorageStorage";
@@ -51,6 +52,9 @@ const bootstrap = ({ apiUrl, authToken }) => {
51
52
  getCheckoutBooking,
52
53
  saveCheckoutBooking,
53
54
  checkoutBookingsDependencies: [{ httpPost }],
55
+ getCheckoutFeedback,
56
+ saveCheckoutFeedback,
57
+ checkoutFeedbacksDependencies: [{ httpPost }],
54
58
  });
55
59
  };
56
60
  export { bootstrap };
@@ -0,0 +1,14 @@
1
+ import { CheckoutFeedbackProjection } from "../../../projection/checkoutFeedback/checkoutFeedback";
2
+ interface CheckoutFeedbackDataSourceFunctionArgs {
3
+ readonly data: CheckoutFeedbackProjection;
4
+ }
5
+ interface CheckoutFeedbackDataSource {
6
+ readonly getCheckoutFeedback: (id: string) => CheckoutFeedbackProjection | undefined;
7
+ readonly saveCheckoutFeedback: (checkoutFeedback: CheckoutFeedbackProjection) => void;
8
+ }
9
+ interface CheckoutFeedbackDataSourceFunction {
10
+ (args: CheckoutFeedbackDataSourceFunctionArgs): CheckoutFeedbackDataSource;
11
+ }
12
+ declare const checkoutFeedbackDataSource: CheckoutFeedbackDataSourceFunction;
13
+ export type { CheckoutFeedbackDataSource };
14
+ export { checkoutFeedbackDataSource };
@@ -0,0 +1,12 @@
1
+ const checkoutFeedbackDataSource = ({ data: initialData }) => {
2
+ let data = initialData;
3
+ const getCheckoutFeedback = () => data;
4
+ const saveCheckoutFeedback = (checkoutFeedback) => {
5
+ data = checkoutFeedback;
6
+ };
7
+ return {
8
+ getCheckoutFeedback,
9
+ saveCheckoutFeedback,
10
+ };
11
+ };
12
+ export { checkoutFeedbackDataSource };
@@ -0,0 +1,14 @@
1
+ import { RepositoryGetFunctionArgs, RepositorySaveFunctionArgs } from "@lookiero/messaging";
2
+ import { CheckoutFeedback } from "../../../domain/checkoutFeedback/model/checkoutFeedback";
3
+ import { CheckoutFeedbacksGetFunction, CheckoutFeedbacksSaveFunction } from "../../../domain/checkoutFeedback/model/checkoutFeedbacks";
4
+ import { CheckoutFeedbackProjection } from "../../../projection/checkoutFeedback/checkoutFeedback";
5
+ import { CheckoutFeedbackDataSource } from "./checkoutFeedbackDataSource";
6
+ declare const toCheckoutFeedbackProjection: (checkoutFeedback: CheckoutFeedback) => CheckoutFeedbackProjection;
7
+ declare const getCheckoutFeedback: CheckoutFeedbacksGetFunction<RepositoryGetFunctionArgs>;
8
+ interface DataSourceCheckoutItemsSaveFunctionArgs extends RepositorySaveFunctionArgs {
9
+ readonly dataSource: CheckoutFeedbackDataSource;
10
+ }
11
+ interface DataSourceCheckoutItemsSaveFunction extends CheckoutFeedbacksSaveFunction<DataSourceCheckoutItemsSaveFunctionArgs> {
12
+ }
13
+ declare const saveCheckoutFeedback: DataSourceCheckoutItemsSaveFunction;
14
+ export { getCheckoutFeedback, saveCheckoutFeedback, toCheckoutFeedbackProjection };
@@ -0,0 +1,19 @@
1
+ import invariant from "tiny-invariant";
2
+ import { viewCheckoutFeedbackById, } from "../../../projection/checkoutFeedback/viewCheckoutFeedbackById";
3
+ const toCheckoutFeedbackDomain = (checkoutFeedback) => {
4
+ invariant(checkoutFeedback, "No checkoutFeedback found!");
5
+ return {
6
+ aggregateId: checkoutFeedback.id,
7
+ feedbacks: checkoutFeedback.feedbacks,
8
+ domainEvents: [],
9
+ };
10
+ };
11
+ const toCheckoutFeedbackProjection = (checkoutFeedback) => ({
12
+ id: checkoutFeedback.aggregateId,
13
+ feedbacks: checkoutFeedback.feedbacks,
14
+ });
15
+ const getCheckoutFeedback = ({ queryBus }) => async (aggregateId) => toCheckoutFeedbackDomain(await queryBus(viewCheckoutFeedbackById({ checkoutFeedbackId: aggregateId })));
16
+ const saveCheckoutFeedback = ({ dataSource }) => async (aggregateRoot) => {
17
+ dataSource.saveCheckoutFeedback(toCheckoutFeedbackProjection(aggregateRoot));
18
+ };
19
+ export { getCheckoutFeedback, saveCheckoutFeedback, toCheckoutFeedbackProjection };
@@ -0,0 +1,16 @@
1
+ import { RepositoryGetFunctionArgs, RepositorySaveFunctionArgs } from "@lookiero/messaging";
2
+ import { CheckoutFeedbacksGetFunction, CheckoutFeedbacksSaveFunction } from "../../../../domain/checkoutFeedback/model/checkoutFeedbacks";
3
+ import { HttpPostFunction } from "../../../delivery/http/httpClient";
4
+ interface HttpCheckoutFeedbacksGetFunctionArgs extends RepositoryGetFunctionArgs {
5
+ }
6
+ interface HttpCheckoutFeedbacksGetFunction extends CheckoutFeedbacksGetFunction<HttpCheckoutFeedbacksGetFunctionArgs> {
7
+ }
8
+ declare const getCheckoutFeedback: HttpCheckoutFeedbacksGetFunction;
9
+ interface HttpCheckoutFeedbacksSaveFunctionArgs extends RepositorySaveFunctionArgs {
10
+ readonly httpPost: HttpPostFunction;
11
+ }
12
+ interface HttpCheckoutFeedbacksSaveFunction extends CheckoutFeedbacksSaveFunction<HttpCheckoutFeedbacksSaveFunctionArgs> {
13
+ }
14
+ declare const saveCheckoutFeedback: HttpCheckoutFeedbacksSaveFunction;
15
+ export type { HttpCheckoutFeedbacksSaveFunction };
16
+ export { getCheckoutFeedback, saveCheckoutFeedback };
@@ -0,0 +1,14 @@
1
+ import invariant from "tiny-invariant";
2
+ import { viewCheckoutFeedbackById, } from "../../../../projection/checkoutFeedback/viewCheckoutFeedbackById";
3
+ import { httpCheckoutFeedbacksGive } from "./httpCheckoutFeedbacksGive";
4
+ const toDomain = (checkoutFeedback) => {
5
+ invariant(checkoutFeedback, "Not checkoutFeedback found!");
6
+ return {
7
+ aggregateId: checkoutFeedback.id,
8
+ feedbacks: checkoutFeedback.feedbacks,
9
+ domainEvents: [],
10
+ };
11
+ };
12
+ const getCheckoutFeedback = ({ queryBus }) => async (aggregateId) => toDomain(await queryBus(viewCheckoutFeedbackById({ checkoutFeedbackId: aggregateId })));
13
+ const saveCheckoutFeedback = ({ httpPost }) => async (aggregateRoot) => await httpCheckoutFeedbacksGive({ httpPost })(aggregateRoot);
14
+ export { getCheckoutFeedback, saveCheckoutFeedback };
@@ -0,0 +1,5 @@
1
+ import { HttpCheckoutFeedbacksSaveFunction } from "./httpCheckoutFeedbacks";
2
+ interface HttpCheckoutFeedbackGiveFunction extends HttpCheckoutFeedbacksSaveFunction {
3
+ }
4
+ declare const httpCheckoutFeedbacksGive: HttpCheckoutFeedbackGiveFunction;
5
+ export { httpCheckoutFeedbacksGive };
@@ -0,0 +1,13 @@
1
+ import { CHECKOUT_FEEDBACK_GIVEN, } from "../../../../domain/checkoutFeedback/model/checkoutFeedbackGiven";
2
+ const isCheckoutFeedbackGiven = (event) => event.name === CHECKOUT_FEEDBACK_GIVEN;
3
+ const httpCheckoutFeedbacksGive = ({ httpPost }) => async ({ aggregateId, feedbacks, domainEvents }) => {
4
+ const checkoutFeedbackGiven = domainEvents.find(isCheckoutFeedbackGiven);
5
+ if (!checkoutFeedbackGiven) {
6
+ return;
7
+ }
8
+ await httpPost({
9
+ endpoint: "/give-checkout-feedback",
10
+ body: { checkoutId: aggregateId, feedbacks },
11
+ });
12
+ };
13
+ export { httpCheckoutFeedbacksGive };
@@ -0,0 +1,17 @@
1
+ import { CommandStatus } from "@lookiero/messaging-react";
2
+ import { Feedbacks } from "../../../../domain/checkoutFeedback/model/feedbacks";
3
+ interface GiveCheckoutFeedbackFunctionArgs {
4
+ readonly feedbacks: Feedbacks;
5
+ }
6
+ interface GiveCheckoutFeedbackFunction {
7
+ (args: GiveCheckoutFeedbackFunctionArgs): Promise<void>;
8
+ }
9
+ type UseGiveCheckoutFeedback = [giveCheckoutFeedback: GiveCheckoutFeedbackFunction, status: CommandStatus];
10
+ interface UseGiveCheckoutFeedbackFunctionArgs {
11
+ readonly checkoutId: string;
12
+ }
13
+ interface UseGiveCheckoutFeedbackFunction {
14
+ (args: UseGiveCheckoutFeedbackFunctionArgs): UseGiveCheckoutFeedback;
15
+ }
16
+ declare const useGiveCheckoutFeedback: UseGiveCheckoutFeedbackFunction;
17
+ export { useGiveCheckoutFeedback };
@@ -0,0 +1,13 @@
1
+ import { useCommand } from "@lookiero/messaging-react";
2
+ import { useCallback } from "react";
3
+ import { giveCheckoutFeedback as giveCheckoutFeedbackCommand } from "../../../../domain/checkoutFeedback/command/giveCheckoutFeedback";
4
+ import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
5
+ const useGiveCheckoutFeedback = ({ checkoutId }) => {
6
+ const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
7
+ const giveCheckoutFeedback = useCallback(({ feedbacks }) => commandBus(giveCheckoutFeedbackCommand({
8
+ aggregateId: checkoutId,
9
+ feedbacks,
10
+ })), [checkoutId, commandBus]);
11
+ return [giveCheckoutFeedback, status];
12
+ };
13
+ export { useGiveCheckoutFeedback };
@@ -1,4 +1,6 @@
1
1
  import { useQuery } from "@lookiero/messaging-react";
2
+ import { CHECKOUT_PAID } from "../../../../domain/checkout/model/checkoutPaid";
3
+ import { CHECKOUT_FEEDBACK_GIVEN, } from "../../../../domain/checkoutFeedback/model/checkoutFeedbackGiven";
2
4
  import { CHECKOUT_ITEM_KEPT } from "../../../../domain/checkoutItem/model/checkoutItemKept";
3
5
  import { CHECKOUT_ITEM_REPLACED, } from "../../../../domain/checkoutItem/model/checkoutItemReplaced";
4
6
  import { CHECKOUT_ITEM_RETURNED, } from "../../../../domain/checkoutItem/model/checkoutItemReturned";
@@ -7,7 +9,13 @@ import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
7
9
  const isCheckoutItemKept = (event) => event.name === CHECKOUT_ITEM_KEPT;
8
10
  const isCheckoutItemReturned = (event) => event.name === CHECKOUT_ITEM_RETURNED;
9
11
  const isCheckoutItemReplaced = (event) => event.name === CHECKOUT_ITEM_REPLACED;
10
- const shouldInvalidate = (event) => isCheckoutItemKept(event) || isCheckoutItemReplaced(event) || isCheckoutItemReturned(event);
12
+ const isCheckoutPaid = (event) => event.name === CHECKOUT_PAID;
13
+ const isCheckoutFeedbackGiven = (event) => event.name === CHECKOUT_FEEDBACK_GIVEN;
14
+ const shouldInvalidate = (event) => isCheckoutItemKept(event) ||
15
+ isCheckoutItemReplaced(event) ||
16
+ isCheckoutItemReturned(event) ||
17
+ isCheckoutPaid(event) ||
18
+ isCheckoutFeedbackGiven(event);
11
19
  const useViewFirstAvailableCheckoutByCustomerId = ({ customerId }) => useQuery({
12
20
  query: viewFirstAvailableCheckoutByCustomerId({ customerId }),
13
21
  contextId: MESSAGING_CONTEXT_ID,
@@ -0,0 +1,12 @@
1
+ import { CheckoutFeedbackByIdView } from "../../../projection/checkoutFeedback/viewCheckoutFeedbackById";
2
+ import { HttpPostFunction } from "../../delivery/http/httpClient";
3
+ interface HttpCheckoutFeebackByIdView extends CheckoutFeedbackByIdView {
4
+ }
5
+ interface HttpCheckoutFeebackByIdViewFunctionArgs {
6
+ readonly httpPost: HttpPostFunction;
7
+ }
8
+ interface HttpCheckoutFeebackByIdViewFunction {
9
+ (args: HttpCheckoutFeebackByIdViewFunctionArgs): HttpCheckoutFeebackByIdView;
10
+ }
11
+ declare const httpCheckoutFeebackByIdView: HttpCheckoutFeebackByIdViewFunction;
12
+ export { httpCheckoutFeebackByIdView };
@@ -0,0 +1,9 @@
1
+ const httpCheckoutFeebackByIdView = ({ httpPost }) => async ({ checkoutFeedbackId, signal }) => {
2
+ const response = await httpPost({
3
+ endpoint: "/view-checkout-feedback-by-id",
4
+ body: { checkoutFeedbackId },
5
+ signal,
6
+ });
7
+ return !response.ok || response.status === 404 ? null : (await response.json()).result;
8
+ };
9
+ export { httpCheckoutFeebackByIdView };
@@ -0,0 +1,29 @@
1
+ import { FC, ReactNode } from "react";
2
+ import { FeedbackProjection } from "../../../../../../projection/checkoutFeedback/feedback";
3
+ interface OnChangeCheckoutQuestionFeedbackFunctionArgs {
4
+ readonly checkoutQuestionId: string;
5
+ readonly checkoutQuestionFeedback: string | undefined;
6
+ }
7
+ interface OnChangeCheckoutQuestionFeedbackFunction {
8
+ (args: OnChangeCheckoutQuestionFeedbackFunctionArgs): void;
9
+ }
10
+ interface CheckoutQuestionFeedbackContextProviderProps {
11
+ readonly feedback: FeedbackProjection | undefined;
12
+ readonly children: ReactNode;
13
+ }
14
+ declare const CheckoutQuestionFeedbackProvider: FC<CheckoutQuestionFeedbackContextProviderProps>;
15
+ interface UseCheckoutQuestionFeedbackForIdFunctionArgs {
16
+ readonly id: string;
17
+ }
18
+ interface UseCheckoutQuestionFeedbackForIdFunction {
19
+ (args: UseCheckoutQuestionFeedbackForIdFunctionArgs): {
20
+ readonly feedback: string | undefined;
21
+ readonly onChange: OnChangeCheckoutQuestionFeedbackFunction;
22
+ };
23
+ }
24
+ declare const useCheckoutQuestionFeedbackForId: UseCheckoutQuestionFeedbackForIdFunction;
25
+ interface UseCheckoutQuestionFeedbackFunction {
26
+ (): FeedbackProjection;
27
+ }
28
+ declare const useCheckoutQuestionFeedback: UseCheckoutQuestionFeedbackFunction;
29
+ export { useCheckoutQuestionFeedbackForId, useCheckoutQuestionFeedback, CheckoutQuestionFeedbackProvider };
@@ -0,0 +1,28 @@
1
+ import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
2
+ import invariant from "tiny-invariant";
3
+ const CheckoutQuestionFeedbackContext = createContext(null);
4
+ const CheckoutQuestionFeedbackProvider = ({ feedback = {}, children, }) => {
5
+ const [contextFeedback, setContextFeedback] = useState(feedback);
6
+ const onChange = useCallback(({ checkoutQuestionId, checkoutQuestionFeedback }) => setContextFeedback((feedback) => checkoutQuestionFeedback
7
+ ? { ...feedback, [checkoutQuestionId]: checkoutQuestionFeedback }
8
+ : Object.entries(feedback).reduce((acc, [id, feedback]) => (id !== checkoutQuestionId ? { ...acc, [id]: feedback } : acc), {})), []);
9
+ useEffect(() => setContextFeedback(feedback), [feedback]);
10
+ const value = useMemo(() => ({
11
+ feedback: contextFeedback,
12
+ onChange,
13
+ }), [contextFeedback, onChange]);
14
+ return React.createElement(CheckoutQuestionFeedbackContext.Provider, { value: value }, children);
15
+ };
16
+ const useCheckoutQuestionFeedbackForId = ({ id }) => {
17
+ const checkoutQuestionFeedbackContext = useContext(CheckoutQuestionFeedbackContext);
18
+ invariant(checkoutQuestionFeedbackContext, "Your are trying to use the useCheckoutQuestionFeedbackForId hook without wrapping your app with the <CheckoutQuestionFeedbackProvider>.");
19
+ const { feedback, onChange } = checkoutQuestionFeedbackContext;
20
+ return { feedback: feedback[id], onChange };
21
+ };
22
+ const useCheckoutQuestionFeedback = () => {
23
+ const checkoutQuestionFeedbackContext = useContext(CheckoutQuestionFeedbackContext);
24
+ invariant(checkoutQuestionFeedbackContext, "Your are trying to use the useCheckoutQuestionFeedback hook without wrapping your app with the <CheckoutQuestionFeedbackProvider>.");
25
+ const { feedback } = checkoutQuestionFeedbackContext;
26
+ return feedback;
27
+ };
28
+ export { useCheckoutQuestionFeedbackForId, useCheckoutQuestionFeedback, CheckoutQuestionFeedbackProvider };
@@ -3,16 +3,20 @@ import { BUTTON_VARIANT } from "@lookiero/aurora-next/build/components/atoms/But
3
3
  import { useI18nMessage } from "@lookiero/i18n-react";
4
4
  import React, { useCallback } from "react";
5
5
  import { CHECKOUT_QUESTIONS_PREFIX } from "../../../../../i18n/i18n";
6
+ import { theme } from "../../../../../theme/theme";
7
+ import { useCheckoutQuestionFeedbackForId } from "../../behaviors/useCheckoutQuestionFeedback";
6
8
  import { style } from "./ButtonCheckoutQuestionItem.style";
7
- const ButtonCheckoutQuestionItem = ({ checkoutQuestion }) => {
9
+ const { colorAccent, colorBase } = theme();
10
+ const ButtonCheckoutQuestionItem = ({ checkoutQuestion, checkoutQuestionParentId, }) => {
11
+ const { feedback, onChange } = useCheckoutQuestionFeedbackForId({ id: checkoutQuestionParentId });
8
12
  const optionText = useI18nMessage({ id: checkoutQuestion.name, prefix: CHECKOUT_QUESTIONS_PREFIX });
9
- const handleOnPress = useCallback(() => void 0, []);
13
+ const handleOnPress = useCallback(() => onChange({ checkoutQuestionId: checkoutQuestionParentId, checkoutQuestionFeedback: checkoutQuestion.id }), [onChange, checkoutQuestion.id, checkoutQuestionParentId]);
10
14
  return (React.createElement(Button
11
15
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
12
16
  // @ts-ignore
13
17
  , {
14
18
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
15
19
  // @ts-ignore
16
- style: style.button, variant: BUTTON_VARIANT.SECONDARY, onPress: handleOnPress }, optionText));
20
+ style: [style.button, { backgroundColor: feedback === checkoutQuestion.id ? colorAccent : colorBase }], variant: BUTTON_VARIANT.SECONDARY, onPress: handleOnPress }, optionText));
17
21
  };
18
22
  export { ButtonCheckoutQuestionItem };
@@ -1,10 +1,13 @@
1
1
  import React, { useCallback } from "react";
2
2
  import { Pressable } from "react-native";
3
3
  import invariant from "tiny-invariant";
4
+ import { theme } from "../../../../../theme/theme";
5
+ import { useCheckoutQuestionFeedbackForId } from "../../behaviors/useCheckoutQuestionFeedback";
4
6
  import { style } from "./IconCheckoutQuestionItem.style";
5
7
  import { Happy } from "./icons/Happy";
6
8
  import { Normal } from "./icons/Normal";
7
9
  import { Sad } from "./icons/Sad";
10
+ const { colorAccent } = theme();
8
11
  const ICON = {
9
12
  // eslint-disable-next-line @typescript-eslint/naming-convention
10
13
  "checkout.checkout_question.icon.bad": Sad,
@@ -13,11 +16,12 @@ const ICON = {
13
16
  // eslint-disable-next-line @typescript-eslint/naming-convention
14
17
  "checkout.checkout_question.icon.good": Happy,
15
18
  };
16
- const IconCheckoutQuestionItem = ({ checkoutQuestion }) => {
19
+ const IconCheckoutQuestionItem = ({ checkoutQuestion, checkoutQuestionParentId, }) => {
17
20
  const Icon = ICON[checkoutQuestion.name];
18
- const handleOnPress = useCallback(() => void 0, []);
21
+ const { feedback, onChange } = useCheckoutQuestionFeedbackForId({ id: checkoutQuestionParentId });
22
+ const handleOnPress = useCallback(() => onChange({ checkoutQuestionId: checkoutQuestionParentId, checkoutQuestionFeedback: checkoutQuestion.id }), [onChange, checkoutQuestion.id, checkoutQuestionParentId]);
19
23
  invariant(Icon, "CheckoutQuestion icon does not exist");
20
24
  return (React.createElement(Pressable, { onPress: handleOnPress },
21
- React.createElement(Icon, { style: style.icon, testID: checkoutQuestion.name })));
25
+ React.createElement(Icon, { fill: feedback === checkoutQuestion.id ? colorAccent : "none", style: style.icon, testID: checkoutQuestion.name })));
22
26
  };
23
27
  export { IconCheckoutQuestionItem };
@@ -1,15 +1,16 @@
1
1
  import { useI18nMessage } from "@lookiero/i18n-react";
2
- import React, { useCallback, useState } from "react";
2
+ import React, { useCallback } from "react";
3
3
  import { InputField } from "../../../../../../../shared/ui/components/molecules/inputField/InputField";
4
4
  import { RETURN_QUESTIONS_PREFIX } from "../../../../../i18n/i18n";
5
+ import { useCheckoutQuestionFeedbackForId } from "../../behaviors/useCheckoutQuestionFeedback";
5
6
  const TEXTAREA_MIN_HEIGHT = 96;
6
- const TextareaCheckoutQuestionItem = ({ checkoutQuestion }) => {
7
+ const TextareaCheckoutQuestionItem = ({ checkoutQuestion, checkoutQuestionParentId, }) => {
7
8
  const placeholderText = useI18nMessage({
8
9
  id: checkoutQuestion.placeholder,
9
10
  prefix: RETURN_QUESTIONS_PREFIX,
10
11
  });
11
- const [value, setValue] = useState("");
12
- const handleOnChange = useCallback((value) => setValue(value), []);
13
- return (React.createElement(InputField, { label: placeholderText, minHeight: TEXTAREA_MIN_HEIGHT, placeholder: placeholderText, value: value, multiline: true, onChange: handleOnChange }));
12
+ const { feedback, onChange } = useCheckoutQuestionFeedbackForId({ id: checkoutQuestionParentId });
13
+ const handleOnChange = useCallback((value) => onChange({ checkoutQuestionId: checkoutQuestionParentId, checkoutQuestionFeedback: value }), [onChange, checkoutQuestionParentId]);
14
+ return (React.createElement(InputField, { label: placeholderText, minHeight: TEXTAREA_MIN_HEIGHT, placeholder: placeholderText, value: feedback, multiline: true, onChange: handleOnChange }));
14
15
  };
15
16
  export { TextareaCheckoutQuestionItem };
@@ -1,35 +1,30 @@
1
- import { Button } from "@lookiero/aurora-next/build/components/atoms/Button/Button";
2
- import { useI18nMessage } from "@lookiero/i18n-react";
3
- import { QueryStatus } from "@lookiero/messaging-react";
1
+ import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
4
2
  import React, { useCallback } from "react";
5
3
  import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
4
+ import { useGiveCheckoutFeedback } from "../../../domain/checkoutFeedback/react/useGiveCheckoutFeedback";
6
5
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
7
6
  import { useListCheckoutQuestionsByCheckoutId } from "../../../projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId";
8
7
  import { Body } from "../../components/layouts/body/Body";
8
+ import { CheckoutQuestionFeedbackProvider } from "../../components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionFeedback";
9
9
  import { SafeAreaScrollView } from "../../components/templates/SafeAreaScrollView";
10
- import { I18nMessages } from "../../i18n/i18n";
11
10
  import { style } from "./Feedback.style";
12
11
  import { CheckoutQuestionsForm } from "./components/checkoutQuestionsForm/CheckoutQuestionsForm";
13
12
  const Feedback = ({ customerId }) => {
14
- const buttonText = useI18nMessage({ id: I18nMessages.FEEDBACK_BUTTON });
15
13
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
16
14
  const [checkoutQuestions, checkoutQuestionsStatus] = useListCheckoutQuestionsByCheckoutId({
17
15
  checkoutId: checkout?.id,
18
16
  });
19
- const handlePress = useCallback(() => void 0, []);
17
+ const [giveCheckoutFeedback, giveCheckoutFeedbackStatus] = useGiveCheckoutFeedback({
18
+ checkoutId: checkout?.id,
19
+ });
20
+ const handleOnSubmit = useCallback((feedbacks) => giveCheckoutFeedback({ feedbacks }), [giveCheckoutFeedback]);
20
21
  const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
21
22
  const dependenciesLoaded = dependenciesLoadedStatuses.includes(checkoutStatus) && dependenciesLoadedStatuses.includes(checkoutQuestionsStatus);
22
23
  if (!dependenciesLoaded)
23
24
  return React.createElement(Spinner, null);
24
- return (React.createElement(SafeAreaScrollView, null,
25
- React.createElement(Body, { style: { column: style.bodyColumn } },
26
- React.createElement(CheckoutQuestionsForm, { checkoutQuestions: checkoutQuestions || [] }),
27
- React.createElement(Button
28
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
29
- // @ts-ignore
30
- , {
31
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
32
- // @ts-ignore
33
- style: style.button, onPress: handlePress }, buttonText))));
25
+ return (React.createElement(CheckoutQuestionFeedbackProvider, { feedback: {} },
26
+ React.createElement(SafeAreaScrollView, null,
27
+ React.createElement(Body, { style: { column: style.bodyColumn } },
28
+ React.createElement(CheckoutQuestionsForm, { checkoutQuestions: checkoutQuestions || [], submitButtonDisabled: giveCheckoutFeedbackStatus === CommandStatus.LOADING, onSubmit: handleOnSubmit })))));
34
29
  };
35
30
  export { Feedback };
@@ -2,8 +2,5 @@ declare const style: {
2
2
  bodyColumn: {
3
3
  paddingHorizontal: number;
4
4
  };
5
- button: {
6
- marginTop: number;
7
- };
8
5
  };
9
6
  export { style };
@@ -5,8 +5,5 @@ const style = StyleSheet.create({
5
5
  bodyColumn: {
6
6
  paddingHorizontal: spaceXL,
7
7
  },
8
- button: {
9
- marginTop: 65,
10
- },
11
8
  });
12
9
  export { style };
@@ -1,7 +1,10 @@
1
1
  import { FC } from "react";
2
+ import { FeedbackProjection } from "../../../../../../projection/checkoutFeedback/feedback";
2
3
  import { CheckoutQuestionProjection } from "../../../../../../projection/checkoutQuestion/checkoutQuestion";
3
4
  interface CheckoutQuestionsFormProps {
4
5
  readonly checkoutQuestions: CheckoutQuestionProjection[];
6
+ readonly submitButtonDisabled: boolean;
7
+ readonly onSubmit: (feedback: FeedbackProjection) => void;
5
8
  }
6
9
  declare const CheckoutQuestionsForm: FC<CheckoutQuestionsFormProps>;
7
10
  export { CheckoutQuestionsForm };
@@ -1,12 +1,17 @@
1
- import React from "react";
1
+ import { Button } from "@lookiero/aurora-next/build/components/atoms/Button/Button";
2
+ import { useI18nMessage } from "@lookiero/i18n-react";
3
+ import React, { useCallback } from "react";
2
4
  import { CheckoutQuestionType, } from "../../../../../../projection/checkoutQuestion/checkoutQuestion";
3
5
  import { CheckoutQuestions } from "../../../../components/organisms/checkoutQuestions/CheckoutQuestions";
6
+ import { useCheckoutQuestionFeedback } from "../../../../components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionFeedback";
4
7
  import { CheckoutQuestionItemProvider, } from "../../../../components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionItem";
5
8
  import { ButtonCheckoutQuestionItem } from "../../../../components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem";
6
9
  import { HostDefaultCheckoutQuestionItem } from "../../../../components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultCheckoutQuestionItem";
7
10
  import { HostSelectCheckoutQuestionItem } from "../../../../components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem";
8
11
  import { IconCheckoutQuestionItem } from "../../../../components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem";
9
12
  import { TextareaCheckoutQuestionItem } from "../../../../components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem";
13
+ import { I18nMessages } from "../../../../i18n/i18n";
14
+ import { style } from "./CheckoutQuestionsForm.style";
10
15
  const checkoutQuestionItems = {
11
16
  [CheckoutQuestionType.HOST_DEFAULT]: HostDefaultCheckoutQuestionItem,
12
17
  [CheckoutQuestionType.HOST_TEXTAREA]: HostDefaultCheckoutQuestionItem,
@@ -15,6 +20,16 @@ const checkoutQuestionItems = {
15
20
  [CheckoutQuestionType.ICON]: IconCheckoutQuestionItem,
16
21
  [CheckoutQuestionType.BUTTON]: ButtonCheckoutQuestionItem,
17
22
  };
18
- const CheckoutQuestionsForm = ({ checkoutQuestions }) => (React.createElement(CheckoutQuestionItemProvider, { checkoutQuestionItems: checkoutQuestionItems },
19
- React.createElement(CheckoutQuestions, { checkoutQuestions: checkoutQuestions })));
23
+ const CheckoutQuestionsForm = ({ checkoutQuestions, submitButtonDisabled, onSubmit, }) => {
24
+ const buttonText = useI18nMessage({ id: I18nMessages.FEEDBACK_BUTTON });
25
+ const feedback = useCheckoutQuestionFeedback();
26
+ const handlePress = useCallback(() => onSubmit(feedback), [feedback, onSubmit]);
27
+ return (React.createElement(React.Fragment, null,
28
+ React.createElement(CheckoutQuestionItemProvider, { checkoutQuestionItems: checkoutQuestionItems },
29
+ React.createElement(CheckoutQuestions, { checkoutQuestions: checkoutQuestions })),
30
+ React.createElement(Button, { busy: submitButtonDisabled,
31
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
32
+ // @ts-ignore
33
+ style: style.button, onPress: handlePress }, buttonText)));
34
+ };
20
35
  export { CheckoutQuestionsForm };
@@ -0,0 +1,6 @@
1
+ declare const style: {
2
+ button: {
3
+ marginTop: number;
4
+ };
5
+ };
6
+ export { style };
@@ -0,0 +1,7 @@
1
+ import { StyleSheet } from "react-native";
2
+ const style = StyleSheet.create({
3
+ button: {
4
+ marginTop: 65,
5
+ },
6
+ });
7
+ export { style };
@@ -0,0 +1,6 @@
1
+ import { FeedbackProjection } from "./feedback";
2
+ interface CheckoutFeedbackProjection {
3
+ readonly id: string;
4
+ readonly feedbacks: FeedbackProjection;
5
+ }
6
+ export type { CheckoutFeedbackProjection };
@@ -0,0 +1,3 @@
1
+ type CheckoutQuestionId = string;
2
+ type FeedbackProjection = Record<CheckoutQuestionId, CheckoutQuestionId | string>;
3
+ export type { FeedbackProjection };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,25 @@
1
+ import { CancelableQueryViewArgs, Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
2
+ import { CheckoutFeedbackProjection } from "./checkoutFeedback";
3
+ declare const VIEW_CHECKOUT_FEEDBACK_BY_ID = "view_checkout_feedback_by_id";
4
+ interface ViewCheckoutFeedbackByIdPayload {
5
+ readonly checkoutFeedbackId: string;
6
+ }
7
+ interface ViewCheckoutFeedbackById extends Query<typeof VIEW_CHECKOUT_FEEDBACK_BY_ID>, ViewCheckoutFeedbackByIdPayload {
8
+ }
9
+ interface ViewCheckoutFeedbackByIdFunction {
10
+ (payload: ViewCheckoutFeedbackByIdPayload): ViewCheckoutFeedbackById;
11
+ }
12
+ declare const viewCheckoutFeedbackById: ViewCheckoutFeedbackByIdFunction;
13
+ type ViewCheckoutFeedbackByIdResult = CheckoutFeedbackProjection | null;
14
+ interface CheckoutFeedbackByIdViewArgs extends CancelableQueryViewArgs {
15
+ readonly checkoutFeedbackId: string;
16
+ }
17
+ interface CheckoutFeedbackByIdView {
18
+ (args: CheckoutFeedbackByIdViewArgs): Promise<ViewCheckoutFeedbackByIdResult>;
19
+ }
20
+ interface ViewCheckoutFeedbackByIdHandlerFunctionArgs extends QueryHandlerFunctionArgs {
21
+ readonly view: CheckoutFeedbackByIdView;
22
+ }
23
+ declare const viewCheckoutFeedbackByIdHandler: QueryHandlerFunction<ViewCheckoutFeedbackById, ViewCheckoutFeedbackByIdResult, ViewCheckoutFeedbackByIdHandlerFunctionArgs>;
24
+ export type { ViewCheckoutFeedbackById, CheckoutFeedbackByIdView, ViewCheckoutFeedbackByIdResult };
25
+ export { VIEW_CHECKOUT_FEEDBACK_BY_ID, viewCheckoutFeedbackById, viewCheckoutFeedbackByIdHandler };
@@ -0,0 +1,8 @@
1
+ import { query, } from "@lookiero/messaging";
2
+ const VIEW_CHECKOUT_FEEDBACK_BY_ID = "view_checkout_feedback_by_id";
3
+ const viewCheckoutFeedbackById = (payload) => ({
4
+ ...query({ name: VIEW_CHECKOUT_FEEDBACK_BY_ID }),
5
+ ...payload,
6
+ });
7
+ const viewCheckoutFeedbackByIdHandler = ({ view, signal }) => async ({ checkoutFeedbackId }) => view({ checkoutFeedbackId, signal });
8
+ export { VIEW_CHECKOUT_FEEDBACK_BY_ID, viewCheckoutFeedbackById, viewCheckoutFeedbackByIdHandler };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.3.18",
3
+ "version": "0.3.20",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [