@lookiero/checkout 0.2.52 → 0.3.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.
package/README.md CHANGED
@@ -33,3 +33,18 @@ Once we can replace the build of Jenkins for NPM one, we are going to be able to
33
33
  }
34
34
  }
35
35
  ```
36
+
37
+ We are hiding the node compatibility deprecation warnings in order to obtain a success message from
38
+ the terminal. Remove it once we drop Yarn compatibility.
39
+
40
+ ```json
41
+ {
42
+ (...)
43
+ "scripts": {
44
+ (...)
45
+ "build:app": "tsc -p ./tsconfig.build-app.json --noemit && ENTRY_POINT='./src/Expo.tsx' NODE_ENV=production expo export:web --clear 2> /dev/null"
46
+ (...)
47
+ }
48
+ (...)
49
+ }
50
+ ```
@@ -10,6 +10,7 @@ interface RootFunction {
10
10
  (args: RootFunctionArgs): FC<RootProps>;
11
11
  }
12
12
  interface RootProps {
13
+ readonly basePath: string;
13
14
  readonly locale?: string;
14
15
  readonly customerId: string | undefined;
15
16
  readonly onNotAccessible: () => void;
@@ -1,13 +1,11 @@
1
1
  import React, { useCallback } from "react";
2
2
  import { Platform } from "react-native";
3
3
  import { Routing } from "./routing/Routing";
4
- import { Router } from "./routing/router/Router";
5
4
  const root = ({ Messaging, I18n, development }) =>
6
5
  // eslint-disable-next-line react/display-name, react/prop-types
7
- ({ locale = "en", customerId, onNotAccessible }) => {
6
+ ({ basePath, locale = "en", customerId, onNotAccessible }) => {
8
7
  const handleOnI18nError = useCallback(() => void 0, []);
9
8
  return (React.createElement(Messaging, { includeReactQueryDevTools: Platform.OS === "web" },
10
- React.createElement(Router, null,
11
- React.createElement(Routing, { I18n: I18n, customerId: customerId, locale: locale, onI18nError: development ? undefined : handleOnI18nError, onNotAccessible: onNotAccessible }))));
9
+ React.createElement(Routing, { I18n: I18n, basePath: basePath, customerId: customerId, locale: locale, onI18nError: development ? undefined : handleOnI18nError, onNotAccessible: onNotAccessible })));
12
10
  };
13
11
  export { root };
@@ -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 };
@@ -1,7 +1,9 @@
1
1
  import { FC } from "react";
2
2
  interface CheckoutMiddlewareProps {
3
+ readonly basePath: string;
3
4
  readonly customerId: string;
4
5
  readonly loader?: JSX.Element;
6
+ readonly children: JSX.Element;
5
7
  }
6
8
  declare const CheckoutMiddleware: FC<CheckoutMiddlewareProps>;
7
9
  export { CheckoutMiddleware };
@@ -1,19 +1,19 @@
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 = ({ basePath, 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 });
13
13
  const firstItemWithoutCustomerDecision = checkout?.items.find((item) => [CheckoutItemStatus.EXPIRED, CheckoutItemStatus.INITIAL].includes(item.status));
14
- const introRouteMatch = useMatch(Routes.INTRO);
15
- const itemRouteMatch = useMatch(Routes.ITEM);
16
- const summaryRouteMatch = useMatch(Routes.SUMMARY);
14
+ const introRouteMatch = useMatch(`${basePath}/${Routes.INTRO}`);
15
+ const itemRouteMatch = useMatch(`${basePath}/${Routes.ITEM}`);
16
+ const summaryRouteMatch = useMatch(`${basePath}/${Routes.SUMMARY}`);
17
17
  const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
18
18
  const dependenciesLoaded = dependenciesLoadedStatuses.includes(shouldIntroBeShownStatus) &&
19
19
  dependenciesLoadedStatuses.includes(checkoutStatus);
@@ -25,23 +25,23 @@ const CheckoutMiddleware = ({ customerId, loader = React.createElement(Spinner,
25
25
  introShown.current = true;
26
26
  }
27
27
  else {
28
- return React.createElement(Navigate, { to: Routes.INTRO, replace: true });
28
+ return React.createElement(Navigate, { to: `${basePath}/${Routes.INTRO}`, replace: true });
29
29
  }
30
30
  }
31
31
  else {
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: `${basePath}/${Routes.HOME}`, replace: true });
36
36
  }
37
37
  }
38
38
  if (firstItemWithoutCustomerDecision && !itemRouteMatch) {
39
- return React.createElement(Navigate, { to: generatePath(Routes.ITEM, { id: firstItemWithoutCustomerDecision.id }), replace: true });
39
+ return (React.createElement(Navigate, { to: generatePath(`${basePath}/${Routes.ITEM}`, { id: firstItemWithoutCustomerDecision.id }), replace: true }));
40
40
  }
41
41
  if (firstItemWithoutCustomerDecision === undefined && !summaryRouteMatch) {
42
- return React.createElement(Navigate, { to: Routes.SUMMARY, replace: true });
42
+ return React.createElement(Navigate, { to: `${basePath}/${Routes.SUMMARY}`, replace: true });
43
43
  }
44
44
  }
45
- return React.createElement(Outlet, null);
45
+ return children;
46
46
  };
47
47
  export { CheckoutMiddleware };
@@ -5,6 +5,7 @@ interface RoutingProps {
5
5
  readonly customerId: string | undefined;
6
6
  readonly locale: string;
7
7
  readonly I18n: I18n;
8
+ readonly basePath?: string;
8
9
  readonly onI18nError?: (err: Error) => void;
9
10
  }
10
11
  declare const Routing: FC<RoutingProps>;
@@ -8,52 +8,37 @@ import { Routes } from "./routes";
8
8
  const Intro = lazy(() => import("../views/intro/Intro").then((module) => ({ default: module.Intro })));
9
9
  const Item = lazy(() => import("../views/item/Item").then((module) => ({ default: module.Item })));
10
10
  const Summary = lazy(() => import("../views/summary/Summary").then((module) => ({ default: module.Summary })));
11
- const Routing = ({ onNotAccessible, customerId, locale, I18n, onI18nError }) => {
11
+ const Routing = ({ basePath = "", 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
+ path: "",
15
+ element: (React.createElement(CheckoutAccessibilityMiddleware, { customerId: customerId, onNotAccessible: onNotAccessible },
16
+ React.createElement(I18n, { loader: React.createElement(Spinner, null), locale: locale, onError: onI18nError },
17
+ React.createElement(CheckoutMiddleware, { basePath: basePath, customerId: customerId },
18
+ React.createElement(App, null,
19
+ React.createElement(Outlet, null)))))),
16
20
  children: [
17
21
  {
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
- ],
22
+ path: Routes.INTRO,
23
+ element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
24
+ React.createElement(Intro, { customerId: customerId }))),
25
+ },
26
+ {
27
+ path: Routes.ITEM,
28
+ element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
29
+ React.createElement(Item, { customerId: customerId }))),
30
+ },
31
+ {
32
+ path: Routes.SUMMARY,
33
+ element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
34
+ React.createElement(Summary, { customerId: customerId }))),
35
+ },
36
+ {
37
+ path: "*",
38
+ element: React.createElement(Navigate, { to: `${Routes.HOME}`, replace: true }),
50
39
  },
51
40
  ],
52
41
  },
53
- {
54
- path: "*",
55
- element: React.createElement(Navigate, { to: Routes.CHECKOUT, replace: true }),
56
- },
57
42
  ]);
58
43
  return routes;
59
44
  };
@@ -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.52",
3
+ "version": "0.3.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -16,7 +16,7 @@
16
16
  "web": "expo start --web",
17
17
  "export-analyze-web": "BUNDLE_ANALYZE=true NODE_ENV=production expo export:web",
18
18
  "build": "tsc -b tsconfig.build.json",
19
- "build:app": "tsc -p ./tsconfig.build-app.json --noemit && ENTRY_POINT='./src/Expo.tsx' NODE_ENV=production expo export:web --clear",
19
+ "build:app": "tsc -p ./tsconfig.build-app.json --noemit && ENTRY_POINT='./src/Expo.tsx' NODE_ENV=production expo export:web --clear 2> /dev/null",
20
20
  "lint": "eslint --fix --cache --cache-location ./node_modules/.cache/.eslintcache --ext ts,tsx .",
21
21
  "format": "prettier --write \"**/*.+(json|css|ts|tsx|md)\"",
22
22
  "test": "tsc -p ./tsconfig.test.json --noemit && jest",