@lookiero/checkout 0.4.3 → 0.4.5-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) 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.js +1 -1
  12. package/dist/infrastructure/delivery/mock/dataSourceCheckoutBookings.js +2 -3
  13. package/dist/infrastructure/delivery/mock/dataSourceCheckoutFeedbacks.js +3 -12
  14. package/dist/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.js +1 -1
  15. package/dist/infrastructure/domain/checkoutBooking/react/useBookCheckouBookingForCheckoutItem.d.ts +13 -0
  16. package/dist/infrastructure/domain/checkoutBooking/react/useBookCheckouBookingForCheckoutItem.js +14 -0
  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/bookedSizeChangeProductsVariants/httpBookedSizeChangeProductsVariantsForCheckoutItemView.d.ts +12 -0
  21. package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/httpBookedSizeChangeProductsVariantsForCheckoutItemView.js +9 -0
  22. package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/react/useViewBookedSizeChangeProductsVariantsForCheckoutItem.d.ts +10 -0
  23. package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/react/useViewBookedSizeChangeProductsVariantsForCheckoutItem.js +12 -0
  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 +12 -59
  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/feedback/Feedback.js +2 -1
  39. package/dist/infrastructure/ui/views/header/Header.js +13 -14
  40. package/dist/infrastructure/ui/views/header/Header.style.d.ts +10 -4
  41. package/dist/infrastructure/ui/views/header/Header.style.js +10 -4
  42. package/dist/infrastructure/ui/views/intro/Intro.js +2 -2
  43. package/dist/infrastructure/ui/views/item/Item.js +3 -3
  44. package/dist/infrastructure/ui/views/item/components/banner/CustomerDecissionBanner.d.ts +1 -1
  45. package/dist/infrastructure/ui/views/summary/Summary.js +6 -4
  46. package/dist/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.d.ts +2 -0
  47. package/dist/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.js +1 -1
  48. package/dist/projection/bookedSizeChangeProductsVariants/bookedSizeChangeProductsVariants.d.ts +10 -0
  49. package/dist/projection/bookedSizeChangeProductsVariants/bookedSizeChangeProductsVariants.js +1 -0
  50. package/dist/projection/bookedSizeChangeProductsVariants/viewBookedSizeChangeProductVariantsForCheckoutItem.d.ts +25 -0
  51. package/dist/projection/bookedSizeChangeProductsVariants/viewBookedSizeChangeProductVariantsForCheckoutItem.js +8 -0
  52. package/dist/projection/checkoutBooking/checkoutBooking.d.ts +1 -2
  53. package/package.json +1 -1
@@ -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;
@@ -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, bookedProductsVariantsForCheckoutItemView, 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
  })
@@ -1,20 +1,19 @@
1
1
  import invariant from "tiny-invariant";
2
2
  import { v4 as uuid } from "uuid";
3
- import { CheckoutStatus } from "../../../domain/checkout/model/checkout";
4
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
18
  const getCheckoutBooking = ({ queryBus }) => async (aggregateId) => toCheckoutBookingDomain(await queryBus(viewBookedProductsVariantsForCheckoutItem({ checkoutItemId: aggregateId })));
20
19
  const saveCheckoutBooking = ({ dataSource }) => async (aggregateRoot) => {
@@ -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
  };
