@lookiero/checkout 0.8.3 → 0.8.4-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 (86) hide show
  1. package/dist/domain/checkout/command/markCheckoutAsPaid.d.ts +13 -0
  2. package/dist/domain/checkout/command/markCheckoutAsPaid.js +4 -0
  3. package/dist/domain/checkout/model/checkout.js +1 -0
  4. package/dist/domain/checkout/model/checkoutPaid.d.ts +13 -0
  5. package/dist/domain/checkout/model/checkoutPaid.js +4 -0
  6. package/dist/infrastructure/delivery/http/fetchHttpClient.js +36 -19
  7. package/dist/infrastructure/delivery/http/httpClient.d.ts +9 -3
  8. package/dist/infrastructure/domain/checkout/model/httpCheckoutsMarkAsPaid.d.ts +5 -0
  9. package/dist/infrastructure/domain/checkout/model/httpCheckoutsMarkAsPaid.js +13 -0
  10. package/dist/infrastructure/domain/checkout/react/useMarkCheckoutAsPaid.d.ts +13 -0
  11. package/dist/infrastructure/domain/checkout/react/useMarkCheckoutAsPaid.js +16 -0
  12. package/dist/infrastructure/domain/checkout/react/useStartCheckout.d.ts +1 -1
  13. package/dist/infrastructure/domain/checkout/react/useStartCheckout.js +9 -2
  14. package/dist/infrastructure/domain/checkoutBooking/react/useBookCheckouBookingForCheckoutItem.d.ts +13 -0
  15. package/dist/infrastructure/domain/checkoutBooking/react/useBookCheckouBookingForCheckoutItem.js +14 -0
  16. package/dist/infrastructure/domain/uiSetting/react/useIncrementIntroShownCount.d.ts +10 -0
  17. package/dist/infrastructure/domain/uiSetting/react/useIncrementIntroShownCount.js +11 -0
  18. package/dist/infrastructure/projection/bookedProductsVariants/httpBookedProductsVariantsForCheckoutItemView.js +9 -8
  19. package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/httpBookedSizeChangeProductsVariantsForCheckoutItemView.d.ts +12 -0
  20. package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/httpBookedSizeChangeProductsVariantsForCheckoutItemView.js +9 -0
  21. package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/react/useViewBookedSizeChangeProductsVariantsForCheckoutItem.d.ts +10 -0
  22. package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/react/useViewBookedSizeChangeProductsVariantsForCheckoutItem.js +12 -0
  23. package/dist/infrastructure/projection/checkout/httpCheckoutByIdView.js +9 -8
  24. package/dist/infrastructure/projection/checkout/httpFirstAvailableCheckoutByCustomerIdView.js +9 -8
  25. package/dist/infrastructure/projection/checkout/httpFiveItemsDiscountByCustomerIdView.js +8 -7
  26. package/dist/infrastructure/projection/checkout/httpIsCheckoutEnabledByCustomerIdView.js +8 -7
  27. package/dist/infrastructure/projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId.js +1 -4
  28. package/dist/infrastructure/projection/checkoutBooking/httpCheckoutBookingByIdView.js +9 -8
  29. package/dist/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackByCheckoutIdView.d.ts +12 -0
  30. package/dist/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackByCheckoutIdView.js +9 -0
  31. package/dist/infrastructure/projection/checkoutItem/httpCheckoutItemByIdView.js +9 -8
  32. package/dist/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.js +9 -8
  33. package/dist/infrastructure/projection/payment/httpPaymentFlowPayloadByCheckoutIdView.js +9 -8
  34. package/dist/infrastructure/projection/pricing/httpPricingByCheckoutIdView.js +9 -8
  35. package/dist/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.js +9 -8
  36. package/dist/infrastructure/projection/uiSetting/react/useShouldIntroBeShown.d.ts +6 -0
  37. package/dist/infrastructure/projection/uiSetting/react/useShouldIntroBeShown.js +7 -0
  38. package/dist/infrastructure/projection/uiSetting/react/useViewIntroShownCount.d.ts +6 -0
  39. package/dist/infrastructure/projection/uiSetting/react/useViewIntroShownCount.js +9 -0
  40. package/dist/infrastructure/ui/Root.js +2 -1
  41. package/dist/infrastructure/ui/views/App.style.d.ts +4 -0
  42. package/dist/infrastructure/ui/views/App.style.js +16 -0
  43. package/dist/infrastructure/ui/views/checkout/Checkout.js +5 -3
  44. package/dist/infrastructure/ui/views/header/Header.d.ts +15 -0
  45. package/dist/infrastructure/ui/views/header/Header.js +90 -0
  46. package/dist/infrastructure/ui/views/header/Header.style.d.ts +35 -0
  47. package/dist/infrastructure/ui/views/header/Header.style.js +38 -0
  48. package/dist/infrastructure/ui/views/header/components/Logo.d.ts +7 -0
  49. package/dist/infrastructure/ui/views/header/components/Logo.js +11 -0
  50. package/dist/infrastructure/ui/views/header/components/Logo.style.d.ts +7 -0
  51. package/dist/infrastructure/ui/views/header/components/Logo.style.js +8 -0
  52. package/dist/infrastructure/ui/views/intro/Intro.d.ts +6 -0
  53. package/dist/infrastructure/ui/views/intro/Intro.js +52 -0
  54. package/dist/infrastructure/ui/views/intro/Intro.style.d.ts +55 -0
  55. package/dist/infrastructure/ui/views/intro/Intro.style.js +58 -0
  56. package/dist/projection/bookedSizeChangeProductsVariants/bookedSizeChangeProductsVariants.d.ts +10 -0
  57. package/dist/projection/bookedSizeChangeProductsVariants/bookedSizeChangeProductsVariants.js +1 -0
  58. package/dist/projection/bookedSizeChangeProductsVariants/viewBookedSizeChangeProductVariantsForCheckoutItem.d.ts +25 -0
  59. package/dist/projection/bookedSizeChangeProductsVariants/viewBookedSizeChangeProductVariantsForCheckoutItem.js +8 -0
  60. package/dist/projection/checkoutFeedback/viewCheckoutFeedbackByCheckoutId.d.ts +25 -0
  61. package/dist/projection/checkoutFeedback/viewCheckoutFeedbackByCheckoutId.js +8 -0
  62. package/dist/shared/logging/Logger.d.ts +7 -0
  63. package/dist/shared/logging/Logger.js +1 -0
  64. package/dist/shared/logging/SentryLogger.d.ts +3 -8
  65. package/dist/shared/logging/SentryLogger.js +27 -33
  66. package/dist/shared/logging/SentryLoggerHOC.d.ts +15 -0
  67. package/dist/shared/logging/SentryLoggerHOC.js +22 -0
  68. package/dist/shared/logging/location.d.ts +3 -0
  69. package/dist/shared/logging/location.js +5 -0
  70. package/dist/shared/logging/matchRoutes.d.ts +3 -0
  71. package/dist/shared/logging/matchRoutes.js +7 -0
  72. package/dist/shared/logging/reactRouterV6Instrumentation/reactRouterV6Instrumentation.native.d.ts +29 -0
  73. package/dist/shared/logging/reactRouterV6Instrumentation/reactRouterV6Instrumentation.native.js +134 -0
  74. package/dist/shared/logging/reactRouterV6Instrumentation/transactionContext.d.ts +22 -0
  75. package/dist/shared/logging/reactRouterV6Instrumentation/transactionContext.js +15 -0
  76. package/dist/shared/logging/reactRouterV6Instrumentation.native.d.ts +27 -0
  77. package/dist/shared/logging/reactRouterV6Instrumentation.native.js +115 -0
  78. package/dist/shared/notifications/domain/notification/command/removeNotification.tes.d.ts +1 -0
  79. package/dist/shared/notifications/domain/notification/command/removeNotification.tes.js +9 -0
  80. package/package.json +2 -1
  81. package/dist/infrastructure/ui/hooks/usePaymentInstrumentEvents.d.ts +0 -2
  82. package/dist/infrastructure/ui/hooks/usePaymentInstrumentEvents.js +0 -28
  83. package/dist/infrastructure/ui/hooks/useToast.d.ts +0 -11
  84. package/dist/infrastructure/ui/hooks/useToast.js +0 -44
  85. package/dist/infrastructure/ui/views/checkout/components/paymentInstrument/PaymentInstrument.d.ts +0 -6
  86. package/dist/infrastructure/ui/views/checkout/components/paymentInstrument/PaymentInstrument.js +0 -10
@@ -0,0 +1,13 @@
1
+ import { Command } from "@lookiero/messaging";
2
+ declare const MARK_CHECKOUT_AS_PAID = "mark_checkout_as_paid";
3
+ interface MarkCheckoutAsPaidPayload {
4
+ readonly aggregateId: string;
5
+ }
6
+ interface MarkCheckoutAsPaid extends Command<typeof MARK_CHECKOUT_AS_PAID>, MarkCheckoutAsPaidPayload {
7
+ }
8
+ interface MarkCheckoutAsPaidFunction {
9
+ (payload: MarkCheckoutAsPaidPayload): MarkCheckoutAsPaid;
10
+ }
11
+ declare const markCheckoutAsPaid: MarkCheckoutAsPaidFunction;
12
+ export type { MarkCheckoutAsPaid };
13
+ export { MARK_CHECKOUT_AS_PAID, markCheckoutAsPaid };
@@ -0,0 +1,4 @@
1
+ import { command } from "@lookiero/messaging";
2
+ const MARK_CHECKOUT_AS_PAID = "mark_checkout_as_paid";
3
+ const markCheckoutAsPaid = ({ aggregateId }) => command({ aggregateId, name: MARK_CHECKOUT_AS_PAID });
4
+ export { MARK_CHECKOUT_AS_PAID, markCheckoutAsPaid };
@@ -11,6 +11,7 @@ var CheckoutStatus;
11
11
  })(CheckoutStatus || (CheckoutStatus = {}));
12
12
  const startCheckoutHandler = () => async ({ aggregateRoot, command }) => {
13
13
  const { aggregateId } = command;
14
+ invariant(aggregateRoot.status !== CheckoutStatus.STARTED, "Checkout is already started");
14
15
  invariant(aggregateRoot.status !== CheckoutStatus.SUBMITTED, "Checkout is already submitted");
15
16
  invariant(aggregateRoot.status !== CheckoutStatus.COMPLETED, "Checkout is already completed");
16
17
  return {
@@ -0,0 +1,13 @@
1
+ import { DomainEvent } from "@lookiero/messaging";
2
+ declare const CHECKOUT_PAID = "checkout_paid";
3
+ interface CheckoutPaidPayload {
4
+ readonly aggregateId: string;
5
+ }
6
+ interface CheckoutPaid extends DomainEvent<typeof CHECKOUT_PAID>, CheckoutPaidPayload {
7
+ }
8
+ interface CheckoutPaidFunction {
9
+ (payload: CheckoutPaidPayload): CheckoutPaid;
10
+ }
11
+ declare const checkoutPaid: CheckoutPaidFunction;
12
+ export type { CheckoutPaid };
13
+ export { CHECKOUT_PAID, checkoutPaid };
@@ -0,0 +1,4 @@
1
+ import { domainEvent } from "@lookiero/messaging";
2
+ const CHECKOUT_PAID = "checkout_paid";
3
+ const checkoutPaid = ({ aggregateId }) => domainEvent({ aggregateId, name: CHECKOUT_PAID });
4
+ export { CHECKOUT_PAID, checkoutPaid };
@@ -1,20 +1,37 @@
1
- const fetchHttpPost = ({ apiUrl, getAuthToken }) => async ({ endpoint, body, signal }) => fetch(`${apiUrl}${endpoint}`, {
2
- method: "POST",
3
- headers: {
4
- ["Content-Type"]: "application/json",
5
- authorization: `Bearer ${await getAuthToken()}`,
6
- },
7
- body: JSON.stringify(body),
8
- signal,
9
- });
10
- const fetchHttpGet = ({ apiUrl, getAuthToken }) => async ({ endpoint, signal }) => fetch(`${apiUrl}${endpoint}`, {
11
- method: "GET",
12
- credentials: "include",
13
- headers: {
14
- Authorization: `Bearer ${await getAuthToken()}`,
15
- ["Content-Type"]: "application/json",
16
- },
17
- referrer: "",
18
- signal,
19
- });
1
+ const fetchHttpPost = ({ apiUrl, getAuthToken }) => async ({ endpoint, body, signal, result }) => {
2
+ const response = await fetch(`${apiUrl}${endpoint}`, {
3
+ method: "POST",
4
+ headers: {
5
+ ["Content-Type"]: "application/json",
6
+ authorization: `Bearer ${await getAuthToken()}`,
7
+ },
8
+ body: JSON.stringify(body),
9
+ signal,
10
+ });
11
+ return await processResponse({ response, result });
12
+ };
13
+ const fetchHttpGet = ({ apiUrl, getAuthToken }) => async ({ endpoint, signal, result }) => {
14
+ const response = await fetch(`${apiUrl}${endpoint}`, {
15
+ method: "GET",
16
+ credentials: "include",
17
+ headers: {
18
+ Authorization: `Bearer ${await getAuthToken()}`,
19
+ ["Content-Type"]: "application/json",
20
+ },
21
+ referrer: "",
22
+ signal,
23
+ });
24
+ return await processResponse({ response, result });
25
+ };
26
+ const processResponse = async ({ response, result }) => {
27
+ if (response.ok) {
28
+ const responseText = await response.text();
29
+ const responseResult = responseText ? JSON.parse(responseText) : responseText;
30
+ return result?.success(responseResult) ?? responseResult;
31
+ }
32
+ if (result?.error !== undefined) {
33
+ return result.error;
34
+ }
35
+ throw new Error(response.statusText);
36
+ };
20
37
  export { fetchHttpGet, fetchHttpPost };
@@ -1,16 +1,22 @@
1
+ interface HttpFunctionResult {
2
+ readonly error: any;
3
+ readonly success: (response: any) => any;
4
+ }
1
5
  interface HttpGetFunctionArgs {
2
6
  readonly endpoint: string;
3
7
  readonly signal?: AbortSignal;
8
+ readonly result?: HttpFunctionResult;
4
9
  }
5
10
  interface HttpGetFunction {
6
- (args: HttpGetFunctionArgs): Promise<Response>;
11
+ (args: HttpGetFunctionArgs): Promise<any>;
7
12
  }
8
13
  interface HttpPostFunctionArgs {
9
14
  readonly endpoint: string;
10
15
  readonly body: Record<string, unknown>;
11
16
  readonly signal?: AbortSignal;
17
+ readonly result?: HttpFunctionResult;
12
18
  }
13
19
  interface HttpPostFunction {
14
- (args: HttpPostFunctionArgs): Promise<Response>;
20
+ (args: HttpPostFunctionArgs): Promise<any>;
15
21
  }
16
- export type { HttpGetFunction, HttpPostFunction };
22
+ export type { HttpGetFunction, HttpPostFunction, HttpFunctionResult };
@@ -0,0 +1,5 @@
1
+ import { HttpCheckoutsSaveFunction } from "./httpCheckouts";
2
+ interface HttpCheckoutsMarkAsPaidFunction extends HttpCheckoutsSaveFunction {
3
+ }
4
+ declare const httpCheckoutsMarkAsPaid: HttpCheckoutsMarkAsPaidFunction;
5
+ export { httpCheckoutsMarkAsPaid };
@@ -0,0 +1,13 @@
1
+ import { CHECKOUT_PAID } from "../../../../domain/checkout/model/checkoutPaid";
2
+ const isCheckoutPaid = (event) => event.name === CHECKOUT_PAID;
3
+ const httpCheckoutsMarkAsPaid = ({ httpPost }) => async ({ aggregateId, domainEvents }) => {
4
+ const checkoutPaid = domainEvents.find(isCheckoutPaid);
5
+ if (!checkoutPaid) {
6
+ return;
7
+ }
8
+ await httpPost({
9
+ endpoint: "/mark-checkout-as-paid",
10
+ body: { checkoutId: aggregateId },
11
+ });
12
+ };
13
+ export { httpCheckoutsMarkAsPaid };
@@ -0,0 +1,13 @@
1
+ import { CommandStatus } from "@lookiero/messaging-react";
2
+ interface MarkAsPaidFunction {
3
+ (): Promise<void>;
4
+ }
5
+ type UseMarkCheckoutAsPaid = [markAsPaid: MarkAsPaidFunction, status: CommandStatus];
6
+ interface UseMarkCheckoutAsPaidFunctionArgs {
7
+ readonly checkoutId?: string;
8
+ }
9
+ interface UseMarkCheckoutAsPaidFunction {
10
+ (args: UseMarkCheckoutAsPaidFunctionArgs): UseMarkCheckoutAsPaid;
11
+ }
12
+ declare const useMarkCheckoutAsPaid: UseMarkCheckoutAsPaidFunction;
13
+ export { useMarkCheckoutAsPaid };
@@ -0,0 +1,16 @@
1
+ import { useCommand } from "@lookiero/messaging-react";
2
+ import { useCallback } from "react";
3
+ import invariant from "tiny-invariant";
4
+ import { markCheckoutAsPaid } from "../../../../domain/checkout/command/markCheckoutAsPaid";
5
+ import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
6
+ const useMarkCheckoutAsPaid = ({ checkoutId }) => {
7
+ const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
8
+ const markAsPaid = useCallback(() => {
9
+ invariant(checkoutId, "CheckoutId must be defined in order to mark the checkout as paid");
10
+ return commandBus(markCheckoutAsPaid({
11
+ aggregateId: checkoutId,
12
+ }));
13
+ }, [checkoutId, commandBus]);
14
+ return [markAsPaid, status];
15
+ };
16
+ export { useMarkCheckoutAsPaid };
@@ -1,6 +1,6 @@
1
1
  import { CommandStatus } from "@lookiero/messaging-react";
2
2
  interface StartCheckoutFunction {
3
- (): Promise<void>;
3
+ (): Promise<void> | undefined;
4
4
  }
5
5
  interface UseStartCheckoutArgs {
6
6
  readonly checkoutId?: string;
@@ -5,9 +5,16 @@ import { startCheckout } from "../../../../domain/checkout/command/startCheckout
5
5
  import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
6
6
  const useStartCheckout = ({ checkoutId }) => {
7
7
  const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
8
- const start = useCallback(() => {
8
+ const start = useCallback(async () => {
9
9
  invariant(checkoutId, "CheckoutId must be defined in order to start checkout");
10
- return commandBus(startCheckout({ aggregateId: checkoutId }));
10
+ try {
11
+ return await commandBus(startCheckout({ aggregateId: checkoutId }));
12
+ }
13
+ catch (error) {
14
+ if (!error?.message?.includes("Checkout is already started")) {
15
+ // logger?.captureException(error as Error);
16
+ }
17
+ }
11
18
  }, [checkoutId, commandBus]);
12
19
  return [start, status];
13
20
  };
@@ -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 };
@@ -0,0 +1,10 @@
1
+ import { CommandStatus } from "@lookiero/messaging-react";
2
+ interface IncrementIntroShownCountFunction {
3
+ (): Promise<void>;
4
+ }
5
+ type UseIncrementIntroShownCount = [incrementIntroShownCount: IncrementIntroShownCountFunction, status: CommandStatus];
6
+ interface UseIncrementIntroShownCountFunction {
7
+ (): UseIncrementIntroShownCount;
8
+ }
9
+ declare const useIncrementIntroShownCount: UseIncrementIntroShownCountFunction;
10
+ export { useIncrementIntroShownCount };
@@ -0,0 +1,11 @@
1
+ import { useCallback } from "react";
2
+ import { useViewIntroShownCount } from "../../../projection/uiSetting/react/useViewIntroShownCount";
3
+ import { UISettings } from "../../../ui/settings/UISettings";
4
+ import { useUpdateUiSetting } from "./useUpdateUiSetting";
5
+ const useIncrementIntroShownCount = () => {
6
+ const [update, status] = useUpdateUiSetting();
7
+ const [introShownCount] = useViewIntroShownCount();
8
+ const incrementIntroShownCount = useCallback(() => update({ key: UISettings.INTRO_SHOWN_COUNT, value: introShownCount + 1 }), [introShownCount, update]);
9
+ return [incrementIntroShownCount, status];
10
+ };
11
+ export { useIncrementIntroShownCount };
@@ -1,9 +1,10 @@
1
- const httpBookedProductsVariantsForCheckoutItemView = ({ httpPost }) => async ({ checkoutItemId, signal }) => {
2
- const response = await httpPost({
3
- endpoint: "/view-booked-product-variants-for-checkout-item",
4
- body: { checkoutItemId },
5
- signal,
6
- });
7
- return !response.ok || response.status === 404 ? null : (await response.json()).result;
8
- };
1
+ const httpBookedProductsVariantsForCheckoutItemView = ({ httpPost }) => async ({ checkoutItemId, signal }) => await httpPost({
2
+ endpoint: "/view-booked-product-variants-for-checkout-item",
3
+ body: { checkoutItemId },
4
+ signal,
5
+ result: {
6
+ error: null,
7
+ success: (response) => response.result,
8
+ },
9
+ });
9
10
  export { httpBookedProductsVariantsForCheckoutItemView };
@@ -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,10 +1,11 @@
1
1
  import { toCheckoutProjection } from "./checkout";
2
- const httpCheckoutByIdView = ({ httpPost }) => async ({ checkoutId, signal }) => {
3
- const response = await httpPost({
4
- endpoint: "/view-checkout-by-id",
5
- body: { checkoutId },
6
- signal,
7
- });
8
- return !response.ok || response.status === 404 ? null : toCheckoutProjection((await response.json()).result);
9
- };
2
+ const httpCheckoutByIdView = ({ httpPost }) => async ({ checkoutId, signal }) => await httpPost({
3
+ endpoint: "/view-checkout-by-id",
4
+ body: { checkoutId },
5
+ signal,
6
+ result: {
7
+ error: null,
8
+ success: (response) => toCheckoutProjection(response.result),
9
+ },
10
+ });
10
11
  export { httpCheckoutByIdView };
@@ -1,10 +1,11 @@
1
1
  import { toCheckoutProjection } from "./checkout";
2
- const httpFirstAvailableCheckoutByCustomerIdView = ({ httpPost }) => async ({ customerId, signal }) => {
3
- const response = await httpPost({
4
- endpoint: "/view-first-available-checkout-by-customer-id",
5
- body: { customerId },
6
- signal,
7
- });
8
- return !response.ok || response.status === 404 ? null : toCheckoutProjection((await response.json()).result);
9
- };
2
+ const httpFirstAvailableCheckoutByCustomerIdView = ({ httpPost }) => async ({ customerId, signal }) => await httpPost({
3
+ endpoint: "/view-first-available-checkout-by-customer-id",
4
+ body: { customerId },
5
+ signal,
6
+ result: {
7
+ error: null,
8
+ success: (response) => toCheckoutProjection(response.result),
9
+ },
10
+ });
10
11
  export { httpFirstAvailableCheckoutByCustomerIdView };
@@ -1,8 +1,9 @@
1
- const httpFiveItemsDiscountByCustomerIdView = ({ httpGet }) => async ({ customerId, signal }) => {
2
- const response = await httpGet({
3
- endpoint: `/view-five-items-discount-by-customer-id/${customerId}`,
4
- signal,
5
- });
6
- return !response.ok ? 0 : await response.json();
7
- };
1
+ const httpFiveItemsDiscountByCustomerIdView = ({ httpGet }) => async ({ customerId, signal }) => await httpGet({
2
+ endpoint: `/view-five-items-discount-by-customer-id/${customerId}`,
3
+ signal,
4
+ result: {
5
+ error: 0,
6
+ success: (response) => response,
7
+ },
8
+ });
8
9
  export { httpFiveItemsDiscountByCustomerIdView };
@@ -1,8 +1,9 @@
1
- const httpIsCheckoutEnabledByCustomerIdView = ({ httpGet }) => async ({ customerId, signal }) => {
2
- const response = await httpGet({
3
- endpoint: `/is-new-checkout-enabled/${customerId}`,
4
- signal,
5
- });
6
- return !response.ok ? false : await response.json();
7
- };
1
+ const httpIsCheckoutEnabledByCustomerIdView = ({ httpGet }) => async ({ customerId, signal }) => await httpGet({
2
+ endpoint: `/is-new-checkout-enabled/${customerId}`,
3
+ signal,
4
+ result: {
5
+ error: false,
6
+ success: (response) => response,
7
+ },
8
+ });
8
9
  export { httpIsCheckoutEnabledByCustomerIdView };
@@ -1,7 +1,6 @@
1
1
  import { useQuery } from "@lookiero/messaging-react";
2
2
  import { CHECKOUT_STARTED } from "../../../../domain/checkout/model/checkoutStarted";
3
3
  import { CHECKOUT_SUBMITTED } from "../../../../domain/checkout/model/checkoutSubmitted";
4
- import { CHECKOUT_BOOKING_BOOKED, } from "../../../../domain/checkoutBooking/model/checkoutBookingBooked";
5
4
  import { CHECKOUT_BOOKING_EXPIRED, } from "../../../../domain/checkoutBooking/model/checkoutBookingExpired";
6
5
  import { CHECKOUT_FEEDBACK_GIVEN, } from "../../../../domain/checkoutFeedback/model/checkoutFeedbackGiven";
7
6
  import { CHECKOUT_ITEM_KEPT } from "../../../../domain/checkoutItem/model/checkoutItemKept";
@@ -16,15 +15,13 @@ const isCheckoutStarted = (event) => event.name === CHECKOUT_STARTED;
16
15
  const isCheckoutSubmitted = (event) => event.name === CHECKOUT_SUBMITTED;
17
16
  const isCheckoutFeedbackGiven = (event) => event.name === CHECKOUT_FEEDBACK_GIVEN;
18
17
  const isCheckoutBookingExpired = (event) => event.name === CHECKOUT_BOOKING_EXPIRED;
19
- const isCheckoutBookingBooked = (event) => event.name === CHECKOUT_BOOKING_BOOKED;
20
18
  const shouldInvalidate = (event) => isCheckoutItemKept(event) ||
21
19
  isCheckoutItemReplaced(event) ||
22
20
  isCheckoutItemReturned(event) ||
23
21
  isCheckoutStarted(event) ||
24
22
  isCheckoutSubmitted(event) ||
25
23
  isCheckoutFeedbackGiven(event) ||
26
- isCheckoutBookingExpired(event) ||
27
- isCheckoutBookingBooked(event);
24
+ isCheckoutBookingExpired(event);
28
25
  const useViewFirstAvailableCheckoutByCustomerId = ({ customerId }) => useQuery({
29
26
  query: viewFirstAvailableCheckoutByCustomerId({ customerId }),
30
27
  contextId: MESSAGING_CONTEXT_ID,
@@ -1,9 +1,10 @@
1
- const httpCheckoutBookingByIdView = ({ httpPost }) => async ({ checkoutBookingId, signal }) => {
2
- const response = await httpPost({
3
- endpoint: "/view-checkout-booking-by-id",
4
- body: { checkoutBookingId },
5
- signal,
6
- });
7
- return !response.ok || response.status === 404 ? null : (await response.json()).result;
8
- };
1
+ const httpCheckoutBookingByIdView = ({ httpPost }) => async ({ checkoutBookingId, signal }) => await httpPost({
2
+ endpoint: "/view-checkout-booking-by-id",
3
+ body: { checkoutBookingId },
4
+ signal,
5
+ result: {
6
+ error: null,
7
+ success: (response) => response.result,
8
+ },
9
+ });
9
10
  export { httpCheckoutBookingByIdView };
@@ -0,0 +1,12 @@
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 };
@@ -0,0 +1,9 @@
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,9 +1,10 @@
1
- const httpCheckoutItemByIdView = ({ httpPost }) => async ({ checkoutItemId, signal }) => {
2
- const response = await httpPost({
3
- endpoint: "/view-checkout-item-by-id",
4
- body: { checkoutItemId },
5
- signal,
6
- });
7
- return !response.ok || response.status === 404 ? null : (await response.json()).result;
8
- };
1
+ const httpCheckoutItemByIdView = ({ httpPost }) => async ({ checkoutItemId, signal }) => await httpPost({
2
+ endpoint: "/view-checkout-item-by-id",
3
+ body: { checkoutItemId },
4
+ signal,
5
+ result: {
6
+ error: null,
7
+ success: (response) => response.result,
8
+ },
9
+ });
9
10
  export { httpCheckoutItemByIdView };
@@ -1,9 +1,10 @@
1
- const httpCheckoutQuestionsByCheckoutIdView = ({ httpPost }) => async ({ checkoutId, signal }) => {
2
- const response = await httpPost({
3
- endpoint: "/list-checkout-questions-by-checkout-id",
4
- body: { checkoutId },
5
- signal,
6
- });
7
- return !response.ok || response.status === 404 ? null : (await response.json()).result;
8
- };
1
+ const httpCheckoutQuestionsByCheckoutIdView = ({ httpPost }) => async ({ checkoutId, signal }) => await httpPost({
2
+ endpoint: "/list-checkout-questions-by-checkout-id",
3
+ body: { checkoutId },
4
+ signal,
5
+ result: {
6
+ error: null,
7
+ success: (response) => response.result,
8
+ },
9
+ });
9
10
  export { httpCheckoutQuestionsByCheckoutIdView };
@@ -1,9 +1,10 @@
1
- const httpPaymentFlowPayloadByCheckoutIdView = ({ httpPost }) => async ({ checkoutId, signal }) => {
2
- const response = await httpPost({
3
- endpoint: "/view-payment-flow-payload-by-checkout-id",
4
- body: { checkoutId },
5
- signal,
6
- });
7
- return !response.ok || response.status === 404 ? null : (await response.json()).result;
8
- };
1
+ const httpPaymentFlowPayloadByCheckoutIdView = ({ httpPost }) => async ({ checkoutId, signal }) => await httpPost({
2
+ endpoint: "/view-payment-flow-payload-by-checkout-id",
3
+ body: { checkoutId },
4
+ signal,
5
+ result: {
6
+ error: null,
7
+ success: (response) => response.result,
8
+ },
9
+ });
9
10
  export { httpPaymentFlowPayloadByCheckoutIdView };
@@ -1,9 +1,10 @@
1
- const httpPricingByCheckoutIdView = ({ httpPost }) => async ({ checkoutId, signal }) => {
2
- const response = await httpPost({
3
- endpoint: "/view-pricing-by-checkout-id",
4
- body: { checkoutId },
5
- signal,
6
- });
7
- return !response.ok || response.status === 404 ? null : (await response.json()).result;
8
- };
1
+ const httpPricingByCheckoutIdView = ({ httpPost }) => async ({ checkoutId, signal }) => await httpPost({
2
+ endpoint: "/view-pricing-by-checkout-id",
3
+ body: { checkoutId },
4
+ signal,
5
+ result: {
6
+ error: null,
7
+ success: (response) => response.result,
8
+ },
9
+ });
9
10
  export { httpPricingByCheckoutIdView };
@@ -1,9 +1,10 @@
1
- const httpReturnQuestionsByCheckoutItemIdView = ({ httpPost }) => async ({ checkoutItemId, signal }) => {
2
- const response = await httpPost({
3
- endpoint: "/list-return-questions-by-checkout-item-id",
4
- body: { checkoutItemId },
5
- signal,
6
- });
7
- return !response.ok || response.status === 404 ? null : (await response.json()).result;
8
- };
1
+ const httpReturnQuestionsByCheckoutItemIdView = ({ httpPost }) => async ({ checkoutItemId, signal }) => await httpPost({
2
+ endpoint: "/list-return-questions-by-checkout-item-id",
3
+ body: { checkoutItemId },
4
+ signal,
5
+ result: {
6
+ error: null,
7
+ success: (response) => response.result,
8
+ },
9
+ });
9
10
  export { httpReturnQuestionsByCheckoutItemIdView };
@@ -0,0 +1,6 @@
1
+ import { QueryStatus } from "@lookiero/messaging-react";
2
+ interface UseShouldIntroBeShownFunction {
3
+ (): [boolean, QueryStatus];
4
+ }
5
+ declare const useShouldIntroBeShown: UseShouldIntroBeShownFunction;
6
+ export { useShouldIntroBeShown };
@@ -0,0 +1,7 @@
1
+ import { useViewIntroShownCount } from "./useViewIntroShownCount";
2
+ const MAX_INTRO_SHOWN_COUNT = 2;
3
+ const useShouldIntroBeShown = () => {
4
+ const [introShownCount, introShownCountStatus] = useViewIntroShownCount();
5
+ return [introShownCount < MAX_INTRO_SHOWN_COUNT, introShownCountStatus];
6
+ };
7
+ export { useShouldIntroBeShown };
@@ -0,0 +1,6 @@
1
+ import { QueryStatus } from "@lookiero/messaging-react";
2
+ interface UseViewIntroShownCountFunction {
3
+ (): [number, QueryStatus];
4
+ }
5
+ declare const useViewIntroShownCount: UseViewIntroShownCountFunction;
6
+ export { useViewIntroShownCount };