@lookiero/checkout 0.4.2 → 0.4.4

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 (54) hide show
  1. package/dist/domain/checkoutBooking/model/checkoutBooking.d.ts +1 -2
  2. package/dist/domain/checkoutBooking/model/checkoutBooking.js +1 -2
  3. package/dist/domain/checkoutFeedback/command/giveCheckoutFeedback.d.ts +1 -1
  4. package/dist/domain/checkoutFeedback/command/giveCheckoutFeedback.js +2 -2
  5. package/dist/domain/checkoutFeedback/model/checkoutFeedback.d.ts +1 -0
  6. package/dist/domain/checkoutFeedback/model/checkoutFeedback.js +3 -2
  7. package/dist/domain/checkoutFeedback/model/checkoutFeedbackGiven.d.ts +1 -0
  8. package/dist/domain/checkoutFeedback/model/checkoutFeedbackGiven.js +4 -1
  9. package/dist/domain/checkoutItem/model/checkoutItem.d.ts +1 -2
  10. package/dist/domain/checkoutItem/model/checkoutItem.js +0 -1
  11. package/dist/infrastructure/delivery/baseBootstrap.d.ts +2 -2
  12. package/dist/infrastructure/delivery/baseBootstrap.js +4 -4
  13. package/dist/infrastructure/delivery/bootstrap.js +2 -2
  14. package/dist/infrastructure/delivery/mock/dataSourceCheckoutBookings.js +4 -5
  15. package/dist/infrastructure/delivery/mock/dataSourceCheckoutFeedbacks.js +3 -12
  16. package/dist/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.js +1 -1
  17. package/dist/infrastructure/domain/checkoutFeedback/model/httpCheckoutFeedbacks.js +2 -11
  18. package/dist/infrastructure/domain/checkoutFeedback/model/httpCheckoutFeedbacksGive.js +2 -2
  19. package/dist/infrastructure/domain/checkoutFeedback/react/useGiveCheckoutFeedback.js +1 -1
  20. package/dist/infrastructure/projection/bookedProductsVariants/httpBookedProductsVariantsForCheckoutItemView.d.ts +12 -0
  21. package/dist/infrastructure/projection/{bookedSizeChangeProductsVariants/httpBookedSizeChangeProductsVariantsForCheckoutItemView.js → bookedProductsVariants/httpBookedProductsVariantsForCheckoutItemView.js} +2 -2
  22. package/dist/infrastructure/projection/bookedProductsVariants/react/useViewBookedProductsVariantsForCheckoutItem.d.ts +10 -0
  23. package/dist/infrastructure/projection/{bookedSizeChangeProductsVariants/react/useViewBookedSizeChangeProductsVariantsForCheckoutItem.js → bookedProductsVariants/react/useViewBookedProductsVariantsForCheckoutItem.js} +4 -4
  24. package/dist/infrastructure/projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId.js +7 -1
  25. package/dist/infrastructure/projection/payment/react/useViewPaymentFlowPayloadByCheckoutId.js +1 -1
  26. package/dist/infrastructure/ui/hooks/useSubmitCheckout.d.ts +23 -0
  27. package/dist/infrastructure/ui/hooks/useSubmitCheckout.js +68 -0
  28. package/dist/infrastructure/ui/i18n/i18n.d.ts +2 -2
  29. package/dist/infrastructure/ui/i18n/i18n.js +2 -2
  30. package/dist/infrastructure/ui/routing/CheckoutMiddleware.js +11 -3
  31. package/dist/infrastructure/ui/routing/Routing.js +9 -1
  32. package/dist/infrastructure/ui/routing/routes.d.ts +1 -0
  33. package/dist/infrastructure/ui/routing/routes.js +1 -0
  34. package/dist/infrastructure/ui/views/checkout/Checkout.d.ts +2 -2
  35. package/dist/infrastructure/ui/views/checkout/Checkout.js +10 -57
  36. package/dist/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.d.ts +7 -0
  37. package/dist/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.js +45 -0
  38. package/dist/infrastructure/ui/views/item/Item.js +9 -9
  39. package/dist/infrastructure/ui/views/item/components/banner/CustomerDecissionBanner.d.ts +1 -1
  40. package/dist/infrastructure/ui/views/item/components/itemActions/ItemActions.d.ts +1 -1
  41. package/dist/projection/{bookedSizeChangeProductsVariants/bookedSizeChangeProductsVariants.d.ts → bookedProductsVariants/bookedProductsVariants.d.ts} +2 -2
  42. package/dist/projection/bookedProductsVariants/viewBookedProductVariantsForCheckoutItem.d.ts +25 -0
  43. package/dist/projection/bookedProductsVariants/viewBookedProductVariantsForCheckoutItem.js +8 -0
  44. package/dist/projection/checkoutBooking/checkoutBooking.d.ts +1 -2
  45. package/package.json +1 -1
  46. package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/httpBookedSizeChangeProductsVariantsForCheckoutItemView.d.ts +0 -12
  47. package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/react/useViewBookedSizeChangeProductsVariantsForCheckoutItem.d.ts +0 -10
  48. package/dist/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackByCheckoutIdView.d.ts +0 -12
  49. package/dist/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackByCheckoutIdView.js +0 -9
  50. package/dist/projection/bookedSizeChangeProductsVariants/viewBookedSizeChangeProductVariantsForCheckoutItem.d.ts +0 -25
  51. package/dist/projection/bookedSizeChangeProductsVariants/viewBookedSizeChangeProductVariantsForCheckoutItem.js +0 -8
  52. package/dist/projection/checkoutFeedback/viewCheckoutFeedbackByCheckoutId.d.ts +0 -25
  53. package/dist/projection/checkoutFeedback/viewCheckoutFeedbackByCheckoutId.js +0 -8
  54. /package/dist/projection/{bookedSizeChangeProductsVariants/bookedSizeChangeProductsVariants.js → bookedProductsVariants/bookedProductsVariants.js} +0 -0
@@ -1,10 +1,9 @@
1
1
  import { AggregateRoot, CommandHandlerFunction } from "@lookiero/messaging";
2
- import { CheckoutStatus } from "../../checkout/model/checkout";
3
2
  import { BlockCheckoutBooking } from "../command/blockCheckoutBooking";
4
3
  import { BookCheckoutBookingForCheckoutItem } from "../command/bookCheckoutBookingForCheckoutItem";
5
4
  interface CheckoutBooking extends AggregateRoot {
6
5
  readonly checkoutItemIds: string[];
7
- readonly checkoutStatus: CheckoutStatus;
6
+ readonly isExpired: boolean;
8
7
  }
9
8
  declare const bookCheckoutBookingForCheckoutItemHandler: CommandHandlerFunction<BookCheckoutBookingForCheckoutItem, CheckoutBooking>;
10
9
  declare const blockCheckoutBookingHandler: CommandHandlerFunction<BlockCheckoutBooking, CheckoutBooking>;
@@ -1,4 +1,3 @@
1
- import { CheckoutStatus } from "../../checkout/model/checkout";
2
1
  import { checkoutBookingBlocked } from "./checkoutBookingBlocked";
3
2
  import { checkoutBookingBooked } from "./checkoutBookingBooked";
4
3
  import { checkoutBookingExpired } from "./checkoutBookingExpired";
@@ -11,7 +10,7 @@ const bookCheckoutBookingForCheckoutItemHandler = () => async ({ aggregateRoot,
11
10
  };
12
11
  const blockCheckoutBookingHandler = () => async ({ aggregateRoot, command }) => {
13
12
  const { aggregateId } = command;
14
- if (aggregateRoot.checkoutStatus === CheckoutStatus.EXPIRED) {
13
+ if (aggregateRoot.isExpired) {
15
14
  return {
16
15
  ...aggregateRoot,
17
16
  domainEvents: [checkoutBookingExpired({ aggregateId })],
@@ -2,7 +2,7 @@ import { Command } from "@lookiero/messaging";
2
2
  import { Feedbacks } from "../model/feedbacks";
3
3
  declare const GIVE_CHECKOUT_FEEDBACK = "give_checkout_feedback";
4
4
  interface GiveCheckoutFeedbackPayload {
5
- readonly aggregateId: string;
5
+ readonly checkoutId: string;
6
6
  readonly feedbacks: Feedbacks;
7
7
  }
8
8
  interface GiveCheckoutFeedback extends Command<typeof GIVE_CHECKOUT_FEEDBACK>, GiveCheckoutFeedbackPayload {
@@ -1,7 +1,7 @@
1
1
  import { command } from "@lookiero/messaging";
2
2
  const GIVE_CHECKOUT_FEEDBACK = "give_checkout_feedback";
3
- const giveCheckoutFeedback = ({ aggregateId, ...payload }) => ({
4
- ...command({ aggregateId, name: GIVE_CHECKOUT_FEEDBACK }),
3
+ const giveCheckoutFeedback = (payload) => ({
4
+ ...command({ name: GIVE_CHECKOUT_FEEDBACK }),
5
5
  ...payload,
6
6
  });
7
7
  export { GIVE_CHECKOUT_FEEDBACK, giveCheckoutFeedback };
@@ -2,6 +2,7 @@ import { AggregateRoot, CommandHandlerFunction } from "@lookiero/messaging";
2
2
  import { GiveCheckoutFeedback } from "../command/giveCheckoutFeedback";
3
3
  import { Feedbacks } from "./feedbacks";
4
4
  interface CheckoutFeedback extends AggregateRoot {
5
+ readonly checkoutId: string;
5
6
  readonly feedbacks: Feedbacks;
6
7
  }
7
8
  declare const giveCheckoutFeedbackHandler: CommandHandlerFunction<GiveCheckoutFeedback, CheckoutFeedback>;
@@ -1,10 +1,11 @@
1
1
  import { checkoutFeedbackGiven } from "./checkoutFeedbackGiven";
2
2
  const giveCheckoutFeedbackHandler = () => async ({ aggregateRoot, command }) => {
3
- const { aggregateId, feedbacks } = command;
3
+ const { aggregateId, checkoutId, feedbacks } = command;
4
4
  return {
5
5
  ...aggregateRoot,
6
+ checkoutId,
6
7
  feedbacks,
7
- domainEvents: [checkoutFeedbackGiven({ aggregateId })],
8
+ domainEvents: [checkoutFeedbackGiven({ aggregateId, checkoutId })],
8
9
  };
9
10
  };
10
11
  export { giveCheckoutFeedbackHandler };
@@ -2,6 +2,7 @@ import { DomainEvent } from "@lookiero/messaging";
2
2
  declare const CHECKOUT_FEEDBACK_GIVEN = "checkout_feedback_given";
3
3
  interface CheckoutFeedbackGivenPayload {
4
4
  readonly aggregateId: string;
5
+ readonly checkoutId: string;
5
6
  }
6
7
  interface CheckoutFeedbackGiven extends DomainEvent<typeof CHECKOUT_FEEDBACK_GIVEN>, CheckoutFeedbackGivenPayload {
7
8
  }
@@ -1,4 +1,7 @@
1
1
  import { domainEvent } from "@lookiero/messaging";
2
2
  const CHECKOUT_FEEDBACK_GIVEN = "checkout_feedback_given";
3
- const checkoutFeedbackGiven = ({ aggregateId }) => domainEvent({ aggregateId, name: CHECKOUT_FEEDBACK_GIVEN });
3
+ const checkoutFeedbackGiven = ({ aggregateId, ...payload }) => ({
4
+ ...domainEvent({ aggregateId, name: CHECKOUT_FEEDBACK_GIVEN }),
5
+ ...payload,
6
+ });
4
7
  export { CHECKOUT_FEEDBACK_GIVEN, checkoutFeedbackGiven };
@@ -8,8 +8,7 @@ declare enum CheckoutItemStatus {
8
8
  INITIAL = "INITIAL",
9
9
  KEPT = "KEPT",
10
10
  RETURNED = "RETURNED",
11
- REPLACED = "REPLACED",
12
- EXPIRED = "EXPIRED"
11
+ REPLACED = "REPLACED"
13
12
  }
14
13
  interface CheckoutItem extends AggregateRoot {
15
14
  readonly status: CheckoutItemStatus;
@@ -7,7 +7,6 @@ var CheckoutItemStatus;
7
7
  CheckoutItemStatus["KEPT"] = "KEPT";
8
8
  CheckoutItemStatus["RETURNED"] = "RETURNED";
9
9
  CheckoutItemStatus["REPLACED"] = "REPLACED";
10
- CheckoutItemStatus["EXPIRED"] = "EXPIRED";
11
10
  })(CheckoutItemStatus || (CheckoutItemStatus = {}));
12
11
  const keepCheckoutItemHandler = () => async ({ aggregateRoot, command }) => {
13
12
  const { aggregateId } = command;
@@ -10,7 +10,7 @@ import { CheckoutItem } from "../../domain/checkoutItem/model/checkoutItem";
10
10
  import { CheckoutItemsGetFunction, CheckoutItemsSaveFunction } from "../../domain/checkoutItem/model/checkoutItems";
11
11
  import { UiSetting } from "../../domain/uiSetting/model/uiSetting";
12
12
  import { UiSettingGetFunction, UiSettingSaveFunction } from "../../domain/uiSetting/model/uiSettings";
13
- import { BookedSizeChangeProductsVariantsForCheckoutItemView } from "../../projection/bookedSizeChangeProductsVariants/viewBookedSizeChangeProductVariantsForCheckoutItem";
13
+ import { BookedProductsVariantsForCheckoutItemView } from "../../projection/bookedProductsVariants/viewBookedProductVariantsForCheckoutItem";
14
14
  import { CheckoutByIdView } from "../../projection/checkout/viewCheckoutById";
15
15
  import { FirstAvailableCheckoutByCustomerIdView } from "../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
16
16
  import { FiveItemsDiscountByCustomerIdView } from "../../projection/checkout/viewFiveItemsDiscountByCustomerId";
@@ -34,7 +34,7 @@ interface BaseBootstrapFunctionArgs<UiSettingGetFunctionArgs extends RepositoryG
34
34
  readonly checkoutItemByIdView: CheckoutItemByIdView;
35
35
  readonly checkoutBookingByIdView: CheckoutBookingByIdView;
36
36
  readonly returnQuestionsByCheckoutItemIdView: ReturnQuestionsByCheckoutItemIdView;
37
- readonly bookedSizeChangeProductsVariantsForCheckoutItemView: BookedSizeChangeProductsVariantsForCheckoutItemView;
37
+ readonly bookedProductsVariantsForCheckoutItemView: BookedProductsVariantsForCheckoutItemView;
38
38
  readonly pricingByCheckoutIdView: PricingByCheckoutIdView;
39
39
  readonly paymentFlowPayloadByCheckoutIdView: PaymentFlowPayloadByCheckoutIdView;
40
40
  readonly checkoutQuestionsByCheckoutIdView: CheckoutQuestionsByCheckoutIdView;
@@ -13,7 +13,7 @@ import { RETURN_CHECKOUT_ITEM } from "../../domain/checkoutItem/command/returnCh
13
13
  import { keepCheckoutItemHandler, replaceCheckoutItemHandler, returnCheckoutItemHandler, } from "../../domain/checkoutItem/model/checkoutItem";
14
14
  import { UPDATE_UI_SETTING } from "../../domain/uiSetting/command/updateUiSetting";
15
15
  import { updateUiSettingHandler } from "../../domain/uiSetting/model/uiSetting";
16
- import { viewBookedSizeChangeProductsVariantsForCheckoutItemHandler, VIEW_BOOKED_SIZE_CHANGE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM, } from "../../projection/bookedSizeChangeProductsVariants/viewBookedSizeChangeProductVariantsForCheckoutItem";
16
+ import { viewBookedProductsVariantsForCheckoutItemHandler, VIEW_BOOKED_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM, } from "../../projection/bookedProductsVariants/viewBookedProductVariantsForCheckoutItem";
17
17
  import { viewCheckoutByIdHandler, VIEW_CHECKOUT_BY_ID, } from "../../projection/checkout/viewCheckoutById";
18
18
  import { viewFirstAvailableCheckoutByCustomerIdHandler, VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID, } from "../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
19
19
  import { viewFiveItemsDiscountByCustomerIdHandler, VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID, } from "../../projection/checkout/viewFiveItemsDiscountByCustomerId";
@@ -27,7 +27,7 @@ import { viewPricingByCheckoutIdHandler, VIEW_PRICING_BY_CHECKOUT_ID, } from "..
27
27
  import { listReturnQuestionsByCheckoutItemIdHandler, LIST_RETURN_QUESTIONS_BY_CHECKOUT_ITEM_ID, } from "../../projection/returnQuestion/listReturnQuestionsByCheckoutItemId";
28
28
  import { viewUiSettingByKeyHandler, VIEW_UI_SETTING_BY_KEY, } from "../../projection/uiSetting/viewUiSettingByKey";
29
29
  const MESSAGING_CONTEXT_ID = "Checkout";
30
- const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdView, isCheckoutEnabledByCustomerIdView, fiveItemsDiscountByCustomerIdView, uiSettingByKeyView, checkoutItemByIdView, returnQuestionsByCheckoutItemIdView, bookedSizeChangeProductsVariantsForCheckoutItemView, checkoutBookingByIdView, pricingByCheckoutIdView, paymentFlowPayloadByCheckoutIdView, checkoutQuestionsByCheckoutIdView, getUiSetting, saveUiSetting, uiSettingsDependencies, getCheckout, saveCheckout, checkoutsDependencies, getCheckoutItem, saveCheckoutItem, checkoutItemsDependencies, getCheckoutBooking, saveCheckoutBooking, checkoutBookingsDependencies, getCheckoutFeedback, saveCheckoutFeedback, checkoutFeedbacksDependencies, }) => messagingBootstrap({ id: MESSAGING_CONTEXT_ID })
30
+ const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdView, isCheckoutEnabledByCustomerIdView, fiveItemsDiscountByCustomerIdView, checkoutItemByIdView, returnQuestionsByCheckoutItemIdView, bookedProductsVariantsForCheckoutItemView, checkoutBookingByIdView, pricingByCheckoutIdView, paymentFlowPayloadByCheckoutIdView, checkoutQuestionsByCheckoutIdView, uiSettingByKeyView, getUiSetting, saveUiSetting, uiSettingsDependencies, getCheckout, saveCheckout, checkoutsDependencies, getCheckoutItem, saveCheckoutItem, checkoutItemsDependencies, getCheckoutBooking, saveCheckoutBooking, checkoutBookingsDependencies, getCheckoutFeedback, saveCheckoutFeedback, checkoutFeedbacksDependencies, }) => messagingBootstrap({ id: MESSAGING_CONTEXT_ID })
31
31
  .query(VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID, viewFiveItemsDiscountByCustomerIdHandler, {
32
32
  view: fiveItemsDiscountByCustomerIdView,
33
33
  })
@@ -64,8 +64,8 @@ const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdVie
64
64
  .query(VIEW_CHECKOUT_BOOKING_BY_ID, viewCheckoutBookingByIdHandler, {
65
65
  view: checkoutBookingByIdView,
66
66
  })
67
- .query(VIEW_BOOKED_SIZE_CHANGE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM, viewBookedSizeChangeProductsVariantsForCheckoutItemHandler, {
68
- view: bookedSizeChangeProductsVariantsForCheckoutItemView,
67
+ .query(VIEW_BOOKED_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM, viewBookedProductsVariantsForCheckoutItemHandler, {
68
+ view: bookedProductsVariantsForCheckoutItemView,
69
69
  })
70
70
  .command(BOOK_CHECKOUT_BOOKING_FOR_CHECKOUT_ITEM, bookCheckoutBookingForCheckoutItemHandler)(getCheckoutBooking, saveCheckoutBooking, ...checkoutBookingsDependencies)
71
71
  .command(BLOCK_CHECKOUT_BOOKING, blockCheckoutBookingHandler)(getCheckoutBooking, saveCheckoutBooking, ...checkoutBookingsDependencies)
@@ -4,7 +4,7 @@ import { getCheckoutFeedback, saveCheckoutFeedback } from "../domain/checkoutFee
4
4
  import { getCheckoutItem, saveCheckoutItem } from "../domain/checkoutItem/model/httpCheckoutItems";
5
5
  import { getUiSetting, saveUiSetting } from "../domain/uiSetting/model/storageUiSettings";
6
6
  import { read, write } from "../persistence/asyncStorageStorage";
7
- import { httpBookedSizeChangeProductsVariantsForCheckoutItemView } from "../projection/bookedSizeChangeProductsVariants/httpBookedSizeChangeProductsVariantsForCheckoutItemView";
7
+ import { httpBookedProductsVariantsForCheckoutItemView } from "../projection/bookedProductsVariants/httpBookedProductsVariantsForCheckoutItemView";
8
8
  import { httpCheckoutByIdView } from "../projection/checkout/httpCheckoutByIdView";
9
9
  import { httpFirstAvailableCheckoutByCustomerIdView } from "../projection/checkout/httpFirstAvailableCheckoutByCustomerIdView";
10
10
  import { httpFiveItemsDiscountByCustomerIdView } from "../projection/checkout/httpFiveItemsDiscountByCustomerIdView";
@@ -30,7 +30,7 @@ const bootstrap = ({ apiUrl, getAuthToken }) => {
30
30
  checkoutItemByIdView: httpCheckoutItemByIdView({ httpPost }),
31
31
  returnQuestionsByCheckoutItemIdView: httpReturnQuestionsByCheckoutItemIdView({ httpPost }),
32
32
  checkoutBookingByIdView: httpCheckoutBookingByIdView({ httpPost }),
33
- bookedSizeChangeProductsVariantsForCheckoutItemView: httpBookedSizeChangeProductsVariantsForCheckoutItemView({
33
+ bookedProductsVariantsForCheckoutItemView: httpBookedProductsVariantsForCheckoutItemView({
34
34
  httpPost,
35
35
  }),
36
36
  pricingByCheckoutIdView: httpPricingByCheckoutIdView({
@@ -1,22 +1,21 @@
1
1
  import invariant from "tiny-invariant";
2
2
  import { v4 as uuid } from "uuid";
3
- import { CheckoutStatus } from "../../../domain/checkout/model/checkout";
4
- import { viewBookedSizeChangeProductsVariantsForCheckoutItem, } from "../../../projection/bookedSizeChangeProductsVariants/viewBookedSizeChangeProductVariantsForCheckoutItem";
3
+ import { viewBookedProductsVariantsForCheckoutItem, } from "../../../projection/bookedProductsVariants/viewBookedProductVariantsForCheckoutItem";
5
4
  const toCheckoutBookingDomain = (checkoutBooking) => {
6
5
  invariant(checkoutBooking, "No checkoutBooking found!");
7
6
  return {
8
7
  aggregateId: uuid(),
9
8
  checkoutItemIds: checkoutBooking.productVariants.map((productVariant) => productVariant.id),
10
- checkoutStatus: CheckoutStatus.AVAILABLE,
9
+ isExpired: false,
11
10
  domainEvents: [],
12
11
  };
13
12
  };
14
13
  const toCheckoutBookingProjection = (checkoutBooking) => ({
15
14
  id: checkoutBooking.aggregateId,
16
15
  checkoutItemIds: checkoutBooking.checkoutItemIds,
17
- checkoutStatus: checkoutBooking.checkoutStatus,
16
+ isExpired: false,
18
17
  });
19
- const getCheckoutBooking = ({ queryBus }) => async (aggregateId) => toCheckoutBookingDomain(await queryBus(viewBookedSizeChangeProductsVariantsForCheckoutItem({ checkoutItemId: aggregateId })));
18
+ const getCheckoutBooking = ({ queryBus }) => async (aggregateId) => toCheckoutBookingDomain(await queryBus(viewBookedProductsVariantsForCheckoutItem({ checkoutItemId: aggregateId })));
20
19
  const saveCheckoutBooking = ({ dataSource }) => async (aggregateRoot) => {
21
20
  dataSource.saveCheckoutBooking(toCheckoutBookingProjection(aggregateRoot));
22
21
  };
@@ -1,16 +1,7 @@
1
- import invariant from "tiny-invariant";
2
- import { v4 as uuid } from "uuid";
3
- import { viewCheckoutFeedbackByCheckoutId, } from "../../../projection/checkoutFeedback/viewCheckoutFeedbackByCheckoutId";
4
- const toCheckoutFeedbackDomain = (checkoutFeedback) => {
5
- invariant(checkoutFeedback, "No checkoutFeedback found!");
6
- return {
7
- aggregateId: uuid(),
8
- feedbacks: checkoutFeedback,
9
- domainEvents: [],
10
- };
11
- };
12
1
  const toCheckoutFeedbackProjection = (checkoutFeedback) => checkoutFeedback.feedbacks;
13
- const getCheckoutFeedback = ({ queryBus }) => async (aggregateId) => toCheckoutFeedbackDomain(await queryBus(viewCheckoutFeedbackByCheckoutId({ checkoutId: aggregateId })));
2
+ const getCheckoutFeedback = () => () => {
3
+ throw new Error("There is no equivalent AggregateRoot in the backend");
4
+ };
14
5
  const saveCheckoutFeedback = ({ dataSource }) => async (aggregateRoot) => {
15
6
  dataSource.saveCheckoutFeedback(toCheckoutFeedbackProjection(aggregateRoot));
16
7
  };
@@ -7,7 +7,7 @@ const toDomain = (checkoutBooking) => {
7
7
  return {
8
8
  aggregateId: checkoutBooking.id,
9
9
  checkoutItemIds: checkoutBooking.checkoutItemIds,
10
- checkoutStatus: checkoutBooking.checkoutStatus,
10
+ isExpired: checkoutBooking.isExpired,
11
11
  domainEvents: [],
12
12
  };
13
13
  };
@@ -1,15 +1,6 @@
1
- import invariant from "tiny-invariant";
2
- import { v4 as uuid } from "uuid";
3
- import { viewCheckoutFeedbackByCheckoutId, } from "../../../../projection/checkoutFeedback/viewCheckoutFeedbackByCheckoutId";
4
1
  import { httpCheckoutFeedbacksGive } from "./httpCheckoutFeedbacksGive";
5
- const toDomain = (checkoutFeedback) => {
6
- invariant(checkoutFeedback, "Not checkoutFeedback found!");
7
- return {
8
- aggregateId: uuid(),
9
- feedbacks: checkoutFeedback,
10
- domainEvents: [],
11
- };
2
+ const getCheckoutFeedback = () => async () => {
3
+ throw new Error("There is no equivalent AggregateRoot in the backend");
12
4
  };
13
- const getCheckoutFeedback = ({ queryBus }) => async (aggregateId) => toDomain(await queryBus(viewCheckoutFeedbackByCheckoutId({ checkoutId: aggregateId })));
14
5
  const saveCheckoutFeedback = ({ httpPost }) => async (aggregateRoot) => await httpCheckoutFeedbacksGive({ httpPost })(aggregateRoot);
15
6
  export { getCheckoutFeedback, saveCheckoutFeedback };
@@ -1,13 +1,13 @@
1
1
  import { CHECKOUT_FEEDBACK_GIVEN, } from "../../../../domain/checkoutFeedback/model/checkoutFeedbackGiven";
2
2
  const isCheckoutFeedbackGiven = (event) => event.name === CHECKOUT_FEEDBACK_GIVEN;
3
- const httpCheckoutFeedbacksGive = ({ httpPost }) => async ({ aggregateId, feedbacks, domainEvents }) => {
3
+ const httpCheckoutFeedbacksGive = ({ httpPost }) => async ({ checkoutId, feedbacks, domainEvents }) => {
4
4
  const checkoutFeedbackGiven = domainEvents.find(isCheckoutFeedbackGiven);
5
5
  if (!checkoutFeedbackGiven) {
6
6
  return;
7
7
  }
8
8
  await httpPost({
9
9
  endpoint: "/give-checkout-feedback",
10
- body: { checkoutId: aggregateId, feedbacks },
10
+ body: { checkoutId, feedbacks },
11
11
  });
12
12
  };
13
13
  export { httpCheckoutFeedbacksGive };
@@ -5,7 +5,7 @@ import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
5
5
  const useGiveCheckoutFeedback = ({ checkoutId }) => {
6
6
  const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
7
7
  const giveCheckoutFeedback = useCallback(({ feedbacks }) => commandBus(giveCheckoutFeedbackCommand({
8
- aggregateId: checkoutId,
8
+ checkoutId,
9
9
  feedbacks,
10
10
  })), [checkoutId, commandBus]);
11
11
  return [giveCheckoutFeedback, status];
@@ -0,0 +1,12 @@
1
+ import { BookedProductsVariantsForCheckoutItemView } from "../../../projection/bookedProductsVariants/viewBookedProductVariantsForCheckoutItem";
2
+ import { HttpPostFunction } from "../../delivery/http/httpClient";
3
+ interface HttpBookedProductsVariantsForCheckoutItemView extends BookedProductsVariantsForCheckoutItemView {
4
+ }
5
+ interface HttpBookedProductsVariantsForCheckoutItemViewFunctionArgs {
6
+ readonly httpPost: HttpPostFunction;
7
+ }
8
+ interface HttpBookedProductsVariantsForCheckoutItemViewFunction {
9
+ (args: HttpBookedProductsVariantsForCheckoutItemViewFunctionArgs): HttpBookedProductsVariantsForCheckoutItemView;
10
+ }
11
+ declare const httpBookedProductsVariantsForCheckoutItemView: HttpBookedProductsVariantsForCheckoutItemViewFunction;
12
+ export { httpBookedProductsVariantsForCheckoutItemView };
@@ -1,4 +1,4 @@
1
- const httpBookedSizeChangeProductsVariantsForCheckoutItemView = ({ httpPost }) => async ({ checkoutItemId, signal }) => {
1
+ const httpBookedProductsVariantsForCheckoutItemView = ({ httpPost }) => async ({ checkoutItemId, signal }) => {
2
2
  const response = await httpPost({
3
3
  endpoint: "/view-booked-product-variants-for-checkout-item",
4
4
  body: { checkoutItemId },
@@ -6,4 +6,4 @@ const httpBookedSizeChangeProductsVariantsForCheckoutItemView = ({ httpPost }) =
6
6
  });
7
7
  return !response.ok || response.status === 404 ? null : (await response.json()).result;
8
8
  };
9
- export { httpBookedSizeChangeProductsVariantsForCheckoutItemView };
9
+ export { httpBookedProductsVariantsForCheckoutItemView };
@@ -0,0 +1,10 @@
1
+ import { UseQueryFunctionResult } from "@lookiero/messaging-react";
2
+ import { BookedProductsVariantsProjection } from "../../../../projection/bookedProductsVariants/bookedProductsVariants";
3
+ interface UseViewBookedProductsVariantsForCheckoutItemFunctionArgs {
4
+ readonly checkoutItemId: string;
5
+ }
6
+ interface UseViewBookedProductsVariantsForCheckoutItemFunction {
7
+ (args: UseViewBookedProductsVariantsForCheckoutItemFunctionArgs): UseQueryFunctionResult<BookedProductsVariantsProjection>;
8
+ }
9
+ declare const useViewBookedProductsVariantsForCheckoutItem: UseViewBookedProductsVariantsForCheckoutItemFunction;
10
+ export { useViewBookedProductsVariantsForCheckoutItem };
@@ -1,12 +1,12 @@
1
1
  import { useQuery } from "@lookiero/messaging-react";
2
2
  import { CHECKOUT_BOOKING_BOOKED, } from "../../../../domain/checkoutBooking/model/checkoutBookingBooked";
3
- import { viewBookedSizeChangeProductsVariantsForCheckoutItem } from "../../../../projection/bookedSizeChangeProductsVariants/viewBookedSizeChangeProductVariantsForCheckoutItem";
3
+ import { viewBookedProductsVariantsForCheckoutItem } from "../../../../projection/bookedProductsVariants/viewBookedProductVariantsForCheckoutItem";
4
4
  import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
5
5
  const isCheckoutBookingBooked = (event) => event.name === CHECKOUT_BOOKING_BOOKED;
6
- const useViewBookedSizeChangeProductsVariantsForCheckoutItem = ({ checkoutItemId }) => useQuery({
7
- query: viewBookedSizeChangeProductsVariantsForCheckoutItem({ checkoutItemId }),
6
+ const useViewBookedProductsVariantsForCheckoutItem = ({ checkoutItemId, }) => useQuery({
7
+ query: viewBookedProductsVariantsForCheckoutItem({ checkoutItemId }),
8
8
  contextId: MESSAGING_CONTEXT_ID,
9
9
  invalidation: isCheckoutBookingBooked,
10
10
  options: { staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
11
11
  });
12
- export { useViewBookedSizeChangeProductsVariantsForCheckoutItem };
12
+ export { useViewBookedProductsVariantsForCheckoutItem };
@@ -1,5 +1,7 @@
1
1
  import { useQuery } from "@lookiero/messaging-react";
2
2
  import { CHECKOUT_PAID } from "../../../../domain/checkout/model/checkoutPaid";
3
+ import { CHECKOUT_BOOKING_BOOKED, } from "../../../../domain/checkoutBooking/model/checkoutBookingBooked";
4
+ import { CHECKOUT_BOOKING_EXPIRED, } from "../../../../domain/checkoutBooking/model/checkoutBookingExpired";
3
5
  import { CHECKOUT_FEEDBACK_GIVEN, } from "../../../../domain/checkoutFeedback/model/checkoutFeedbackGiven";
4
6
  import { CHECKOUT_ITEM_KEPT } from "../../../../domain/checkoutItem/model/checkoutItemKept";
5
7
  import { CHECKOUT_ITEM_REPLACED, } from "../../../../domain/checkoutItem/model/checkoutItemReplaced";
@@ -11,11 +13,15 @@ const isCheckoutItemReturned = (event) => event.name === CHECKOUT_ITEM_RETURNED;
11
13
  const isCheckoutItemReplaced = (event) => event.name === CHECKOUT_ITEM_REPLACED;
12
14
  const isCheckoutPaid = (event) => event.name === CHECKOUT_PAID;
13
15
  const isCheckoutFeedbackGiven = (event) => event.name === CHECKOUT_FEEDBACK_GIVEN;
16
+ const isCheckoutBookingExpired = (event) => event.name === CHECKOUT_BOOKING_EXPIRED;
17
+ const isCheckoutBookingBooked = (event) => event.name === CHECKOUT_BOOKING_BOOKED;
14
18
  const shouldInvalidate = (event) => isCheckoutItemKept(event) ||
15
19
  isCheckoutItemReplaced(event) ||
16
20
  isCheckoutItemReturned(event) ||
17
21
  isCheckoutPaid(event) ||
18
- isCheckoutFeedbackGiven(event);
22
+ isCheckoutFeedbackGiven(event) ||
23
+ isCheckoutBookingExpired(event) ||
24
+ isCheckoutBookingBooked(event);
19
25
  const useViewFirstAvailableCheckoutByCustomerId = ({ customerId }) => useQuery({
20
26
  query: viewFirstAvailableCheckoutByCustomerId({ customerId }),
21
27
  contextId: MESSAGING_CONTEXT_ID,
@@ -12,6 +12,6 @@ const useViewPaymentFlowPayloadByCheckoutId = ({ checkoutId }) => useQuery({
12
12
  query: viewPaymentFlowPayloadByCheckoutId({ checkoutId: checkoutId }),
13
13
  contextId: MESSAGING_CONTEXT_ID,
14
14
  invalidation: shouldInvalidate,
15
- options: { staleTime: Infinity, retry: false, refetchOnWindowFocus: false, enabled: Boolean(checkoutId) },
15
+ options: { enabled: Boolean(checkoutId) },
16
16
  });
17
17
  export { useViewPaymentFlowPayloadByCheckoutId };
@@ -0,0 +1,23 @@
1
+ import { PaymentFlowRef } from "@lookiero/payments-front";
2
+ import { RefObject } from "react";
3
+ import { PaymentFlowPayloadProjection } from "../../../projection/payment/paymentFlowPayload";
4
+ type Status = "idle" | "loading" | "success" | "error";
5
+ interface SubmitCheckoutFunctionArgs {
6
+ readonly paymentFlowPayload: PaymentFlowPayloadProjection;
7
+ }
8
+ interface SubmitCheckoutFunction {
9
+ (args: SubmitCheckoutFunctionArgs): Promise<void>;
10
+ }
11
+ type UseSubmitCheckoutResult = [submitCheckout: SubmitCheckoutFunction, status: Status];
12
+ interface UseSubmitCheckoutFunctionArgs {
13
+ readonly checkoutId: string;
14
+ readonly checkoutBookingId: string;
15
+ readonly paymentFlowRef: RefObject<PaymentFlowRef>;
16
+ readonly onError: () => void;
17
+ }
18
+ interface UseSubmitCheckoutFunction {
19
+ (args: UseSubmitCheckoutFunctionArgs): UseSubmitCheckoutResult;
20
+ }
21
+ declare const useSubmitCheckout: UseSubmitCheckoutFunction;
22
+ export type { Status };
23
+ export { useSubmitCheckout };
@@ -0,0 +1,68 @@
1
+ import { CommandStatus } from "@lookiero/messaging-react";
2
+ import { ChargeStatus } from "@lookiero/payments-front/build/infrastructure/CheckoutAPI";
3
+ import { useCallback, useMemo, useState } from "react";
4
+ import { useCreateNotification } from "../../../shared/notifications";
5
+ import { NotificationLevel } from "../../../shared/notifications/domain/notification/model/notification";
6
+ import { useMarkCheckoutAsPaid } from "../../domain/checkout/react/useMarkCheckoutAsPaid";
7
+ import { useBlockCheckoutBooking } from "../../domain/checkoutBooking/react/useBlockCheckoutBooking";
8
+ import { I18nMessages } from "../i18n/i18n";
9
+ const useSubmitCheckout = ({ checkoutId, checkoutBookingId, paymentFlowRef, onError }) => {
10
+ const [markAsPaid, markAsPaidStatus] = useMarkCheckoutAsPaid({ checkoutId });
11
+ const [blockCheckoutBooking, blockCheckoutBookingStatus] = useBlockCheckoutBooking({ checkoutBookingId });
12
+ const [createNotification] = useCreateNotification();
13
+ const [startLegacyBoxCheckoutStatus, setStartLegacyBoxCheckoutStatus] = useState("idle");
14
+ const submitCheckout = useCallback(async ({ paymentFlowPayload }) => {
15
+ try {
16
+ await blockCheckoutBooking();
17
+ }
18
+ catch (error) { }
19
+ paymentFlowRef.current?.startLegacyBoxCheckout(
20
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
21
+ // @ts-ignore
22
+ paymentFlowPayload, async ({ status }) => {
23
+ setStartLegacyBoxCheckoutStatus("loading");
24
+ if (status === ChargeStatus.REJECTED) {
25
+ createNotification({
26
+ level: NotificationLevel.ERROR,
27
+ bodyI18nKey: I18nMessages.CHECKOUT_TOAST_PAYMENT_REJECTED,
28
+ });
29
+ setStartLegacyBoxCheckoutStatus("error");
30
+ }
31
+ else if (status === ChargeStatus.ERROR) {
32
+ createNotification({
33
+ level: NotificationLevel.ERROR,
34
+ bodyI18nKey: I18nMessages.CHECKOUT_TOAST_PAYMENT_ERROR,
35
+ });
36
+ setStartLegacyBoxCheckoutStatus("error");
37
+ }
38
+ else if (status === ChargeStatus.EXECUTED) {
39
+ setStartLegacyBoxCheckoutStatus("success");
40
+ try {
41
+ await markAsPaid();
42
+ }
43
+ catch (error) { }
44
+ }
45
+ });
46
+ }, [blockCheckoutBooking, createNotification, markAsPaid, paymentFlowRef]);
47
+ const status = useMemo(() => {
48
+ if (blockCheckoutBookingStatus === CommandStatus.LOADING ||
49
+ startLegacyBoxCheckoutStatus === "loading" ||
50
+ markAsPaidStatus === CommandStatus.LOADING) {
51
+ return "loading";
52
+ }
53
+ if (blockCheckoutBookingStatus === CommandStatus.SUCCESS &&
54
+ startLegacyBoxCheckoutStatus === "success" &&
55
+ markAsPaidStatus === CommandStatus.SUCCESS) {
56
+ return "success";
57
+ }
58
+ if (blockCheckoutBookingStatus === CommandStatus.ERROR ||
59
+ startLegacyBoxCheckoutStatus === "error" ||
60
+ markAsPaidStatus === CommandStatus.ERROR) {
61
+ onError();
62
+ return "error";
63
+ }
64
+ return "idle";
65
+ }, [blockCheckoutBookingStatus, markAsPaidStatus, onError, startLegacyBoxCheckoutStatus]);
66
+ return [submitCheckout, status];
67
+ };
68
+ export { useSubmitCheckout };
@@ -49,8 +49,8 @@ declare enum I18nMessages {
49
49
  PRODUCT_VARIANT_SIZE_CHANGE = "product_variant.size_change",
50
50
  CHECKOUT_TITLE = "checkout.title",
51
51
  CHECKOUT_PAY_BUTTON = "checkout.pay_button",
52
- CHECKOUT_TOAST_REJECTED = "checkout.toast_rejected",
53
- CHECKOUT_TOAST_ERROR = "checkout.toast_error",
52
+ CHECKOUT_TOAST_PAYMENT_REJECTED = "checkout.toast_payment_rejected",
53
+ CHECKOUT_TOAST_PAYMENT_ERROR = "checkout.toast_payment_error",
54
54
  CHECKOUT_SUCCESS_MODAL_TITLE = "checkout.success_modal_title",
55
55
  CHECKOUT_SUCCESS_MODAL_DESCRIPTION = "checkout.success_modal_description",
56
56
  CHECKOUT_SUCCESS_MODAL_BUTTON = "checkout.success_modal_button",
@@ -50,8 +50,8 @@ var I18nMessages;
50
50
  I18nMessages["PRODUCT_VARIANT_SIZE_CHANGE"] = "product_variant.size_change";
51
51
  I18nMessages["CHECKOUT_TITLE"] = "checkout.title";
52
52
  I18nMessages["CHECKOUT_PAY_BUTTON"] = "checkout.pay_button";
53
- I18nMessages["CHECKOUT_TOAST_REJECTED"] = "checkout.toast_rejected";
54
- I18nMessages["CHECKOUT_TOAST_ERROR"] = "checkout.toast_error";
53
+ I18nMessages["CHECKOUT_TOAST_PAYMENT_REJECTED"] = "checkout.toast_payment_rejected";
54
+ I18nMessages["CHECKOUT_TOAST_PAYMENT_ERROR"] = "checkout.toast_payment_error";
55
55
  I18nMessages["CHECKOUT_SUCCESS_MODAL_TITLE"] = "checkout.success_modal_title";
56
56
  I18nMessages["CHECKOUT_SUCCESS_MODAL_DESCRIPTION"] = "checkout.success_modal_description";
57
57
  I18nMessages["CHECKOUT_SUCCESS_MODAL_BUTTON"] = "checkout.success_modal_button";
@@ -14,21 +14,29 @@ const CheckoutMiddleware = ({ customerId, loader = React.createElement(Spinner,
14
14
  const [shouldIntroBeShown, shouldIntroBeShownStatus] = useShouldIntroBeShown();
15
15
  const navigatedToFirstItemWithoutCustomerDecision = useRef(false);
16
16
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
17
- const firstItemWithoutCustomerDecision = checkout?.items.find((item) => [CheckoutItemStatus.EXPIRED, CheckoutItemStatus.INITIAL].includes(item.status));
17
+ const firstItemWithoutCustomerDecision = checkout?.items.find((item) => item.status === CheckoutItemStatus.INITIAL);
18
18
  const introRouteMatch = useMatch(`${basePath}/${Routes.INTRO}`);
19
19
  const itemRouteMatch = useMatch(`${basePath}/${Routes.ITEM}`);
20
20
  const itemDetailRouteMatch = useMatch(`${basePath}/${Routes.ITEM_DETAIL}`);
21
21
  const summaryRouteMatch = useMatch(`${basePath}/${Routes.SUMMARY}`);
22
22
  const checkoutRouteMatch = useMatch(`${basePath}/${Routes.CHECKOUT}`);
23
23
  const feedbackRouteMatch = useMatch(`${basePath}/${Routes.FEEDBACK}`);
24
+ const checkoutPaymentRouteMatch = useMatch(`${basePath}/${Routes.CHECKOUT}/${Routes.CHECKOUT_PAYMENT}`);
25
+ const checkoutShown = useRef(false);
26
+ checkoutShown.current = checkoutShown.current || (Boolean(checkoutRouteMatch) && !Boolean(checkoutPaymentRouteMatch));
24
27
  const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
25
28
  const dependenciesLoaded = dependenciesLoadedStatuses.includes(shouldIntroBeShownStatus) &&
26
29
  (dependenciesLoadedStatuses.includes(checkoutStatus) || checkout);
27
30
  if (!dependenciesLoaded) {
28
31
  return loader;
29
32
  }
33
+ /* Prevent direct payment access */
34
+ if (checkoutPaymentRouteMatch && !checkoutShown.current) {
35
+ return React.createElement(Navigate, { to: `${basePath}/${Routes.HOME}`, replace: true });
36
+ }
30
37
  /* Navigate to the feedback if checkout is paid */
31
- if (checkout?.status === CheckoutStatus.PAID && !(feedbackRouteMatch || checkoutRouteMatch)) {
38
+ if (checkout?.status === CheckoutStatus.PAID &&
39
+ !(feedbackRouteMatch || checkoutRouteMatch || checkoutPaymentRouteMatch)) {
32
40
  return React.createElement(Navigate, { to: `${basePath}/${Routes.FEEDBACK}`, replace: true });
33
41
  }
34
42
  /* Navigate to the summary if required */
@@ -36,7 +44,7 @@ const CheckoutMiddleware = ({ customerId, loader = React.createElement(Spinner,
36
44
  checkout?.status === CheckoutStatus.STARTED ||
37
45
  checkout?.status === CheckoutStatus.NOTIFIED) &&
38
46
  firstItemWithoutCustomerDecision === undefined &&
39
- !(summaryRouteMatch || itemDetailRouteMatch || checkoutRouteMatch)) {
47
+ !(summaryRouteMatch || itemDetailRouteMatch || checkoutRouteMatch || checkoutPaymentRouteMatch)) {
40
48
  return React.createElement(Navigate, { to: `${basePath}/${Routes.SUMMARY}`, replace: true });
41
49
  }
42
50
  /* Navigate to the Intro if required */
@@ -2,6 +2,7 @@ import React, { lazy, Suspense } from "react";
2
2
  import { Navigate, Outlet, useRoutes } from "react-router-native";
3
3
  import { Spinner } from "../../../shared/ui/components/atoms/spinner/Spinner";
4
4
  import { App } from "../views/App";
5
+ import { CheckoutPaymentModal } from "../views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal";
5
6
  import { CheckoutAccessibilityMiddleware } from "./CheckoutAccessibilityMiddleware";
6
7
  import { CheckoutMiddleware } from "./CheckoutMiddleware";
7
8
  import { Routes } from "./routes";
@@ -45,7 +46,14 @@ const Routing = ({ basePath = "", customerId, locale, I18n, getAuthToken, menu,
45
46
  {
46
47
  path: Routes.CHECKOUT,
47
48
  element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
48
- React.createElement(Checkout, { customerId: customerId, getAuthToken: getAuthToken, useRedirect: useRedirect }))),
49
+ React.createElement(Checkout, { customerId: customerId, useRedirect: useRedirect },
50
+ React.createElement(Outlet, null)))),
51
+ children: [
52
+ {
53
+ path: Routes.CHECKOUT_PAYMENT,
54
+ element: React.createElement(CheckoutPaymentModal, { customerId: customerId, getAuthToken: getAuthToken }),
55
+ },
56
+ ],
49
57
  },
50
58
  {
51
59
  path: Routes.FEEDBACK,
@@ -5,6 +5,7 @@ export declare enum Routes {
5
5
  ITEM = "item/:id",
6
6
  SUMMARY = "summary",
7
7
  CHECKOUT = "checkout",
8
+ CHECKOUT_PAYMENT = "payment",
8
9
  FEEDBACK = "feedback",
9
10
  NOT_FOUND = "not-found"
10
11
  }
@@ -6,6 +6,7 @@ export var Routes;
6
6
  Routes["ITEM"] = "item/:id";
7
7
  Routes["SUMMARY"] = "summary";
8
8
  Routes["CHECKOUT"] = "checkout";
9
+ Routes["CHECKOUT_PAYMENT"] = "payment";
9
10
  Routes["FEEDBACK"] = "feedback";
10
11
  Routes["NOT_FOUND"] = "not-found";
11
12
  })(Routes || (Routes = {}));
@@ -1,7 +1,7 @@
1
- import { FC } from "react";
1
+ import { FC, ReactNode } from "react";
2
2
  interface CheckoutProps {
3
+ readonly children?: ReactNode;
3
4
  readonly customerId: string;
4
- readonly getAuthToken: () => Promise<string>;
5
5
  readonly useRedirect: () => Record<string, string>;
6
6
  }
7
7
  declare const Checkout: FC<CheckoutProps>;
@@ -1,18 +1,13 @@
1
1
  import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
2
2
  import { useI18nMessage } from "@lookiero/i18n-react";
3
- import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
4
- import { PaymentFlow, PaymentInstrumentSelect, PaymentMethod, Section } from "@lookiero/payments-front";
5
- import { ChargeStatus } from "@lookiero/payments-front/build/infrastructure/CheckoutAPI";
6
- import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
3
+ import { QueryStatus } from "@lookiero/messaging-react";
4
+ import { PaymentInstrumentSelect, PaymentMethod, Section } from "@lookiero/payments-front";
5
+ import React, { useCallback, useMemo, useRef } from "react";
7
6
  import { View } from "react-native";
8
7
  import { useNavigate } from "react-router-native";
9
8
  import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
10
- import { useCreateNotification } from "../../../../shared/notifications";
11
- import { NotificationLevel } from "../../../../shared/notifications/domain/notification/model/notification";
12
9
  import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
13
- import { useMarkCheckoutAsPaid } from "../../../domain/checkout/react/useMarkCheckoutAsPaid";
14
10
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
15
- import { useViewPaymentFlowPayloadByCheckoutId } from "../../../projection/payment/react/useViewPaymentFlowPayloadByCheckoutId";
16
11
  import { useViewPricingByCheckoutId } from "../../../projection/pricing/react/useViewPricingByCheckoutId";
17
12
  import { Body } from "../../components/layouts/body/Body";
18
13
  import { SafeAreaScrollView } from "../../components/templates/SafeAreaScrollView";
@@ -23,60 +18,17 @@ import { HEADER_HEIGHT } from "../header/Header.style";
23
18
  import { ProductVariant } from "../item/components/productVariant/ProductVariant";
24
19
  import { Pricing } from "../summary/components/pricing/Pricing";
25
20
  import { style } from "./Checkout.style";
26
- import { CheckoutSuccessModal } from "./components/checkoutSuccessModal/CheckoutSuccessModal";
27
21
  import { DeliveryBanner } from "./components/deliveryBanner/DeliveryBanner";
28
- const Checkout = ({ customerId, getAuthToken, useRedirect }) => {
22
+ const Checkout = ({ children, customerId, useRedirect }) => {
29
23
  const titleText = useI18nMessage({ id: I18nMessages.CHECKOUT_TITLE });
30
24
  const paymentInstrumentSelectRef = useRef(null);
31
- const paymentFlowRef = useRef(null);
32
- const [authToken, setAuthToken] = useState();
33
- useEffect(() => {
34
- const loadAuthToken = async () => setAuthToken(await getAuthToken());
35
- loadAuthToken();
36
- }, [getAuthToken]);
37
25
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
38
26
  const [pricing, pricingStatus] = useViewPricingByCheckoutId({ checkoutId: checkout?.id });
39
- const [paymentFlowPayload] = useViewPaymentFlowPayloadByCheckoutId({
40
- checkoutId: checkout?.id,
41
- });
42
- const [markAsPaid, markAsPaidStatus] = useMarkCheckoutAsPaid({ checkoutId: checkout?.id });
43
- const [createNotification] = useCreateNotification();
44
- const [success, setSuccess] = useState(false);
45
- const [processingCheckout, setProcessingCheckout] = useState(false);
46
27
  const navigate = useNavigate();
47
28
  const basePath = useBasePath();
48
29
  const { returnUrl } = useRedirect();
49
- const handleOnSubmitCheckout = useCallback(() => {
50
- if (!paymentFlowRef.current) {
51
- return;
52
- }
53
- setProcessingCheckout(true);
54
- setSuccess(false);
55
- paymentFlowRef.current.startLegacyBoxCheckout(
56
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
57
- // @ts-ignore
58
- paymentFlowPayload, async ({ status, final }) => {
59
- if (status === ChargeStatus.REJECTED) {
60
- createNotification({ level: NotificationLevel.ERROR, bodyI18nKey: I18nMessages.CHECKOUT_TOAST_REJECTED });
61
- }
62
- else if (status === ChargeStatus.ERROR) {
63
- createNotification({ level: NotificationLevel.ERROR, bodyI18nKey: I18nMessages.CHECKOUT_TOAST_ERROR });
64
- }
65
- else if (status === ChargeStatus.EXECUTED) {
66
- try {
67
- await markAsPaid();
68
- setSuccess(true);
69
- }
70
- catch (e) { }
71
- }
72
- if (final) {
73
- setProcessingCheckout(false);
74
- }
75
- });
76
- }, [createNotification, markAsPaid, paymentFlowPayload]);
77
- const handleOnSuccessModalDismiss = useCallback(() => {
78
- setSuccess(false);
79
- navigate(`${basePath}/${Routes.FEEDBACK}`);
30
+ const handleOnSubmit = useCallback(() => {
31
+ navigate(`${basePath}/${Routes.CHECKOUT}/${Routes.CHECKOUT_PAYMENT}`);
80
32
  }, [basePath, navigate]);
81
33
  const checkoutItemsKept = useMemo(() => checkout?.items.filter((checkoutItem) => checkoutItem.status === CheckoutItemStatus.KEPT || checkoutItem.status === CheckoutItemStatus.REPLACED), [checkout?.items]);
82
34
  const hasReplacedCheckoutItem = useMemo(() => checkout?.items.some((checkoutItem) => checkoutItem.status === CheckoutItemStatus.REPLACED), [checkout?.items]);
@@ -86,7 +38,6 @@ const Checkout = ({ customerId, getAuthToken, useRedirect }) => {
86
38
  if (!dependenciesLoaded)
87
39
  return React.createElement(Spinner, null);
88
40
  return (React.createElement(React.Fragment, null,
89
- React.createElement(CheckoutSuccessModal, { visible: success, onDismiss: handleOnSuccessModalDismiss }),
90
41
  React.createElement(SafeAreaScrollView, { scrollerPaddingTop: HEADER_HEIGHT },
91
42
  React.createElement(Body, { style: { column: style.bodyColumn } },
92
43
  hasReplacedCheckoutItem && (React.createElement(View, { style: style.deliveryBannerContainer },
@@ -96,7 +47,9 @@ const Checkout = ({ customerId, getAuthToken, useRedirect }) => {
96
47
  checkoutItemsKept?.map((checkoutItem) => (React.createElement(View, { key: checkoutItem.id, style: style.checkoutItemKept, testID: "checkout-items-kept" },
97
48
  React.createElement(ProductVariant, { brand: checkoutItem.productVariant.brand, color: checkoutItem.productVariant.color, media: checkoutItem.productVariant.media, name: checkoutItem.productVariant.name, price: checkoutItem.price, size: checkoutItem.productVariant.size, status: checkoutItem.status })))),
98
49
  pricing && (React.createElement(View, { style: style.pricingContainer },
99
- React.createElement(Pricing, { balanceDiscount: pricing.balanceDiscount, busy: processingCheckout || markAsPaidStatus === CommandStatus.LOADING, collapsible: false, discount: pricing.discount, discountPercentage: pricing.discountPercentage, orderTotal: pricing.orderTotal, service: pricing.service, subtotal: pricing.subtotal, totalCheckoutItemsKept: checkoutItemsKept?.length || 0, onSubmit: handleOnSubmitCheckout }))))),
100
- authToken && React.createElement(PaymentFlow, { ref: paymentFlowRef, token: authToken })));
50
+ React.createElement(Pricing, { balanceDiscount: pricing.balanceDiscount,
51
+ // busy={submitCheckoutStatus === "loading"}
52
+ collapsible: false, discount: pricing.discount, discountPercentage: pricing.discountPercentage, orderTotal: pricing.orderTotal, service: pricing.service, subtotal: pricing.subtotal, totalCheckoutItemsKept: checkoutItemsKept?.length || 0, onSubmit: handleOnSubmit }))))),
53
+ children));
101
54
  };
102
55
  export { Checkout };
@@ -0,0 +1,7 @@
1
+ import { FC } from "react";
2
+ interface CheckoutPaymentModalProps {
3
+ readonly customerId: string;
4
+ readonly getAuthToken: () => Promise<string>;
5
+ }
6
+ declare const CheckoutPaymentModal: FC<CheckoutPaymentModalProps>;
7
+ export { CheckoutPaymentModal };
@@ -0,0 +1,45 @@
1
+ import { QueryStatus } from "@lookiero/messaging-react";
2
+ import { PaymentFlow } from "@lookiero/payments-front";
3
+ import React, { useCallback, useEffect, useRef, useState } from "react";
4
+ import { useNavigate } from "react-router-native";
5
+ import { useViewFirstAvailableCheckoutByCustomerId } from "../../../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
6
+ import { useViewPaymentFlowPayloadByCheckoutId } from "../../../../../projection/payment/react/useViewPaymentFlowPayloadByCheckoutId";
7
+ import { useSubmitCheckout } from "../../../../hooks/useSubmitCheckout";
8
+ import { Routes } from "../../../../routing/routes";
9
+ import { useBasePath } from "../../../../routing/useBasePath";
10
+ import { CheckoutSuccessModal } from "../checkoutSuccessModal/CheckoutSuccessModal";
11
+ const CheckoutPaymentModal = ({ customerId, getAuthToken }) => {
12
+ const paymentFlowRef = useRef(null);
13
+ const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
14
+ const [paymentFlowPayload] = useViewPaymentFlowPayloadByCheckoutId({
15
+ checkoutId: checkout?.id,
16
+ });
17
+ const [authToken, setAuthToken] = useState();
18
+ useEffect(() => {
19
+ const loadAuthToken = async () => setAuthToken(await getAuthToken());
20
+ loadAuthToken();
21
+ }, [getAuthToken]);
22
+ const basePath = useBasePath();
23
+ const navigate = useNavigate();
24
+ const handleOnSuccessModalDismiss = useCallback(() => navigate(`${basePath}/${Routes.FEEDBACK}`), [basePath, navigate]);
25
+ const handleOnErrorSubmitCheckout = useCallback(() => navigate(`${basePath}/${Routes.CHECKOUT}`), [basePath, navigate]);
26
+ const [submitCheckout, submitCheckoutStatus] = useSubmitCheckout({
27
+ checkoutId: checkout?.id,
28
+ checkoutBookingId: checkout?.checkoutBookingId,
29
+ paymentFlowRef,
30
+ onError: handleOnErrorSubmitCheckout,
31
+ });
32
+ useEffect(() => {
33
+ if (paymentFlowPayload) {
34
+ submitCheckout({ paymentFlowPayload });
35
+ }
36
+ }, [paymentFlowPayload, submitCheckout]);
37
+ const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
38
+ const dependenciesLoaded = dependenciesLoadedStatuses.includes(checkoutStatus) || checkout;
39
+ if (!dependenciesLoaded)
40
+ return null;
41
+ return (React.createElement(React.Fragment, null,
42
+ React.createElement(CheckoutSuccessModal, { visible: submitCheckoutStatus === "success", onDismiss: handleOnSuccessModalDismiss }),
43
+ authToken && React.createElement(PaymentFlow, { ref: paymentFlowRef, token: authToken })));
44
+ };
45
+ export { CheckoutPaymentModal };
@@ -9,7 +9,7 @@ import { useBookCheckoutBookingForCheckoutItem } from "../../../domain/checkoutB
9
9
  import { useKeepCheckoutItem } from "../../../domain/checkoutItem/react/useKeepCheckoutItem";
10
10
  import { useReplaceCheckoutItem } from "../../../domain/checkoutItem/react/useReplaceCheckoutItem";
11
11
  import { useReturnCheckoutItem } from "../../../domain/checkoutItem/react/useReturnCheckoutItem";
12
- import { useViewBookedSizeChangeProductsVariantsForCheckoutItem } from "../../../projection/bookedSizeChangeProductsVariants/react/useViewBookedSizeChangeProductsVariantsForCheckoutItem";
12
+ import { useViewBookedProductsVariantsForCheckoutItem } from "../../../projection/bookedProductsVariants/react/useViewBookedProductsVariantsForCheckoutItem";
13
13
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
14
14
  import { useListReturnQuestionsByCheckoutItemId } from "../../../projection/returnQuestion/react/useListReturnQuestionsByCheckoutItemId";
15
15
  import { Body } from "../../components/layouts/body/Body";
@@ -41,7 +41,7 @@ const Item = ({ customerId }) => {
41
41
  if (itemRouteMatch) {
42
42
  const nextItemWithoutCustomerDecision = checkout?.items
43
43
  .filter((item) => item.id !== id)
44
- .find((item) => [CheckoutItemStatus.EXPIRED, CheckoutItemStatus.INITIAL].includes(item.status));
44
+ .find((item) => item.status === CheckoutItemStatus.INITIAL);
45
45
  if (nextItemWithoutCustomerDecision) {
46
46
  navigate(generatePath(`${basePath}/${Routes.ITEM}`, { id: nextItemWithoutCustomerDecision.id }));
47
47
  }
@@ -52,7 +52,7 @@ const Item = ({ customerId }) => {
52
52
  }, [itemRouteMatch, itemDetailRouteMatch, checkout?.items, id, navigate, basePath]);
53
53
  const [customerDecissionMade, setCustomerDecissionMade] = useState();
54
54
  useEffect(() => {
55
- setCustomerDecissionMade(checkoutItem.status !== CheckoutItemStatus.INITIAL && checkoutItem.status !== CheckoutItemStatus.EXPIRED);
55
+ setCustomerDecissionMade(checkoutItem.status !== CheckoutItemStatus.INITIAL);
56
56
  }, [checkoutItem.status, id]);
57
57
  const handleOnBannerPress = useCallback(() => setCustomerDecissionMade(false), []);
58
58
  const [keepCheckoutItem, keepCheckoutItemStatus] = useKeepCheckoutItem({ checkoutItemId: checkoutItem.id });
@@ -73,7 +73,7 @@ const Item = ({ customerId }) => {
73
73
  navigateToNextView();
74
74
  }
75
75
  }, [navigateToNextView, replaceCheckoutItemStatus]);
76
- const [bookedSizeChangeProductsVariants, bookedSizeChangeProductsVariantsStatus] = useViewBookedSizeChangeProductsVariantsForCheckoutItem({
76
+ const [bookedProductsVariants, bookedProductsVariantsStatus] = useViewBookedProductsVariantsForCheckoutItem({
77
77
  checkoutItemId: checkoutItem.id,
78
78
  });
79
79
  const [bookCheckoutBooking] = useBookCheckoutBookingForCheckoutItem({
@@ -81,8 +81,8 @@ const Item = ({ customerId }) => {
81
81
  checkoutBookingId: checkout?.checkoutBookingId,
82
82
  });
83
83
  useEffect(() => {
84
- checkout && bookedSizeChangeProductsVariants === null && bookCheckoutBooking();
85
- }, [bookCheckoutBooking, bookedSizeChangeProductsVariants, checkout]);
84
+ checkout && bookedProductsVariants === null && bookCheckoutBooking();
85
+ }, [bookCheckoutBooking, bookedProductsVariants, checkout]);
86
86
  const [returnQuestions, returnQuestionsStatus] = useListReturnQuestionsByCheckoutItemId({
87
87
  checkoutItemId: checkoutItem.id,
88
88
  });
@@ -127,8 +127,8 @@ const Item = ({ customerId }) => {
127
127
  const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
128
128
  const dependenciesLoaded = dependenciesLoadedStatuses.includes(returnQuestionsStatus) &&
129
129
  (dependenciesLoadedStatuses.includes(checkoutStatus) || checkout) &&
130
- dependenciesLoadedStatuses.includes(bookedSizeChangeProductsVariantsStatus) &&
131
- bookedSizeChangeProductsVariants;
130
+ dependenciesLoadedStatuses.includes(bookedProductsVariantsStatus) &&
131
+ bookedProductsVariants;
132
132
  if (!dependenciesLoaded)
133
133
  return React.createElement(Spinner, null);
134
134
  const { price } = checkoutItem;
@@ -145,7 +145,7 @@ const Item = ({ customerId }) => {
145
145
  React.createElement(ProductVariantDescription, { brand: brand, color: color, name: name, price: price, size: productVariantSelected.size }),
146
146
  checkoutItem.status === CheckoutItemStatus.RETURNED && (React.createElement(View, { style: style.feedbackContainer },
147
147
  React.createElement(ReturnQuestionsFeedback, { returnQuestions: returnQuestions || [], onEditFeedback: handleOnEditFeedback })))))),
148
- !customerDecissionMade && (React.createElement(ItemActions, { keepButtonLoading: keepCheckoutItemStatus === CommandStatus.LOADING, productVariantSelected: productVariantSelected, productVariants: bookedSizeChangeProductsVariants?.productVariants || [], returnButtonLoading: returnCheckoutItemStatus === CommandStatus.LOADING, sizeSelectorDisabled: replaceCheckoutItemStatus === CommandStatus.LOADING, onKeep: handleOnKeep, onLayout: handleOnStickyLayout, onReplace: handleOnReplace, onReturn: handleOnReturn, onSizeSelectorPress: handleOnShowSizeWithoutStockModal })),
148
+ !customerDecissionMade && (React.createElement(ItemActions, { keepButtonLoading: keepCheckoutItemStatus === CommandStatus.LOADING, productVariantSelected: productVariantSelected, productVariants: bookedProductsVariants?.productVariants || [], returnButtonLoading: returnCheckoutItemStatus === CommandStatus.LOADING, sizeSelectorDisabled: replaceCheckoutItemStatus === CommandStatus.LOADING, onKeep: handleOnKeep, onLayout: handleOnStickyLayout, onReplace: handleOnReplace, onReturn: handleOnReturn, onSizeSelectorPress: handleOnShowSizeWithoutStockModal })),
149
149
  React.createElement(ReturnQuestionsForm, { checkoutItemPrice: checkoutItem.price, productVariant: checkoutItem.productVariant, returnQuestions: returnQuestions || [], visible: returnQuestionsVisible, onClose: handleOnHideReturnQuestions, onSubmit: handleOnSubmit })));
150
150
  };
151
151
  export { Item };
@@ -1,6 +1,6 @@
1
1
  import { FC } from "react";
2
2
  import { CheckoutItemStatus } from "../../../../../../domain/checkoutItem/model/checkoutItem";
3
- type CustomerDecissionBannerStatus = Exclude<CheckoutItemStatus, CheckoutItemStatus.INITIAL | CheckoutItemStatus.EXPIRED>;
3
+ type CustomerDecissionBannerStatus = Exclude<CheckoutItemStatus, CheckoutItemStatus.INITIAL>;
4
4
  interface CustomerDecissionBannerProps {
5
5
  readonly checkoutItemStatus: CustomerDecissionBannerStatus;
6
6
  readonly onPress: () => void;
@@ -1,5 +1,5 @@
1
1
  import { FC } from "react";
2
- import { ProductVariantProjection } from "../../../../../../projection/bookedSizeChangeProductsVariants/bookedSizeChangeProductsVariants";
2
+ import { ProductVariantProjection } from "../../../../../../projection/bookedProductsVariants/bookedProductsVariants";
3
3
  import { Layout } from "../../../../../../shared/ui/components/layouts/sticky/Sticky";
4
4
  interface ItemActionsProps {
5
5
  readonly productVariants: ProductVariantProjection[];
@@ -3,7 +3,7 @@ interface ProductVariantProjection {
3
3
  readonly id: string;
4
4
  readonly size: SizeProjection;
5
5
  }
6
- interface BookedSizeChangeProductsVariantsProjection {
6
+ interface BookedProductsVariantsProjection {
7
7
  readonly productVariants: ProductVariantProjection[];
8
8
  }
9
- export type { BookedSizeChangeProductsVariantsProjection, ProductVariantProjection };
9
+ export type { BookedProductsVariantsProjection, ProductVariantProjection };
@@ -0,0 +1,25 @@
1
+ import { CancelableQueryViewArgs, Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
2
+ import { BookedProductsVariantsProjection } from "./bookedProductsVariants";
3
+ declare const VIEW_BOOKED_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM = "view_booked_product_variants_for_checkout_item";
4
+ interface ViewBookedProductsVariantsForCheckoutItemPayload {
5
+ readonly checkoutItemId: string;
6
+ }
7
+ interface ViewBookedProductsVariantsForCheckoutItem extends Query<typeof VIEW_BOOKED_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM>, ViewBookedProductsVariantsForCheckoutItemPayload {
8
+ }
9
+ interface ViewBookedProductsVariantsForCheckoutItemFunction {
10
+ (payload: ViewBookedProductsVariantsForCheckoutItemPayload): ViewBookedProductsVariantsForCheckoutItem;
11
+ }
12
+ declare const viewBookedProductsVariantsForCheckoutItem: ViewBookedProductsVariantsForCheckoutItemFunction;
13
+ type ViewBookedProductsVariantsForCheckoutItemResult = BookedProductsVariantsProjection | null;
14
+ interface BookedProductsVariantsForCheckoutItemViewArgs extends CancelableQueryViewArgs {
15
+ readonly checkoutItemId: string;
16
+ }
17
+ interface BookedProductsVariantsForCheckoutItemView {
18
+ (args: BookedProductsVariantsForCheckoutItemViewArgs): Promise<ViewBookedProductsVariantsForCheckoutItemResult>;
19
+ }
20
+ interface ViewBookedProductsVariantsForCheckoutItemHandlerFunctionArgs extends QueryHandlerFunctionArgs {
21
+ readonly view: BookedProductsVariantsForCheckoutItemView;
22
+ }
23
+ declare const viewBookedProductsVariantsForCheckoutItemHandler: QueryHandlerFunction<ViewBookedProductsVariantsForCheckoutItem, ViewBookedProductsVariantsForCheckoutItemResult, ViewBookedProductsVariantsForCheckoutItemHandlerFunctionArgs>;
24
+ export type { ViewBookedProductsVariantsForCheckoutItem, BookedProductsVariantsForCheckoutItemView, ViewBookedProductsVariantsForCheckoutItemResult, };
25
+ export { VIEW_BOOKED_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM, viewBookedProductsVariantsForCheckoutItem, viewBookedProductsVariantsForCheckoutItemHandler, };
@@ -0,0 +1,8 @@
1
+ import { query, } from "@lookiero/messaging";
2
+ const VIEW_BOOKED_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM = "view_booked_product_variants_for_checkout_item";
3
+ const viewBookedProductsVariantsForCheckoutItem = (payload) => ({
4
+ ...query({ name: VIEW_BOOKED_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM }),
5
+ ...payload,
6
+ });
7
+ const viewBookedProductsVariantsForCheckoutItemHandler = ({ view, signal }) => async ({ checkoutItemId }) => view({ checkoutItemId, signal });
8
+ export { VIEW_BOOKED_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM, viewBookedProductsVariantsForCheckoutItem, viewBookedProductsVariantsForCheckoutItemHandler, };
@@ -1,7 +1,6 @@
1
- import { CheckoutStatus } from "../../domain/checkout/model/checkout";
2
1
  interface CheckoutBookingProjection {
3
2
  readonly id: string;
4
3
  readonly checkoutItemIds: string[];
5
- readonly checkoutStatus: CheckoutStatus;
4
+ readonly isExpired: boolean;
6
5
  }
7
6
  export type { CheckoutBookingProjection };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -1,12 +0,0 @@
1
- import { BookedSizeChangeProductsVariantsForCheckoutItemView } from "../../../projection/bookedSizeChangeProductsVariants/viewBookedSizeChangeProductVariantsForCheckoutItem";
2
- import { HttpPostFunction } from "../../delivery/http/httpClient";
3
- interface HttpBookedSizeChangeProductsVariantsForCheckoutItemView extends BookedSizeChangeProductsVariantsForCheckoutItemView {
4
- }
5
- interface HttpBookedSizeChangeProductsVariantsForCheckoutItemViewFunctionArgs {
6
- readonly httpPost: HttpPostFunction;
7
- }
8
- interface HttpBookedSizeChangeProductsVariantsForCheckoutItemViewFunction {
9
- (args: HttpBookedSizeChangeProductsVariantsForCheckoutItemViewFunctionArgs): HttpBookedSizeChangeProductsVariantsForCheckoutItemView;
10
- }
11
- declare const httpBookedSizeChangeProductsVariantsForCheckoutItemView: HttpBookedSizeChangeProductsVariantsForCheckoutItemViewFunction;
12
- export { httpBookedSizeChangeProductsVariantsForCheckoutItemView };
@@ -1,10 +0,0 @@
1
- import { UseQueryFunctionResult } from "@lookiero/messaging-react";
2
- import { BookedSizeChangeProductsVariantsProjection } from "../../../../projection/bookedSizeChangeProductsVariants/bookedSizeChangeProductsVariants";
3
- interface UseViewBookedSizeChangeProductsVariantsForCheckoutItemFunctionArgs {
4
- readonly checkoutItemId: string;
5
- }
6
- interface UseViewBookedSizeChangeProductsVariantsForCheckoutItemFunction {
7
- (args: UseViewBookedSizeChangeProductsVariantsForCheckoutItemFunctionArgs): UseQueryFunctionResult<BookedSizeChangeProductsVariantsProjection>;
8
- }
9
- declare const useViewBookedSizeChangeProductsVariantsForCheckoutItem: UseViewBookedSizeChangeProductsVariantsForCheckoutItemFunction;
10
- export { useViewBookedSizeChangeProductsVariantsForCheckoutItem };
@@ -1,12 +0,0 @@
1
- import { CheckoutFeedbackByCheckoutIdView } from "../../../projection/checkoutFeedback/viewCheckoutFeedbackByCheckoutId";
2
- import { HttpPostFunction } from "../../delivery/http/httpClient";
3
- interface HttpCheckoutFeebackByCheckoutIdView extends CheckoutFeedbackByCheckoutIdView {
4
- }
5
- interface HttpCheckoutFeebackByCheckoutIdViewFunctionArgs {
6
- readonly httpPost: HttpPostFunction;
7
- }
8
- interface HttpCheckoutFeebackByCheckoutIdViewFunction {
9
- (args: HttpCheckoutFeebackByCheckoutIdViewFunctionArgs): HttpCheckoutFeebackByCheckoutIdView;
10
- }
11
- declare const httpCheckoutFeebackByCheckoutIdView: HttpCheckoutFeebackByCheckoutIdViewFunction;
12
- export { httpCheckoutFeebackByCheckoutIdView };
@@ -1,9 +0,0 @@
1
- const httpCheckoutFeebackByCheckoutIdView = ({ httpPost }) => async ({ checkoutId, signal }) => {
2
- const response = await httpPost({
3
- endpoint: "/view-checkout-feedback-by-checkout-id",
4
- body: { checkoutId },
5
- signal,
6
- });
7
- return !response.ok || response.status === 404 ? null : (await response.json()).result;
8
- };
9
- export { httpCheckoutFeebackByCheckoutIdView };
@@ -1,25 +0,0 @@
1
- import { CancelableQueryViewArgs, Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
2
- import { BookedSizeChangeProductsVariantsProjection } from "./bookedSizeChangeProductsVariants";
3
- declare const VIEW_BOOKED_SIZE_CHANGE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM = "view_booked_size_change_product_variants_for_checkout_item";
4
- interface ViewBookedSizeChangeProductsVariantsForCheckoutItemPayload {
5
- readonly checkoutItemId: string;
6
- }
7
- interface ViewBookedSizeChangeProductsVariantsForCheckoutItem extends Query<typeof VIEW_BOOKED_SIZE_CHANGE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM>, ViewBookedSizeChangeProductsVariantsForCheckoutItemPayload {
8
- }
9
- interface ViewBookedSizeChangeProductsVariantsForCheckoutItemFunction {
10
- (payload: ViewBookedSizeChangeProductsVariantsForCheckoutItemPayload): ViewBookedSizeChangeProductsVariantsForCheckoutItem;
11
- }
12
- declare const viewBookedSizeChangeProductsVariantsForCheckoutItem: ViewBookedSizeChangeProductsVariantsForCheckoutItemFunction;
13
- type ViewBookedSizeChangeProductsVariantsForCheckoutItemResult = BookedSizeChangeProductsVariantsProjection | null;
14
- interface BookedSizeChangeProductsVariantsForCheckoutItemViewArgs extends CancelableQueryViewArgs {
15
- readonly checkoutItemId: string;
16
- }
17
- interface BookedSizeChangeProductsVariantsForCheckoutItemView {
18
- (args: BookedSizeChangeProductsVariantsForCheckoutItemViewArgs): Promise<ViewBookedSizeChangeProductsVariantsForCheckoutItemResult>;
19
- }
20
- interface ViewBookedSizeChangeProductsVariantsForCheckoutItemHandlerFunctionArgs extends QueryHandlerFunctionArgs {
21
- readonly view: BookedSizeChangeProductsVariantsForCheckoutItemView;
22
- }
23
- declare const viewBookedSizeChangeProductsVariantsForCheckoutItemHandler: QueryHandlerFunction<ViewBookedSizeChangeProductsVariantsForCheckoutItem, ViewBookedSizeChangeProductsVariantsForCheckoutItemResult, ViewBookedSizeChangeProductsVariantsForCheckoutItemHandlerFunctionArgs>;
24
- export type { ViewBookedSizeChangeProductsVariantsForCheckoutItem, BookedSizeChangeProductsVariantsForCheckoutItemView, ViewBookedSizeChangeProductsVariantsForCheckoutItemResult, };
25
- export { VIEW_BOOKED_SIZE_CHANGE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM, viewBookedSizeChangeProductsVariantsForCheckoutItem, viewBookedSizeChangeProductsVariantsForCheckoutItemHandler, };
@@ -1,8 +0,0 @@
1
- import { query, } from "@lookiero/messaging";
2
- const VIEW_BOOKED_SIZE_CHANGE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM = "view_booked_size_change_product_variants_for_checkout_item";
3
- const viewBookedSizeChangeProductsVariantsForCheckoutItem = (payload) => ({
4
- ...query({ name: VIEW_BOOKED_SIZE_CHANGE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM }),
5
- ...payload,
6
- });
7
- const viewBookedSizeChangeProductsVariantsForCheckoutItemHandler = ({ view, signal }) => async ({ checkoutItemId }) => view({ checkoutItemId, signal });
8
- export { VIEW_BOOKED_SIZE_CHANGE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM, viewBookedSizeChangeProductsVariantsForCheckoutItem, viewBookedSizeChangeProductsVariantsForCheckoutItemHandler, };
@@ -1,25 +0,0 @@
1
- import { CancelableQueryViewArgs, Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
2
- import { CheckoutFeedbackProjection } from "./checkoutFeedback";
3
- declare const VIEW_CHECKOUT_FEEDBACK_BY_CHECKOUT_ID = "view_checkout_feedback_by_checkout_id";
4
- interface ViewCheckoutFeedbackByCheckoutIdPayload {
5
- readonly checkoutId: string;
6
- }
7
- interface ViewCheckoutFeedbackByCheckoutId extends Query<typeof VIEW_CHECKOUT_FEEDBACK_BY_CHECKOUT_ID>, ViewCheckoutFeedbackByCheckoutIdPayload {
8
- }
9
- interface ViewCheckoutFeedbackByCheckoutIdFunction {
10
- (payload: ViewCheckoutFeedbackByCheckoutIdPayload): ViewCheckoutFeedbackByCheckoutId;
11
- }
12
- declare const viewCheckoutFeedbackByCheckoutId: ViewCheckoutFeedbackByCheckoutIdFunction;
13
- type ViewCheckoutFeedbackByCheckoutIdResult = CheckoutFeedbackProjection | null;
14
- interface CheckoutFeedbackByCheckoutIdViewArgs extends CancelableQueryViewArgs {
15
- readonly checkoutId: string;
16
- }
17
- interface CheckoutFeedbackByCheckoutIdView {
18
- (args: CheckoutFeedbackByCheckoutIdViewArgs): Promise<ViewCheckoutFeedbackByCheckoutIdResult>;
19
- }
20
- interface ViewCheckoutFeedbackByCheckoutIdHandlerFunctionArgs extends QueryHandlerFunctionArgs {
21
- readonly view: CheckoutFeedbackByCheckoutIdView;
22
- }
23
- declare const viewCheckoutFeedbackByCheckoutIdHandler: QueryHandlerFunction<ViewCheckoutFeedbackByCheckoutId, ViewCheckoutFeedbackByCheckoutIdResult, ViewCheckoutFeedbackByCheckoutIdHandlerFunctionArgs>;
24
- export type { ViewCheckoutFeedbackByCheckoutId, CheckoutFeedbackByCheckoutIdView, ViewCheckoutFeedbackByCheckoutIdResult, };
25
- export { VIEW_CHECKOUT_FEEDBACK_BY_CHECKOUT_ID, viewCheckoutFeedbackByCheckoutId, viewCheckoutFeedbackByCheckoutIdHandler, };
@@ -1,8 +0,0 @@
1
- import { query, } from "@lookiero/messaging";
2
- const VIEW_CHECKOUT_FEEDBACK_BY_CHECKOUT_ID = "view_checkout_feedback_by_checkout_id";
3
- const viewCheckoutFeedbackByCheckoutId = (payload) => ({
4
- ...query({ name: VIEW_CHECKOUT_FEEDBACK_BY_CHECKOUT_ID }),
5
- ...payload,
6
- });
7
- const viewCheckoutFeedbackByCheckoutIdHandler = ({ view, signal }) => async ({ checkoutId }) => view({ checkoutId, signal });
8
- export { VIEW_CHECKOUT_FEEDBACK_BY_CHECKOUT_ID, viewCheckoutFeedbackByCheckoutId, viewCheckoutFeedbackByCheckoutIdHandler, };