@@ -0,0 +1,13 @@
1
+ import { CommandStatus } from "@lookiero/messaging-react";
2
+ interface BookFunction {
3
+ (): Promise<void>;
4
+ }
5
+ type UseBookCheckouBookingForCheckoutItem = [book: BookFunction, status: CommandStatus];
6
+ interface UseBookCheckouBookingForCheckoutItemFunctionArgs {
7
+ readonly checkoutItemId: string;
8
+ }
9
+ interface UseBookCheckouBookingForCheckoutItemFunction {
10
+ (args: UseBookCheckouBookingForCheckoutItemFunctionArgs): UseBookCheckouBookingForCheckoutItem;
11
+ }
12
+ declare const useBookCheckouBookingForCheckoutItem: UseBookCheckouBookingForCheckoutItemFunction;
13
+ export { useBookCheckouBookingForCheckoutItem };
@@ -0,0 +1,14 @@
1
+ import { useCommand } from "@lookiero/messaging-react";
2
+ import { useCallback } from "react";
3
+ import { v4 as uuid } from "uuid";
4
+ import { bookCheckoutBookingForCheckoutItem } from "../../../../domain/checkoutBooking/command/bookCheckoutBookingForCheckoutItem";
5
+ import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
6
+ const useBookCheckouBookingForCheckoutItem = ({ checkoutItemId }) => {
7
+ const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
8
+ const book = useCallback(() => commandBus(bookCheckoutBookingForCheckoutItem({
9
+ aggregateId: uuid(),
10
+ checkoutItemId,
11
+ })), [checkoutItemId, commandBus]);
12
+ return [book, status];
13
+ };
14
+ export { useBookCheckouBookingForCheckoutItem };
@@ -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 { 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 };
@@ -0,0 +1,9 @@
1
+ const httpBookedSizeChangeProductsVariantsForCheckoutItemView = ({ httpPost }) => async ({ checkoutItemId, signal }) => {
2
+ const response = await httpPost({
3
+ endpoint: "/view-booked-size-change-product-variants-for-checkout-item",
4
+ body: { checkoutItemId },
5
+ signal,
6
+ });
7
+ return !response.ok || response.status === 404 ? null : (await response.json()).result;
8
+ };
9
+ export { httpBookedSizeChangeProductsVariantsForCheckoutItemView };
@@ -0,0 +1,10 @@
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 };
@@ -0,0 +1,12 @@
1
+ import { useQuery } from "@lookiero/messaging-react";
2
+ import { CHECKOUT_BOOKING_BOOKED, } from "../../../../domain/checkoutBooking/model/checkoutBookingBooked";
3
+ import { viewBookedSizeChangeProductsVariantsForCheckoutItem } from "../../../../projection/bookedSizeChangeProductsVariants/viewBookedSizeChangeProductVariantsForCheckoutItem";
4
+ import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
5
+ const isCheckoutBookingBooked = (event) => event.name === CHECKOUT_BOOKING_BOOKED;
6
+ const useViewBookedSizeChangeProductsVariantsForCheckoutItem = ({ checkoutItemId }) => useQuery({
7
+ query: viewBookedSizeChangeProductsVariantsForCheckoutItem({ checkoutItemId }),
8
+ contextId: MESSAGING_CONTEXT_ID,
9
+ invalidation: isCheckoutBookingBooked,
10
+ options: { staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
11
+ });
12
+ export { useViewBookedSizeChangeProductsVariantsForCheckoutItem };
@@ -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";
7
- import { View } from "react-native";
3
+ import { QueryStatus } from "@lookiero/messaging-react";
4
+ import { PaymentInstrumentSelect, PaymentMethod, Section } from "@lookiero/payments-front";
5
+ import React, { useCallback, useMemo, useRef } from "react";
6
+ import { Platform, 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,8 +38,7 @@ 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
- React.createElement(SafeAreaScrollView, { scrollerPaddingTop: HEADER_HEIGHT },
41
+ React.createElement(SafeAreaScrollView, { scrollerPaddingTop: Platform.OS === "web" ? HEADER_HEIGHT : 0 },
91
42
  React.createElement(Body, { style: { column: style.bodyColumn } },
92
43
  hasReplacedCheckoutItem && (React.createElement(View, { style: style.deliveryBannerContainer },
93
44
  React.createElement(DeliveryBanner, null))),
@@ -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 };
@@ -1,5 +1,6 @@
1
1
  import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
2
2
  import React, { useCallback } from "react";
3
+ import { Platform } from "react-native";
3
4
  import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
4
5
  import { useGiveCheckoutFeedback } from "../../../domain/checkoutFeedback/react/useGiveCheckoutFeedback";
5
6
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
@@ -29,7 +30,7 @@ const Feedback = ({ customerId }) => {
29
30
  if (!dependenciesLoaded)
30
31
  return React.createElement(Spinner, null);
31
32
  return (React.createElement(CheckoutQuestionFeedbackProvider, { feedback: {} },
32
- React.createElement(SafeAreaScrollView, { scrollerPaddingTop: HEADER_HEIGHT },
33
+ React.createElement(SafeAreaScrollView, { scrollerPaddingTop: Platform.OS === "web" ? HEADER_HEIGHT : 0 },
33
34
  React.createElement(Body, { style: { column: style.bodyColumn } },
34
35
  React.createElement(CheckoutQuestionsForm, { checkoutQuestions: checkoutQuestions || [], submitButtonDisabled: giveCheckoutFeedbackStatus === CommandStatus.LOADING, onSubmit: handleOnSubmit })))));
35
36
  };
@@ -2,7 +2,7 @@ import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Tex
2
2
  import { useI18nMessage } from "@lookiero/i18n-react";
3
3
  import React, { useCallback, useState } from "react";
4
4
  import { View } from "react-native";
5
- import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
5
+ import { SafeAreaView } from "react-native-safe-area-context";
6
6
  import { generatePath, useMatch, useNavigate, useParams } from "react-router-native";
7
7
  import { ButtonIcon } from "../../../../shared/ui/components/molecules/buttonIcon/ButtonIcon";
8
8
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
@@ -12,11 +12,11 @@ import { useBasePath } from "../../routing/useBasePath";
12
12
  import { style } from "./Header.style";
13
13
  import { Logo } from "./components/Logo";
14
14
  const ButtonIconPlaceholder = () => React.createElement(View, { style: style.buttonIconPlaceholder });
15
- const DefaultHeader = ({ onOpenMenu, style: customStyle }) => (React.createElement(View, { style: customStyle, testID: "default-header" },
15
+ const DefaultHeader = ({ onOpenMenu }) => (React.createElement(View, { style: style.header, testID: "default-header" },
16
16
  React.createElement(Logo, { style: style.logo }),
17
17
  React.createElement(ButtonIconPlaceholder, null),
18
18
  React.createElement(ButtonIcon, { name: "menu", onPress: onOpenMenu })));
19
- const ItemHeader = ({ items, item, style: customStyle }) => {
19
+ const ItemHeader = ({ items, item }) => {
20
20
  const title = useI18nMessage({ id: I18nMessages.HEADER_CHECKOUT_TITLE });
21
21
  const itemIndex = items.indexOf(item);
22
22
  const isFirstItem = itemIndex === 0;
@@ -33,32 +33,31 @@ const ItemHeader = ({ items, item, style: customStyle }) => {
33
33
  const nextItem = items[nextItemIndex];
34
34
  navigate(generatePath(`${basePath}/${Routes.ITEM}`, { id: nextItem.id }));
35
35
  }, [basePath, itemIndex, items, navigate]);
36
- return (React.createElement(View, { style: customStyle, testID: "item-header" },
36
+ return (React.createElement(View, { style: style.header, testID: "item-header" },
37
37
  !isFirstItem ? React.createElement(ButtonIcon, { name: "arrow-left", onPress: navigateToPreviousItem }) : React.createElement(ButtonIconPlaceholder, null),
38
38
  React.createElement(Text, { level: 3, style: style.title, detail: true }, title),
39
39
  !isLastItem ? React.createElement(ButtonIcon, { name: "arrow-right", onPress: navigateToNextItem }) : React.createElement(ButtonIconPlaceholder, null)));
40
40
  };
41
- const ItemDetailHeader = ({ style: customStyle }) => {
41
+ const ItemDetailHeader = () => {
42
42
  const title = useI18nMessage({ id: I18nMessages.HEADER_CHECKOUT_TITLE });
43
43
  const navigate = useNavigate();
44
44
  const handleOnBack = useCallback(() => navigate(-1), [navigate]);
45
- return (React.createElement(View, { style: customStyle, testID: "item-detail-header" },
45
+ return (React.createElement(View, { style: style.header, testID: "item-detail-header" },
46
46
  React.createElement(ButtonIconPlaceholder, null),
47
47
  React.createElement(Text, { level: 3, style: style.title, detail: true }, title),
48
48
  React.createElement(ButtonIcon, { name: "close", onPress: handleOnBack })));
49
49
  };
50
- const CheckoutHeader = ({ style: customStyle }) => {
50
+ const CheckoutHeader = () => {
51
51
  const title = useI18nMessage({ id: I18nMessages.HEADER_COMPLETE_CHECKOUT_TITLE });
52
52
  const basePath = useBasePath();
53
53
  const navigate = useNavigate();
54
54
  const handleOnBack = useCallback(() => navigate(`${basePath}/${Routes.SUMMARY}`), [basePath, navigate]);
55
- return (React.createElement(View, { style: customStyle, testID: "checkout-header" },
55
+ return (React.createElement(View, { style: style.header, testID: "checkout-header" },
56
56
  React.createElement(ButtonIcon, { name: "arrow-left", onPress: handleOnBack }),
57
57
  React.createElement(Text, { level: 3, style: style.title, detail: true }, title),
58
58
  React.createElement(ButtonIconPlaceholder, null)));
59
59
  };
60
60
  const Header = ({ customerId, menu: Menu, style: customStyle }) => {
61
- const { top: safeAreaInsetTop } = useSafeAreaInsets();
62
61
  const { id: itemId } = useParams();
63
62
  const [checkout] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
64
63
  const currentItem = checkout?.items.find((item) => item.id === itemId);
@@ -72,19 +71,19 @@ const Header = ({ customerId, menu: Menu, style: customStyle }) => {
72
71
  let header;
73
72
  if (checkout?.items && currentItem) {
74
73
  if (itemRouteMatch) {
75
- header = React.createElement(ItemHeader, { item: currentItem, items: checkout.items, style: style.header });
74
+ header = React.createElement(ItemHeader, { item: currentItem, items: checkout.items });
76
75
  }
77
76
  else if (itemDetailRouteMatch) {
78
- header = React.createElement(ItemDetailHeader, { style: style.header });
77
+ header = React.createElement(ItemDetailHeader, null);
79
78
  }
80
79
  }
81
80
  else if (checkoutRouteMatch) {
82
- header = React.createElement(CheckoutHeader, { style: style.header });
81
+ header = React.createElement(CheckoutHeader, null);
83
82
  }
84
83
  else {
85
- header = React.createElement(DefaultHeader, { style: style.header, onOpenMenu: handleOnOpenMenu });
84
+ header = React.createElement(DefaultHeader, { onOpenMenu: handleOnOpenMenu });
86
85
  }
87
- return (React.createElement(SafeAreaView, { edges: ["top"], style: [style.container, { paddingTop: safeAreaInsetTop }, customStyle] },
86
+ return (React.createElement(SafeAreaView, { edges: ["top"], style: [style.container, customStyle] },
88
87
  header,
89
88
  React.createElement(Menu, { visible: menuVisible, onClose: handleOnCloseMenu })));
90
89
  };
@@ -1,21 +1,27 @@
1
1
  declare const HEADER_HEIGHT: number;
2
2
  declare const style: {
3
3
  buttonIconPlaceholder: {
4
+ flexGrow: number;
4
5
  height: number;
5
6
  width: number;
6
7
  };
7
8
  container: {
8
- backgroundColor: string;
9
- flex: number;
9
+ flexDirection: "row";
10
+ flexGrow: number;
10
11
  height: number;
11
- paddingHorizontal: number;
12
12
  width: string;
13
13
  };
14
14
  header: {
15
15
  alignItems: "center";
16
- flex: number;
16
+ backgroundColor: string;
17
17
  flexDirection: "row";
18
+ flexGrow: number;
19
+ flexWrap: "nowrap";
20
+ height: number;
18
21
  justifyContent: "space-between";
22
+ overflow: "visible";
23
+ paddingHorizontal: number;
24
+ width: string;
19
25
  };
20
26
  logo: {
21
27
  left: number;
@@ -4,21 +4,27 @@ const { colorBase, spaceXXL, spaceXXXL, spaceS } = theme();
4
4
  const HEADER_HEIGHT = spaceXXXL;
5
5
  const style = StyleSheet.create({
6
6
  buttonIconPlaceholder: {
7
+ flexGrow: 0,
7
8
  height: spaceXXL,
8
9
  width: spaceXXL,
9
10
  },
10
11
  container: {
11
- backgroundColor: colorBase,
12
- flex: 1,
12
+ flexDirection: "row",
13
+ flexGrow: 0,
13
14
  height: HEADER_HEIGHT,
14
- paddingHorizontal: spaceS,
15
15
  width: "100%",
16
16
  },
17
17
  header: {
18
18
  alignItems: "center",
19
- flex: 1,
19
+ backgroundColor: colorBase,
20
20
  flexDirection: "row",
21
+ flexGrow: 0,
22
+ flexWrap: "nowrap",
23
+ height: HEADER_HEIGHT,
21
24
  justifyContent: "space-between",
25
+ overflow: "visible",
26
+ paddingHorizontal: spaceS,
27
+ width: "100%",
22
28
  },
23
29
  logo: {
24
30
  left: 0,
@@ -4,7 +4,7 @@ import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Tex
4
4
  import { useI18nMessage } from "@lookiero/i18n-react";
5
5
  import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
6
6
  import React from "react";
7
- import { View } from "react-native";
7
+ import { Platform, View } from "react-native";
8
8
  import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
9
9
  import { useIncrementIntroShownCount } from "../../../domain/uiSetting/react/useIncrementIntroShownCount";
10
10
  import { useViewFiveItemsDiscountByCustomerId } from "../../../projection/checkout/react/useViewFiveItemsDiscountByCustomerId";
@@ -30,7 +30,7 @@ const Intro = ({ customerId }) => {
30
30
  const [incrementIntroShownCount, incrementIntroShownCountStatus] = useIncrementIntroShownCount();
31
31
  if (fiveItemsDiscountStatus === QueryStatus.LOADING)
32
32
  return React.createElement(Spinner, null);
33
- return (React.createElement(SafeAreaScrollView, { scrollerPaddingTop: HEADER_HEIGHT },
33
+ return (React.createElement(SafeAreaScrollView, { scrollerPaddingTop: Platform.OS === "web" ? HEADER_HEIGHT : 0 },
34
34
  React.createElement(Body, { style: { column: style.bodyColumn } },
35
35
  React.createElement(View, { style: style.container },
36
36
  React.createElement(View, { style: style.content },
@@ -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 });
@@ -136,7 +136,7 @@ const Item = ({ customerId }) => {
136
136
  return (React.createElement(ReturnQuestionFeedbackProvider, { feedback: checkoutItem.feedbacks || {} },
137
137
  React.createElement(SizeWithoutStockModal, { visible: sizeWithoutStockModalVisible, onDismiss: handleOnHideSizeWithoutStockModal }),
138
138
  React.createElement(SizeChangeModal, { visible: sizeChangeModalVisible, onDismiss: handleOnHideSizeChangeModal }),
139
- React.createElement(SafeAreaScrollView, { scrollerPaddingTop: HEADER_HEIGHT },
139
+ React.createElement(SafeAreaScrollView, { scrollerPaddingTop: Platform.OS === "web" ? HEADER_HEIGHT : 0 },
140
140
  React.createElement(Body, null,
141
141
  customerDecissionMade && (React.createElement(CustomerDecissionBanner, { checkoutItemStatus: checkoutItem.status, onPress: handleOnBannerPress })),
142
142
  React.createElement(View, { style: [style.container, { paddingBottom: Platform.OS === "web" ? spaceXL : stickyHeight }] },
@@ -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;
@@ -2,7 +2,7 @@ import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Tex
2
2
  import { useI18nMessage } from "@lookiero/i18n-react";
3
3
  import { QueryStatus } from "@lookiero/messaging-react";
4
4
  import React, { useCallback, useMemo, useState } from "react";
5
- import { View } from "react-native";
5
+ import { Platform, View } from "react-native";
6
6
  import { generatePath, useNavigate } from "react-router-native";
7
7
  import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
8
8
  import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
@@ -24,6 +24,8 @@ const { spaceXL } = theme();
24
24
  const Summary = ({ customerId }) => {
25
25
  const titleText = useI18nMessage({ id: I18nMessages.SUMMARY_TITLE });
26
26
  const descriptionText = useI18nMessage({ id: I18nMessages.SUMMARY_DESCRIPTION });
27
+ const [pricingHeight, setPricingHeight] = useState(0);
28
+ const handleOnPricingLayout = useCallback(({ height }) => setPricingHeight(height), []);
27
29
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
28
30
  const [pricing, pricingStatus] = useViewPricingByCheckoutId({ checkoutId: checkout?.id });
29
31
  const [fiveItemsDiscount = 0, fiveItemsDiscountStatus] = useViewFiveItemsDiscountByCustomerId({ customerId });
@@ -42,13 +44,13 @@ const Summary = ({ customerId }) => {
42
44
  if (!dependenciesLoaded)
43
45
  return React.createElement(Spinner, null);
44
46
  return (React.createElement(React.Fragment, null,
45
- React.createElement(SafeAreaScrollView, { scrollerPaddingTop: HEADER_HEIGHT, style: { safeAreaView: style.container } },
46
- React.createElement(Body, { style: { row: { paddingBottom: spaceXL } } },
47
+ React.createElement(SafeAreaScrollView, { scrollerPaddingTop: Platform.OS === "web" ? HEADER_HEIGHT : 0, style: { safeAreaView: style.container } },
48
+ React.createElement(Body, { style: { row: { paddingBottom: pricingHeight || spaceXL } } },
47
49
  fiveItemsDiscount !== 0 && React.createElement(FiveItemsDiscountBanner, { fiveItemsDiscount: fiveItemsDiscount }),
48
50
  React.createElement(View, { style: style.content },
49
51
  React.createElement(Text, { level: 3, style: style.title, heading: true }, titleText),
50
52
  React.createElement(Text, { level: 3, style: style.description, body: true }, descriptionText)),
51
53
  React.createElement(CheckoutItemsTabs, { checkoutItemsKept: checkoutItemsKept || [], checkoutItemsReturned: checkoutItemsReturned || [], onPressItem: handleOnPressItem }))),
52
- pricing && (React.createElement(StickyPricing, { collapsed: pricingCollapsed, pricing: pricing, totalCheckoutItemsKept: checkoutItemsKept?.length || 0, onPress: handleOnPressPricing, onSubmit: handleOnSubmit }))));
54
+ pricing && (React.createElement(StickyPricing, { collapsed: pricingCollapsed, pricing: pricing, totalCheckoutItemsKept: checkoutItemsKept?.length || 0, onLayout: Platform.OS !== "web" ? handleOnPricingLayout : undefined, onPress: handleOnPressPricing, onSubmit: handleOnSubmit }))));
53
55
  };
54
56
  export { Summary };
@@ -1,11 +1,13 @@
1
1
  import { FC } from "react";
2
2
  import { PricingProjection } from "../../../../../../projection/pricing/pricing";
3
+ import { Layout } from "../../../../../../shared/ui/components/layouts/sticky/Sticky";
3
4
  interface StickyPricingProps {
4
5
  readonly pricing: PricingProjection;
5
6
  readonly totalCheckoutItemsKept: number;
6
7
  readonly collapsed: boolean;
7
8
  readonly onPress: () => void;
8
9
  readonly onSubmit: () => void;
10
+ readonly onLayout?: ({ width, height }: Layout) => void;
9
11
  }
10
12
  declare const StickyPricing: FC<StickyPricingProps>;
11
13
  export { StickyPricing };
@@ -3,7 +3,7 @@ import { Sticky } from "../../../../../../shared/ui/components/layouts/sticky/St
3
3
  import { Body } from "../../../../components/layouts/body/Body";
4
4
  import { Pricing } from "../pricing/Pricing";
5
5
  import { style } from "./StickyPricing.style";
6
- const StickyPricing = ({ pricing, totalCheckoutItemsKept, collapsed, onPress, onSubmit }) => (React.createElement(Sticky, null,
6
+ const StickyPricing = ({ pricing, totalCheckoutItemsKept, collapsed, onPress, onSubmit, onLayout, }) => (React.createElement(Sticky, { onLayout: onLayout },
7
7
  React.createElement(Body, { style: { column: style.container } },
8
8
  React.createElement(Pricing, { balanceDiscount: pricing.balanceDiscount, collapsed: collapsed, discount: pricing.discount, discountPercentage: pricing.discountPercentage, orderTotal: pricing.orderTotal, service: pricing.service, subtotal: pricing.subtotal, totalCheckoutItemsKept: totalCheckoutItemsKept, onPress: onPress, onSubmit: onSubmit }))));
9
9
  export { StickyPricing };
@@ -0,0 +1,10 @@
1
+ import { SizeProjection } from "../shared/size";
2
+ interface ProductVariantProjection {
3
+ readonly id: string;
4
+ readonly size: SizeProjection;
5
+ }
6
+ interface BookedSizeChangeProductsVariantsProjection {
7
+ readonly bookingId: string;
8
+ readonly productVariants: ProductVariantProjection[];
9
+ }
10
+ export type { BookedSizeChangeProductsVariantsProjection, ProductVariantProjection };
@@ -0,0 +1,25 @@
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, };
@@ -0,0 +1,8 @@
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,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.3",
3
+ "version": "0.4.5-beta.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [