@lookiero/checkout 0.2.51 → 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 +15 -0
- package/dist/infrastructure/delivery/baseBootstrap.d.ts +2 -0
- package/dist/infrastructure/delivery/baseBootstrap.js +5 -1
- package/dist/infrastructure/delivery/bootstrap.js +4 -0
- package/dist/infrastructure/projection/pricing/httpPricingByCheckoutIdView.d.ts +12 -0
- package/dist/infrastructure/projection/pricing/httpPricingByCheckoutIdView.js +9 -0
- package/dist/infrastructure/projection/pricing/pricing.mock.d.ts +3 -0
- package/dist/{projection → infrastructure/projection}/pricing/pricing.mock.js +1 -1
- package/dist/infrastructure/projection/pricing/react/useViewPricingByCheckoutId.d.ts +10 -0
- package/dist/infrastructure/projection/pricing/react/useViewPricingByCheckoutId.js +9 -0
- package/dist/infrastructure/ui/Root.d.ts +1 -0
- package/dist/infrastructure/ui/Root.js +2 -4
- 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 +2 -0
- package/dist/infrastructure/ui/routing/CheckoutMiddleware.js +10 -10
- package/dist/infrastructure/ui/routing/Routing.d.ts +1 -0
- package/dist/infrastructure/ui/routing/Routing.js +24 -39
- 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/dist/infrastructure/ui/views/summary/Summary.js +1 -1
- package/dist/projection/pricing/viewPricingByCheckoutId.d.ts +25 -0
- package/dist/projection/pricing/viewPricingByCheckoutId.js +8 -0
- package/package.json +2 -2
- package/dist/projection/pricing/pricing.mock.d.ts +0 -3
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
|
+
```
|
|
@@ -14,6 +14,7 @@ import { FirstAvailableCheckoutByCustomerIdView } from "../../projection/checkou
|
|
|
14
14
|
import { FiveItemsDiscountByCustomerIdView } from "../../projection/checkout/viewFiveItemsDiscountByCustomerId";
|
|
15
15
|
import { IsCheckoutEnabledByCustomerIdView } from "../../projection/checkout/viewIsCheckoutEnabledByCustomerId";
|
|
16
16
|
import { CheckoutItemByIdView } from "../../projection/checkoutItem/viewCheckoutItemById";
|
|
17
|
+
import { PricingByCheckoutIdView } from "../../projection/pricing/viewPricingByCheckoutId";
|
|
17
18
|
import { ReturnQuestionsByCheckoutItemIdView } from "../../projection/returnQuestion/listReturnQuestionsByCheckoutItemId";
|
|
18
19
|
import { UiSettingByKeyView } from "../../projection/uiSetting/viewUiSettingByKey";
|
|
19
20
|
declare const MESSAGING_CONTEXT_ID = "Checkout";
|
|
@@ -28,6 +29,7 @@ interface BaseBootstrapFunctionArgs<UiSettingGetFunctionArgs extends RepositoryG
|
|
|
28
29
|
readonly checkoutItemByIdView: CheckoutItemByIdView;
|
|
29
30
|
readonly returnQuestionsByCheckoutItemIdView: ReturnQuestionsByCheckoutItemIdView;
|
|
30
31
|
readonly bookedSizeChangeProductsVariantsForCheckoutItemView: BookedSizeChangeProductsVariantsForCheckoutItemView;
|
|
32
|
+
readonly pricingByCheckoutIdView: PricingByCheckoutIdView;
|
|
31
33
|
readonly getUiSetting: UiSettingGetFunction<UiSettingGetFunctionArgs>;
|
|
32
34
|
readonly saveUiSetting: UiSettingSaveFunction<UiSettingSaveFunctionArgs>;
|
|
33
35
|
readonly uiSettingsDependencies: NeverWhenEmptyRecord<[
|
|
@@ -16,10 +16,11 @@ import { viewFiveItemsDiscountByCustomerIdHandler, VIEW_FIVE_ITEMS_DISCOUNT_BY_C
|
|
|
16
16
|
import { viewIsCheckoutAccessibleByCustomerIdHandler, VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, } from "../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
|
|
17
17
|
import { viewIsCheckoutEnabledByCustomerIdHandler, VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID, } from "../../projection/checkout/viewIsCheckoutEnabledByCustomerId";
|
|
18
18
|
import { viewCheckoutItemByIdHandler, VIEW_CHECKOUT_ITEM_BY_ID, } from "../../projection/checkoutItem/viewCheckoutItemById";
|
|
19
|
+
import { viewPricingByCheckoutIdHandler, VIEW_PRICING_BY_CHECKOUT_ID, } from "../../projection/pricing/viewPricingByCheckoutId";
|
|
19
20
|
import { listReturnQuestionsByCheckoutItemIdHandler, LIST_RETURN_QUESTIONS_BY_CHECKOUT_ITEM_ID, } from "../../projection/returnQuestion/listReturnQuestionsByCheckoutItemId";
|
|
20
21
|
import { viewUiSettingByKeyHandler, VIEW_UI_SETTING_BY_KEY, } from "../../projection/uiSetting/viewUiSettingByKey";
|
|
21
22
|
const MESSAGING_CONTEXT_ID = "Checkout";
|
|
22
|
-
const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdView, isCheckoutEnabledByCustomerIdView, fiveItemsDiscountByCustomerIdView, uiSettingByKeyView, checkoutItemByIdView, returnQuestionsByCheckoutItemIdView, bookedSizeChangeProductsVariantsForCheckoutItemView, getUiSetting, saveUiSetting, uiSettingsDependencies, getCheckout, saveCheckout, checkoutsDependencies, getCheckoutItem, saveCheckoutItem, checkoutItemsDependencies, getCheckoutBooking, saveCheckoutBooking, checkoutBookingsDependencies, }) => messagingBootstrap({ id: MESSAGING_CONTEXT_ID })
|
|
23
|
+
const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdView, isCheckoutEnabledByCustomerIdView, fiveItemsDiscountByCustomerIdView, uiSettingByKeyView, checkoutItemByIdView, returnQuestionsByCheckoutItemIdView, bookedSizeChangeProductsVariantsForCheckoutItemView, pricingByCheckoutIdView, getUiSetting, saveUiSetting, uiSettingsDependencies, getCheckout, saveCheckout, checkoutsDependencies, getCheckoutItem, saveCheckoutItem, checkoutItemsDependencies, getCheckoutBooking, saveCheckoutBooking, checkoutBookingsDependencies, }) => messagingBootstrap({ id: MESSAGING_CONTEXT_ID })
|
|
23
24
|
.query(VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID, viewFiveItemsDiscountByCustomerIdHandler, {
|
|
24
25
|
view: fiveItemsDiscountByCustomerIdView,
|
|
25
26
|
})
|
|
@@ -43,6 +44,9 @@ const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdVie
|
|
|
43
44
|
.command(KEEP_CHECKOUT_ITEM, keepCheckoutItemHandler)(getCheckoutItem, saveCheckoutItem, ...checkoutItemsDependencies)
|
|
44
45
|
.command(RETURN_CHECKOUT_ITEM, returnCheckoutItemHandler)(getCheckoutItem, saveCheckoutItem, ...checkoutItemsDependencies)
|
|
45
46
|
.command(REPLACE_CHECKOUT_ITEM, replaceCheckoutItemHandler)(getCheckoutItem, saveCheckoutItem, ...checkoutItemsDependencies)
|
|
47
|
+
.query(VIEW_PRICING_BY_CHECKOUT_ID, viewPricingByCheckoutIdHandler, {
|
|
48
|
+
view: pricingByCheckoutIdView,
|
|
49
|
+
})
|
|
46
50
|
.query(VIEW_BOOKED_SIZE_CHANGE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM, viewBookedSizeChangeProductsVariantsForCheckoutItemHandler, {
|
|
47
51
|
view: bookedSizeChangeProductsVariantsForCheckoutItemView,
|
|
48
52
|
})
|
|
@@ -9,6 +9,7 @@ import { httpFirstAvailableCheckoutByCustomerIdView } from "../projection/checko
|
|
|
9
9
|
import { httpFiveItemsDiscountByCustomerIdView } from "../projection/checkout/httpFiveItemsDiscountByCustomerIdView";
|
|
10
10
|
import { httpIsCheckoutEnabledByCustomerIdView } from "../projection/checkout/httpIsCheckoutEnabledByCustomerIdView";
|
|
11
11
|
import { httpCheckoutItemByIdView } from "../projection/checkoutItem/httpCheckoutItemByIdView";
|
|
12
|
+
import { httpPricingByCheckoutIdView } from "../projection/pricing/httpPricingByCheckoutIdView";
|
|
12
13
|
import { httpReturnQuestionsByCheckoutItemIdView } from "../projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView";
|
|
13
14
|
import { storageUiSettingByKeyView } from "../projection/uiSetting/storageUiSettingByKeyView";
|
|
14
15
|
import { baseBootstrap } from "./baseBootstrap";
|
|
@@ -27,6 +28,9 @@ const bootstrap = ({ apiUrl, getAuthToken }) => {
|
|
|
27
28
|
bookedSizeChangeProductsVariantsForCheckoutItemView: httpBookedSizeChangeProductsVariantsForCheckoutItemView({
|
|
28
29
|
httpPost,
|
|
29
30
|
}),
|
|
31
|
+
pricingByCheckoutIdView: httpPricingByCheckoutIdView({
|
|
32
|
+
httpPost,
|
|
33
|
+
}),
|
|
30
34
|
getUiSetting,
|
|
31
35
|
saveUiSetting,
|
|
32
36
|
uiSettingsDependencies: [{ read, write }],
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PricingByCheckoutIdView } from "../../../projection/pricing/viewPricingByCheckoutId";
|
|
2
|
+
import { HttpPostFunction } from "../../delivery/http/httpClient";
|
|
3
|
+
interface HttpPricingByCheckoutIdView extends PricingByCheckoutIdView {
|
|
4
|
+
}
|
|
5
|
+
interface HttpPricingByCheckoutIdViewFunctionArgs {
|
|
6
|
+
readonly httpPost: HttpPostFunction;
|
|
7
|
+
}
|
|
8
|
+
interface HttpPricingByCheckoutIdViewFunction {
|
|
9
|
+
(args: HttpPricingByCheckoutIdViewFunctionArgs): HttpPricingByCheckoutIdView;
|
|
10
|
+
}
|
|
11
|
+
declare const httpPricingByCheckoutIdView: HttpPricingByCheckoutIdViewFunction;
|
|
12
|
+
export { httpPricingByCheckoutIdView };
|
|
@@ -0,0 +1,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
|
+
};
|
|
9
|
+
export { httpPricingByCheckoutIdView };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { UseQueryFunctionResult } from "@lookiero/messaging-react";
|
|
2
|
+
import { PricingProjection } from "../../../../projection/pricing/pricing";
|
|
3
|
+
interface UseViewPricingByCheckoutIdFunctionArgs {
|
|
4
|
+
readonly checkoutId: string;
|
|
5
|
+
}
|
|
6
|
+
interface UseViewPricingByCheckoutIdFunction {
|
|
7
|
+
(args: UseViewPricingByCheckoutIdFunctionArgs): UseQueryFunctionResult<PricingProjection>;
|
|
8
|
+
}
|
|
9
|
+
declare const useViewPricingByCheckoutId: UseViewPricingByCheckoutIdFunction;
|
|
10
|
+
export { useViewPricingByCheckoutId };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useQuery } from "@lookiero/messaging-react";
|
|
2
|
+
import { viewPricingByCheckoutId } from "../../../../projection/pricing/viewPricingByCheckoutId";
|
|
3
|
+
import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
|
|
4
|
+
const useViewPricingByCheckoutId = ({ checkoutId }) => useQuery({
|
|
5
|
+
query: viewPricingByCheckoutId({ checkoutId }),
|
|
6
|
+
contextId: MESSAGING_CONTEXT_ID,
|
|
7
|
+
options: { staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
|
|
8
|
+
});
|
|
9
|
+
export { useViewPricingByCheckoutId };
|
|
@@ -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(
|
|
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)
|
|
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,
|
|
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
|
|
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.
|
|
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
|
|
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
|
|
42
|
+
return React.createElement(Navigate, { to: `${basePath}/${Routes.SUMMARY}`, replace: true });
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
return
|
|
45
|
+
return children;
|
|
46
46
|
};
|
|
47
47
|
export { CheckoutMiddleware };
|
|
@@ -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:
|
|
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(
|
|
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
|
-
],
|
|
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,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 };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { QueryStatus } from "@lookiero/messaging-react";
|
|
2
2
|
import React, { useCallback, useState } from "react";
|
|
3
|
-
import { pricing } from "../../../../projection/pricing/pricing.mock";
|
|
4
3
|
import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
|
|
4
|
+
import { pricing } from "../../../projection/pricing/pricing.mock";
|
|
5
5
|
import { Body } from "../../components/layouts/body/Body";
|
|
6
6
|
import { SafeAreaScrollView } from "../../components/templates/SafeAreaScrollView";
|
|
7
7
|
import { Spinner } from "../../shared/components/atoms/spinner/Spinner";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CancelableQueryViewArgs, Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
|
|
2
|
+
import { PricingProjection } from "./pricing";
|
|
3
|
+
declare const VIEW_PRICING_BY_CHECKOUT_ID = "view_pricing_by_checkout_id";
|
|
4
|
+
interface ViewPricingByCheckoutIdPayload {
|
|
5
|
+
readonly checkoutId: string;
|
|
6
|
+
}
|
|
7
|
+
interface ViewPricingByCheckoutId extends Query<typeof VIEW_PRICING_BY_CHECKOUT_ID>, ViewPricingByCheckoutIdPayload {
|
|
8
|
+
}
|
|
9
|
+
interface ViewPricingByCheckoutIdFunction {
|
|
10
|
+
(payload: ViewPricingByCheckoutIdPayload): ViewPricingByCheckoutId;
|
|
11
|
+
}
|
|
12
|
+
declare const viewPricingByCheckoutId: ViewPricingByCheckoutIdFunction;
|
|
13
|
+
declare type ViewPricingByCheckoutIdResult = PricingProjection | null;
|
|
14
|
+
interface PricingByCheckoutIdViewArgs extends CancelableQueryViewArgs {
|
|
15
|
+
readonly checkoutId: string;
|
|
16
|
+
}
|
|
17
|
+
interface PricingByCheckoutIdView {
|
|
18
|
+
(args: PricingByCheckoutIdViewArgs): Promise<ViewPricingByCheckoutIdResult>;
|
|
19
|
+
}
|
|
20
|
+
interface ViewPricingByCheckoutIdHandlerFunctionArgs extends QueryHandlerFunctionArgs {
|
|
21
|
+
readonly view: PricingByCheckoutIdView;
|
|
22
|
+
}
|
|
23
|
+
declare const viewPricingByCheckoutIdHandler: QueryHandlerFunction<ViewPricingByCheckoutId, ViewPricingByCheckoutIdResult, ViewPricingByCheckoutIdHandlerFunctionArgs>;
|
|
24
|
+
export type { ViewPricingByCheckoutId, PricingByCheckoutIdView, ViewPricingByCheckoutIdResult };
|
|
25
|
+
export { VIEW_PRICING_BY_CHECKOUT_ID, viewPricingByCheckoutId, viewPricingByCheckoutIdHandler };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { query, } from "@lookiero/messaging";
|
|
2
|
+
const VIEW_PRICING_BY_CHECKOUT_ID = "view_pricing_by_checkout_id";
|
|
3
|
+
const viewPricingByCheckoutId = (payload) => ({
|
|
4
|
+
...query({ name: VIEW_PRICING_BY_CHECKOUT_ID }),
|
|
5
|
+
...payload,
|
|
6
|
+
});
|
|
7
|
+
const viewPricingByCheckoutIdHandler = ({ view, signal }) => async ({ checkoutId }) => view({ checkoutId, signal });
|
|
8
|
+
export { VIEW_PRICING_BY_CHECKOUT_ID, viewPricingByCheckoutId, viewPricingByCheckoutIdHandler };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lookiero/checkout",
|
|
3
|
-
"version": "0.
|
|
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",
|