@lookiero/checkout 6.6.0 → 7.0.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/dist/index.d.ts +0 -8
- package/dist/index.js +0 -3
- package/dist/src/Expo.js +0 -2
- package/dist/src/infrastructure/delivery/baseBootstrap.js +0 -2
- package/dist/src/infrastructure/ui/routing/Routing.js +13 -15
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/index.ts +0 -17
- package/package.json +1 -3
- package/src/Expo.tsx +0 -3
- package/src/infrastructure/delivery/baseBootstrap.ts +0 -5
- package/src/infrastructure/ui/routing/Routing.tsx +18 -24
- package/dist/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.d.ts +0 -10
- package/dist/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.js +0 -17
- package/dist/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.d.ts +0 -9
- package/dist/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.js +0 -21
- package/dist/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.d.ts +0 -17
- package/dist/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.js +0 -13
- package/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.test.ts +0 -45
- package/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.ts +0 -33
- package/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.test.tsx +0 -74
- package/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.tsx +0 -39
- package/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.test.ts +0 -54
- package/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.ts +0 -46
package/dist/index.d.ts
CHANGED
|
@@ -8,16 +8,9 @@ import { KameleoonEnvironment } from "./src/infrastructure/ab-testing/kameleoonE
|
|
|
8
8
|
import { RootProps } from "./src/infrastructure/ui/Root";
|
|
9
9
|
import { translationEndpoint, translationExternalEndpoint } from "./src/infrastructure/ui/i18n/translationEndpoint";
|
|
10
10
|
import { CheckoutProjection } from "./src/projection/checkout/checkout";
|
|
11
|
-
import { IsCheckoutAccessibleByCustomerIdProjection } from "./src/projection/checkout/viewIsCheckoutAccessibleByCustomerId";
|
|
12
11
|
import { Customer } from "./src/projection/shared/customer";
|
|
13
12
|
import { Order } from "./src/projection/shared/order";
|
|
14
13
|
import { Subscription } from "./src/projection/shared/subscription";
|
|
15
|
-
interface IsCheckoutAccessibleFunctionArgs {
|
|
16
|
-
readonly customerId: string | undefined;
|
|
17
|
-
}
|
|
18
|
-
interface IsCheckoutAccessibleFunction {
|
|
19
|
-
(args: IsCheckoutAccessibleFunctionArgs): Promise<IsCheckoutAccessibleByCustomerIdProjection>;
|
|
20
|
-
}
|
|
21
14
|
interface FirstAvailableCheckoutByCustomerIdFunctionArgs {
|
|
22
15
|
readonly customerId: string | undefined;
|
|
23
16
|
}
|
|
@@ -33,7 +26,6 @@ interface BootstrapFunctionArgs {
|
|
|
33
26
|
}
|
|
34
27
|
interface BootstrapFunctionReturn {
|
|
35
28
|
readonly root: (args: SentryLoggerFunctionArgs) => ComponentType<RootProps>;
|
|
36
|
-
readonly isCheckoutAccessible: IsCheckoutAccessibleFunction;
|
|
37
29
|
readonly firstAvailableCheckoutByCustomerId: FirstAvailableCheckoutByCustomerIdFunction;
|
|
38
30
|
}
|
|
39
31
|
interface BootstrapFunction {
|
package/dist/index.js
CHANGED
|
@@ -7,18 +7,15 @@ import { root } from "./src/infrastructure/ui/Root";
|
|
|
7
7
|
import { fetchTranslations } from "./src/infrastructure/ui/i18n/fetchTranslations";
|
|
8
8
|
import { translationEndpoint, translationExternalEndpoint } from "./src/infrastructure/ui/i18n/translationEndpoint";
|
|
9
9
|
import { viewFirstAvailableCheckoutByCustomerId } from "./src/projection/checkout/viewFirstAvailableCheckoutByCustomerId";
|
|
10
|
-
import { viewIsCheckoutAccessibleByCustomerId, } from "./src/projection/checkout/viewIsCheckoutAccessibleByCustomerId";
|
|
11
10
|
const bootstrap = ({ apiUrl, getAuthToken, translations, sentry, kameleoon }) => {
|
|
12
11
|
const { Component: Messaging, queryBus } = checkoutBootstrap({ apiUrl, getAuthToken });
|
|
13
12
|
const I18n = i18n({
|
|
14
13
|
fetchTranslation: fetchTranslations({ translations }),
|
|
15
14
|
contextId: "CheckoutI18n",
|
|
16
15
|
});
|
|
17
|
-
const isCheckoutAccessible = ({ customerId }) => queryBus(viewIsCheckoutAccessibleByCustomerId({ customerId }));
|
|
18
16
|
const firstAvailableCheckoutByCustomerId = ({ customerId }) => queryBus(viewFirstAvailableCheckoutByCustomerId({ customerId: customerId }));
|
|
19
17
|
return {
|
|
20
18
|
root: root({ Messaging, I18n, getAuthToken, sentry, kameleoon }),
|
|
21
|
-
isCheckoutAccessible,
|
|
22
19
|
firstAvailableCheckoutByCustomerId,
|
|
23
20
|
};
|
|
24
21
|
};
|
package/dist/src/Expo.js
CHANGED
|
@@ -25,7 +25,6 @@ import { viewBookedProductsVariantsForCheckoutItemHandler, VIEW_BOOKED_PRODUCT_V
|
|
|
25
25
|
import { viewCheckoutByIdHandler, VIEW_CHECKOUT_BY_ID, } from "../../projection/checkout/viewCheckoutById";
|
|
26
26
|
import { viewFirstAvailableCheckoutByCustomerIdHandler, VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID, } from "../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
|
|
27
27
|
import { viewFiveItemsDiscountByCustomerIdHandler, VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID, } from "../../projection/checkout/viewFiveItemsDiscountByCustomerId";
|
|
28
|
-
import { viewIsCheckoutAccessibleByCustomerIdHandler, VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, } from "../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
|
|
29
28
|
import { viewIsCheckoutEnabledByCustomerIdHandler, VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID, } from "../../projection/checkout/viewIsCheckoutEnabledByCustomerId";
|
|
30
29
|
import { viewIsSizeChangeEnabledByCheckoutIdHandler, VIEW_IS_SIZE_CHANGE_ENABLED_BY_CHECKOUT_ID, } from "../../projection/checkout/viewIsSizeChangeEnabledByCheckoutId";
|
|
31
30
|
import { viewCheckoutBookingByIdHandler, VIEW_CHECKOUT_BOOKING_BY_ID, } from "../../projection/checkoutBooking/viewCheckoutBookingById";
|
|
@@ -53,7 +52,6 @@ const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdVie
|
|
|
53
52
|
.query(VIEW_IS_SIZE_CHANGE_ENABLED_BY_CHECKOUT_ID, viewIsSizeChangeEnabledByCheckoutIdHandler, {
|
|
54
53
|
view: isSizeChangeEnabledByCheckoutIdView,
|
|
55
54
|
})
|
|
56
|
-
.query(VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, viewIsCheckoutAccessibleByCustomerIdHandler)
|
|
57
55
|
.command(START_CHECKOUT, startCheckoutHandler)(getCheckout, saveCheckout, ...checkoutsDependencies)
|
|
58
56
|
.command(SUBMIT_CHECKOUT, submitCheckoutHandler)(getCheckout, saveCheckout, ...checkoutsDependencies)
|
|
59
57
|
.query(VIEW_CHECKOUT_ITEM_BY_ID, viewCheckoutItemByIdHandler, {
|
|
@@ -1,32 +1,30 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { memo, Suspense } from "react";
|
|
2
2
|
import { Navigate, Outlet, useRoutes as reactRouterUseRoutes } from "react-router-native";
|
|
3
3
|
import { Spinner } from "@lookiero/aurora";
|
|
4
4
|
import { Kameleoon } from "@lookiero/sty-psp-ab-testing";
|
|
5
5
|
import { StaticInfoProvider } from "../hooks/useStaticInfo";
|
|
6
6
|
import { App } from "../views/App";
|
|
7
|
+
import { Checkout } from "../views/checkout/Checkout";
|
|
7
8
|
import { CheckoutPaymentModal } from "../views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal";
|
|
8
|
-
import {
|
|
9
|
+
import { Feedback } from "../views/feedback/Feedback";
|
|
10
|
+
import { Item } from "../views/item/Item";
|
|
11
|
+
import { Return } from "../views/return/Return";
|
|
12
|
+
import { Summary } from "../views/summary/Summary";
|
|
13
|
+
import { SummaryTabs } from "../views/summaryTabs/SummaryTabs";
|
|
9
14
|
import { CheckoutMiddleware } from "./CheckoutMiddleware";
|
|
10
15
|
import { Routes } from "./routes";
|
|
11
16
|
import { BasePathProvider } from "./useBasePath";
|
|
12
|
-
const Item = lazy(() => import("../views/item/Item").then((module) => ({ default: module.Item })));
|
|
13
|
-
const Summary = lazy(() => import("../views/summary/Summary").then((module) => ({ default: module.Summary })));
|
|
14
|
-
const SummaryTabs = lazy(() => import("../views/summaryTabs/SummaryTabs").then((module) => ({ default: module.SummaryTabs })));
|
|
15
|
-
const Checkout = lazy(() => import("../views/checkout/Checkout").then((module) => ({ default: module.Checkout })));
|
|
16
|
-
const Feedback = lazy(() => import("../views/feedback/Feedback").then((module) => ({ default: module.Feedback })));
|
|
17
|
-
const Return = lazy(() => import("../views/return/Return").then((module) => ({ default: module.Return })));
|
|
18
17
|
const Routing = ({ basePath = "", customer, order, subscription, locale, I18n, kameleoon, layout, getAuthToken, onI18nError, onNotAccessible, onCheckoutSubmitted, useRedirect, useRoutes = reactRouterUseRoutes, }) => {
|
|
19
18
|
return useRoutes([
|
|
20
19
|
{
|
|
21
20
|
path: "",
|
|
22
21
|
element: (React.createElement(BasePathProvider, { basePath: basePath },
|
|
23
|
-
React.createElement(
|
|
24
|
-
React.createElement(
|
|
25
|
-
React.createElement(
|
|
26
|
-
React.createElement(
|
|
27
|
-
React.createElement(
|
|
28
|
-
React.createElement(
|
|
29
|
-
React.createElement(Outlet, null))))))))),
|
|
22
|
+
React.createElement(StaticInfoProvider, { customer: customer, kameleoon: kameleoon },
|
|
23
|
+
React.createElement(I18n, { loader: React.createElement(Spinner, null), locale: locale, onError: onI18nError },
|
|
24
|
+
React.createElement(Kameleoon, { loader: React.createElement(Spinner, null), siteCode: kameleoon.siteCode },
|
|
25
|
+
React.createElement(CheckoutMiddleware, { customerId: customer?.customerId, onNotAccessible: onNotAccessible },
|
|
26
|
+
React.createElement(App, null,
|
|
27
|
+
React.createElement(Outlet, null)))))))),
|
|
30
28
|
children: [
|
|
31
29
|
{
|
|
32
30
|
path: Routes.ITEM,
|
package/dist/src/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "
|
|
1
|
+
export declare const VERSION = "7.0.0";
|
package/dist/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "
|
|
1
|
+
export const VERSION = "7.0.0";
|
package/index.ts
CHANGED
|
@@ -12,22 +12,10 @@ import { fetchTranslations } from "./src/infrastructure/ui/i18n/fetchTranslation
|
|
|
12
12
|
import { translationEndpoint, translationExternalEndpoint } from "./src/infrastructure/ui/i18n/translationEndpoint";
|
|
13
13
|
import { CheckoutProjection } from "./src/projection/checkout/checkout";
|
|
14
14
|
import { viewFirstAvailableCheckoutByCustomerId } from "./src/projection/checkout/viewFirstAvailableCheckoutByCustomerId";
|
|
15
|
-
import {
|
|
16
|
-
IsCheckoutAccessibleByCustomerIdProjection,
|
|
17
|
-
viewIsCheckoutAccessibleByCustomerId,
|
|
18
|
-
} from "./src/projection/checkout/viewIsCheckoutAccessibleByCustomerId";
|
|
19
15
|
import { Customer } from "./src/projection/shared/customer";
|
|
20
16
|
import { Order } from "./src/projection/shared/order";
|
|
21
17
|
import { Subscription } from "./src/projection/shared/subscription";
|
|
22
18
|
|
|
23
|
-
interface IsCheckoutAccessibleFunctionArgs {
|
|
24
|
-
readonly customerId: string | undefined;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
interface IsCheckoutAccessibleFunction {
|
|
28
|
-
(args: IsCheckoutAccessibleFunctionArgs): Promise<IsCheckoutAccessibleByCustomerIdProjection>;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
19
|
interface FirstAvailableCheckoutByCustomerIdFunctionArgs {
|
|
32
20
|
readonly customerId: string | undefined;
|
|
33
21
|
}
|
|
@@ -46,7 +34,6 @@ interface BootstrapFunctionArgs {
|
|
|
46
34
|
|
|
47
35
|
interface BootstrapFunctionReturn {
|
|
48
36
|
readonly root: (args: SentryLoggerFunctionArgs) => ComponentType<RootProps>;
|
|
49
|
-
readonly isCheckoutAccessible: IsCheckoutAccessibleFunction;
|
|
50
37
|
readonly firstAvailableCheckoutByCustomerId: FirstAvailableCheckoutByCustomerIdFunction;
|
|
51
38
|
}
|
|
52
39
|
|
|
@@ -61,15 +48,11 @@ const bootstrap: BootstrapFunction = ({ apiUrl, getAuthToken, translations, sent
|
|
|
61
48
|
contextId: "CheckoutI18n",
|
|
62
49
|
});
|
|
63
50
|
|
|
64
|
-
const isCheckoutAccessible: IsCheckoutAccessibleFunction = ({ customerId }) =>
|
|
65
|
-
queryBus(viewIsCheckoutAccessibleByCustomerId({ customerId }));
|
|
66
|
-
|
|
67
51
|
const firstAvailableCheckoutByCustomerId: FirstAvailableCheckoutByCustomerIdFunction = ({ customerId }) =>
|
|
68
52
|
queryBus(viewFirstAvailableCheckoutByCustomerId({ customerId: customerId as string }));
|
|
69
53
|
|
|
70
54
|
return {
|
|
71
55
|
root: root({ Messaging, I18n, getAuthToken, sentry, kameleoon }),
|
|
72
|
-
isCheckoutAccessible,
|
|
73
56
|
firstAvailableCheckoutByCustomerId,
|
|
74
57
|
};
|
|
75
58
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lookiero/checkout",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"sideEffects": "false",
|
|
@@ -32,8 +32,6 @@
|
|
|
32
32
|
"@lookiero/sty-psp-uuid": "^0.1.0",
|
|
33
33
|
"@react-native-async-storage/async-storage": "^1.22.3",
|
|
34
34
|
"@react-spring/native": "9.6.1",
|
|
35
|
-
"react-native-gesture-handler": "^2.12.0",
|
|
36
|
-
"react-native-keyboard-aware-scroll-view": "^0.9.5",
|
|
37
35
|
"react-native-svg": "^13.4.0",
|
|
38
36
|
"tiny-invariant": "^1.3.1"
|
|
39
37
|
},
|
package/src/Expo.tsx
CHANGED
|
@@ -72,10 +72,6 @@ import {
|
|
|
72
72
|
viewFiveItemsDiscountByCustomerIdHandler,
|
|
73
73
|
VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID,
|
|
74
74
|
} from "../../projection/checkout/viewFiveItemsDiscountByCustomerId";
|
|
75
|
-
import {
|
|
76
|
-
viewIsCheckoutAccessibleByCustomerIdHandler,
|
|
77
|
-
VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID,
|
|
78
|
-
} from "../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
|
|
79
75
|
import {
|
|
80
76
|
IsCheckoutEnabledByCustomerIdView,
|
|
81
77
|
viewIsCheckoutEnabledByCustomerIdHandler,
|
|
@@ -261,7 +257,6 @@ const baseBootstrap: BaseBootstrapFunction = ({
|
|
|
261
257
|
.query(VIEW_IS_SIZE_CHANGE_ENABLED_BY_CHECKOUT_ID, viewIsSizeChangeEnabledByCheckoutIdHandler, {
|
|
262
258
|
view: isSizeChangeEnabledByCheckoutIdView,
|
|
263
259
|
})
|
|
264
|
-
.query(VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, viewIsCheckoutAccessibleByCustomerIdHandler)
|
|
265
260
|
.command(START_CHECKOUT, startCheckoutHandler)(getCheckout, saveCheckout, ...checkoutsDependencies)
|
|
266
261
|
.command(SUBMIT_CHECKOUT, submitCheckoutHandler)(getCheckout, saveCheckout, ...checkoutsDependencies)
|
|
267
262
|
.query(VIEW_CHECKOUT_ITEM_BY_ID, viewCheckoutItemByIdHandler, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { FC,
|
|
1
|
+
import React, { FC, memo, Suspense } from "react";
|
|
2
2
|
import { Navigate, Outlet, useRoutes as reactRouterUseRoutes } from "react-router-native";
|
|
3
3
|
import { Spinner } from "@lookiero/aurora";
|
|
4
4
|
import { I18n } from "@lookiero/i18n-react";
|
|
@@ -10,21 +10,17 @@ import { Subscription } from "../../../projection/shared/subscription";
|
|
|
10
10
|
import { KameleoonEnvironment } from "../../ab-testing/kameleoonEnvironment";
|
|
11
11
|
import { StaticInfoProvider } from "../hooks/useStaticInfo";
|
|
12
12
|
import { App } from "../views/App";
|
|
13
|
+
import { Checkout } from "../views/checkout/Checkout";
|
|
13
14
|
import { CheckoutPaymentModal } from "../views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal";
|
|
14
|
-
import {
|
|
15
|
+
import { Feedback } from "../views/feedback/Feedback";
|
|
16
|
+
import { Item } from "../views/item/Item";
|
|
17
|
+
import { Return } from "../views/return/Return";
|
|
18
|
+
import { Summary } from "../views/summary/Summary";
|
|
19
|
+
import { SummaryTabs } from "../views/summaryTabs/SummaryTabs";
|
|
15
20
|
import { CheckoutMiddleware } from "./CheckoutMiddleware";
|
|
16
21
|
import { Routes } from "./routes";
|
|
17
22
|
import { BasePathProvider } from "./useBasePath";
|
|
18
23
|
|
|
19
|
-
const Item = lazy(() => import("../views/item/Item").then((module) => ({ default: module.Item })));
|
|
20
|
-
const Summary = lazy(() => import("../views/summary/Summary").then((module) => ({ default: module.Summary })));
|
|
21
|
-
const SummaryTabs = lazy(() =>
|
|
22
|
-
import("../views/summaryTabs/SummaryTabs").then((module) => ({ default: module.SummaryTabs })),
|
|
23
|
-
);
|
|
24
|
-
const Checkout = lazy(() => import("../views/checkout/Checkout").then((module) => ({ default: module.Checkout })));
|
|
25
|
-
const Feedback = lazy(() => import("../views/feedback/Feedback").then((module) => ({ default: module.Feedback })));
|
|
26
|
-
const Return = lazy(() => import("../views/return/Return").then((module) => ({ default: module.Return })));
|
|
27
|
-
|
|
28
24
|
interface RoutingProps {
|
|
29
25
|
readonly basePath?: string;
|
|
30
26
|
readonly customer: Customer;
|
|
@@ -63,19 +59,17 @@ const Routing: FC<RoutingProps> = ({
|
|
|
63
59
|
path: "",
|
|
64
60
|
element: (
|
|
65
61
|
<BasePathProvider basePath={basePath}>
|
|
66
|
-
<
|
|
67
|
-
<
|
|
68
|
-
<
|
|
69
|
-
<
|
|
70
|
-
<
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
</StaticInfoProvider>
|
|
78
|
-
</CheckoutAccessibilityMiddleware>
|
|
62
|
+
<StaticInfoProvider customer={customer} kameleoon={kameleoon}>
|
|
63
|
+
<I18n loader={<Spinner />} locale={locale} onError={onI18nError}>
|
|
64
|
+
<Kameleoon loader={<Spinner />} siteCode={kameleoon.siteCode}>
|
|
65
|
+
<CheckoutMiddleware customerId={customer?.customerId as string} onNotAccessible={onNotAccessible}>
|
|
66
|
+
<App>
|
|
67
|
+
<Outlet />
|
|
68
|
+
</App>
|
|
69
|
+
</CheckoutMiddleware>
|
|
70
|
+
</Kameleoon>
|
|
71
|
+
</I18n>
|
|
72
|
+
</StaticInfoProvider>
|
|
79
73
|
</BasePathProvider>
|
|
80
74
|
),
|
|
81
75
|
children: [
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { UseQueryFunctionResult } from "@lookiero/messaging-react";
|
|
2
|
-
import { IsCheckoutAccessibleByCustomerIdProjection } from "../../../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
|
|
3
|
-
interface UseViewIsCheckoutAccessibleByCustomerIdFunctionArgs {
|
|
4
|
-
readonly customerId: string | undefined;
|
|
5
|
-
}
|
|
6
|
-
interface UseViewIsCheckoutAccessibleByCustomerIdFunction {
|
|
7
|
-
(args: UseViewIsCheckoutAccessibleByCustomerIdFunctionArgs): UseQueryFunctionResult<IsCheckoutAccessibleByCustomerIdProjection>;
|
|
8
|
-
}
|
|
9
|
-
declare const useViewIsCheckoutAccessibleByCustomerId: UseViewIsCheckoutAccessibleByCustomerIdFunction;
|
|
10
|
-
export { useViewIsCheckoutAccessibleByCustomerId };
|
package/dist/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { useQuery } from "@lookiero/messaging-react";
|
|
2
|
-
import { isCheckoutFeedbackGiven } from "../../../../domain/checkoutFeedback/model/checkoutFeedbackGiven";
|
|
3
|
-
import { viewIsCheckoutAccessibleByCustomerId, } from "../../../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
|
|
4
|
-
import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
|
|
5
|
-
const useViewIsCheckoutAccessibleByCustomerId = ({ customerId }) => useQuery({
|
|
6
|
-
query: viewIsCheckoutAccessibleByCustomerId({ customerId }),
|
|
7
|
-
contextId: MESSAGING_CONTEXT_ID,
|
|
8
|
-
invalidation: isCheckoutFeedbackGiven,
|
|
9
|
-
options: {
|
|
10
|
-
refetchOnMount: "always",
|
|
11
|
-
staleTime: Infinity,
|
|
12
|
-
retry: false,
|
|
13
|
-
refetchOnWindowFocus: false,
|
|
14
|
-
cacheTime: 0,
|
|
15
|
-
},
|
|
16
|
-
});
|
|
17
|
-
export { useViewIsCheckoutAccessibleByCustomerId };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { FC } from "react";
|
|
2
|
-
interface CheckoutAccessibilityMiddlewareProps {
|
|
3
|
-
readonly customerId: string | undefined;
|
|
4
|
-
readonly onNotAccessible: () => void;
|
|
5
|
-
readonly loader?: JSX.Element;
|
|
6
|
-
readonly children: JSX.Element;
|
|
7
|
-
}
|
|
8
|
-
declare const CheckoutAccessibilityMiddleware: FC<CheckoutAccessibilityMiddlewareProps>;
|
|
9
|
-
export { CheckoutAccessibilityMiddleware };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from "react";
|
|
2
|
-
import { Spinner } from "@lookiero/aurora";
|
|
3
|
-
import { QueryStatus } from "@lookiero/messaging-react";
|
|
4
|
-
import { useViewIsCheckoutAccessibleByCustomerId } from "../../projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId";
|
|
5
|
-
const CheckoutAccessibilityMiddleware = ({ customerId, onNotAccessible, loader = React.createElement(Spinner, null), children, }) => {
|
|
6
|
-
const [accessible, status] = useViewIsCheckoutAccessibleByCustomerId({ customerId });
|
|
7
|
-
const onNotAccessibleRef = useRef(onNotAccessible);
|
|
8
|
-
onNotAccessibleRef.current = onNotAccessible;
|
|
9
|
-
const notAccessible = accessible === false || status === QueryStatus.ERROR;
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
if (notAccessible) {
|
|
12
|
-
onNotAccessibleRef.current();
|
|
13
|
-
}
|
|
14
|
-
}, [notAccessible]);
|
|
15
|
-
return accessible === undefined && [QueryStatus.IDLE, QueryStatus.LOADING].includes(status)
|
|
16
|
-
? loader
|
|
17
|
-
: accessible
|
|
18
|
-
? children
|
|
19
|
-
: null;
|
|
20
|
-
};
|
|
21
|
-
export { CheckoutAccessibilityMiddleware };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
|
|
2
|
-
type IsCheckoutAccessibleByCustomerIdProjection = boolean;
|
|
3
|
-
declare const VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID = "view_is_checkout_accessible_by_customer_id";
|
|
4
|
-
interface ViewIsCheckoutAccessibleByCustomerIdPayload {
|
|
5
|
-
readonly customerId: string | undefined;
|
|
6
|
-
}
|
|
7
|
-
interface ViewIsCheckoutAccessibleByCustomerId extends Query<typeof VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID>, ViewIsCheckoutAccessibleByCustomerIdPayload {
|
|
8
|
-
}
|
|
9
|
-
interface ViewIsCheckoutAccessibleByCustomerIdFunction {
|
|
10
|
-
(payload: ViewIsCheckoutAccessibleByCustomerIdPayload): ViewIsCheckoutAccessibleByCustomerId;
|
|
11
|
-
}
|
|
12
|
-
declare const viewIsCheckoutAccessibleByCustomerId: ViewIsCheckoutAccessibleByCustomerIdFunction;
|
|
13
|
-
interface ViewIsCheckoutAccessibleByCustomerIdHandlerFunctionArgs extends QueryHandlerFunctionArgs {
|
|
14
|
-
}
|
|
15
|
-
declare const viewIsCheckoutAccessibleByCustomerIdHandler: QueryHandlerFunction<ViewIsCheckoutAccessibleByCustomerId, IsCheckoutAccessibleByCustomerIdProjection, ViewIsCheckoutAccessibleByCustomerIdHandlerFunctionArgs>;
|
|
16
|
-
export type { IsCheckoutAccessibleByCustomerIdProjection };
|
|
17
|
-
export { VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, viewIsCheckoutAccessibleByCustomerId, viewIsCheckoutAccessibleByCustomerIdHandler, };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { query } from "@lookiero/messaging";
|
|
2
|
-
import { viewFirstAvailableCheckoutByCustomerId } from "./viewFirstAvailableCheckoutByCustomerId";
|
|
3
|
-
import { viewIsCheckoutEnabledByCustomerId } from "./viewIsCheckoutEnabledByCustomerId";
|
|
4
|
-
const VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID = "view_is_checkout_accessible_by_customer_id";
|
|
5
|
-
const viewIsCheckoutAccessibleByCustomerId = (payload) => ({
|
|
6
|
-
...query({ name: VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID }),
|
|
7
|
-
...payload,
|
|
8
|
-
});
|
|
9
|
-
const isNonEmptyCustomerId = (customerId) => Boolean(customerId);
|
|
10
|
-
const viewIsCheckoutAccessibleByCustomerIdHandler = ({ queryBus }) => async ({ customerId }) => isNonEmptyCustomerId(customerId) &&
|
|
11
|
-
Boolean(await queryBus(viewFirstAvailableCheckoutByCustomerId({ customerId }))) &&
|
|
12
|
-
Boolean(await queryBus(viewIsCheckoutEnabledByCustomerId({ customerId })));
|
|
13
|
-
export { VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, viewIsCheckoutAccessibleByCustomerId, viewIsCheckoutAccessibleByCustomerIdHandler, };
|
package/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.test.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { renderHook, waitFor } from "@testing-library/react-native";
|
|
2
|
-
import { bootstrap, QueryStatus } from "@lookiero/messaging-react";
|
|
3
|
-
import { CheckoutProjection } from "../../../../projection/checkout/checkout";
|
|
4
|
-
import {
|
|
5
|
-
viewFirstAvailableCheckoutByCustomerIdHandler,
|
|
6
|
-
VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID,
|
|
7
|
-
} from "../../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
|
|
8
|
-
import {
|
|
9
|
-
viewIsCheckoutAccessibleByCustomerIdHandler,
|
|
10
|
-
VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID,
|
|
11
|
-
} from "../../../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
|
|
12
|
-
import {
|
|
13
|
-
viewIsCheckoutEnabledByCustomerIdHandler,
|
|
14
|
-
VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID,
|
|
15
|
-
} from "../../../../projection/checkout/viewIsCheckoutEnabledByCustomerId";
|
|
16
|
-
import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
|
|
17
|
-
import { useViewIsCheckoutAccessibleByCustomerId as sut } from "./useViewIsCheckoutAccessibleByCustomerId";
|
|
18
|
-
|
|
19
|
-
const customerId = "29790d24-b139-4ab8-b618-d796d101e974";
|
|
20
|
-
const checkoutProjection: CheckoutProjection = { id: "75574065-5838-42de-9924-c712f7854347" } as CheckoutProjection;
|
|
21
|
-
const firstAvailableCheckoutByCustomerIdViewMock = jest.fn().mockReturnValue(checkoutProjection);
|
|
22
|
-
const isCheckoutAccessibleByCustomerIdViewMock = jest.fn().mockReturnValue(checkoutProjection);
|
|
23
|
-
|
|
24
|
-
const { Component: Messaging } = bootstrap({ id: MESSAGING_CONTEXT_ID })
|
|
25
|
-
.query(VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID, viewFirstAvailableCheckoutByCustomerIdHandler, {
|
|
26
|
-
view: firstAvailableCheckoutByCustomerIdViewMock,
|
|
27
|
-
})
|
|
28
|
-
.query(VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID, viewIsCheckoutEnabledByCustomerIdHandler, {
|
|
29
|
-
view: isCheckoutAccessibleByCustomerIdViewMock,
|
|
30
|
-
})
|
|
31
|
-
.query(VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, viewIsCheckoutAccessibleByCustomerIdHandler)
|
|
32
|
-
.build();
|
|
33
|
-
|
|
34
|
-
describe("useViewIsCheckoutAccessibleByCustomerId integration hook", () => {
|
|
35
|
-
it("returns success as the query status and the result itself after rendering the hook", async () => {
|
|
36
|
-
const { result } = renderHook(() => sut({ customerId }), { wrapper: Messaging });
|
|
37
|
-
|
|
38
|
-
await waitFor(() => {
|
|
39
|
-
const [projection, status] = result.current;
|
|
40
|
-
|
|
41
|
-
expect(projection).toBe(true);
|
|
42
|
-
expect(status).toBe(QueryStatus.SUCCESS);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
});
|
package/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { useQuery, UseQueryFunctionResult } from "@lookiero/messaging-react";
|
|
2
|
-
import { isCheckoutFeedbackGiven } from "../../../../domain/checkoutFeedback/model/checkoutFeedbackGiven";
|
|
3
|
-
import {
|
|
4
|
-
IsCheckoutAccessibleByCustomerIdProjection,
|
|
5
|
-
viewIsCheckoutAccessibleByCustomerId,
|
|
6
|
-
} from "../../../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
|
|
7
|
-
import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
|
|
8
|
-
|
|
9
|
-
interface UseViewIsCheckoutAccessibleByCustomerIdFunctionArgs {
|
|
10
|
-
readonly customerId: string | undefined;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface UseViewIsCheckoutAccessibleByCustomerIdFunction {
|
|
14
|
-
(
|
|
15
|
-
args: UseViewIsCheckoutAccessibleByCustomerIdFunctionArgs,
|
|
16
|
-
): UseQueryFunctionResult<IsCheckoutAccessibleByCustomerIdProjection>;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const useViewIsCheckoutAccessibleByCustomerId: UseViewIsCheckoutAccessibleByCustomerIdFunction = ({ customerId }) =>
|
|
20
|
-
useQuery({
|
|
21
|
-
query: viewIsCheckoutAccessibleByCustomerId({ customerId }),
|
|
22
|
-
contextId: MESSAGING_CONTEXT_ID,
|
|
23
|
-
invalidation: isCheckoutFeedbackGiven,
|
|
24
|
-
options: {
|
|
25
|
-
refetchOnMount: "always",
|
|
26
|
-
staleTime: Infinity,
|
|
27
|
-
retry: false,
|
|
28
|
-
refetchOnWindowFocus: false,
|
|
29
|
-
cacheTime: 0,
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
export { useViewIsCheckoutAccessibleByCustomerId };
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { render, RenderResult } from "@testing-library/react-native";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { Text } from "react-native";
|
|
4
|
-
import { MemoryRouter, Outlet, Route, Routes } from "react-router-native";
|
|
5
|
-
import { QueryStatus } from "@lookiero/messaging-react";
|
|
6
|
-
import { useViewIsCheckoutAccessibleByCustomerId } from "../../projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId";
|
|
7
|
-
import { CheckoutAccessibilityMiddleware } from "./CheckoutAccessibilityMiddleware";
|
|
8
|
-
|
|
9
|
-
jest.mock("../../projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId", () => ({
|
|
10
|
-
useViewIsCheckoutAccessibleByCustomerId: jest.fn(),
|
|
11
|
-
}));
|
|
12
|
-
|
|
13
|
-
const customerId = "29790d24-b139-4ab8-b618-d796d101e974";
|
|
14
|
-
const checkoutRouteText = "checkout-route-component";
|
|
15
|
-
const loaderText = "loader-component";
|
|
16
|
-
|
|
17
|
-
interface RenderCheckoutAccessibilityMiddlewareArgs {
|
|
18
|
-
readonly onNotAccessible?: () => void;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
interface RenderCheckoutAccessibilityMiddlewareFunction {
|
|
22
|
-
(args?: RenderCheckoutAccessibilityMiddlewareArgs): RenderResult;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const renderCheckoutAccessibilityMiddleware: RenderCheckoutAccessibilityMiddlewareFunction = ({
|
|
26
|
-
onNotAccessible = () => void 0,
|
|
27
|
-
} = {}) =>
|
|
28
|
-
render(
|
|
29
|
-
<MemoryRouter initialEntries={["/"]}>
|
|
30
|
-
<Routes>
|
|
31
|
-
<Route
|
|
32
|
-
path="/"
|
|
33
|
-
element={
|
|
34
|
-
<CheckoutAccessibilityMiddleware
|
|
35
|
-
customerId={customerId}
|
|
36
|
-
loader={<Text>{loaderText}</Text>}
|
|
37
|
-
onNotAccessible={onNotAccessible}
|
|
38
|
-
>
|
|
39
|
-
<Outlet />
|
|
40
|
-
</CheckoutAccessibilityMiddleware>
|
|
41
|
-
}
|
|
42
|
-
>
|
|
43
|
-
<Route element={<Text>{checkoutRouteText}</Text>} path="/" />
|
|
44
|
-
</Route>
|
|
45
|
-
</Routes>
|
|
46
|
-
</MemoryRouter>,
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
describe("CheckoutAccessibilityMiddleware component", () => {
|
|
50
|
-
it("renders a loader while processing viewIsCheckoutAccessibleByCustomerId use-case", async () => {
|
|
51
|
-
(useViewIsCheckoutAccessibleByCustomerId as jest.Mock).mockReturnValue([undefined, QueryStatus.LOADING]);
|
|
52
|
-
const { findByText } = renderCheckoutAccessibilityMiddleware();
|
|
53
|
-
const loader = await findByText(loaderText);
|
|
54
|
-
|
|
55
|
-
expect(loader).toBeTruthy();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("renders its Outlet's content if it is accessible", async () => {
|
|
59
|
-
(useViewIsCheckoutAccessibleByCustomerId as jest.Mock).mockReturnValue([true, QueryStatus.SUCCESS]);
|
|
60
|
-
const { findByText } = renderCheckoutAccessibilityMiddleware();
|
|
61
|
-
const checkoutContent = await findByText(checkoutRouteText);
|
|
62
|
-
|
|
63
|
-
expect(checkoutContent).toBeTruthy();
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it("calls onNotAccessible callback if it is not accessible", async () => {
|
|
67
|
-
(useViewIsCheckoutAccessibleByCustomerId as jest.Mock).mockReturnValue([false, QueryStatus.SUCCESS]);
|
|
68
|
-
const onNotAccessibleFn = jest.fn();
|
|
69
|
-
const { toJSON } = renderCheckoutAccessibilityMiddleware({ onNotAccessible: onNotAccessibleFn });
|
|
70
|
-
|
|
71
|
-
expect(toJSON()).toBeNull();
|
|
72
|
-
expect(onNotAccessibleFn).toHaveBeenCalled();
|
|
73
|
-
});
|
|
74
|
-
});
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React, { FC, useEffect, useRef } from "react";
|
|
2
|
-
import { Spinner } from "@lookiero/aurora";
|
|
3
|
-
import { QueryStatus } from "@lookiero/messaging-react";
|
|
4
|
-
import { useViewIsCheckoutAccessibleByCustomerId } from "../../projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId";
|
|
5
|
-
|
|
6
|
-
interface CheckoutAccessibilityMiddlewareProps {
|
|
7
|
-
readonly customerId: string | undefined;
|
|
8
|
-
readonly onNotAccessible: () => void;
|
|
9
|
-
readonly loader?: JSX.Element;
|
|
10
|
-
readonly children: JSX.Element;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const CheckoutAccessibilityMiddleware: FC<CheckoutAccessibilityMiddlewareProps> = ({
|
|
14
|
-
customerId,
|
|
15
|
-
onNotAccessible,
|
|
16
|
-
loader = <Spinner />,
|
|
17
|
-
children,
|
|
18
|
-
}) => {
|
|
19
|
-
const [accessible, status] = useViewIsCheckoutAccessibleByCustomerId({ customerId });
|
|
20
|
-
|
|
21
|
-
const onNotAccessibleRef = useRef(onNotAccessible);
|
|
22
|
-
onNotAccessibleRef.current = onNotAccessible;
|
|
23
|
-
|
|
24
|
-
const notAccessible = accessible === false || status === QueryStatus.ERROR;
|
|
25
|
-
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
if (notAccessible) {
|
|
28
|
-
onNotAccessibleRef.current();
|
|
29
|
-
}
|
|
30
|
-
}, [notAccessible]);
|
|
31
|
-
|
|
32
|
-
return accessible === undefined && [QueryStatus.IDLE, QueryStatus.LOADING].includes(status)
|
|
33
|
-
? loader
|
|
34
|
-
: accessible
|
|
35
|
-
? children
|
|
36
|
-
: null;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export { CheckoutAccessibilityMiddleware };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { bootstrap } from "@lookiero/messaging";
|
|
2
|
-
import { CheckoutProjection } from "./checkout";
|
|
3
|
-
import {
|
|
4
|
-
viewFirstAvailableCheckoutByCustomerIdHandler,
|
|
5
|
-
VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID,
|
|
6
|
-
} from "./viewFirstAvailableCheckoutByCustomerId";
|
|
7
|
-
import {
|
|
8
|
-
viewIsCheckoutAccessibleByCustomerId,
|
|
9
|
-
viewIsCheckoutAccessibleByCustomerIdHandler,
|
|
10
|
-
VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID,
|
|
11
|
-
} from "./viewIsCheckoutAccessibleByCustomerId";
|
|
12
|
-
import {
|
|
13
|
-
viewIsCheckoutEnabledByCustomerIdHandler,
|
|
14
|
-
VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID,
|
|
15
|
-
} from "./viewIsCheckoutEnabledByCustomerId";
|
|
16
|
-
|
|
17
|
-
const customerId = "29790d24-b139-4ab8-b618-d796d101e974";
|
|
18
|
-
const checkoutProjection: CheckoutProjection = { id: "75574065-5838-42de-9924-c712f7854347" } as CheckoutProjection;
|
|
19
|
-
const firstAvailableCheckoutByCustomerIdViewMock = jest.fn();
|
|
20
|
-
const isCheckoutEnabledByCustomerIdViewMock = jest.fn();
|
|
21
|
-
|
|
22
|
-
const { queryBus } = bootstrap()
|
|
23
|
-
.query(VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID, viewFirstAvailableCheckoutByCustomerIdHandler, {
|
|
24
|
-
view: firstAvailableCheckoutByCustomerIdViewMock,
|
|
25
|
-
})
|
|
26
|
-
.query(VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID, viewIsCheckoutEnabledByCustomerIdHandler, {
|
|
27
|
-
view: isCheckoutEnabledByCustomerIdViewMock,
|
|
28
|
-
})
|
|
29
|
-
.query(VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, viewIsCheckoutAccessibleByCustomerIdHandler)
|
|
30
|
-
.build();
|
|
31
|
-
|
|
32
|
-
// expectedResult, customerId, CheckoutProjection, isCheckoutEnabled
|
|
33
|
-
type Scenarios = [boolean, string | undefined, CheckoutProjection | undefined, boolean][];
|
|
34
|
-
const scenarios: Scenarios = [
|
|
35
|
-
[false, undefined, checkoutProjection, true],
|
|
36
|
-
[false, customerId, undefined, true],
|
|
37
|
-
[false, customerId, checkoutProjection, false],
|
|
38
|
-
[true, customerId, checkoutProjection, true],
|
|
39
|
-
];
|
|
40
|
-
|
|
41
|
-
describe("viewIsCheckoutAccessibleByCustomerId", () => {
|
|
42
|
-
test.each(scenarios)(
|
|
43
|
-
"Returns %s when customer is %s, checkout projection is %s and the checkout is enabled: %s",
|
|
44
|
-
async (expectedResult, customerId, checkout, isEnabled) => {
|
|
45
|
-
firstAvailableCheckoutByCustomerIdViewMock.mockReturnValue(checkout);
|
|
46
|
-
isCheckoutEnabledByCustomerIdViewMock.mockReturnValue(isEnabled);
|
|
47
|
-
const query = viewIsCheckoutAccessibleByCustomerId({ customerId });
|
|
48
|
-
|
|
49
|
-
const result = await queryBus(query);
|
|
50
|
-
|
|
51
|
-
expect(result).toBe(expectedResult);
|
|
52
|
-
},
|
|
53
|
-
);
|
|
54
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { query, Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
|
|
2
|
-
import { viewFirstAvailableCheckoutByCustomerId } from "./viewFirstAvailableCheckoutByCustomerId";
|
|
3
|
-
import { viewIsCheckoutEnabledByCustomerId } from "./viewIsCheckoutEnabledByCustomerId";
|
|
4
|
-
|
|
5
|
-
type IsCheckoutAccessibleByCustomerIdProjection = boolean;
|
|
6
|
-
|
|
7
|
-
const VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID = "view_is_checkout_accessible_by_customer_id";
|
|
8
|
-
|
|
9
|
-
interface ViewIsCheckoutAccessibleByCustomerIdPayload {
|
|
10
|
-
readonly customerId: string | undefined;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface ViewIsCheckoutAccessibleByCustomerId
|
|
14
|
-
extends Query<typeof VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID>,
|
|
15
|
-
ViewIsCheckoutAccessibleByCustomerIdPayload {}
|
|
16
|
-
|
|
17
|
-
interface ViewIsCheckoutAccessibleByCustomerIdFunction {
|
|
18
|
-
(payload: ViewIsCheckoutAccessibleByCustomerIdPayload): ViewIsCheckoutAccessibleByCustomerId;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const viewIsCheckoutAccessibleByCustomerId: ViewIsCheckoutAccessibleByCustomerIdFunction = (payload) => ({
|
|
22
|
-
...query({ name: VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID }),
|
|
23
|
-
...payload,
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
interface ViewIsCheckoutAccessibleByCustomerIdHandlerFunctionArgs extends QueryHandlerFunctionArgs {}
|
|
27
|
-
|
|
28
|
-
const isNonEmptyCustomerId = (customerId: string | undefined): customerId is string => Boolean(customerId);
|
|
29
|
-
|
|
30
|
-
const viewIsCheckoutAccessibleByCustomerIdHandler: QueryHandlerFunction<
|
|
31
|
-
ViewIsCheckoutAccessibleByCustomerId,
|
|
32
|
-
IsCheckoutAccessibleByCustomerIdProjection,
|
|
33
|
-
ViewIsCheckoutAccessibleByCustomerIdHandlerFunctionArgs
|
|
34
|
-
> =
|
|
35
|
-
({ queryBus }) =>
|
|
36
|
-
async ({ customerId }) =>
|
|
37
|
-
isNonEmptyCustomerId(customerId) &&
|
|
38
|
-
Boolean(await queryBus(viewFirstAvailableCheckoutByCustomerId({ customerId }))) &&
|
|
39
|
-
Boolean(await queryBus(viewIsCheckoutEnabledByCustomerId({ customerId })));
|
|
40
|
-
|
|
41
|
-
export type { IsCheckoutAccessibleByCustomerIdProjection };
|
|
42
|
-
export {
|
|
43
|
-
VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID,
|
|
44
|
-
viewIsCheckoutAccessibleByCustomerId,
|
|
45
|
-
viewIsCheckoutAccessibleByCustomerIdHandler,
|
|
46
|
-
};
|