@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.
- package/dist/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.d.ts +1 -0
- package/dist/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.js +6 -3
- package/dist/infrastructure/ui/routing/CheckoutMiddleware.d.ts +1 -0
- package/dist/infrastructure/ui/routing/CheckoutMiddleware.js +4 -4
- package/dist/infrastructure/ui/routing/Routing.js +22 -38
- package/dist/infrastructure/ui/routing/routes.d.ts +4 -4
- package/dist/infrastructure/ui/routing/routes.js +4 -4
- package/dist/infrastructure/ui/views/App.d.ts +4 -1
- package/dist/infrastructure/ui/views/App.js +2 -4
- package/package.json +1 -1
|
@@ -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)
|
|
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,12 +1,12 @@
|
|
|
1
1
|
import { QueryStatus } from "@lookiero/messaging-react";
|
|
2
2
|
import React, { useRef } from "react";
|
|
3
|
-
import { generatePath, Navigate,
|
|
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.
|
|
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
|
|
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
|
-
|
|
15
|
-
|
|
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(
|
|
20
|
-
React.createElement(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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,7 +1,7 @@
|
|
|
1
1
|
export var Routes;
|
|
2
2
|
(function (Routes) {
|
|
3
|
-
Routes["
|
|
4
|
-
Routes["INTRO"] = "
|
|
5
|
-
Routes["ITEM"] = "
|
|
6
|
-
Routes["SUMMARY"] = "
|
|
3
|
+
Routes["HOME"] = "/";
|
|
4
|
+
Routes["INTRO"] = "intro";
|
|
5
|
+
Routes["ITEM"] = "item/:id";
|
|
6
|
+
Routes["SUMMARY"] = "summary";
|
|
7
7
|
})(Routes || (Routes = {}));
|
|
@@ -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
|
-
|
|
5
|
-
|
|
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 };
|