@lookiero/checkout 2.4.0 → 2.4.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.
@@ -19,6 +19,11 @@ const useSubmitCheckout = ({ checkoutId, checkoutBookingId, paymentFlowRef, onEr
19
19
  catch (error) {
20
20
  return;
21
21
  }
22
+ /**
23
+ * paymentFlowRef.current is not properly set between render-cycles,
24
+ * so we have to defer the startLegacyBoxCheckout invocation.
25
+ */
26
+ await new Promise((resolve) => setTimeout(() => resolve(0), 200));
22
27
  paymentFlowRef.current?.startLegacyBoxCheckout(
23
28
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
24
29
  // @ts-ignore
@@ -1,6 +1,7 @@
1
1
  import { FC } from "react";
2
2
  interface CheckoutMiddlewareProps {
3
3
  readonly customerId: string;
4
+ readonly onNotAccessible: () => void;
4
5
  readonly loader?: JSX.Element;
5
6
  readonly children: JSX.Element;
6
7
  }
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useRef } from "react";
2
- import { generatePath, Navigate, useMatch, useNavigate } from "react-router-native";
2
+ import { generatePath, useMatch, useNavigate } from "react-router-native";
3
3
  import { CheckoutStatus } from "../../../domain/checkout/model/checkout";
4
4
  import { CheckoutItemStatus } from "../../../domain/checkoutItem/model/checkoutItem";
5
5
  import { useLogger } from "../../../shared/logging/useLogger";
@@ -9,7 +9,7 @@ import { useViewFirstAvailableCheckoutByCustomerId } from "../../projection/chec
9
9
  import { useViewIsSizeChangeEnabledByCheckoutId } from "../../projection/checkout/react/useViewIsSizeChangeEnabledByCheckoutId";
10
10
  import { Routes } from "./routes";
11
11
  import { useBasePath } from "./useBasePath";
12
- const CheckoutMiddleware = ({ customerId, loader = React.createElement(Spinner, null), children }) => {
12
+ const CheckoutMiddleware = ({ customerId, onNotAccessible, loader = React.createElement(Spinner, null), children, }) => {
13
13
  const logger = useLogger();
14
14
  const basePath = useBasePath();
15
15
  const navigate = useNavigate();
@@ -79,7 +79,8 @@ const CheckoutMiddleware = ({ customerId, loader = React.createElement(Spinner,
79
79
  }
80
80
  /* Prevent direct payment access */
81
81
  if (checkoutPaymentRouteMatch && !checkoutShown.current) {
82
- return React.createElement(Navigate, { to: `${basePath}/${Routes.HOME}`, replace: true });
82
+ onNotAccessible();
83
+ return null;
83
84
  }
84
85
  return children;
85
86
  };
@@ -18,7 +18,7 @@ const Routing = ({ basePath = "", customer, locale, I18n, getAuthToken, onI18nEr
18
18
  element: (React.createElement(BasePathProvider, { basePath: basePath },
19
19
  React.createElement(CheckoutAccessibilityMiddleware, { customerId: customer?.customerId, onNotAccessible: onNotAccessible },
20
20
  React.createElement(I18n, { loader: React.createElement(Spinner, null), locale: locale, onError: onI18nError },
21
- React.createElement(CheckoutMiddleware, { customerId: customer?.customerId },
21
+ React.createElement(CheckoutMiddleware, { customerId: customer?.customerId, onNotAccessible: onNotAccessible },
22
22
  React.createElement(App, { country: customer?.country, customerId: customer?.customerId, onOpenMenu: onOpenMenu },
23
23
  React.createElement(Outlet, null))))))),
24
24
  children: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [