@lookiero/checkout 0.8.16 → 0.8.18

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 (91) hide show
  1. package/dist/domain/checkout/event/createModalNotificationWhenCheckoutSubmitted.d.ts +7 -0
  2. package/dist/domain/checkout/event/createModalNotificationWhenCheckoutSubmitted.js +12 -0
  3. package/dist/domain/checkoutBooking/event/createToastNotificationWhenCheckoutBookingExpired.d.ts +7 -0
  4. package/dist/domain/checkoutBooking/event/createToastNotificationWhenCheckoutBookingExpired.js +13 -0
  5. package/dist/domain/checkoutItem/event/createModalNotificationWhenCheckoutItemReplaced.d.ts +7 -0
  6. package/dist/domain/checkoutItem/event/createModalNotificationWhenCheckoutItemReplaced.js +12 -0
  7. package/dist/domain/checkoutItem/model/checkoutItem.js +1 -0
  8. package/dist/infrastructure/delivery/baseBootstrap.js +8 -2
  9. package/dist/infrastructure/delivery/mock/checkoutDataSource.js +4 -1
  10. package/dist/infrastructure/domain/checkout/react/useSubmitCheckout.js +2 -2
  11. package/dist/infrastructure/domain/checkoutBooking/react/useBlockCheckoutBooking.js +2 -2
  12. package/dist/infrastructure/domain/checkoutBooking/react/useBookCheckoutBookingForCheckoutItem.js +2 -2
  13. package/dist/infrastructure/domain/checkoutFeedback/react/useGiveCheckoutFeedback.js +2 -2
  14. package/dist/infrastructure/domain/checkoutItem/react/useKeepCheckoutItem.js +3 -5
  15. package/dist/infrastructure/domain/checkoutItem/react/useReplaceCheckoutItem.js +3 -6
  16. package/dist/infrastructure/domain/checkoutItem/react/useResetCheckoutItem.js +3 -5
  17. package/dist/infrastructure/domain/checkoutItem/react/useReturnCheckoutItem.js +3 -6
  18. package/dist/infrastructure/projection/bookedProductsVariants/react/useViewBookedProductsVariantsForCheckoutItem.js +4 -1
  19. package/dist/infrastructure/projection/checkout/react/useViewFiveItemsDiscountByCustomerId.js +1 -1
  20. package/dist/infrastructure/projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId.js +1 -1
  21. package/dist/infrastructure/projection/payment/react/useViewPaymentFlowPayloadByCheckoutId.js +6 -1
  22. package/dist/infrastructure/projection/pricing/react/useViewPricingByCheckoutId.js +6 -1
  23. package/dist/infrastructure/projection/returnQuestion/react/useListReturnQuestionsByCheckoutItemId.js +1 -1
  24. package/dist/infrastructure/ui/hooks/usePaymentInstrumentEvents.js +2 -2
  25. package/dist/infrastructure/ui/hooks/useSubmitCheckout.js +2 -2
  26. package/dist/infrastructure/ui/routing/CheckoutMiddleware.js +54 -36
  27. package/dist/infrastructure/ui/routing/Routing.js +1 -7
  28. package/dist/infrastructure/ui/views/App.js +4 -4
  29. package/dist/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.js +3 -7
  30. package/dist/infrastructure/ui/views/feedback/Feedback.js +10 -3
  31. package/dist/infrastructure/ui/views/item/Item.js +9 -53
  32. package/dist/infrastructure/ui/views/item/components/banner/CustomerDecissionBanner.d.ts +1 -0
  33. package/dist/infrastructure/ui/views/item/components/banner/CustomerDecissionBanner.js +10 -4
  34. package/dist/infrastructure/ui/views/item/components/banner/CustomerDecissionBanner.style.d.ts +8 -1
  35. package/dist/infrastructure/ui/views/item/components/banner/CustomerDecissionBanner.style.js +8 -1
  36. package/dist/infrastructure/ui/views/item/components/itemActions/ItemActions.js +2 -1
  37. package/dist/shared/notifications/domain/notification/command/createModalNotification.d.ts +18 -0
  38. package/dist/shared/notifications/domain/notification/command/createModalNotification.js +9 -0
  39. package/dist/shared/notifications/domain/notification/command/createToastNotification.d.ts +18 -0
  40. package/dist/shared/notifications/domain/notification/command/createToastNotification.js +9 -0
  41. package/dist/shared/notifications/domain/notification/model/notification.d.ts +11 -4
  42. package/dist/shared/notifications/domain/notification/model/notification.js +20 -4
  43. package/dist/shared/notifications/index.d.ts +3 -2
  44. package/dist/shared/notifications/index.js +3 -2
  45. package/dist/shared/notifications/infrastructure/delivery/bootstrap.js +7 -4
  46. package/dist/shared/notifications/infrastructure/domain/notification/model/storageNotifications.js +3 -1
  47. package/dist/shared/notifications/infrastructure/domain/notification/model/storageNotificationsCreate.d.ts +1 -1
  48. package/dist/shared/notifications/infrastructure/domain/notification/model/storageNotificationsCreate.js +3 -1
  49. package/dist/shared/notifications/infrastructure/domain/notification/react/useCreateModalNotification.d.ts +20 -0
  50. package/dist/shared/notifications/infrastructure/domain/notification/react/useCreateModalNotification.js +22 -0
  51. package/dist/shared/notifications/infrastructure/domain/notification/react/useCreateToastNotification.d.ts +21 -0
  52. package/dist/shared/notifications/infrastructure/domain/notification/react/{useCreateNotification.js → useCreateToastNotification.js} +4 -4
  53. package/dist/shared/notifications/infrastructure/persistence/notificationDto.d.ts +3 -1
  54. package/dist/shared/notifications/infrastructure/projection/notification/notification.d.ts +2 -2
  55. package/dist/shared/notifications/infrastructure/projection/notification/notification.js +16 -6
  56. package/dist/shared/notifications/infrastructure/ui/components/modalNotifications/ModalNotificationItem.d.ts +10 -0
  57. package/dist/shared/notifications/infrastructure/ui/components/modalNotifications/ModalNotificationItem.js +26 -0
  58. package/dist/{infrastructure/ui/views/checkout/components/checkoutSuccessModal/CheckoutSuccessModal.style.js → shared/notifications/infrastructure/ui/components/modalNotifications/ModalNotificationItem.style.js} +1 -1
  59. package/dist/shared/notifications/infrastructure/ui/components/modalNotifications/ModalNotifications.d.ts +8 -0
  60. package/dist/shared/notifications/infrastructure/ui/components/modalNotifications/ModalNotifications.js +6 -0
  61. package/dist/shared/notifications/infrastructure/ui/components/modalNotifications/ModalNotifications.style.d.ts +25 -0
  62. package/dist/shared/notifications/infrastructure/ui/components/modalNotifications/ModalNotifications.style.js +18 -0
  63. package/dist/shared/notifications/infrastructure/ui/components/toastNotifications/ToastNotificationItem.d.ts +12 -0
  64. package/dist/shared/notifications/infrastructure/ui/components/{NotificationItem.js → toastNotifications/ToastNotificationItem.js} +4 -4
  65. package/dist/shared/notifications/infrastructure/ui/components/toastNotifications/ToastNotifications.d.ts +9 -0
  66. package/dist/shared/notifications/infrastructure/ui/components/toastNotifications/ToastNotifications.js +20 -0
  67. package/dist/shared/notifications/infrastructure/ui/components/{Notifications.style.js → toastNotifications/ToastNotifications.style.js} +1 -1
  68. package/dist/shared/notifications/infrastructure/ui/views/Notifications.js +9 -3
  69. package/dist/shared/notifications/projection/notification/notification.d.ts +18 -2
  70. package/dist/shared/notifications/projection/notification/notification.js +8 -1
  71. package/dist/shared/ui/components/atoms/spinner/Spinner.d.ts +6 -1
  72. package/dist/shared/ui/components/atoms/spinner/Spinner.js +2 -2
  73. package/dist/shared/ui/components/layouts/modal/Modal.d.ts +1 -0
  74. package/dist/shared/ui/components/layouts/modal/Modal.js +2 -2
  75. package/package.json +7 -5
  76. package/dist/domain/checkoutBooking/event/createNotificationWhenCheckoutBookingExpired.d.ts +0 -6
  77. package/dist/domain/checkoutBooking/event/createNotificationWhenCheckoutBookingExpired.js +0 -13
  78. package/dist/infrastructure/ui/views/checkout/components/checkoutSuccessModal/CheckoutSuccessModal.d.ts +0 -7
  79. package/dist/infrastructure/ui/views/checkout/components/checkoutSuccessModal/CheckoutSuccessModal.js +0 -25
  80. package/dist/infrastructure/ui/views/item/components/sizeChangeModal/SizeChangeModal.d.ts +0 -7
  81. package/dist/infrastructure/ui/views/item/components/sizeChangeModal/SizeChangeModal.js +0 -25
  82. package/dist/infrastructure/ui/views/item/components/sizeChangeModal/SizeChangeModal.style.d.ts +0 -16
  83. package/dist/infrastructure/ui/views/item/components/sizeChangeModal/SizeChangeModal.style.js +0 -19
  84. package/dist/shared/notifications/domain/notification/command/createNotification.d.ts +0 -17
  85. package/dist/shared/notifications/domain/notification/command/createNotification.js +0 -7
  86. package/dist/shared/notifications/infrastructure/domain/notification/react/useCreateNotification.d.ts +0 -21
  87. package/dist/shared/notifications/infrastructure/ui/components/NotificationItem.d.ts +0 -12
  88. package/dist/shared/notifications/infrastructure/ui/components/Notifications.d.ts +0 -9
  89. package/dist/shared/notifications/infrastructure/ui/components/Notifications.js +0 -20
  90. /package/dist/{infrastructure/ui/views/checkout/components/checkoutSuccessModal/CheckoutSuccessModal.style.d.ts → shared/notifications/infrastructure/ui/components/modalNotifications/ModalNotificationItem.style.d.ts} +0 -0
  91. /package/dist/shared/notifications/infrastructure/ui/components/{Notifications.style.d.ts → toastNotifications/ToastNotifications.style.d.ts} +0 -0
@@ -0,0 +1,7 @@
1
+ import { ProcessManagerFunction } from "@lookiero/messaging";
2
+ import { CheckoutSubmitted } from "../model/checkoutSubmitted";
3
+ declare const CHECKOUT_SUCCESS_NOTIFICATION_ID = "fa25dcdd-9f5d-4760-9e6f-27174205b1fa";
4
+ interface CreateModalNotificationWhenCheckoutSubmittedFunction extends ProcessManagerFunction<CheckoutSubmitted> {
5
+ }
6
+ declare const createModalNotificationWhenCheckoutSubmitted: CreateModalNotificationWhenCheckoutSubmittedFunction;
7
+ export { createModalNotificationWhenCheckoutSubmitted, CHECKOUT_SUCCESS_NOTIFICATION_ID };
@@ -0,0 +1,12 @@
1
+ import { I18nMessages } from "../../../infrastructure/ui/i18n/i18n";
2
+ import { createModalNotification } from "../../../shared/notifications/domain/notification/command/createModalNotification";
3
+ const CHECKOUT_SUCCESS_NOTIFICATION_ID = "fa25dcdd-9f5d-4760-9e6f-27174205b1fa";
4
+ const createModalNotificationWhenCheckoutSubmitted = ({ commandBus }) => async () => {
5
+ await commandBus(createModalNotification({
6
+ aggregateId: CHECKOUT_SUCCESS_NOTIFICATION_ID,
7
+ titleI18nKey: I18nMessages.CHECKOUT_SUCCESS_MODAL_TITLE,
8
+ bodyI18nKey: I18nMessages.CHECKOUT_SUCCESS_MODAL_DESCRIPTION,
9
+ acceptI18nKey: I18nMessages.CHECKOUT_SUCCESS_MODAL_BUTTON,
10
+ }));
11
+ };
12
+ export { createModalNotificationWhenCheckoutSubmitted, CHECKOUT_SUCCESS_NOTIFICATION_ID };
@@ -0,0 +1,7 @@
1
+ import { ProcessManagerFunction } from "@lookiero/messaging";
2
+ import { CheckoutBookingExpired } from "../model/checkoutBookingExpired";
3
+ declare const CHECKOUT_BOOKING_EXPIRED_NOTIFICATION_ID = "d423934e-2499-46ab-8cfb-39e1e398237e";
4
+ interface CreateToastNotificationWhenCheckoutBookingExpiredFunction extends ProcessManagerFunction<CheckoutBookingExpired> {
5
+ }
6
+ declare const createToastNotificationWhenCheckoutBookingExpired: CreateToastNotificationWhenCheckoutBookingExpiredFunction;
7
+ export { createToastNotificationWhenCheckoutBookingExpired, CHECKOUT_BOOKING_EXPIRED_NOTIFICATION_ID };
@@ -0,0 +1,13 @@
1
+ import { I18nMessages } from "../../../infrastructure/ui/i18n/i18n";
2
+ import { createToastNotification } from "../../../shared/notifications/domain/notification/command/createToastNotification";
3
+ import { NotificationLevel } from "../../../shared/notifications/domain/notification/model/notification";
4
+ const CHECKOUT_BOOKING_EXPIRED_NOTIFICATION_ID = "d423934e-2499-46ab-8cfb-39e1e398237e";
5
+ const createToastNotificationWhenCheckoutBookingExpired = ({ commandBus }) => async () => {
6
+ await commandBus(createToastNotification({
7
+ aggregateId: CHECKOUT_BOOKING_EXPIRED_NOTIFICATION_ID,
8
+ level: NotificationLevel.ERROR,
9
+ titleI18nKey: undefined,
10
+ bodyI18nKey: I18nMessages.CHECKOUT_TOAST_BOOKING_EXPIRED,
11
+ }));
12
+ };
13
+ export { createToastNotificationWhenCheckoutBookingExpired, CHECKOUT_BOOKING_EXPIRED_NOTIFICATION_ID };
@@ -0,0 +1,7 @@
1
+ import { ProcessManagerFunction } from "@lookiero/messaging";
2
+ import { CheckoutItemReplaced } from "../model/checkoutItemReplaced";
3
+ declare const SIZE_CHANGE_NOTIFICATION_ID = "ce89b8b2-e025-4b54-8cdc-52520dc3dd23";
4
+ interface CreateModalNotificationWhenCheckoutItemReplacedFunction extends ProcessManagerFunction<CheckoutItemReplaced> {
5
+ }
6
+ declare const createModalNotificationWhenCheckoutItemReplaced: CreateModalNotificationWhenCheckoutItemReplacedFunction;
7
+ export { createModalNotificationWhenCheckoutItemReplaced, SIZE_CHANGE_NOTIFICATION_ID };
@@ -0,0 +1,12 @@
1
+ import { I18nMessages } from "../../../infrastructure/ui/i18n/i18n";
2
+ import { createModalNotification } from "../../../shared/notifications/domain/notification/command/createModalNotification";
3
+ const SIZE_CHANGE_NOTIFICATION_ID = "ce89b8b2-e025-4b54-8cdc-52520dc3dd23";
4
+ const createModalNotificationWhenCheckoutItemReplaced = ({ commandBus }) => async () => {
5
+ await commandBus(createModalNotification({
6
+ aggregateId: SIZE_CHANGE_NOTIFICATION_ID,
7
+ titleI18nKey: I18nMessages.SIZE_CHANGE_MODAL_TITLE,
8
+ bodyI18nKey: I18nMessages.SIZE_CHANGE_MODAL_DESCRIPTION,
9
+ acceptI18nKey: I18nMessages.SIZE_CHANGE_MODAL_BUTTON,
10
+ }));
11
+ };
12
+ export { createModalNotificationWhenCheckoutItemReplaced, SIZE_CHANGE_NOTIFICATION_ID };
@@ -39,6 +39,7 @@ const resetCheckoutItemHandler = () => async ({ aggregateRoot, command }) => {
39
39
  const { aggregateId } = command;
40
40
  return {
41
41
  ...aggregateRoot,
42
+ status: CheckoutItemStatus.INITIAL,
42
43
  domainEvents: [checkoutItemReset({ aggregateId })],
43
44
  };
44
45
  };
@@ -1,10 +1,12 @@
1
1
  import { bootstrap as messagingBootstrap } from "@lookiero/messaging-react";
2
2
  import { START_CHECKOUT } from "../../domain/checkout/command/startCheckout";
3
3
  import { SUBMIT_CHECKOUT } from "../../domain/checkout/command/submitCheckout";
4
+ import { createModalNotificationWhenCheckoutSubmitted } from "../../domain/checkout/event/createModalNotificationWhenCheckoutSubmitted";
4
5
  import { submitCheckoutHandler, startCheckoutHandler } from "../../domain/checkout/model/checkout";
6
+ import { CHECKOUT_SUBMITTED } from "../../domain/checkout/model/checkoutSubmitted";
5
7
  import { BLOCK_CHECKOUT_BOOKING } from "../../domain/checkoutBooking/command/blockCheckoutBooking";
6
8
  import { BOOK_CHECKOUT_BOOKING_FOR_CHECKOUT_ITEM } from "../../domain/checkoutBooking/command/bookCheckoutBookingForCheckoutItem";
7
- import { createNotificationWhenCheckoutBookingExpired } from "../../domain/checkoutBooking/event/createNotificationWhenCheckoutBookingExpired";
9
+ import { createToastNotificationWhenCheckoutBookingExpired } from "../../domain/checkoutBooking/event/createToastNotificationWhenCheckoutBookingExpired";
8
10
  import { blockCheckoutBookingHandler, bookCheckoutBookingForCheckoutItemHandler, } from "../../domain/checkoutBooking/model/checkoutBooking";
9
11
  import { CHECKOUT_BOOKING_EXPIRED } from "../../domain/checkoutBooking/model/checkoutBookingExpired";
10
12
  import { GIVE_CHECKOUT_FEEDBACK } from "../../domain/checkoutFeedback/command/giveCheckoutFeedback";
@@ -13,7 +15,9 @@ import { KEEP_CHECKOUT_ITEM } from "../../domain/checkoutItem/command/keepChecko
13
15
  import { REPLACE_CHECKOUT_ITEM } from "../../domain/checkoutItem/command/replaceCheckoutItem";
14
16
  import { RESET_CHECKOUT_ITEM } from "../../domain/checkoutItem/command/resetCheckoutItem";
15
17
  import { RETURN_CHECKOUT_ITEM } from "../../domain/checkoutItem/command/returnCheckoutItem";
18
+ import { createModalNotificationWhenCheckoutItemReplaced } from "../../domain/checkoutItem/event/createModalNotificationWhenCheckoutItemReplaced";
16
19
  import { keepCheckoutItemHandler, replaceCheckoutItemHandler, resetCheckoutItemHandler, returnCheckoutItemHandler, } from "../../domain/checkoutItem/model/checkoutItem";
20
+ import { CHECKOUT_ITEM_REPLACED } from "../../domain/checkoutItem/model/checkoutItemReplaced";
17
21
  import { UPDATE_UI_SETTING } from "../../domain/uiSetting/command/updateUiSetting";
18
22
  import { updateUiSettingHandler } from "../../domain/uiSetting/model/uiSetting";
19
23
  import { viewBookedProductsVariantsForCheckoutItemHandler, VIEW_BOOKED_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM, } from "../../projection/bookedProductsVariants/viewBookedProductVariantsForCheckoutItem";
@@ -81,7 +85,9 @@ const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdVie
81
85
  view: uiSettingByKeyView,
82
86
  })
83
87
  .command(UPDATE_UI_SETTING, updateUiSettingHandler)(getUiSetting, saveUiSetting, ...uiSettingsDependencies)
84
- .processManager(CHECKOUT_BOOKING_EXPIRED, createNotificationWhenCheckoutBookingExpired);
88
+ .processManager(CHECKOUT_BOOKING_EXPIRED, createToastNotificationWhenCheckoutBookingExpired)
89
+ .processManager(CHECKOUT_ITEM_REPLACED, createModalNotificationWhenCheckoutItemReplaced)
90
+ .processManager(CHECKOUT_SUBMITTED, createModalNotificationWhenCheckoutSubmitted);
85
91
  messaging = bootstrapNotifications({ messaging, storage: inMemoryStorageNotifications() });
86
92
  return messaging.build();
87
93
  };
@@ -6,7 +6,10 @@ const checkoutDataSource = ({ data: initialData }) => {
6
6
  };
7
7
  const getCheckoutItem = (id) => data.items.find((item) => item.id === id) || null;
8
8
  const saveCheckoutItem = (checkoutItem) => {
9
- data = { ...data, items: data.items.map((item) => (item.id === checkoutItem.id ? checkoutItem : item)) };
9
+ data = {
10
+ ...data,
11
+ items: data.items.map((item) => item.id === checkoutItem.id ? { ...checkoutItem, productVariant: item.productVariant } : item),
12
+ };
10
13
  };
11
14
  return {
12
15
  getCheckout,
@@ -2,13 +2,13 @@ import { useCommand } from "@lookiero/messaging-react";
2
2
  import { useCallback } from "react";
3
3
  import invariant from "tiny-invariant";
4
4
  import { submitCheckout } from "../../../../domain/checkout/command/submitCheckout";
5
- import { useCreateNotification } from "../../../../shared/notifications";
5
+ import { useCreateToastNotification } from "../../../../shared/notifications";
6
6
  import { NotificationLevel } from "../../../../shared/notifications/domain/notification/model/notification";
7
7
  import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
8
8
  import { I18nMessages } from "../../../ui/i18n/i18n";
9
9
  const useSubmitCheckout = ({ checkoutId, logger }) => {
10
10
  const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
11
- const [createNotification] = useCreateNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
11
+ const [createNotification] = useCreateToastNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
12
12
  const submit = useCallback(async () => {
13
13
  invariant(checkoutId, "CheckoutId must be defined in order to submit checkout");
14
14
  try {
@@ -1,13 +1,13 @@
1
1
  import { useCommand } from "@lookiero/messaging-react";
2
2
  import { useCallback } from "react";
3
3
  import { blockCheckoutBooking as blockCheckoutBookingCommand } from "../../../../domain/checkoutBooking/command/blockCheckoutBooking";
4
- import { useCreateNotification } from "../../../../shared/notifications";
4
+ import { useCreateToastNotification } from "../../../../shared/notifications";
5
5
  import { NotificationLevel } from "../../../../shared/notifications/domain/notification/model/notification";
6
6
  import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
7
7
  import { I18nMessages } from "../../../ui/i18n/i18n";
8
8
  const useBlockCheckoutBooking = ({ checkoutBookingId, logger }) => {
9
9
  const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
10
- const [createNotification] = useCreateNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
10
+ const [createNotification] = useCreateToastNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
11
11
  const blockCheckoutBooking = useCallback(async () => {
12
12
  try {
13
13
  await commandBus(blockCheckoutBookingCommand({
@@ -2,13 +2,13 @@ import { useCommand } from "@lookiero/messaging-react";
2
2
  import { useCallback } from "react";
3
3
  import { v4 as uuid } from "uuid";
4
4
  import { bookCheckoutBookingForCheckoutItem } from "../../../../domain/checkoutBooking/command/bookCheckoutBookingForCheckoutItem";
5
- import { useCreateNotification } from "../../../../shared/notifications";
5
+ import { useCreateToastNotification } from "../../../../shared/notifications";
6
6
  import { NotificationLevel } from "../../../../shared/notifications/domain/notification/model/notification";
7
7
  import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
8
8
  import { I18nMessages } from "../../../ui/i18n/i18n";
9
9
  const useBookCheckoutBookingForCheckoutItem = ({ checkoutItemId, checkoutBookingId, logger, }) => {
10
10
  const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
11
- const [createNotification] = useCreateNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
11
+ const [createNotification] = useCreateToastNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
12
12
  const book = useCallback(async () => {
13
13
  try {
14
14
  await commandBus(bookCheckoutBookingForCheckoutItem({
@@ -1,13 +1,13 @@
1
1
  import { useCommand } from "@lookiero/messaging-react";
2
2
  import { useCallback } from "react";
3
3
  import { giveCheckoutFeedback as giveCheckoutFeedbackCommand } from "../../../../domain/checkoutFeedback/command/giveCheckoutFeedback";
4
- import { useCreateNotification } from "../../../../shared/notifications";
4
+ import { useCreateToastNotification } from "../../../../shared/notifications";
5
5
  import { NotificationLevel } from "../../../../shared/notifications/domain/notification/model/notification";
6
6
  import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
7
7
  import { I18nMessages } from "../../../ui/i18n/i18n";
8
8
  const useGiveCheckoutFeedback = ({ checkoutId, logger }) => {
9
9
  const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
10
- const [createNotification] = useCreateNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
10
+ const [createNotification] = useCreateToastNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
11
11
  const giveCheckoutFeedback = useCallback(async ({ feedbacks }) => {
12
12
  try {
13
13
  await commandBus(giveCheckoutFeedbackCommand({
@@ -1,18 +1,16 @@
1
1
  import { useCommand } from "@lookiero/messaging-react";
2
2
  import { useCallback } from "react";
3
3
  import { keepCheckoutItem } from "../../../../domain/checkoutItem/command/keepCheckoutItem";
4
- import { useCreateNotification } from "../../../../shared/notifications";
4
+ import { useCreateToastNotification } from "../../../../shared/notifications";
5
5
  import { NotificationLevel } from "../../../../shared/notifications/domain/notification/model/notification";
6
6
  import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
7
7
  import { I18nMessages } from "../../../ui/i18n/i18n";
8
8
  const useKeepCheckoutItem = ({ checkoutItemId, logger }) => {
9
9
  const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
10
- const [createNotification] = useCreateNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
10
+ const [createNotification] = useCreateToastNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
11
11
  const keep = useCallback(async () => {
12
12
  try {
13
- await commandBus(keepCheckoutItem({
14
- aggregateId: checkoutItemId,
15
- }));
13
+ await commandBus(keepCheckoutItem({ aggregateId: checkoutItemId }));
16
14
  }
17
15
  catch (error) {
18
16
  logger.captureException(error);
@@ -1,19 +1,16 @@
1
1
  import { useCommand } from "@lookiero/messaging-react";
2
2
  import { useCallback } from "react";
3
3
  import { replaceCheckoutItem } from "../../../../domain/checkoutItem/command/replaceCheckoutItem";
4
- import { useCreateNotification } from "../../../../shared/notifications";
4
+ import { useCreateToastNotification } from "../../../../shared/notifications";
5
5
  import { NotificationLevel } from "../../../../shared/notifications/domain/notification/model/notification";
6
6
  import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
7
7
  import { I18nMessages } from "../../../ui/i18n/i18n";
8
8
  const useReplaceCheckoutItem = ({ checkoutItemId, logger }) => {
9
9
  const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
10
- const [createNotification] = useCreateNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
10
+ const [createNotification] = useCreateToastNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
11
11
  const replace = useCallback(async ({ replacedForId }) => {
12
12
  try {
13
- await commandBus(replaceCheckoutItem({
14
- aggregateId: checkoutItemId,
15
- replacedForId,
16
- }));
13
+ await commandBus(replaceCheckoutItem({ aggregateId: checkoutItemId, replacedForId }));
17
14
  }
18
15
  catch (error) {
19
16
  logger.captureException(error);
@@ -1,18 +1,16 @@
1
1
  import { useCommand } from "@lookiero/messaging-react";
2
2
  import { useCallback } from "react";
3
3
  import { resetCheckoutItem } from "../../../../domain/checkoutItem/command/resetCheckoutItem";
4
- import { useCreateNotification } from "../../../../shared/notifications";
4
+ import { useCreateToastNotification } from "../../../../shared/notifications";
5
5
  import { NotificationLevel } from "../../../../shared/notifications/domain/notification/model/notification";
6
6
  import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
7
7
  import { I18nMessages } from "../../../ui/i18n/i18n";
8
8
  const useResetCheckoutItem = ({ checkoutItemId, logger }) => {
9
9
  const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
10
- const [createNotification] = useCreateNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
10
+ const [createNotification] = useCreateToastNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
11
11
  const reset = useCallback(async () => {
12
12
  try {
13
- await commandBus(resetCheckoutItem({
14
- aggregateId: checkoutItemId,
15
- }));
13
+ await commandBus(resetCheckoutItem({ aggregateId: checkoutItemId }));
16
14
  }
17
15
  catch (error) {
18
16
  logger.captureException(error);
@@ -1,19 +1,16 @@
1
1
  import { useCommand } from "@lookiero/messaging-react";
2
2
  import { useCallback } from "react";
3
3
  import { returnCheckoutItem as returnCheckoutItemCommand } from "../../../../domain/checkoutItem/command/returnCheckoutItem";
4
- import { useCreateNotification } from "../../../../shared/notifications";
4
+ import { useCreateToastNotification } from "../../../../shared/notifications";
5
5
  import { NotificationLevel } from "../../../../shared/notifications/domain/notification/model/notification";
6
6
  import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
7
7
  import { I18nMessages } from "../../../ui/i18n/i18n";
8
8
  const useReturnCheckoutItem = ({ checkoutItemId, logger }) => {
9
9
  const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
10
- const [createNotification] = useCreateNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
10
+ const [createNotification] = useCreateToastNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
11
11
  const returnCheckoutItem = useCallback(async ({ feedbacks }) => {
12
12
  try {
13
- await commandBus(returnCheckoutItemCommand({
14
- aggregateId: checkoutItemId,
15
- feedbacks,
16
- }));
13
+ await commandBus(returnCheckoutItemCommand({ aggregateId: checkoutItemId, feedbacks }));
17
14
  }
18
15
  catch (error) {
19
16
  logger.captureException(error);
@@ -1,12 +1,15 @@
1
1
  import { useQuery } from "@lookiero/messaging-react";
2
2
  import { CHECKOUT_BOOKING_BOOKED, } from "../../../../domain/checkoutBooking/model/checkoutBookingBooked";
3
+ import { CHECKOUT_BOOKING_EXPIRED } from "../../../../domain/checkoutBooking/model/checkoutBookingExpired";
3
4
  import { viewBookedProductsVariantsForCheckoutItem } from "../../../../projection/bookedProductsVariants/viewBookedProductVariantsForCheckoutItem";
4
5
  import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
5
6
  const isCheckoutBookingBooked = (event) => event.name === CHECKOUT_BOOKING_BOOKED;
7
+ const isCheckoutBookingExpired = (event) => event.name === CHECKOUT_BOOKING_EXPIRED;
8
+ const shouldInvalidate = (event) => isCheckoutBookingBooked(event) || isCheckoutBookingExpired(event);
6
9
  const useViewBookedProductsVariantsForCheckoutItem = ({ checkoutItemId, }) => useQuery({
7
10
  query: viewBookedProductsVariantsForCheckoutItem({ checkoutItemId }),
8
11
  contextId: MESSAGING_CONTEXT_ID,
9
- invalidation: isCheckoutBookingBooked,
12
+ invalidation: shouldInvalidate,
10
13
  options: { refetchOnMount: "always", staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
11
14
  });
12
15
  export { useViewBookedProductsVariantsForCheckoutItem };
@@ -4,6 +4,6 @@ import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
4
4
  const useViewFiveItemsDiscountByCustomerId = ({ customerId }) => useQuery({
5
5
  query: viewFiveItemsDiscountByCustomerId({ customerId }),
6
6
  contextId: MESSAGING_CONTEXT_ID,
7
- options: { refetchOnMount: "always", staleTime: Infinity, cacheTime: 0 },
7
+ options: { staleTime: Infinity },
8
8
  });
9
9
  export { useViewFiveItemsDiscountByCustomerId };
@@ -4,6 +4,6 @@ import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
4
4
  const useListCheckoutQuestionsByCheckoutId = ({ checkoutId }) => useQuery({
5
5
  query: listCheckoutQuestionsByCheckoutId({ checkoutId }),
6
6
  contextId: MESSAGING_CONTEXT_ID,
7
- options: { refetchOnMount: "always", staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
7
+ options: { staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
8
8
  });
9
9
  export { useListCheckoutQuestionsByCheckoutId };
@@ -1,13 +1,18 @@
1
1
  import { useQuery } from "@lookiero/messaging-react";
2
2
  import { CHECKOUT_ITEM_KEPT } from "../../../../domain/checkoutItem/model/checkoutItemKept";
3
3
  import { CHECKOUT_ITEM_REPLACED, } from "../../../../domain/checkoutItem/model/checkoutItemReplaced";
4
+ import { CHECKOUT_ITEM_RESET } from "../../../../domain/checkoutItem/model/checkoutItemReset";
4
5
  import { CHECKOUT_ITEM_RETURNED, } from "../../../../domain/checkoutItem/model/checkoutItemReturned";
5
6
  import { viewPaymentFlowPayloadByCheckoutId } from "../../../../projection/payment/viewPaymentFlowPayloadByCheckoutId";
6
7
  import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
7
8
  const isCheckoutItemKept = (event) => event.name === CHECKOUT_ITEM_KEPT;
8
9
  const isCheckoutItemReturned = (event) => event.name === CHECKOUT_ITEM_RETURNED;
9
10
  const isCheckoutItemReplaced = (event) => event.name === CHECKOUT_ITEM_REPLACED;
10
- const shouldInvalidate = (event) => isCheckoutItemKept(event) || isCheckoutItemReplaced(event) || isCheckoutItemReturned(event);
11
+ const isCheckoutItemReset = (event) => event.name === CHECKOUT_ITEM_RESET;
12
+ const shouldInvalidate = (event) => isCheckoutItemKept(event) ||
13
+ isCheckoutItemReplaced(event) ||
14
+ isCheckoutItemReturned(event) ||
15
+ isCheckoutItemReset(event);
11
16
  const useViewPaymentFlowPayloadByCheckoutId = ({ checkoutId }) => useQuery({
12
17
  query: viewPaymentFlowPayloadByCheckoutId({ checkoutId: checkoutId }),
13
18
  contextId: MESSAGING_CONTEXT_ID,
@@ -1,13 +1,18 @@
1
1
  import { useQuery } from "@lookiero/messaging-react";
2
2
  import { CHECKOUT_ITEM_KEPT } from "../../../../domain/checkoutItem/model/checkoutItemKept";
3
3
  import { CHECKOUT_ITEM_REPLACED, } from "../../../../domain/checkoutItem/model/checkoutItemReplaced";
4
+ import { CHECKOUT_ITEM_RESET } from "../../../../domain/checkoutItem/model/checkoutItemReset";
4
5
  import { CHECKOUT_ITEM_RETURNED, } from "../../../../domain/checkoutItem/model/checkoutItemReturned";
5
6
  import { viewPricingByCheckoutId } from "../../../../projection/pricing/viewPricingByCheckoutId";
6
7
  import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
7
8
  const isCheckoutItemKept = (event) => event.name === CHECKOUT_ITEM_KEPT;
8
9
  const isCheckoutItemReturned = (event) => event.name === CHECKOUT_ITEM_RETURNED;
9
10
  const isCheckoutItemReplaced = (event) => event.name === CHECKOUT_ITEM_REPLACED;
10
- const shouldInvalidate = (event) => isCheckoutItemKept(event) || isCheckoutItemReplaced(event) || isCheckoutItemReturned(event);
11
+ const isCheckoutItemReset = (event) => event.name === CHECKOUT_ITEM_RESET;
12
+ const shouldInvalidate = (event) => isCheckoutItemKept(event) ||
13
+ isCheckoutItemReplaced(event) ||
14
+ isCheckoutItemReturned(event) ||
15
+ isCheckoutItemReset(event);
11
16
  const useViewPricingByCheckoutId = ({ checkoutId }) => useQuery({
12
17
  query: viewPricingByCheckoutId({ checkoutId }),
13
18
  contextId: MESSAGING_CONTEXT_ID,
@@ -4,6 +4,6 @@ import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
4
4
  const useListReturnQuestionsByCheckoutItemId = ({ checkoutItemId }) => useQuery({
5
5
  query: listReturnQuestionsByCheckoutItemId({ checkoutItemId }),
6
6
  contextId: MESSAGING_CONTEXT_ID,
7
- options: { refetchOnMount: "always", staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
7
+ options: { staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
8
8
  });
9
9
  export { useListReturnQuestionsByCheckoutItemId };
@@ -1,6 +1,6 @@
1
1
  import { useEvent } from "@lookiero/event";
2
2
  import { useCallback, useEffect } from "react";
3
- import { useCreateNotification } from "../../../shared/notifications";
3
+ import { useCreateToastNotification } from "../../../shared/notifications";
4
4
  import { MESSAGING_CONTEXT_ID } from "../../delivery/baseBootstrap";
5
5
  import { I18nMessages } from "../i18n/i18n";
6
6
  import { useToast } from "./useToast";
@@ -9,7 +9,7 @@ const PAYMENT_SUCCESS = "PAYMENT_INSTRUMENT_UPDATED";
9
9
  const usePaymentInstrumentEvents = ({ logger }) => {
10
10
  const { subscribe, unsubscribe } = useEvent();
11
11
  const { showError, showSuccess } = useToast();
12
- const [createNotification] = useCreateNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
12
+ const [createNotification] = useCreateToastNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
13
13
  const onSuccess = useCallback(({ message }) => showSuccess({ message: message.id }), [showSuccess]);
14
14
  const onError = useCallback(({ error }) => {
15
15
  if (error.toaster) {
@@ -1,7 +1,7 @@
1
1
  import { CommandStatus } from "@lookiero/messaging-react";
2
2
  import { ChargeStatus } from "@lookiero/payments-front/build/infrastructure/CheckoutAPI";
3
3
  import { useCallback, useMemo, useState } from "react";
4
- import { useCreateNotification } from "../../../shared/notifications";
4
+ import { useCreateToastNotification } from "../../../shared/notifications";
5
5
  import { NotificationLevel } from "../../../shared/notifications/domain/notification/model/notification";
6
6
  import { MESSAGING_CONTEXT_ID } from "../../delivery/baseBootstrap";
7
7
  import { useSubmitCheckout as useSubmitCheckoutCommand } from "../../domain/checkout/react/useSubmitCheckout";
@@ -10,7 +10,7 @@ import { I18nMessages } from "../i18n/i18n";
10
10
  const useSubmitCheckout = ({ checkoutId, checkoutBookingId, paymentFlowRef, onError, logger, }) => {
11
11
  const [submitCheckoutCommand, submitCheckoutCommandStatus] = useSubmitCheckoutCommand({ checkoutId, logger });
12
12
  const [blockCheckoutBooking, blockCheckoutBookingStatus] = useBlockCheckoutBooking({ checkoutBookingId, logger });
13
- const [createNotification] = useCreateNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
13
+ const [createNotification] = useCreateToastNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
14
14
  const [startLegacyBoxCheckoutStatus, setStartLegacyBoxCheckoutStatus] = useState("idle");
15
15
  const submitCheckout = useCallback(async ({ paymentFlowPayload }) => {
16
16
  try {
@@ -1,6 +1,5 @@
1
- import { QueryStatus } from "@lookiero/messaging-react";
2
1
  import React, { useEffect, useRef } from "react";
3
- import { generatePath, Navigate, useMatch } from "react-router-native";
2
+ import { generatePath, Navigate, useMatch, useNavigate } from "react-router-native";
4
3
  import { CheckoutStatus } from "../../../domain/checkout/model/checkout";
5
4
  import { CheckoutItemStatus } from "../../../domain/checkoutItem/model/checkoutItem";
6
5
  import { useLogger } from "../../../shared/logging/useLogger";
@@ -12,54 +11,73 @@ import { useBasePath } from "./useBasePath";
12
11
  const CheckoutMiddleware = ({ customerId, loader = React.createElement(Spinner, null), children }) => {
13
12
  const logger = useLogger();
14
13
  const basePath = useBasePath();
15
- const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
16
- const firstItemWithoutCustomerDecision = checkout?.items.find((item) => item.status === CheckoutItemStatus.INITIAL);
17
- const [startCheckout] = useStartCheckout({ checkoutId: checkout?.id, logger });
18
- useEffect(() => {
19
- if (checkout?.id) {
20
- startCheckout();
21
- }
22
- }, [checkout?.id, startCheckout]);
14
+ const navigate = useNavigate();
15
+ const navigateRef = useRef(navigate);
16
+ navigateRef.current = navigate;
23
17
  const itemRouteMatch = useMatch(`${basePath}/${Routes.ITEM}`);
18
+ const itemRouteMatchRef = useRef(itemRouteMatch);
19
+ itemRouteMatchRef.current = itemRouteMatch;
24
20
  const itemDetailRouteMatch = useMatch(`${basePath}/${Routes.ITEM_DETAIL}`);
21
+ const itemDetailRouteMatchRef = useRef(itemDetailRouteMatch);
22
+ itemDetailRouteMatchRef.current = itemDetailRouteMatch;
25
23
  const summaryRouteMatch = useMatch(`${basePath}/${Routes.SUMMARY}`);
24
+ const summaryRouteMatchRef = useRef(summaryRouteMatch);
25
+ summaryRouteMatchRef.current = summaryRouteMatch;
26
26
  const checkoutRouteMatch = useMatch(`${basePath}/${Routes.CHECKOUT}`);
27
+ const checkoutRouteMatchRef = useRef(checkoutRouteMatch);
28
+ checkoutRouteMatchRef.current = checkoutRouteMatch;
27
29
  const feedbackRouteMatch = useMatch(`${basePath}/${Routes.FEEDBACK}`);
30
+ const feedbackRouteMatchRef = useRef(feedbackRouteMatch);
31
+ feedbackRouteMatchRef.current = feedbackRouteMatch;
28
32
  const checkoutPaymentRouteMatch = useMatch(`${basePath}/${Routes.CHECKOUT}/${Routes.CHECKOUT_PAYMENT}`);
33
+ const checkoutPaymentRouteMatchRef = useRef(checkoutPaymentRouteMatch);
34
+ checkoutPaymentRouteMatchRef.current = checkoutPaymentRouteMatch;
29
35
  const checkoutShown = useRef(false);
30
36
  checkoutShown.current = checkoutShown.current || (Boolean(checkoutRouteMatch) && !Boolean(checkoutPaymentRouteMatch));
31
- const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
32
- const dependenciesLoaded = dependenciesLoadedStatuses.includes(checkoutStatus) || checkout;
33
- if (!dependenciesLoaded) {
37
+ const [checkout] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
38
+ const checkoutItemsRef = useRef();
39
+ const [startCheckout] = useStartCheckout({ checkoutId: checkout?.id, logger });
40
+ useEffect(() => {
41
+ if (checkout?.id) {
42
+ startCheckout();
43
+ }
44
+ }, [checkout?.id, startCheckout]);
45
+ useEffect(() => {
46
+ /* Navigate to the feedback if checkout is submitted */
47
+ if (checkout?.status === CheckoutStatus.SUBMITTED && !feedbackRouteMatchRef.current) {
48
+ navigateRef.current(`${basePath}/${Routes.FEEDBACK}`, { replace: true });
49
+ }
50
+ else if ([CheckoutStatus.AVAILABLE, CheckoutStatus.STARTED, CheckoutStatus.NOTIFIED].includes(checkout?.status)) {
51
+ /**
52
+ * If the customer has just reset an item's decission, navigate to that item.
53
+ * Otherwise, navigate to the first item without customer decission.
54
+ */
55
+ const itemWithoutCustomerDecision = checkout?.items.find((item) => item.status === CheckoutItemStatus.INITIAL &&
56
+ checkoutItemsRef.current?.find((previousItem) => previousItem.id === item.id && previousItem.status !== CheckoutItemStatus.INITIAL)) || checkout?.items.find((item) => item.status === CheckoutItemStatus.INITIAL);
57
+ checkoutItemsRef.current = checkout?.items;
58
+ /* Navigate to the summary if required */
59
+ if (itemWithoutCustomerDecision === undefined &&
60
+ !(summaryRouteMatchRef.current ||
61
+ itemDetailRouteMatchRef.current ||
62
+ checkoutRouteMatchRef.current ||
63
+ checkoutPaymentRouteMatchRef.current)) {
64
+ navigateRef.current(`${basePath}/${Routes.SUMMARY}`, { replace: true });
65
+ }
66
+ if (itemWithoutCustomerDecision &&
67
+ !(itemRouteMatchRef.current && itemRouteMatchRef.current.params.id === itemWithoutCustomerDecision.id)) {
68
+ navigateRef.current(generatePath(`${basePath}/${Routes.ITEM}`, { id: itemWithoutCustomerDecision.id }), {
69
+ replace: true,
70
+ });
71
+ }
72
+ }
73
+ }, [basePath, checkout?.status, checkout?.items]);
74
+ if (!checkout) {
34
75
  return loader;
35
76
  }
36
77
  /* Prevent direct payment access */
37
78
  if (checkoutPaymentRouteMatch && !checkoutShown.current) {
38
79
  return React.createElement(Navigate, { to: `${basePath}/${Routes.HOME}`, replace: true });
39
80
  }
40
- /* Navigate to the feedback if checkout is submitted */
41
- if (checkout?.status === CheckoutStatus.SUBMITTED &&
42
- !(feedbackRouteMatch || checkoutRouteMatch || checkoutPaymentRouteMatch)) {
43
- return React.createElement(Navigate, { to: `${basePath}/${Routes.FEEDBACK}`, replace: true });
44
- }
45
- /* Navigate to the summary if required */
46
- if ((checkout?.status === CheckoutStatus.AVAILABLE ||
47
- checkout?.status === CheckoutStatus.STARTED ||
48
- checkout?.status === CheckoutStatus.NOTIFIED) &&
49
- firstItemWithoutCustomerDecision === undefined &&
50
- !(summaryRouteMatch || itemDetailRouteMatch || checkoutRouteMatch || checkoutPaymentRouteMatch)) {
51
- return React.createElement(Navigate, { to: `${basePath}/${Routes.SUMMARY}`, replace: true });
52
- }
53
- /* Item/ItemDetail 404 - Not found */
54
- if (itemRouteMatch || itemDetailRouteMatch) {
55
- const checkoutItem = checkout?.items.find((item) => item.id === itemRouteMatch?.params.id || itemDetailRouteMatch?.params.id);
56
- if (!checkoutItem) {
57
- return React.createElement(Navigate, { to: `${basePath}/${Routes.HOME}`, replace: true });
58
- }
59
- }
60
- if (firstItemWithoutCustomerDecision && !itemRouteMatch) {
61
- return (React.createElement(Navigate, { to: generatePath(`${basePath}/${Routes.ITEM}`, { id: firstItemWithoutCustomerDecision.id }), replace: true }));
62
- }
63
81
  return children;
64
82
  };
65
83
  export { CheckoutMiddleware };
@@ -11,7 +11,6 @@ const Item = lazy(() => import("../views/item/Item").then((module) => ({ default
11
11
  const Summary = lazy(() => import("../views/summary/Summary").then((module) => ({ default: module.Summary })));
12
12
  const Checkout = lazy(() => import("../views/checkout/Checkout").then((module) => ({ default: module.Checkout })));
13
13
  const Feedback = lazy(() => import("../views/feedback/Feedback").then((module) => ({ default: module.Feedback })));
14
- const NotFound = lazy(() => import("../views/notFound/NotFound").then((module) => ({ default: module.NotFound })));
15
14
  const Routing = ({ basePath = "", customer, locale, I18n, menu, tabBar, getAuthToken, onI18nError, onNotAccessible, useRedirect, useRoutes = reactRouterUseRoutes, }) => {
16
15
  return useRoutes([
17
16
  {
@@ -55,14 +54,9 @@ const Routing = ({ basePath = "", customer, locale, I18n, menu, tabBar, getAuthT
55
54
  element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
56
55
  React.createElement(Feedback, { country: customer?.country, customerId: customer?.customerId }))),
57
56
  },
58
- {
59
- path: Routes.NOT_FOUND,
60
- element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
61
- React.createElement(NotFound, { country: customer?.country, customerId: customer?.customerId }))),
62
- },
63
57
  {
64
58
  path: "*",
65
- element: React.createElement(Navigate, { to: `${Routes.NOT_FOUND}`, replace: true }),
59
+ element: React.createElement(Navigate, { to: `${Routes.HOME}`, replace: true }),
66
60
  },
67
61
  ],
68
62
  },
@@ -8,8 +8,8 @@ import { theme } from "../theme/theme";
8
8
  import { Navigation } from "./navigation/Navigation";
9
9
  const { colorBase } = theme();
10
10
  const App = ({ customerId, menu, tabBar, children }) => (React.createElement(SafeAreaProvider, null,
11
- React.createElement(StatusBar, { backgroundColor: colorBase, barStyle: "dark-content", translucent: true }),
12
- React.createElement(Notifications, { contextId: MESSAGING_CONTEXT_ID }),
13
- React.createElement(Navigation, { customerId: customerId, menu: menu, tabBar: tabBar },
14
- React.createElement(PortalProvider, null, children))));
11
+ React.createElement(PortalProvider, null,
12
+ React.createElement(StatusBar, { backgroundColor: colorBase, barStyle: "dark-content", translucent: true }),
13
+ React.createElement(Notifications, { contextId: MESSAGING_CONTEXT_ID }),
14
+ React.createElement(Navigation, { customerId: customerId, menu: menu, tabBar: tabBar }, children))));
15
15
  export { App };
@@ -8,7 +8,6 @@ import { useViewPaymentFlowPayloadByCheckoutId } from "../../../../../projection
8
8
  import { useSubmitCheckout } from "../../../../hooks/useSubmitCheckout";
9
9
  import { Routes } from "../../../../routing/routes";
10
10
  import { useBasePath } from "../../../../routing/useBasePath";
11
- import { CheckoutSuccessModal } from "../checkoutSuccessModal/CheckoutSuccessModal";
12
11
  const CheckoutPaymentModal = ({ customerId, getAuthToken }) => {
13
12
  const paymentFlowRef = useRef(null);
14
13
  const logger = useLogger();
@@ -23,9 +22,8 @@ const CheckoutPaymentModal = ({ customerId, getAuthToken }) => {
23
22
  }, [getAuthToken]);
24
23
  const basePath = useBasePath();
25
24
  const navigate = useNavigate();
26
- const handleOnSuccessModalDismiss = useCallback(() => navigate(`${basePath}/${Routes.FEEDBACK}`, { replace: true }), [basePath, navigate]);
27
25
  const handleOnErrorSubmitCheckout = useCallback(() => navigate(`${basePath}/${Routes.CHECKOUT}`, { replace: true }), [basePath, navigate]);
28
- const [submitCheckout, submitCheckoutStatus] = useSubmitCheckout({
26
+ const [submitCheckout] = useSubmitCheckout({
29
27
  checkoutId: checkout?.id,
30
28
  checkoutBookingId: checkout?.checkoutBookingId,
31
29
  paymentFlowRef,
@@ -38,11 +36,9 @@ const CheckoutPaymentModal = ({ customerId, getAuthToken }) => {
38
36
  }
39
37
  }, [paymentFlowPayload, submitCheckout]);
40
38
  const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
41
- const dependenciesLoaded = dependenciesLoadedStatuses.includes(checkoutStatus) || checkout;
39
+ const dependenciesLoaded = (dependenciesLoadedStatuses.includes(checkoutStatus) || checkout) && authToken;
42
40
  if (!dependenciesLoaded)
43
41
  return null;
44
- return (React.createElement(React.Fragment, null,
45
- React.createElement(CheckoutSuccessModal, { visible: submitCheckoutStatus === "success", onDismiss: handleOnSuccessModalDismiss }),
46
- authToken && React.createElement(PaymentFlow, { ref: paymentFlowRef, token: authToken })));
42
+ return React.createElement(PaymentFlow, { ref: paymentFlowRef, token: authToken });
47
43
  };
48
44
  export { CheckoutPaymentModal };