@lookiero/checkout 0.2.48-beta.0 → 0.2.48-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.
@@ -3,6 +3,7 @@ interface CheckoutAccessibilityMiddlewareProps {
3
3
  readonly customerId: string | undefined;
4
4
  readonly onNotAccessible: () => void;
5
5
  readonly loader?: JSX.Element;
6
+ readonly children: JSX.Element;
6
7
  }
7
8
  declare const CheckoutAccessibilityMiddleware: FC<CheckoutAccessibilityMiddlewareProps>;
8
9
  export { CheckoutAccessibilityMiddleware };
@@ -1,9 +1,8 @@
1
1
  import { QueryStatus } from "@lookiero/messaging-react";
2
2
  import React, { useEffect, useRef } from "react";
3
- import { Outlet } from "react-router-native";
4
3
  import { useViewIsCheckoutAccessibleByCustomerId } from "../../projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId";
5
4
  import { Spinner } from "../shared/components/atoms/spinner/Spinner";
6
- const CheckoutAccessibilityMiddleware = ({ customerId, onNotAccessible, loader = React.createElement(Spinner, null), }) => {
5
+ const CheckoutAccessibilityMiddleware = ({ customerId, onNotAccessible, loader = React.createElement(Spinner, null), children, }) => {
7
6
  const [accessible, status] = useViewIsCheckoutAccessibleByCustomerId({ customerId });
8
7
  const onNotAccessibleRef = useRef(onNotAccessible);
9
8
  onNotAccessibleRef.current = onNotAccessible;
@@ -13,6 +12,10 @@ const CheckoutAccessibilityMiddleware = ({ customerId, onNotAccessible, loader =
13
12
  onNotAccessibleRef.current();
14
13
  }
15
14
  }, [notAccessible, onNotAccessible]);
16
- return accessible === undefined && [QueryStatus.IDLE, QueryStatus.LOADING].includes(status) ? (loader) : accessible ? (React.createElement(Outlet, null)) : null;
15
+ return accessible === undefined && [QueryStatus.IDLE, QueryStatus.LOADING].includes(status)
16
+ ? loader
17
+ : accessible
18
+ ? children
19
+ : null;
17
20
  };
18
21
  export { CheckoutAccessibilityMiddleware };
@@ -2,6 +2,7 @@ import { FC } from "react";
2
2
  interface CheckoutMiddlewareProps {
3
3
  readonly customerId: string;
4
4
  readonly loader?: JSX.Element;
5
+ readonly children: JSX.Element;
5
6
  }
6
7
  declare const CheckoutMiddleware: FC<CheckoutMiddlewareProps>;
7
8
  export { CheckoutMiddleware };
@@ -1,12 +1,12 @@
1
1
  import { QueryStatus } from "@lookiero/messaging-react";
2
2
  import React, { useRef } from "react";
3
- import { generatePath, Navigate, Outlet, useMatch } from "react-router-native";
3
+ import { generatePath, Navigate, useMatch } from "react-router-native";
4
4
  import { CheckoutItemStatus } from "../../../domain/checkoutItem/model/checkoutItem";
5
5
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
6
6
  import { useShouldIntroBeShown } from "../../projection/uiSetting/react/useShouldIntroBeShown";
7
7
  import { Spinner } from "../shared/components/atoms/spinner/Spinner";
8
8
  import { Routes } from "./routes";
9
- const CheckoutMiddleware = ({ customerId, loader = React.createElement(Spinner, null) }) => {
9
+ const CheckoutMiddleware = ({ customerId, loader = React.createElement(Spinner, null), children }) => {
10
10
  const introShown = useRef(false);
11
11
  const [shouldIntroBeShown, shouldIntroBeShownStatus] = useShouldIntroBeShown();
12
12
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
@@ -32,7 +32,7 @@ const CheckoutMiddleware = ({ customerId, loader = React.createElement(Spinner,
32
32
  if (itemRouteMatch) {
33
33
  const checkoutItem = checkout?.items.find((item) => item.id === itemRouteMatch.params.id);
34
34
  if (!checkoutItem) {
35
- return React.createElement(Navigate, { to: Routes.CHECKOUT, replace: true });
35
+ return React.createElement(Navigate, { to: Routes.HOME, replace: true });
36
36
  }
37
37
  }
38
38
  if (firstItemWithoutCustomerDecision && !itemRouteMatch) {
@@ -42,6 +42,6 @@ const CheckoutMiddleware = ({ customerId, loader = React.createElement(Spinner,
42
42
  return React.createElement(Navigate, { to: Routes.SUMMARY, replace: true });
43
43
  }
44
44
  }
45
- return React.createElement(Outlet, null);
45
+ return children;
46
46
  };
47
47
  export { CheckoutMiddleware };
@@ -11,49 +11,33 @@ const Summary = lazy(() => import("../views/summary/Summary").then((module) => (
11
11
  const Routing = ({ onNotAccessible, customerId, locale, I18n, onI18nError }) => {
12
12
  const routes = useRoutes([
13
13
  {
14
- path: Routes.CHECKOUT,
15
- element: React.createElement(CheckoutAccessibilityMiddleware, { customerId: customerId, onNotAccessible: onNotAccessible }),
14
+ element: (React.createElement(CheckoutAccessibilityMiddleware, { customerId: customerId, onNotAccessible: onNotAccessible },
15
+ React.createElement(I18n, { loader: React.createElement(Spinner, null), locale: locale, onError: onI18nError },
16
+ React.createElement(CheckoutMiddleware, { customerId: customerId },
17
+ React.createElement(App, null,
18
+ React.createElement(Outlet, null)))))),
16
19
  children: [
17
20
  {
18
- path: "",
19
- element: (React.createElement(I18n, { loader: React.createElement(Spinner, null), locale: locale, onError: onI18nError },
20
- React.createElement(Outlet, null))),
21
- children: [
22
- {
23
- path: "",
24
- element: React.createElement(CheckoutMiddleware, { customerId: customerId }),
25
- children: [
26
- {
27
- path: "",
28
- element: React.createElement(App, null),
29
- children: [
30
- {
31
- path: Routes.INTRO,
32
- element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
33
- React.createElement(Intro, { customerId: customerId }))),
34
- },
35
- {
36
- path: Routes.ITEM,
37
- element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
38
- React.createElement(Item, { customerId: customerId }))),
39
- },
40
- {
41
- path: Routes.SUMMARY,
42
- element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
43
- React.createElement(Summary, { customerId: customerId }))),
44
- },
45
- ],
46
- },
47
- ],
48
- },
49
- ],
21
+ path: Routes.INTRO,
22
+ element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
23
+ React.createElement(Intro, { customerId: customerId }))),
24
+ },
25
+ {
26
+ path: Routes.ITEM,
27
+ element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
28
+ React.createElement(Item, { customerId: customerId }))),
29
+ },
30
+ {
31
+ path: Routes.SUMMARY,
32
+ element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
33
+ React.createElement(Summary, { customerId: customerId }))),
34
+ },
35
+ {
36
+ path: "*",
37
+ element: React.createElement(Navigate, { to: Routes.HOME, replace: true }),
50
38
  },
51
39
  ],
52
40
  },
53
- {
54
- path: "*",
55
- element: React.createElement(Navigate, { to: Routes.CHECKOUT, replace: true }),
56
- },
57
41
  ]);
58
42
  return routes;
59
43
  };
@@ -1,6 +1,6 @@
1
1
  export declare enum Routes {
2
- CHECKOUT = "/checkout",
3
- INTRO = "/checkout/intro",
4
- ITEM = "/checkout/item/:id",
5
- SUMMARY = "/checkout/summary"
2
+ HOME = "/",
3
+ INTRO = "intro",
4
+ ITEM = "item/:id",
5
+ SUMMARY = "summary"
6
6
  }
@@ -1,7 +1,7 @@
1
1
  export var Routes;
2
2
  (function (Routes) {
3
- Routes["CHECKOUT"] = "/checkout";
4
- Routes["INTRO"] = "/checkout/intro";
5
- Routes["ITEM"] = "/checkout/item/:id";
6
- Routes["SUMMARY"] = "/checkout/summary";
3
+ Routes["HOME"] = "/";
4
+ Routes["INTRO"] = "intro";
5
+ Routes["ITEM"] = "item/:id";
6
+ Routes["SUMMARY"] = "summary";
7
7
  })(Routes || (Routes = {}));
@@ -1,3 +1,6 @@
1
1
  import { FC } from "react";
2
- declare const App: FC;
2
+ interface AppProps {
3
+ readonly children: JSX.Element;
4
+ }
5
+ declare const App: FC<AppProps>;
3
6
  export { App };
@@ -1,8 +1,6 @@
1
1
  import { PortalProvider } from "@gorhom/portal";
2
2
  import React from "react";
3
3
  import { SafeAreaProvider } from "react-native-safe-area-context";
4
- import { Outlet } from "react-router-native";
5
- const App = () => (React.createElement(SafeAreaProvider, null,
6
- React.createElement(PortalProvider, null,
7
- React.createElement(Outlet, null))));
4
+ const App = ({ children }) => (React.createElement(SafeAreaProvider, null,
5
+ React.createElement(PortalProvider, null, children)));
8
6
  export { App };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.2.48-beta.0",
3
+ "version": "0.2.48-beta.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [