@lookiero/checkout 0.4.3 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) 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/checkoutFeedback/model/httpCheckoutFeedbacks.js +2 -11
  16. package/dist/infrastructure/domain/checkoutFeedback/model/httpCheckoutFeedbacksGive.js +2 -2
  17. package/dist/infrastructure/domain/checkoutFeedback/react/useGiveCheckoutFeedback.js +1 -1
  18. package/dist/infrastructure/projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId.js +7 -1
  19. package/dist/infrastructure/projection/payment/react/useViewPaymentFlowPayloadByCheckoutId.js +1 -1
  20. package/dist/infrastructure/ui/hooks/useSubmitCheckout.d.ts +23 -0
  21. package/dist/infrastructure/ui/hooks/useSubmitCheckout.js +68 -0
  22. package/dist/infrastructure/ui/i18n/i18n.d.ts +2 -2
  23. package/dist/infrastructure/ui/i18n/i18n.js +2 -2
  24. package/dist/infrastructure/ui/routing/CheckoutMiddleware.js +11 -3
  25. package/dist/infrastructure/ui/routing/Routing.js +9 -1
  26. package/dist/infrastructure/ui/routing/routes.d.ts +1 -0
  27. package/dist/infrastructure/ui/routing/routes.js +1 -0
  28. package/dist/infrastructure/ui/views/checkout/Checkout.d.ts +2 -2
  29. package/dist/infrastructure/ui/views/checkout/Checkout.js +10 -57
  30. package/dist/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.d.ts +7 -0
  31. package/dist/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.js +45 -0
  32. package/dist/infrastructure/ui/views/item/Item.js +2 -2
  33. package/dist/infrastructure/ui/views/item/components/banner/CustomerDecissionBanner.d.ts +1 -1
  34. package/dist/projection/checkoutBooking/checkoutBooking.d.ts +1 -2
  35. package/package.json +1 -1
  36. package/dist/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackByCheckoutIdView.d.ts +0 -12
  37. package/dist/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackByCheckoutIdView.js +0 -9
  38. package/dist/projection/checkoutFeedback/viewCheckoutFeedbackByCheckoutId.d.ts +0 -25
  39. package/dist/projection/checkoutFeedback/viewCheckoutFeedbackByCheckoutId.js +0 -8
@@ -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
  };
@@ -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];
@@ -1,5 +1,7 @@
1
1
  import { useQuery } from "@lookiero/messaging-react";
2
2
  import { CHECKOUT_PAID } from "../../../../domain/checkout/model/checkoutPaid";
3
+ import { CHECKOUT_BOOKING_BOOKED, } from "../../../../domain/checkoutBooking/model/checkoutBookingBooked";
4
+ import { CHECKOUT_BOOKING_EXPIRED, } from "../../../../domain/checkoutBooking/model/checkoutBookingExpired";
3
5
  import { CHECKOUT_FEEDBACK_GIVEN, } from "../../../../domain/checkoutFeedback/model/checkoutFeedbackGiven";
4
6
  import { CHECKOUT_ITEM_KEPT } from "../../../../domain/checkoutItem/model/checkoutItemKept";
5
7
  import { CHECKOUT_ITEM_REPLACED, } from "../../../../domain/checkoutItem/model/checkoutItemReplaced";
@@ -11,11 +13,15 @@ const isCheckoutItemReturned = (event) => event.name === CHECKOUT_ITEM_RETURNED;
11
13
  const isCheckoutItemReplaced = (event) => event.name === CHECKOUT_ITEM_REPLACED;
12
14
  const isCheckoutPaid = (event) => event.name === CHECKOUT_PAID;
13
15
  const isCheckoutFeedbackGiven = (event) => event.name === CHECKOUT_FEEDBACK_GIVEN;
16
+ const isCheckoutBookingExpired = (event) => event.name === CHECKOUT_BOOKING_EXPIRED;
17
+ const isCheckoutBookingBooked = (event) => event.name === CHECKOUT_BOOKING_BOOKED;
14
18
  const shouldInvalidate = (event) => isCheckoutItemKept(event) ||
15
19
  isCheckoutItemReplaced(event) ||
16
20
  isCheckoutItemReturned(event) ||
17
21
  isCheckoutPaid(event) ||
18
- isCheckoutFeedbackGiven(event);
22
+ isCheckoutFeedbackGiven(event) ||
23
+ isCheckoutBookingExpired(event) ||
24
+ isCheckoutBookingBooked(event);
19
25
  const useViewFirstAvailableCheckoutByCustomerId = ({ customerId }) => useQuery({
20
26
  query: viewFirstAvailableCheckoutByCustomerId({ customerId }),
21
27
  contextId: MESSAGING_CONTEXT_ID,
@@ -12,6 +12,6 @@ const useViewPaymentFlowPayloadByCheckoutId = ({ checkoutId }) => useQuery({
12
12
  query: viewPaymentFlowPayloadByCheckoutId({ checkoutId: checkoutId }),
13
13
  contextId: MESSAGING_CONTEXT_ID,
14
14
  invalidation: shouldInvalidate,
15
- options: { staleTime: Infinity, retry: false, refetchOnWindowFocus: false, enabled: Boolean(checkoutId) },
15
+ options: { enabled: Boolean(checkoutId) },
16
16
  });
17
17
  export { useViewPaymentFlowPayloadByCheckoutId };
@@ -0,0 +1,23 @@
1
+ import { PaymentFlowRef } from "@lookiero/payments-front";
2
+ import { RefObject } from "react";
3
+ import { PaymentFlowPayloadProjection } from "../../../projection/payment/paymentFlowPayload";
4
+ type Status = "idle" | "loading" | "success" | "error";
5
+ interface SubmitCheckoutFunctionArgs {
6
+ readonly paymentFlowPayload: PaymentFlowPayloadProjection;
7
+ }
8
+ interface SubmitCheckoutFunction {
9
+ (args: SubmitCheckoutFunctionArgs): Promise<void>;
10
+ }
11
+ type UseSubmitCheckoutResult = [submitCheckout: SubmitCheckoutFunction, status: Status];
12
+ interface UseSubmitCheckoutFunctionArgs {
13
+ readonly checkoutId: string;
14
+ readonly checkoutBookingId: string;
15
+ readonly paymentFlowRef: RefObject<PaymentFlowRef>;
16
+ readonly onError: () => void;
17
+ }
18
+ interface UseSubmitCheckoutFunction {
19
+ (args: UseSubmitCheckoutFunctionArgs): UseSubmitCheckoutResult;
20
+ }
21
+ declare const useSubmitCheckout: UseSubmitCheckoutFunction;
22
+ export type { Status };
23
+ export { useSubmitCheckout };
@@ -0,0 +1,68 @@
1
+ import { CommandStatus } from "@lookiero/messaging-react";
2
+ import { ChargeStatus } from "@lookiero/payments-front/build/infrastructure/CheckoutAPI";
3
+ import { useCallback, useMemo, useState } from "react";
4
+ import { useCreateNotification } from "../../../shared/notifications";
5
+ import { NotificationLevel } from "../../../shared/notifications/domain/notification/model/notification";
6
+ import { useMarkCheckoutAsPaid } from "../../domain/checkout/react/useMarkCheckoutAsPaid";
7
+ import { useBlockCheckoutBooking } from "../../domain/checkoutBooking/react/useBlockCheckoutBooking";
8
+ import { I18nMessages } from "../i18n/i18n";
9
+ const useSubmitCheckout = ({ checkoutId, checkoutBookingId, paymentFlowRef, onError }) => {
10
+ const [markAsPaid, markAsPaidStatus] = useMarkCheckoutAsPaid({ checkoutId });
11
+ const [blockCheckoutBooking, blockCheckoutBookingStatus] = useBlockCheckoutBooking({ checkoutBookingId });
12
+ const [createNotification] = useCreateNotification();
13
+ const [startLegacyBoxCheckoutStatus, setStartLegacyBoxCheckoutStatus] = useState("idle");
14
+ const submitCheckout = useCallback(async ({ paymentFlowPayload }) => {
15
+ try {
16
+ await blockCheckoutBooking();
17
+ }
18
+ catch (error) { }
19
+ paymentFlowRef.current?.startLegacyBoxCheckout(
20
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
21
+ // @ts-ignore
22
+ paymentFlowPayload, async ({ status }) => {
23
+ setStartLegacyBoxCheckoutStatus("loading");
24
+ if (status === ChargeStatus.REJECTED) {
25
+ createNotification({
26
+ level: NotificationLevel.ERROR,
27
+ bodyI18nKey: I18nMessages.CHECKOUT_TOAST_PAYMENT_REJECTED,
28
+ });
29
+ setStartLegacyBoxCheckoutStatus("error");
30
+ }
31
+ else if (status === ChargeStatus.ERROR) {
32
+ createNotification({
33
+ level: NotificationLevel.ERROR,
34
+ bodyI18nKey: I18nMessages.CHECKOUT_TOAST_PAYMENT_ERROR,
35
+ });
36
+ setStartLegacyBoxCheckoutStatus("error");
37
+ }
38
+ else if (status === ChargeStatus.EXECUTED) {
39
+ setStartLegacyBoxCheckoutStatus("success");
40
+ try {
41
+ await markAsPaid();
42
+ }
43
+ catch (error) { }
44
+ }
45
+ });
46
+ }, [blockCheckoutBooking, createNotification, markAsPaid, paymentFlowRef]);
47
+ const status = useMemo(() => {
48
+ if (blockCheckoutBookingStatus === CommandStatus.LOADING ||
49
+ startLegacyBoxCheckoutStatus === "loading" ||
50
+ markAsPaidStatus === CommandStatus.LOADING) {
51
+ return "loading";
52
+ }
53
+ if (blockCheckoutBookingStatus === CommandStatus.SUCCESS &&
54
+ startLegacyBoxCheckoutStatus === "success" &&
55
+ markAsPaidStatus === CommandStatus.SUCCESS) {
56
+ return "success";
57
+ }
58
+ if (blockCheckoutBookingStatus === CommandStatus.ERROR ||
59
+ startLegacyBoxCheckoutStatus === "error" ||
60
+ markAsPaidStatus === CommandStatus.ERROR) {
61
+ onError();
62
+ return "error";
63
+ }
64
+ return "idle";
65
+ }, [blockCheckoutBookingStatus, markAsPaidStatus, onError, startLegacyBoxCheckoutStatus]);
66
+ return [submitCheckout, status];
67
+ };
68
+ export { useSubmitCheckout };
@@ -49,8 +49,8 @@ declare enum I18nMessages {
49
49
  PRODUCT_VARIANT_SIZE_CHANGE = "product_variant.size_change",
50
50
  CHECKOUT_TITLE = "checkout.title",
51
51
  CHECKOUT_PAY_BUTTON = "checkout.pay_button",
52
- CHECKOUT_TOAST_REJECTED = "checkout.toast_rejected",
53
- CHECKOUT_TOAST_ERROR = "checkout.toast_error",
52
+ CHECKOUT_TOAST_PAYMENT_REJECTED = "checkout.toast_payment_rejected",
53
+ CHECKOUT_TOAST_PAYMENT_ERROR = "checkout.toast_payment_error",
54
54
  CHECKOUT_SUCCESS_MODAL_TITLE = "checkout.success_modal_title",
55
55
  CHECKOUT_SUCCESS_MODAL_DESCRIPTION = "checkout.success_modal_description",
56
56
  CHECKOUT_SUCCESS_MODAL_BUTTON = "checkout.success_modal_button",
@@ -50,8 +50,8 @@ var I18nMessages;
50
50
  I18nMessages["PRODUCT_VARIANT_SIZE_CHANGE"] = "product_variant.size_change";
51
51
  I18nMessages["CHECKOUT_TITLE"] = "checkout.title";
52
52
  I18nMessages["CHECKOUT_PAY_BUTTON"] = "checkout.pay_button";
53
- I18nMessages["CHECKOUT_TOAST_REJECTED"] = "checkout.toast_rejected";
54
- I18nMessages["CHECKOUT_TOAST_ERROR"] = "checkout.toast_error";
53
+ I18nMessages["CHECKOUT_TOAST_PAYMENT_REJECTED"] = "checkout.toast_payment_rejected";
54
+ I18nMessages["CHECKOUT_TOAST_PAYMENT_ERROR"] = "checkout.toast_payment_error";
55
55
  I18nMessages["CHECKOUT_SUCCESS_MODAL_TITLE"] = "checkout.success_modal_title";
56
56
  I18nMessages["CHECKOUT_SUCCESS_MODAL_DESCRIPTION"] = "checkout.success_modal_description";
57
57
  I18nMessages["CHECKOUT_SUCCESS_MODAL_BUTTON"] = "checkout.success_modal_button";
@@ -14,21 +14,29 @@ const CheckoutMiddleware = ({ customerId, loader = React.createElement(Spinner,
14
14
  const [shouldIntroBeShown, shouldIntroBeShownStatus] = useShouldIntroBeShown();
15
15
  const navigatedToFirstItemWithoutCustomerDecision = useRef(false);
16
16
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
17
- const firstItemWithoutCustomerDecision = checkout?.items.find((item) => [CheckoutItemStatus.EXPIRED, CheckoutItemStatus.INITIAL].includes(item.status));
17
+ const firstItemWithoutCustomerDecision = checkout?.items.find((item) => item.status === CheckoutItemStatus.INITIAL);
18
18
  const introRouteMatch = useMatch(`${basePath}/${Routes.INTRO}`);
19
19
  const itemRouteMatch = useMatch(`${basePath}/${Routes.ITEM}`);
20
20
  const itemDetailRouteMatch = useMatch(`${basePath}/${Routes.ITEM_DETAIL}`);
21
21
  const summaryRouteMatch = useMatch(`${basePath}/${Routes.SUMMARY}`);
22
22
  const checkoutRouteMatch = useMatch(`${basePath}/${Routes.CHECKOUT}`);
23
23
  const feedbackRouteMatch = useMatch(`${basePath}/${Routes.FEEDBACK}`);
24
+ const checkoutPaymentRouteMatch = useMatch(`${basePath}/${Routes.CHECKOUT}/${Routes.CHECKOUT_PAYMENT}`);
25
+ const checkoutShown = useRef(false);
26
+ checkoutShown.current = checkoutShown.current || (Boolean(checkoutRouteMatch) && !Boolean(checkoutPaymentRouteMatch));
24
27
  const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
25
28
  const dependenciesLoaded = dependenciesLoadedStatuses.includes(shouldIntroBeShownStatus) &&
26
29
  (dependenciesLoadedStatuses.includes(checkoutStatus) || checkout);
27
30
  if (!dependenciesLoaded) {
28
31
  return loader;
29
32
  }
33
+ /* Prevent direct payment access */
34
+ if (checkoutPaymentRouteMatch && !checkoutShown.current) {
35
+ return React.createElement(Navigate, { to: `${basePath}/${Routes.HOME}`, replace: true });
36
+ }
30
37
  /* Navigate to the feedback if checkout is paid */
31
- if (checkout?.status === CheckoutStatus.PAID && !(feedbackRouteMatch || checkoutRouteMatch)) {
38
+ if (checkout?.status === CheckoutStatus.PAID &&
39
+ !(feedbackRouteMatch || checkoutRouteMatch || checkoutPaymentRouteMatch)) {
32
40
  return React.createElement(Navigate, { to: `${basePath}/${Routes.FEEDBACK}`, replace: true });
33
41
  }
34
42
  /* Navigate to the summary if required */
@@ -36,7 +44,7 @@ const CheckoutMiddleware = ({ customerId, loader = React.createElement(Spinner,
36
44
  checkout?.status === CheckoutStatus.STARTED ||
37
45
  checkout?.status === CheckoutStatus.NOTIFIED) &&
38
46
  firstItemWithoutCustomerDecision === undefined &&
39
- !(summaryRouteMatch || itemDetailRouteMatch || checkoutRouteMatch)) {
47
+ !(summaryRouteMatch || itemDetailRouteMatch || checkoutRouteMatch || checkoutPaymentRouteMatch)) {
40
48
  return React.createElement(Navigate, { to: `${basePath}/${Routes.SUMMARY}`, replace: true });
41
49
  }
42
50
  /* Navigate to the Intro if required */
@@ -2,6 +2,7 @@ import React, { lazy, Suspense } from "react";
2
2
  import { Navigate, Outlet, useRoutes } from "react-router-native";
3
3
  import { Spinner } from "../../../shared/ui/components/atoms/spinner/Spinner";
4
4
  import { App } from "../views/App";
5
+ import { CheckoutPaymentModal } from "../views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal";
5
6
  import { CheckoutAccessibilityMiddleware } from "./CheckoutAccessibilityMiddleware";
6
7
  import { CheckoutMiddleware } from "./CheckoutMiddleware";
7
8
  import { Routes } from "./routes";
@@ -45,7 +46,14 @@ const Routing = ({ basePath = "", customerId, locale, I18n, getAuthToken, menu,
45
46
  {
46
47
  path: Routes.CHECKOUT,
47
48
  element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
48
- React.createElement(Checkout, { customerId: customerId, getAuthToken: getAuthToken, useRedirect: useRedirect }))),
49
+ React.createElement(Checkout, { customerId: customerId, useRedirect: useRedirect },
50
+ React.createElement(Outlet, null)))),
51
+ children: [
52
+ {
53
+ path: Routes.CHECKOUT_PAYMENT,
54
+ element: React.createElement(CheckoutPaymentModal, { customerId: customerId, getAuthToken: getAuthToken }),
55
+ },
56
+ ],
49
57
  },
50
58
  {
51
59
  path: Routes.FEEDBACK,
@@ -5,6 +5,7 @@ export declare enum Routes {
5
5
  ITEM = "item/:id",
6
6
  SUMMARY = "summary",
7
7
  CHECKOUT = "checkout",
8
+ CHECKOUT_PAYMENT = "payment",
8
9
  FEEDBACK = "feedback",
9
10
  NOT_FOUND = "not-found"
10
11
  }
@@ -6,6 +6,7 @@ export var Routes;
6
6
  Routes["ITEM"] = "item/:id";
7
7
  Routes["SUMMARY"] = "summary";
8
8
  Routes["CHECKOUT"] = "checkout";
9
+ Routes["CHECKOUT_PAYMENT"] = "payment";
9
10
  Routes["FEEDBACK"] = "feedback";
10
11
  Routes["NOT_FOUND"] = "not-found";
11
12
  })(Routes || (Routes = {}));
@@ -1,7 +1,7 @@
1
- import { FC } from "react";
1
+ import { FC, ReactNode } from "react";
2
2
  interface CheckoutProps {
3
+ readonly children?: ReactNode;
3
4
  readonly customerId: string;
4
- readonly getAuthToken: () => Promise<string>;
5
5
  readonly useRedirect: () => Record<string, string>;
6
6
  }
7
7
  declare const Checkout: FC<CheckoutProps>;
@@ -1,18 +1,13 @@
1
1
  import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
2
2
  import { useI18nMessage } from "@lookiero/i18n-react";
3
- import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
4
- import { PaymentFlow, PaymentInstrumentSelect, PaymentMethod, Section } from "@lookiero/payments-front";
5
- import { ChargeStatus } from "@lookiero/payments-front/build/infrastructure/CheckoutAPI";
6
- import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
3
+ import { QueryStatus } from "@lookiero/messaging-react";
4
+ import { PaymentInstrumentSelect, PaymentMethod, Section } from "@lookiero/payments-front";
5
+ import React, { useCallback, useMemo, useRef } from "react";
7
6
  import { View } from "react-native";
8
7
  import { useNavigate } from "react-router-native";
9
8
  import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
10
- import { useCreateNotification } from "../../../../shared/notifications";
11
- import { NotificationLevel } from "../../../../shared/notifications/domain/notification/model/notification";
12
9
  import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
13
- import { useMarkCheckoutAsPaid } from "../../../domain/checkout/react/useMarkCheckoutAsPaid";
14
10
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
15
- import { useViewPaymentFlowPayloadByCheckoutId } from "../../../projection/payment/react/useViewPaymentFlowPayloadByCheckoutId";
16
11
  import { useViewPricingByCheckoutId } from "../../../projection/pricing/react/useViewPricingByCheckoutId";
17
12
  import { Body } from "../../components/layouts/body/Body";
18
13
  import { SafeAreaScrollView } from "../../components/templates/SafeAreaScrollView";
@@ -23,60 +18,17 @@ import { HEADER_HEIGHT } from "../header/Header.style";
23
18
  import { ProductVariant } from "../item/components/productVariant/ProductVariant";
24
19
  import { Pricing } from "../summary/components/pricing/Pricing";
25
20
  import { style } from "./Checkout.style";
26
- import { CheckoutSuccessModal } from "./components/checkoutSuccessModal/CheckoutSuccessModal";
27
21
  import { DeliveryBanner } from "./components/deliveryBanner/DeliveryBanner";
28
- const Checkout = ({ customerId, getAuthToken, useRedirect }) => {
22
+ const Checkout = ({ children, customerId, useRedirect }) => {
29
23
  const titleText = useI18nMessage({ id: I18nMessages.CHECKOUT_TITLE });
30
24
  const paymentInstrumentSelectRef = useRef(null);
31
- const paymentFlowRef = useRef(null);
32
- const [authToken, setAuthToken] = useState();
33
- useEffect(() => {
34
- const loadAuthToken = async () => setAuthToken(await getAuthToken());
35
- loadAuthToken();
36
- }, [getAuthToken]);
37
25
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
38
26
  const [pricing, pricingStatus] = useViewPricingByCheckoutId({ checkoutId: checkout?.id });
39
- const [paymentFlowPayload] = useViewPaymentFlowPayloadByCheckoutId({
40
- checkoutId: checkout?.id,
41
- });
42
- const [markAsPaid, markAsPaidStatus] = useMarkCheckoutAsPaid({ checkoutId: checkout?.id });
43
- const [createNotification] = useCreateNotification();
44
- const [success, setSuccess] = useState(false);
45
- const [processingCheckout, setProcessingCheckout] = useState(false);
46
27
  const navigate = useNavigate();
47
28
  const basePath = useBasePath();
48
29
  const { returnUrl } = useRedirect();
49
- const handleOnSubmitCheckout = useCallback(() => {
50
- if (!paymentFlowRef.current) {
51
- return;
52
- }
53
- setProcessingCheckout(true);
54
- setSuccess(false);
55
- paymentFlowRef.current.startLegacyBoxCheckout(
56
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
57
- // @ts-ignore
58
- paymentFlowPayload, async ({ status, final }) => {
59
- if (status === ChargeStatus.REJECTED) {
60
- createNotification({ level: NotificationLevel.ERROR, bodyI18nKey: I18nMessages.CHECKOUT_TOAST_REJECTED });
61
- }
62
- else if (status === ChargeStatus.ERROR) {
63
- createNotification({ level: NotificationLevel.ERROR, bodyI18nKey: I18nMessages.CHECKOUT_TOAST_ERROR });
64
- }
65
- else if (status === ChargeStatus.EXECUTED) {
66
- try {
67
- await markAsPaid();
68
- setSuccess(true);
69
- }
70
- catch (e) { }
71
- }
72
- if (final) {
73
- setProcessingCheckout(false);
74
- }
75
- });
76
- }, [createNotification, markAsPaid, paymentFlowPayload]);
77
- const handleOnSuccessModalDismiss = useCallback(() => {
78
- setSuccess(false);
79
- navigate(`${basePath}/${Routes.FEEDBACK}`);
30
+ const handleOnSubmit = useCallback(() => {
31
+ navigate(`${basePath}/${Routes.CHECKOUT}/${Routes.CHECKOUT_PAYMENT}`);
80
32
  }, [basePath, navigate]);
81
33
  const checkoutItemsKept = useMemo(() => checkout?.items.filter((checkoutItem) => checkoutItem.status === CheckoutItemStatus.KEPT || checkoutItem.status === CheckoutItemStatus.REPLACED), [checkout?.items]);
82
34
  const hasReplacedCheckoutItem = useMemo(() => checkout?.items.some((checkoutItem) => checkoutItem.status === CheckoutItemStatus.REPLACED), [checkout?.items]);
@@ -86,7 +38,6 @@ const Checkout = ({ customerId, getAuthToken, useRedirect }) => {
86
38
  if (!dependenciesLoaded)
87
39
  return React.createElement(Spinner, null);
88
40
  return (React.createElement(React.Fragment, null,
89
- React.createElement(CheckoutSuccessModal, { visible: success, onDismiss: handleOnSuccessModalDismiss }),
90
41
  React.createElement(SafeAreaScrollView, { scrollerPaddingTop: HEADER_HEIGHT },
91
42
  React.createElement(Body, { style: { column: style.bodyColumn } },
92
43
  hasReplacedCheckoutItem && (React.createElement(View, { style: style.deliveryBannerContainer },
@@ -96,7 +47,9 @@ const Checkout = ({ customerId, getAuthToken, useRedirect }) => {
96
47
  checkoutItemsKept?.map((checkoutItem) => (React.createElement(View, { key: checkoutItem.id, style: style.checkoutItemKept, testID: "checkout-items-kept" },
97
48
  React.createElement(ProductVariant, { brand: checkoutItem.productVariant.brand, color: checkoutItem.productVariant.color, media: checkoutItem.productVariant.media, name: checkoutItem.productVariant.name, price: checkoutItem.price, size: checkoutItem.productVariant.size, status: checkoutItem.status })))),
98
49
  pricing && (React.createElement(View, { style: style.pricingContainer },
99
- React.createElement(Pricing, { balanceDiscount: pricing.balanceDiscount, busy: processingCheckout || markAsPaidStatus === CommandStatus.LOADING, collapsible: false, discount: pricing.discount, discountPercentage: pricing.discountPercentage, orderTotal: pricing.orderTotal, service: pricing.service, subtotal: pricing.subtotal, totalCheckoutItemsKept: checkoutItemsKept?.length || 0, onSubmit: handleOnSubmitCheckout }))))),
100
- authToken && React.createElement(PaymentFlow, { ref: paymentFlowRef, token: authToken })));
50
+ React.createElement(Pricing, { balanceDiscount: pricing.balanceDiscount,
51
+ // busy={submitCheckoutStatus === "loading"}
52
+ collapsible: false, discount: pricing.discount, discountPercentage: pricing.discountPercentage, orderTotal: pricing.orderTotal, service: pricing.service, subtotal: pricing.subtotal, totalCheckoutItemsKept: checkoutItemsKept?.length || 0, onSubmit: handleOnSubmit }))))),
53
+ children));
101
54
  };
102
55
  export { Checkout };
@@ -0,0 +1,7 @@
1
+ import { FC } from "react";
2
+ interface CheckoutPaymentModalProps {
3
+ readonly customerId: string;
4
+ readonly getAuthToken: () => Promise<string>;
5
+ }
6
+ declare const CheckoutPaymentModal: FC<CheckoutPaymentModalProps>;
7
+ export { CheckoutPaymentModal };
@@ -0,0 +1,45 @@
1
+ import { QueryStatus } from "@lookiero/messaging-react";
2
+ import { PaymentFlow } from "@lookiero/payments-front";
3
+ import React, { useCallback, useEffect, useRef, useState } from "react";
4
+ import { useNavigate } from "react-router-native";
5
+ import { useViewFirstAvailableCheckoutByCustomerId } from "../../../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
6
+ import { useViewPaymentFlowPayloadByCheckoutId } from "../../../../../projection/payment/react/useViewPaymentFlowPayloadByCheckoutId";
7
+ import { useSubmitCheckout } from "../../../../hooks/useSubmitCheckout";
8
+ import { Routes } from "../../../../routing/routes";
9
+ import { useBasePath } from "../../../../routing/useBasePath";
10
+ import { CheckoutSuccessModal } from "../checkoutSuccessModal/CheckoutSuccessModal";
11
+ const CheckoutPaymentModal = ({ customerId, getAuthToken }) => {
12
+ const paymentFlowRef = useRef(null);
13
+ const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
14
+ const [paymentFlowPayload] = useViewPaymentFlowPayloadByCheckoutId({
15
+ checkoutId: checkout?.id,
16
+ });
17
+ const [authToken, setAuthToken] = useState();
18
+ useEffect(() => {
19
+ const loadAuthToken = async () => setAuthToken(await getAuthToken());
20
+ loadAuthToken();
21
+ }, [getAuthToken]);
22
+ const basePath = useBasePath();
23
+ const navigate = useNavigate();
24
+ const handleOnSuccessModalDismiss = useCallback(() => navigate(`${basePath}/${Routes.FEEDBACK}`), [basePath, navigate]);
25
+ const handleOnErrorSubmitCheckout = useCallback(() => navigate(`${basePath}/${Routes.CHECKOUT}`), [basePath, navigate]);
26
+ const [submitCheckout, submitCheckoutStatus] = useSubmitCheckout({
27
+ checkoutId: checkout?.id,
28
+ checkoutBookingId: checkout?.checkoutBookingId,
29
+ paymentFlowRef,
30
+ onError: handleOnErrorSubmitCheckout,
31
+ });
32
+ useEffect(() => {
33
+ if (paymentFlowPayload) {
34
+ submitCheckout({ paymentFlowPayload });
35
+ }
36
+ }, [paymentFlowPayload, submitCheckout]);
37
+ const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
38
+ const dependenciesLoaded = dependenciesLoadedStatuses.includes(checkoutStatus) || checkout;
39
+ if (!dependenciesLoaded)
40
+ return null;
41
+ return (React.createElement(React.Fragment, null,
42
+ React.createElement(CheckoutSuccessModal, { visible: submitCheckoutStatus === "success", onDismiss: handleOnSuccessModalDismiss }),
43
+ authToken && React.createElement(PaymentFlow, { ref: paymentFlowRef, token: authToken })));
44
+ };
45
+ export { CheckoutPaymentModal };
@@ -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 });
@@ -1,6 +1,6 @@
1
1
  import { FC } from "react";
2
2
  import { CheckoutItemStatus } from "../../../../../../domain/checkoutItem/model/checkoutItem";
3
- type CustomerDecissionBannerStatus = Exclude<CheckoutItemStatus, CheckoutItemStatus.INITIAL | CheckoutItemStatus.EXPIRED>;
3
+ type CustomerDecissionBannerStatus = Exclude<CheckoutItemStatus, CheckoutItemStatus.INITIAL>;
4
4
  interface CustomerDecissionBannerProps {
5
5
  readonly checkoutItemStatus: CustomerDecissionBannerStatus;
6
6
  readonly onPress: () => void;
@@ -1,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.4",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -1,12 +0,0 @@
1
- import { CheckoutFeedbackByCheckoutIdView } from "../../../projection/checkoutFeedback/viewCheckoutFeedbackByCheckoutId";
2
- import { HttpPostFunction } from "../../delivery/http/httpClient";
3
- interface HttpCheckoutFeebackByCheckoutIdView extends CheckoutFeedbackByCheckoutIdView {
4
- }
5
- interface HttpCheckoutFeebackByCheckoutIdViewFunctionArgs {
6
- readonly httpPost: HttpPostFunction;
7
- }
8
- interface HttpCheckoutFeebackByCheckoutIdViewFunction {
9
- (args: HttpCheckoutFeebackByCheckoutIdViewFunctionArgs): HttpCheckoutFeebackByCheckoutIdView;
10
- }
11
- declare const httpCheckoutFeebackByCheckoutIdView: HttpCheckoutFeebackByCheckoutIdViewFunction;
12
- export { httpCheckoutFeebackByCheckoutIdView };
@@ -1,9 +0,0 @@
1
- const httpCheckoutFeebackByCheckoutIdView = ({ httpPost }) => async ({ checkoutId, signal }) => {
2
- const response = await httpPost({
3
- endpoint: "/view-checkout-feedback-by-checkout-id",
4
- body: { checkoutId },
5
- signal,
6
- });
7
- return !response.ok || response.status === 404 ? null : (await response.json()).result;
8
- };
9
- export { httpCheckoutFeebackByCheckoutIdView };
@@ -1,25 +0,0 @@
1
- import { CancelableQueryViewArgs, Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
2
- import { CheckoutFeedbackProjection } from "./checkoutFeedback";
3
- declare const VIEW_CHECKOUT_FEEDBACK_BY_CHECKOUT_ID = "view_checkout_feedback_by_checkout_id";
4
- interface ViewCheckoutFeedbackByCheckoutIdPayload {
5
- readonly checkoutId: string;
6
- }
7
- interface ViewCheckoutFeedbackByCheckoutId extends Query<typeof VIEW_CHECKOUT_FEEDBACK_BY_CHECKOUT_ID>, ViewCheckoutFeedbackByCheckoutIdPayload {
8
- }
9
- interface ViewCheckoutFeedbackByCheckoutIdFunction {
10
- (payload: ViewCheckoutFeedbackByCheckoutIdPayload): ViewCheckoutFeedbackByCheckoutId;
11
- }
12
- declare const viewCheckoutFeedbackByCheckoutId: ViewCheckoutFeedbackByCheckoutIdFunction;
13
- type ViewCheckoutFeedbackByCheckoutIdResult = CheckoutFeedbackProjection | null;
14
- interface CheckoutFeedbackByCheckoutIdViewArgs extends CancelableQueryViewArgs {
15
- readonly checkoutId: string;
16
- }
17
- interface CheckoutFeedbackByCheckoutIdView {
18
- (args: CheckoutFeedbackByCheckoutIdViewArgs): Promise<ViewCheckoutFeedbackByCheckoutIdResult>;
19
- }
20
- interface ViewCheckoutFeedbackByCheckoutIdHandlerFunctionArgs extends QueryHandlerFunctionArgs {
21
- readonly view: CheckoutFeedbackByCheckoutIdView;
22
- }
23
- declare const viewCheckoutFeedbackByCheckoutIdHandler: QueryHandlerFunction<ViewCheckoutFeedbackByCheckoutId, ViewCheckoutFeedbackByCheckoutIdResult, ViewCheckoutFeedbackByCheckoutIdHandlerFunctionArgs>;
24
- export type { ViewCheckoutFeedbackByCheckoutId, CheckoutFeedbackByCheckoutIdView, ViewCheckoutFeedbackByCheckoutIdResult, };
25
- export { VIEW_CHECKOUT_FEEDBACK_BY_CHECKOUT_ID, viewCheckoutFeedbackByCheckoutId, viewCheckoutFeedbackByCheckoutIdHandler, };
@@ -1,8 +0,0 @@
1
- import { query, } from "@lookiero/messaging";
2
- const VIEW_CHECKOUT_FEEDBACK_BY_CHECKOUT_ID = "view_checkout_feedback_by_checkout_id";
3
- const viewCheckoutFeedbackByCheckoutId = (payload) => ({
4
- ...query({ name: VIEW_CHECKOUT_FEEDBACK_BY_CHECKOUT_ID }),
5
- ...payload,
6
- });
7
- const viewCheckoutFeedbackByCheckoutIdHandler = ({ view, signal }) => async ({ checkoutId }) => view({ checkoutId, signal });
8
- export { VIEW_CHECKOUT_FEEDBACK_BY_CHECKOUT_ID, viewCheckoutFeedbackByCheckoutId, viewCheckoutFeedbackByCheckoutIdHandler, };