@lookiero/checkout 0.8.4-beta.0 → 0.8.4-beta.1

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 (82) hide show
  1. package/dist/domain/checkout/model/checkout.js +0 -1
  2. package/dist/infrastructure/delivery/http/fetchHttpClient.js +19 -36
  3. package/dist/infrastructure/delivery/http/httpClient.d.ts +3 -9
  4. package/dist/infrastructure/domain/checkout/react/useStartCheckout.d.ts +1 -1
  5. package/dist/infrastructure/domain/checkout/react/useStartCheckout.js +2 -9
  6. package/dist/infrastructure/projection/bookedProductsVariants/httpBookedProductsVariantsForCheckoutItemView.js +8 -9
  7. package/dist/infrastructure/projection/checkout/httpCheckoutByIdView.js +8 -9
  8. package/dist/infrastructure/projection/checkout/httpFirstAvailableCheckoutByCustomerIdView.js +8 -9
  9. package/dist/infrastructure/projection/checkout/httpFiveItemsDiscountByCustomerIdView.js +7 -8
  10. package/dist/infrastructure/projection/checkout/httpIsCheckoutEnabledByCustomerIdView.js +7 -8
  11. package/dist/infrastructure/projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId.js +4 -1
  12. package/dist/infrastructure/projection/checkoutBooking/httpCheckoutBookingByIdView.js +8 -9
  13. package/dist/infrastructure/projection/checkoutItem/httpCheckoutItemByIdView.js +8 -9
  14. package/dist/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.js +8 -9
  15. package/dist/infrastructure/projection/payment/httpPaymentFlowPayloadByCheckoutIdView.js +8 -9
  16. package/dist/infrastructure/projection/pricing/httpPricingByCheckoutIdView.js +8 -9
  17. package/dist/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.js +8 -9
  18. package/dist/infrastructure/ui/Root.js +1 -2
  19. package/dist/infrastructure/ui/hooks/usePaymentInstrumentEvents.d.ts +2 -0
  20. package/dist/infrastructure/ui/hooks/usePaymentInstrumentEvents.js +28 -0
  21. package/dist/infrastructure/ui/hooks/usePaymentInstrumentUpdateEvents.d.ts +2 -0
  22. package/dist/infrastructure/ui/hooks/usePaymentInstrumentUpdateEvents.js +28 -0
  23. package/dist/infrastructure/ui/hooks/useToast.d.ts +11 -0
  24. package/dist/infrastructure/ui/hooks/useToast.js +44 -0
  25. package/dist/infrastructure/ui/views/checkout/Checkout.js +3 -5
  26. package/dist/infrastructure/ui/views/checkout/components/paymentInstrument/PaymentInstrument.d.ts +6 -0
  27. package/dist/infrastructure/ui/views/checkout/components/paymentInstrument/PaymentInstrument.js +10 -0
  28. package/dist/infrastructure/ui/views/intro/Intro.js +1 -1
  29. package/dist/infrastructure/ui/views/intro/Intro.style.d.ts +0 -3
  30. package/dist/infrastructure/ui/views/intro/Intro.style.js +0 -3
  31. package/dist/infrastructure/ui/views/item/components/productVariant/ProductVariant.js +2 -2
  32. package/dist/shared/logging/SentryLogger.d.ts +8 -3
  33. package/dist/shared/logging/SentryLogger.js +33 -27
  34. package/package.json +1 -2
  35. package/dist/domain/checkout/command/markCheckoutAsPaid.d.ts +0 -13
  36. package/dist/domain/checkout/command/markCheckoutAsPaid.js +0 -4
  37. package/dist/domain/checkout/model/checkoutPaid.d.ts +0 -13
  38. package/dist/domain/checkout/model/checkoutPaid.js +0 -4
  39. package/dist/infrastructure/domain/checkout/model/httpCheckoutsMarkAsPaid.d.ts +0 -5
  40. package/dist/infrastructure/domain/checkout/model/httpCheckoutsMarkAsPaid.js +0 -13
  41. package/dist/infrastructure/domain/checkout/react/useMarkCheckoutAsPaid.d.ts +0 -13
  42. package/dist/infrastructure/domain/checkout/react/useMarkCheckoutAsPaid.js +0 -16
  43. package/dist/infrastructure/domain/checkoutBooking/react/useBookCheckouBookingForCheckoutItem.d.ts +0 -13
  44. package/dist/infrastructure/domain/checkoutBooking/react/useBookCheckouBookingForCheckoutItem.js +0 -14
  45. package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/httpBookedSizeChangeProductsVariantsForCheckoutItemView.d.ts +0 -12
  46. package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/httpBookedSizeChangeProductsVariantsForCheckoutItemView.js +0 -9
  47. package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/react/useViewBookedSizeChangeProductsVariantsForCheckoutItem.d.ts +0 -10
  48. package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/react/useViewBookedSizeChangeProductsVariantsForCheckoutItem.js +0 -12
  49. package/dist/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackByCheckoutIdView.d.ts +0 -12
  50. package/dist/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackByCheckoutIdView.js +0 -9
  51. package/dist/infrastructure/ui/views/App.style.d.ts +0 -4
  52. package/dist/infrastructure/ui/views/App.style.js +0 -16
  53. package/dist/infrastructure/ui/views/header/Header.d.ts +0 -15
  54. package/dist/infrastructure/ui/views/header/Header.js +0 -90
  55. package/dist/infrastructure/ui/views/header/Header.style.d.ts +0 -35
  56. package/dist/infrastructure/ui/views/header/Header.style.js +0 -38
  57. package/dist/infrastructure/ui/views/header/components/Logo.d.ts +0 -7
  58. package/dist/infrastructure/ui/views/header/components/Logo.js +0 -11
  59. package/dist/infrastructure/ui/views/header/components/Logo.style.d.ts +0 -7
  60. package/dist/infrastructure/ui/views/header/components/Logo.style.js +0 -8
  61. package/dist/projection/bookedSizeChangeProductsVariants/bookedSizeChangeProductsVariants.d.ts +0 -10
  62. package/dist/projection/bookedSizeChangeProductsVariants/bookedSizeChangeProductsVariants.js +0 -1
  63. package/dist/projection/bookedSizeChangeProductsVariants/viewBookedSizeChangeProductVariantsForCheckoutItem.d.ts +0 -25
  64. package/dist/projection/bookedSizeChangeProductsVariants/viewBookedSizeChangeProductVariantsForCheckoutItem.js +0 -8
  65. package/dist/projection/checkoutFeedback/viewCheckoutFeedbackByCheckoutId.d.ts +0 -25
  66. package/dist/projection/checkoutFeedback/viewCheckoutFeedbackByCheckoutId.js +0 -8
  67. package/dist/shared/logging/Logger.d.ts +0 -7
  68. package/dist/shared/logging/Logger.js +0 -1
  69. package/dist/shared/logging/SentryLoggerHOC.d.ts +0 -15
  70. package/dist/shared/logging/SentryLoggerHOC.js +0 -22
  71. package/dist/shared/logging/location.d.ts +0 -3
  72. package/dist/shared/logging/location.js +0 -5
  73. package/dist/shared/logging/matchRoutes.d.ts +0 -3
  74. package/dist/shared/logging/matchRoutes.js +0 -7
  75. package/dist/shared/logging/reactRouterV6Instrumentation/reactRouterV6Instrumentation.native.d.ts +0 -29
  76. package/dist/shared/logging/reactRouterV6Instrumentation/reactRouterV6Instrumentation.native.js +0 -134
  77. package/dist/shared/logging/reactRouterV6Instrumentation/transactionContext.d.ts +0 -22
  78. package/dist/shared/logging/reactRouterV6Instrumentation/transactionContext.js +0 -15
  79. package/dist/shared/logging/reactRouterV6Instrumentation.native.d.ts +0 -27
  80. package/dist/shared/logging/reactRouterV6Instrumentation.native.js +0 -115
  81. package/dist/shared/notifications/domain/notification/command/removeNotification.tes.d.ts +0 -1
  82. package/dist/shared/notifications/domain/notification/command/removeNotification.tes.js +0 -9
@@ -11,7 +11,6 @@ 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");
15
14
  invariant(aggregateRoot.status !== CheckoutStatus.SUBMITTED, "Checkout is already submitted");
16
15
  invariant(aggregateRoot.status !== CheckoutStatus.COMPLETED, "Checkout is already completed");
17
16
  return {
@@ -1,37 +1,20 @@
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
- };
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
+ });
37
20
  export { fetchHttpGet, fetchHttpPost };
@@ -1,22 +1,16 @@
1
- interface HttpFunctionResult {
2
- readonly error: any;
3
- readonly success: (response: any) => any;
4
- }
5
1
  interface HttpGetFunctionArgs {
6
2
  readonly endpoint: string;
7
3
  readonly signal?: AbortSignal;
8
- readonly result?: HttpFunctionResult;
9
4
  }
10
5
  interface HttpGetFunction {
11
- (args: HttpGetFunctionArgs): Promise<any>;
6
+ (args: HttpGetFunctionArgs): Promise<Response>;
12
7
  }
13
8
  interface HttpPostFunctionArgs {
14
9
  readonly endpoint: string;
15
10
  readonly body: Record<string, unknown>;
16
11
  readonly signal?: AbortSignal;
17
- readonly result?: HttpFunctionResult;
18
12
  }
19
13
  interface HttpPostFunction {
20
- (args: HttpPostFunctionArgs): Promise<any>;
14
+ (args: HttpPostFunctionArgs): Promise<Response>;
21
15
  }
22
- export type { HttpGetFunction, HttpPostFunction, HttpFunctionResult };
16
+ export type { HttpGetFunction, HttpPostFunction };
@@ -1,6 +1,6 @@
1
1
  import { CommandStatus } from "@lookiero/messaging-react";
2
2
  interface StartCheckoutFunction {
3
- (): Promise<void> | undefined;
3
+ (): Promise<void>;
4
4
  }
5
5
  interface UseStartCheckoutArgs {
6
6
  readonly checkoutId?: string;
@@ -5,16 +5,9 @@ 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(async () => {
8
+ const start = useCallback(() => {
9
9
  invariant(checkoutId, "CheckoutId must be defined in order to start checkout");
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
- }
10
+ return commandBus(startCheckout({ aggregateId: checkoutId }));
18
11
  }, [checkoutId, commandBus]);
19
12
  return [start, status];
20
13
  };
@@ -1,10 +1,9 @@
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
- });
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
+ };
10
9
  export { httpBookedProductsVariantsForCheckoutItemView };
@@ -1,11 +1,10 @@
1
1
  import { toCheckoutProjection } from "./checkout";
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
- });
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
+ };
11
10
  export { httpCheckoutByIdView };
@@ -1,11 +1,10 @@
1
1
  import { toCheckoutProjection } from "./checkout";
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
- });
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
+ };
11
10
  export { httpFirstAvailableCheckoutByCustomerIdView };
@@ -1,9 +1,8 @@
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
- });
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
+ };
9
8
  export { httpFiveItemsDiscountByCustomerIdView };
@@ -1,9 +1,8 @@
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
- });
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
+ };
9
8
  export { httpIsCheckoutEnabledByCustomerIdView };
@@ -1,6 +1,7 @@
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";
4
5
  import { CHECKOUT_BOOKING_EXPIRED, } from "../../../../domain/checkoutBooking/model/checkoutBookingExpired";
5
6
  import { CHECKOUT_FEEDBACK_GIVEN, } from "../../../../domain/checkoutFeedback/model/checkoutFeedbackGiven";
6
7
  import { CHECKOUT_ITEM_KEPT } from "../../../../domain/checkoutItem/model/checkoutItemKept";
@@ -15,13 +16,15 @@ const isCheckoutStarted = (event) => event.name === CHECKOUT_STARTED;
15
16
  const isCheckoutSubmitted = (event) => event.name === CHECKOUT_SUBMITTED;
16
17
  const isCheckoutFeedbackGiven = (event) => event.name === CHECKOUT_FEEDBACK_GIVEN;
17
18
  const isCheckoutBookingExpired = (event) => event.name === CHECKOUT_BOOKING_EXPIRED;
19
+ const isCheckoutBookingBooked = (event) => event.name === CHECKOUT_BOOKING_BOOKED;
18
20
  const shouldInvalidate = (event) => isCheckoutItemKept(event) ||
19
21
  isCheckoutItemReplaced(event) ||
20
22
  isCheckoutItemReturned(event) ||
21
23
  isCheckoutStarted(event) ||
22
24
  isCheckoutSubmitted(event) ||
23
25
  isCheckoutFeedbackGiven(event) ||
24
- isCheckoutBookingExpired(event);
26
+ isCheckoutBookingExpired(event) ||
27
+ isCheckoutBookingBooked(event);
25
28
  const useViewFirstAvailableCheckoutByCustomerId = ({ customerId }) => useQuery({
26
29
  query: viewFirstAvailableCheckoutByCustomerId({ customerId }),
27
30
  contextId: MESSAGING_CONTEXT_ID,
@@ -1,10 +1,9 @@
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
- });
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
+ };
10
9
  export { httpCheckoutBookingByIdView };
@@ -1,10 +1,9 @@
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
- });
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
+ };
10
9
  export { httpCheckoutItemByIdView };
@@ -1,10 +1,9 @@
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
- });
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
+ };
10
9
  export { httpCheckoutQuestionsByCheckoutIdView };
@@ -1,10 +1,9 @@
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
- });
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
+ };
10
9
  export { httpPaymentFlowPayloadByCheckoutIdView };
@@ -1,10 +1,9 @@
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
- });
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
+ };
10
9
  export { httpPricingByCheckoutIdView };
@@ -1,10 +1,9 @@
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
- });
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
+ };
10
9
  export { httpReturnQuestionsByCheckoutItemIdView };
@@ -2,7 +2,6 @@ import React, { useCallback } from "react";
2
2
  import { Platform } from "react-native";
3
3
  import { useRoutes as reactRouterUseRoutes } from "react-router-native";
4
4
  import { sentryLogger } from "../../shared/logging/SentryLogger";
5
- import { sentryLoggerHOC } from "../../shared/logging/SentryLoggerHOC";
6
5
  import { Routing } from "./routing/Routing";
7
6
  const root = ({ Messaging, I18n, getAuthToken, development, sentry }) => {
8
7
  // eslint-disable-next-line react/display-name, react/prop-types
@@ -11,6 +10,6 @@ const root = ({ Messaging, I18n, getAuthToken, development, sentry }) => {
11
10
  return (React.createElement(Messaging, { includeReactQueryDevTools: Platform.OS === "web" },
12
11
  React.createElement(Routing, { I18n: I18n, basePath: basePath, customer: customer, getAuthToken: getAuthToken, locale: locale, menu: menu, tabBar: tabBar, useRedirect: useRedirect, useRoutes: useRoutes, onI18nError: development ? undefined : handleOnI18nError, onNotAccessible: onNotAccessible })));
13
12
  };
14
- return sentryLoggerHOC({ logger: sentryLogger(sentry) })(Root);
13
+ return sentryLogger(sentry)(Root);
15
14
  };
16
15
  export { root };
@@ -0,0 +1,2 @@
1
+ declare const usePaymentInstrumentEvents: () => void;
2
+ export { usePaymentInstrumentEvents };
@@ -0,0 +1,28 @@
1
+ import { useEvent } from "@lookiero/event";
2
+ import { useCallback, useEffect } from "react";
3
+ import { useCreateNotification } from "../../../shared/notifications";
4
+ import { MESSAGING_CONTEXT_ID } from "../../delivery/baseBootstrap";
5
+ import { I18nMessages } from "../i18n/i18n";
6
+ import { useToast } from "./useToast";
7
+ const PAYMENT_ERROR = "ERROR";
8
+ const PAYMENT_SUCCESS = "PAYMENT_INSTRUMENT_UPDATED";
9
+ const usePaymentInstrumentEvents = () => {
10
+ const { subscribe, unsubscribe } = useEvent();
11
+ const { showError, showSuccess } = useToast();
12
+ const [createNotification] = useCreateNotification({ contextId: MESSAGING_CONTEXT_ID });
13
+ const onSuccess = useCallback(({ message }) => showSuccess({ message: message.id }), [showSuccess]);
14
+ const onError = useCallback(({ error }) => {
15
+ if (error.toaster) {
16
+ showError({ message: error.toaster.id || I18nMessages.CHECKOUT_TOAST_PAYMENT_ERROR });
17
+ }
18
+ }, [showError]);
19
+ useEffect(() => {
20
+ subscribe({ event: PAYMENT_ERROR }, onError);
21
+ subscribe({ event: PAYMENT_SUCCESS }, onSuccess);
22
+ return () => {
23
+ unsubscribe({ event: PAYMENT_ERROR }, onError);
24
+ unsubscribe({ event: PAYMENT_SUCCESS }, onSuccess);
25
+ };
26
+ }, [subscribe, unsubscribe, createNotification, onError, onSuccess]);
27
+ };
28
+ export { usePaymentInstrumentEvents };
@@ -0,0 +1,2 @@
1
+ declare const usePaymentInstrumentUpdateEvents: () => void;
2
+ export { usePaymentInstrumentUpdateEvents };
@@ -0,0 +1,28 @@
1
+ import { useEvent } from "@lookiero/event";
2
+ import { useCallback, useEffect } from "react";
3
+ import { useCreateNotification } from "../../../shared/notifications";
4
+ import { MESSAGING_CONTEXT_ID } from "../../delivery/baseBootstrap";
5
+ import { I18nMessages } from "../i18n/i18n";
6
+ import { useToast } from "./useToast";
7
+ const PAYMENT_ERROR = "ERROR";
8
+ const PAYMENT_SUCCESS = "PAYMENT_INSTRUMENT_UPDATED";
9
+ const usePaymentInstrumentUpdateEvents = () => {
10
+ const { subscribe, unsubscribe } = useEvent();
11
+ const { showError, showSuccess } = useToast();
12
+ const [createNotification] = useCreateNotification({ contextId: MESSAGING_CONTEXT_ID });
13
+ const onSuccess = useCallback(({ message }) => showSuccess({ message: message.id }), [showSuccess]);
14
+ const onError = useCallback(({ error }) => {
15
+ if (error.toaster) {
16
+ showError({ message: error.toaster.id || I18nMessages.CHECKOUT_TOAST_PAYMENT_ERROR });
17
+ }
18
+ }, [showError]);
19
+ useEffect(() => {
20
+ subscribe({ event: PAYMENT_ERROR }, onError);
21
+ subscribe({ event: PAYMENT_SUCCESS }, onSuccess);
22
+ return () => {
23
+ unsubscribe({ event: PAYMENT_ERROR }, onError);
24
+ unsubscribe({ event: PAYMENT_SUCCESS }, onSuccess);
25
+ };
26
+ }, [subscribe, unsubscribe, createNotification, onError, onSuccess]);
27
+ };
28
+ export { usePaymentInstrumentUpdateEvents };
@@ -0,0 +1,11 @@
1
+ interface ShowErrorFunctionArgs {
2
+ readonly message: string;
3
+ }
4
+ interface ShowErrorFunction {
5
+ (args: ShowErrorFunctionArgs): void;
6
+ }
7
+ declare const useToast: () => {
8
+ showError: ShowErrorFunction;
9
+ showSuccess: ShowErrorFunction;
10
+ };
11
+ export { useToast };
@@ -0,0 +1,44 @@
1
+ import { Notification } from "@lookiero/aurora-next/build/components/molecules/Notification/Notification";
2
+ import { useStack } from "@lookiero/aurora-next/build/contexts/Stack/Stack";
3
+ import { useIntl } from "@lookiero/i18n-react";
4
+ import { useCallback } from "react";
5
+ import { StyleSheet } from "react-native";
6
+ import { v4 as uuid } from "uuid";
7
+ import { theme } from "../theme/theme";
8
+ const { layoutXXS, elevationColor, elevationOffset, elevationOpacityM, elevationRadius } = theme();
9
+ const style = StyleSheet.create({
10
+ container: {
11
+ marginHorizontal: layoutXXS,
12
+ marginTop: layoutXXS,
13
+ shadowColor: elevationColor,
14
+ shadowOffset: elevationOffset,
15
+ shadowOpacity: elevationOpacityM,
16
+ shadowRadius: elevationRadius,
17
+ },
18
+ inAppContainer: {
19
+ top: 75,
20
+ },
21
+ });
22
+ const NOTIFICATION_DEFAULTS = {
23
+ motion: "top",
24
+ timeoutClose: 10000,
25
+ style: style.container,
26
+ };
27
+ const IN_APP_NOTIFICATION_DEFAULTS = {
28
+ ...NOTIFICATION_DEFAULTS,
29
+ style: [style.container, style.inAppContainer],
30
+ };
31
+ const iOSInAppBrowser = window.screen?.height > 667 && /FBIOS/.test(navigator.userAgent);
32
+ const getNotificationDefaults = () => (iOSInAppBrowser ? IN_APP_NOTIFICATION_DEFAULTS : NOTIFICATION_DEFAULTS);
33
+ const useToast = () => {
34
+ const Stack = useStack();
35
+ const intl = useIntl();
36
+ const translate = useCallback((message) => intl.formatMessage({ id: message, defaultMessage: message }), [intl]);
37
+ const showError = useCallback(({ message }) => Stack.alert(uuid(), Notification, { ...getNotificationDefaults(), text: translate(message) }), [Stack, translate]);
38
+ const showSuccess = useCallback(({ message }) => Stack.success(uuid(), Notification, { ...getNotificationDefaults(), text: translate(message) }), [Stack, translate]);
39
+ return {
40
+ showError,
41
+ showSuccess,
42
+ };
43
+ };
44
+ export { useToast };
@@ -1,8 +1,7 @@
1
1
  import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
2
2
  import { useI18nMessage } from "@lookiero/i18n-react";
3
3
  import { QueryStatus } from "@lookiero/messaging-react";
4
- import { PaymentInstrumentSelect, PaymentMethod, Section } from "@lookiero/payments-front";
5
- import React, { useCallback, useMemo, useRef } from "react";
4
+ import React, { useCallback, useMemo } from "react";
6
5
  import { Platform, View } from "react-native";
7
6
  import { useNavigate } from "react-router-native";
8
7
  import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
@@ -21,9 +20,9 @@ import { HEADER_HEIGHT } from "../navigation/components/header/Header.style";
21
20
  import { Pricing } from "../summary/components/pricing/Pricing";
22
21
  import { style } from "./Checkout.style";
23
22
  import { DeliveryBanner } from "./components/deliveryBanner/DeliveryBanner";
23
+ import { PaymentInstrument } from "./components/paymentInstrument/PaymentInstrument";
24
24
  const Checkout = ({ children, customerId, country, useRedirect }) => {
25
25
  const titleText = useI18nMessage({ id: I18nMessages.CHECKOUT_TITLE });
26
- const paymentInstrumentSelectRef = useRef(null);
27
26
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
28
27
  const [pricing, pricingStatus] = useViewPricingByCheckoutId({ checkoutId: checkout?.id });
29
28
  usePageView({
@@ -33,7 +32,6 @@ const Checkout = ({ children, customerId, country, useRedirect }) => {
33
32
  });
34
33
  const navigate = useNavigate();
35
34
  const basePath = useBasePath();
36
- const { returnUrl } = useRedirect();
37
35
  const handleOnSubmit = useCallback(() => {
38
36
  navigate(`${basePath}/${Routes.CHECKOUT}/${Routes.CHECKOUT_PAYMENT}`);
39
37
  }, [basePath, navigate]);
@@ -49,7 +47,7 @@ const Checkout = ({ children, customerId, country, useRedirect }) => {
49
47
  React.createElement(Body, { style: { column: style.bodyColumn } },
50
48
  hasReplacedCheckoutItem && (React.createElement(View, { style: style.deliveryBannerContainer },
51
49
  React.createElement(DeliveryBanner, null))),
52
- React.createElement(PaymentInstrumentSelect, { ref: paymentInstrumentSelectRef, beforeRedirect: returnUrl ? () => Promise.resolve(returnUrl) : undefined, hasError: false, hidePaymentMethods: [PaymentMethod.GOOGLE_PAY], section: Section.BOX_CHECKOUT }),
50
+ React.createElement(PaymentInstrument, { useRedirect: useRedirect }),
53
51
  React.createElement(Text, { level: 3, style: style.title, heading: true }, titleText),
54
52
  checkoutItemsKept?.map((checkoutItem) => (React.createElement(View, { key: checkoutItem.id, style: style.checkoutItemKept, testID: "checkout-items-kept" },
55
53
  React.createElement(ProductVariant, { brand: checkoutItem.productVariant.brand, color: checkoutItem.productVariant.color, country: country, media: checkoutItem.productVariant.media, name: checkoutItem.productVariant.name, price: checkoutItem.price, status: checkoutItem.status, size: checkoutItem.status === CheckoutItemStatus.REPLACED && checkoutItem.replacedFor
@@ -0,0 +1,6 @@
1
+ import { FC } from "react";
2
+ interface PaymentInstrumentProps {
3
+ readonly useRedirect: () => Record<string, string>;
4
+ }
5
+ declare const PaymentInstrument: FC<PaymentInstrumentProps>;
6
+ export { PaymentInstrument };
@@ -0,0 +1,10 @@
1
+ import { PaymentInstrumentSelect, PaymentMethod, Section } from "@lookiero/payments-front";
2
+ import React, { useRef } from "react";
3
+ import { usePaymentInstrumentEvents } from "../../../../hooks/usePaymentInstrumentEvents";
4
+ const PaymentInstrument = ({ useRedirect }) => {
5
+ const paymentInstrumentSelectRef = useRef(null);
6
+ const { returnUrl } = useRedirect();
7
+ usePaymentInstrumentEvents();
8
+ return (React.createElement(PaymentInstrumentSelect, { ref: paymentInstrumentSelectRef, beforeRedirect: returnUrl ? () => Promise.resolve(returnUrl) : undefined, hasError: false, hidePaymentMethods: [PaymentMethod.GOOGLE_PAY], section: Section.BOX_CHECKOUT }));
9
+ };
10
+ export { PaymentInstrument };
@@ -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: Platform.OS === "web" || Platform.OS === "android" ? HEADER_HEIGHT : 0, style: { safeAreaView: style.container } },
33
+ return (React.createElement(SafeAreaScrollView, { scrollerPaddingTop: Platform.OS === "web" || Platform.OS === "android" ? HEADER_HEIGHT : 0 },
34
34
  React.createElement(Body, { style: { column: style.bodyColumn } },
35
35
  React.createElement(View, { style: style.intro },
36
36
  React.createElement(View, { style: style.content },
@@ -7,9 +7,6 @@ declare const style: {
7
7
  flexDirection: "row";
8
8
  marginVertical: number;
9
9
  };
10
- container: {
11
- flex: number;
12
- };
13
10
  content: {
14
11
  alignItems: "center";
15
12
  };
@@ -10,9 +10,6 @@ const style = StyleSheet.create({
10
10
  flexDirection: "row",
11
11
  marginVertical: spaceS,
12
12
  },
13
- container: {
14
- flex: 1,
15
- },
16
13
  content: {
17
14
  alignItems: "center",
18
15
  },
@@ -5,7 +5,7 @@ import { Image, Pressable, View } from "react-native";
5
5
  import Svg, { Line } from "react-native-svg";
6
6
  import { CheckoutItemStatus } from "../../../../../../domain/checkoutItem/model/checkoutItem";
7
7
  import { size } from "../../../../../../projection/shared/size";
8
- import { ButtonIcon } from "../../../../../../shared/ui/components/molecules/buttonIcon/ButtonIcon";
8
+ import { Icon } from "../../../../../../shared/ui/components/atoms/icon/Icon";
9
9
  import { Price } from "../../../../components/atoms/price/Price";
10
10
  import { useMediaImage } from "../../../../hooks/useMediaImage";
11
11
  import { COLOR_I18N_PREFIX, I18nMessages } from "../../../../i18n/i18n";
@@ -39,6 +39,6 @@ const ProductVariant = ({ media, brand, name, price, size: sizeProjection, color
39
39
  status === CheckoutItemStatus.REPLACED && (React.createElement(View, { style: style.sizeChange },
40
40
  React.createElement(Text, { level: 3, style: style.sizeChangeText, detail: true }, sizeChangeText)))),
41
41
  React.createElement(Price, { price: price, variant: "detail" }))),
42
- onPress && React.createElement(ButtonIcon, { name: "arrow-right" })));
42
+ onPress && React.createElement(Icon, { name: "arrow-right" })));
43
43
  };
44
44
  export { ProductVariant };