@lookiero/checkout 6.5.1 → 7.0.0-beta.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.
Files changed (45) hide show
  1. package/dist/index.d.ts +0 -8
  2. package/dist/index.js +0 -3
  3. package/dist/public/public/assets/adaptive-icon.png +0 -0
  4. package/dist/public/public/assets/favicon.png +0 -0
  5. package/dist/public/public/assets/icon.png +0 -0
  6. package/dist/public/public/assets/splash.png +0 -0
  7. package/dist/public/public/images/not-found.png +0 -0
  8. package/dist/src/Expo.js +0 -2
  9. package/dist/src/infrastructure/delivery/baseBootstrap.js +0 -2
  10. package/dist/src/infrastructure/ui/components/layouts/layout/Layout.d.ts +21 -0
  11. package/dist/src/infrastructure/ui/components/layouts/layout/Layout.js +1 -0
  12. package/dist/src/infrastructure/ui/components/layouts/layout/components/footer/Footer.d.ts +6 -0
  13. package/dist/src/infrastructure/ui/components/layouts/layout/components/footer/Footer.js +4 -0
  14. package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.d.ts +6 -0
  15. package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.js +5 -0
  16. package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.style.d.ts +4 -0
  17. package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.style.js +19 -0
  18. package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.d.ts +3 -0
  19. package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.js +18 -0
  20. package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.style.d.ts +12 -0
  21. package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.style.js +13 -0
  22. package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.d.ts +6 -0
  23. package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.js +11 -0
  24. package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.style.d.ts +8 -0
  25. package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.style.js +11 -0
  26. package/dist/src/infrastructure/ui/routing/Routing.js +14 -16
  27. package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.style.d.ts +7 -0
  28. package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.style.js +10 -0
  29. package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.d.ts +13 -0
  30. package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.js +9 -0
  31. package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.style.d.ts +7 -0
  32. package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.style.js +10 -0
  33. package/dist/src/version.d.ts +1 -1
  34. package/dist/src/version.js +1 -1
  35. package/index.ts +0 -17
  36. package/package.json +1 -3
  37. package/src/Expo.tsx +0 -3
  38. package/src/infrastructure/delivery/baseBootstrap.ts +0 -5
  39. package/src/infrastructure/ui/routing/Routing.tsx +20 -26
  40. package/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.test.ts +0 -45
  41. package/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.ts +0 -33
  42. package/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.test.tsx +0 -74
  43. package/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.tsx +0 -39
  44. package/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.test.ts +0 -54
  45. 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
@@ -1,5 +1,3 @@
1
1
  import { registerRootComponent } from "expo";
2
- import { enableLegacyWebImplementation } from "react-native-gesture-handler";
3
2
  import { ExpoRoot } from "./ExpoRoot";
4
- enableLegacyWebImplementation(true);
5
3
  registerRootComponent(ExpoRoot);
@@ -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, {
@@ -0,0 +1,21 @@
1
+ import { FC, ReactNode, RefObject } from "react";
2
+ import { LayoutChangeEvent, ScrollView, StyleProp, ViewStyle } from "react-native";
3
+ interface LayoutStyle {
4
+ readonly safeAreaView: StyleProp<ViewStyle>;
5
+ readonly scrollView: StyleProp<ViewStyle>;
6
+ readonly header: StyleProp<ViewStyle>;
7
+ }
8
+ interface LayoutProps {
9
+ readonly children: ReactNode;
10
+ readonly header?: JSX.Element | null;
11
+ readonly footer?: JSX.Element | null;
12
+ readonly panel?: JSX.Element | null;
13
+ readonly stickyHeader?: boolean;
14
+ readonly stickyHeaderHiddenOnScroll?: boolean;
15
+ readonly scrollRef?: RefObject<ScrollView>;
16
+ readonly scrollEnabled?: boolean;
17
+ readonly style?: Partial<LayoutStyle>;
18
+ readonly onLayout?: (event: LayoutChangeEvent) => void;
19
+ }
20
+ type Layout = FC<LayoutProps>;
21
+ export type { Layout };
@@ -0,0 +1,6 @@
1
+ import { FC, ReactNode } from "react";
2
+ interface FooterProps {
3
+ readonly children: ReactNode;
4
+ }
5
+ declare const Footer: FC<FooterProps>;
6
+ export { Footer };
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { Platform } from "react-native";
3
+ const Footer = ({ children }) => (Platform.OS !== "web" ? React.createElement(React.Fragment, null, children) : null);
4
+ export { Footer };
@@ -0,0 +1,6 @@
1
+ import { FC, ReactNode } from "react";
2
+ interface HeaderProps {
3
+ readonly children: ReactNode;
4
+ }
5
+ declare const Header: FC<HeaderProps>;
6
+ export { Header };
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ import { View } from "react-native";
3
+ import { style } from "./Header.style";
4
+ const Header = ({ children }) => React.createElement(View, { style: style.header }, children);
5
+ export { Header };
@@ -0,0 +1,4 @@
1
+ declare const style: {
2
+ header: {};
3
+ };
4
+ export { style };
@@ -0,0 +1,19 @@
1
+ import { Platform, StyleSheet } from "react-native";
2
+ import { HEADER_HEIGHT } from "../../../../templates/header/Header.style";
3
+ const style = StyleSheet.create({
4
+ header: {
5
+ ...Platform.select({
6
+ web: {
7
+ position: "sticky",
8
+ top: 0,
9
+ zIndex: 10,
10
+ height: HEADER_HEIGHT,
11
+ },
12
+ native: {
13
+ position: "relative",
14
+ height: HEADER_HEIGHT,
15
+ },
16
+ }),
17
+ },
18
+ });
19
+ export { style };
@@ -0,0 +1,3 @@
1
+ import { Layout } from "../Layout";
2
+ declare const DummyLayout: Layout;
3
+ export { DummyLayout };
@@ -0,0 +1,18 @@
1
+ /* eslint-disable react/prop-types */
2
+ import React from "react";
3
+ import { View } from "react-native";
4
+ import { GestureHandlerRootView, ScrollView as RNGHScrollView } from "react-native-gesture-handler";
5
+ import { SafeAreaView } from "react-native-safe-area-context";
6
+ import { Footer as DefaultFooter } from "../../../templates/footer/Footer";
7
+ import { DefaultHeader } from "../../../templates/header/defaultHeader/DefaultHeader";
8
+ import { Footer } from "../components/footer/Footer";
9
+ import { Header } from "../components/header/Header";
10
+ import { style } from "./DummyLayout.style";
11
+ const DummyLayout = ({ children, header = React.createElement(DefaultHeader, null), footer = React.createElement(DefaultFooter, null), panel, style: customStyle, scrollEnabled, onLayout, }) => (React.createElement(SafeAreaView, { style: [style.safeAreaView, customStyle?.safeAreaView] },
12
+ React.createElement(GestureHandlerRootView, { style: { flex: 1 } },
13
+ React.createElement(RNGHScrollView, { contentContainerStyle: [style.scrollView, customStyle?.scrollView], scrollEnabled: scrollEnabled, scrollEventThrottle: 16, showsVerticalScrollIndicator: false, stickyHeaderIndices: [0] },
14
+ React.createElement(Header, null, header),
15
+ panel,
16
+ React.createElement(View, { style: style.children, onLayout: onLayout }, children))),
17
+ React.createElement(Footer, null, footer)));
18
+ export { DummyLayout };
@@ -0,0 +1,12 @@
1
+ declare const style: {
2
+ children: {
3
+ flex: number;
4
+ };
5
+ safeAreaView: {
6
+ flex: number;
7
+ };
8
+ scrollView: {
9
+ flexGrow: number;
10
+ };
11
+ };
12
+ export { style };
@@ -0,0 +1,13 @@
1
+ import { StyleSheet } from "react-native";
2
+ const style = StyleSheet.create({
3
+ children: {
4
+ flex: 1,
5
+ },
6
+ safeAreaView: {
7
+ flex: 1,
8
+ },
9
+ scrollView: {
10
+ flexGrow: 1,
11
+ },
12
+ });
13
+ export { style };
@@ -0,0 +1,6 @@
1
+ import { FC } from "react";
2
+ interface DefaultHeaderProps {
3
+ readonly onPressMenu?: () => void;
4
+ }
5
+ declare const DefaultHeader: FC<DefaultHeaderProps>;
6
+ export { DefaultHeader };
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import { ButtonIcon } from "@lookiero/aurora";
3
+ import { Header } from "../Header";
4
+ import { ButtonIconPlaceholder } from "../buttonIconPlaceholder/ButtonIconPlaceholder";
5
+ import { Logo } from "../logo/Logo";
6
+ import { style } from "./DefaultHeader.style";
7
+ const DefaultHeader = ({ onPressMenu }) => (React.createElement(Header, { testID: "default-header" },
8
+ React.createElement(Logo, null),
9
+ React.createElement(ButtonIconPlaceholder, null),
10
+ React.createElement(ButtonIcon, { name: "menu", style: style.button, testID: "menu-button-icon", onPress: onPressMenu })));
11
+ export { DefaultHeader };
@@ -0,0 +1,8 @@
1
+ declare const style: {
2
+ button: {
3
+ alignSelf: "auto";
4
+ height: number;
5
+ width: number;
6
+ };
7
+ };
8
+ export { style };
@@ -0,0 +1,11 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { theme } from "@lookiero/sty-psp-ui";
3
+ const { space10 } = theme();
4
+ const style = StyleSheet.create({
5
+ button: {
6
+ alignSelf: "auto",
7
+ height: space10,
8
+ width: space10,
9
+ },
10
+ });
11
+ export { style };
@@ -1,34 +1,32 @@
1
- import React, { lazy, memo, Suspense } from "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 { NewFeedbackExperimentProvider } from "../hooks/useNewFeedbackExperiment";
6
6
  import { StaticInfoProvider } from "../hooks/useStaticInfo";
7
7
  import { App } from "../views/App";
8
+ import { Checkout } from "../views/checkout/Checkout";
8
9
  import { CheckoutPaymentModal } from "../views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal";
9
- import { CheckoutAccessibilityMiddleware } from "./CheckoutAccessibilityMiddleware";
10
+ import { Feedback } from "../views/feedback/Feedback";
11
+ import { Item } from "../views/item/Item";
12
+ import { Return } from "../views/return/Return";
13
+ import { Summary } from "../views/summary/Summary";
14
+ import { SummaryTabs } from "../views/summaryTabs/SummaryTabs";
10
15
  import { CheckoutMiddleware } from "./CheckoutMiddleware";
11
16
  import { Routes } from "./routes";
12
17
  import { BasePathProvider } from "./useBasePath";
13
- const Item = lazy(() => import("../views/item/Item").then((module) => ({ default: module.Item })));
14
- const Summary = lazy(() => import("../views/summary/Summary").then((module) => ({ default: module.Summary })));
15
- const SummaryTabs = lazy(() => import("../views/summaryTabs/SummaryTabs").then((module) => ({ default: module.SummaryTabs })));
16
- const Checkout = lazy(() => import("../views/checkout/Checkout").then((module) => ({ default: module.Checkout })));
17
- const Feedback = lazy(() => import("../views/feedback/Feedback").then((module) => ({ default: module.Feedback })));
18
- const Return = lazy(() => import("../views/return/Return").then((module) => ({ default: module.Return })));
19
18
  const Routing = ({ basePath = "", customer, order, subscription, locale, I18n, kameleoon, layout, getAuthToken, onI18nError, onNotAccessible, onCheckoutSubmitted, useRedirect, useRoutes = reactRouterUseRoutes, }) => {
20
19
  return useRoutes([
21
20
  {
22
21
  path: "",
23
22
  element: (React.createElement(BasePathProvider, { basePath: basePath },
24
- React.createElement(CheckoutAccessibilityMiddleware, { customerId: customer?.customerId, onNotAccessible: onNotAccessible },
25
- React.createElement(StaticInfoProvider, { customer: customer, kameleoon: kameleoon },
26
- React.createElement(I18n, { loader: React.createElement(Spinner, null), locale: locale, onError: onI18nError },
27
- React.createElement(Kameleoon, { loader: React.createElement(Spinner, null), siteCode: kameleoon.siteCode },
28
- React.createElement(CheckoutMiddleware, { customerId: customer?.customerId, onNotAccessible: onNotAccessible },
29
- React.createElement(NewFeedbackExperimentProvider, null,
30
- React.createElement(App, null,
31
- React.createElement(Outlet, null)))))))))),
23
+ React.createElement(StaticInfoProvider, { customer: customer, kameleoon: kameleoon },
24
+ React.createElement(I18n, { loader: React.createElement(Spinner, null), locale: locale, onError: onI18nError },
25
+ React.createElement(Kameleoon, { loader: React.createElement(Spinner, null), siteCode: kameleoon.siteCode },
26
+ React.createElement(CheckoutMiddleware, { customerId: customer?.customerId, onNotAccessible: onNotAccessible },
27
+ React.createElement(NewFeedbackExperimentProvider, null,
28
+ React.createElement(App, null,
29
+ React.createElement(Outlet, null))))))))),
32
30
  children: [
33
31
  {
34
32
  path: Routes.ITEM,
@@ -0,0 +1,7 @@
1
+ declare const style: {
2
+ buttonContainer: {
3
+ paddingHorizontal: number;
4
+ paddingVertical: number;
5
+ };
6
+ };
7
+ export { style };
@@ -0,0 +1,10 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { theme } from "@lookiero/sty-psp-ui";
3
+ const { space6, space8 } = theme();
4
+ const style = StyleSheet.create({
5
+ buttonContainer: {
6
+ paddingHorizontal: space6,
7
+ paddingVertical: space8,
8
+ },
9
+ });
10
+ export { style };
@@ -0,0 +1,13 @@
1
+ import { FC } from "react";
2
+ import { LayoutRectangle } from "react-native";
3
+ import { PricingProjection } from "../../../../../../projection/pricing/pricing";
4
+ interface StickyPricingProps {
5
+ readonly pricing: PricingProjection;
6
+ readonly totalCheckoutItemsKept: number;
7
+ readonly collapsed: boolean;
8
+ readonly onPress: () => void;
9
+ readonly onSubmit: () => void;
10
+ readonly onLayout?: ({ width, height }: LayoutRectangle) => void;
11
+ }
12
+ declare const StickyPricing: FC<StickyPricingProps>;
13
+ export { StickyPricing };
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import { Sticky } from "@lookiero/sty-psp-ui";
3
+ import { Body } from "../../../../components/layouts/body/Body";
4
+ import { Pricing } from "../pricing/Pricing";
5
+ import { style } from "./StickyPricing.style";
6
+ const StickyPricing = ({ pricing, totalCheckoutItemsKept, collapsed, onPress, onSubmit, onLayout, }) => (React.createElement(Sticky, { style: style.sticky, onLayout: onLayout },
7
+ React.createElement(Body, null,
8
+ React.createElement(Pricing, { balanceDiscount: pricing.balanceDiscount, collapsed: collapsed, discount: pricing.discount, discountPercentage: pricing.discountPercentage, pendingToPay: pricing.pendingToPay, service: pricing.service, subtotal: pricing.subtotal, totalCheckoutItemsKept: totalCheckoutItemsKept, onPress: onPress, onSubmit: onSubmit }))));
9
+ export { StickyPricing };
@@ -0,0 +1,7 @@
1
+ declare const style: {
2
+ sticky: {
3
+ paddingBottom: number;
4
+ paddingTop: number;
5
+ };
6
+ };
7
+ export { style };
@@ -0,0 +1,10 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { theme } from "@lookiero/sty-psp-ui";
3
+ const { space3, space4 } = theme();
4
+ const style = StyleSheet.create({
5
+ sticky: {
6
+ paddingBottom: space4,
7
+ paddingTop: space3,
8
+ },
9
+ });
10
+ export { style };
@@ -1 +1 @@
1
- export declare const VERSION = "6.5.1";
1
+ export declare const VERSION = "7.0.0-beta.0";
@@ -1 +1 @@
1
- export const VERSION = "6.5.1";
1
+ export const VERSION = "7.0.0-beta.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": "6.5.1",
3
+ "version": "7.0.0-beta.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
@@ -1,7 +1,4 @@
1
1
  import { registerRootComponent } from "expo";
2
- import { enableLegacyWebImplementation } from "react-native-gesture-handler";
3
2
  import { ExpoRoot } from "./ExpoRoot";
4
3
 
5
- enableLegacyWebImplementation(true);
6
-
7
4
  registerRootComponent(ExpoRoot);
@@ -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, lazy, memo, Suspense } from "react";
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";
@@ -11,21 +11,17 @@ import { KameleoonEnvironment } from "../../ab-testing/kameleoonEnvironment";
11
11
  import { NewFeedbackExperimentProvider } from "../hooks/useNewFeedbackExperiment";
12
12
  import { StaticInfoProvider } from "../hooks/useStaticInfo";
13
13
  import { App } from "../views/App";
14
+ import { Checkout } from "../views/checkout/Checkout";
14
15
  import { CheckoutPaymentModal } from "../views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal";
15
- import { CheckoutAccessibilityMiddleware } from "./CheckoutAccessibilityMiddleware";
16
+ import { Feedback } from "../views/feedback/Feedback";
17
+ import { Item } from "../views/item/Item";
18
+ import { Return } from "../views/return/Return";
19
+ import { Summary } from "../views/summary/Summary";
20
+ import { SummaryTabs } from "../views/summaryTabs/SummaryTabs";
16
21
  import { CheckoutMiddleware } from "./CheckoutMiddleware";
17
22
  import { Routes } from "./routes";
18
23
  import { BasePathProvider } from "./useBasePath";
19
24
 
20
- const Item = lazy(() => import("../views/item/Item").then((module) => ({ default: module.Item })));
21
- const Summary = lazy(() => import("../views/summary/Summary").then((module) => ({ default: module.Summary })));
22
- const SummaryTabs = lazy(() =>
23
- import("../views/summaryTabs/SummaryTabs").then((module) => ({ default: module.SummaryTabs })),
24
- );
25
- const Checkout = lazy(() => import("../views/checkout/Checkout").then((module) => ({ default: module.Checkout })));
26
- const Feedback = lazy(() => import("../views/feedback/Feedback").then((module) => ({ default: module.Feedback })));
27
- const Return = lazy(() => import("../views/return/Return").then((module) => ({ default: module.Return })));
28
-
29
25
  interface RoutingProps {
30
26
  readonly basePath?: string;
31
27
  readonly customer: Customer;
@@ -64,21 +60,19 @@ const Routing: FC<RoutingProps> = ({
64
60
  path: "",
65
61
  element: (
66
62
  <BasePathProvider basePath={basePath}>
67
- <CheckoutAccessibilityMiddleware customerId={customer?.customerId} onNotAccessible={onNotAccessible}>
68
- <StaticInfoProvider customer={customer} kameleoon={kameleoon}>
69
- <I18n loader={<Spinner />} locale={locale} onError={onI18nError}>
70
- <Kameleoon loader={<Spinner />} siteCode={kameleoon.siteCode}>
71
- <CheckoutMiddleware customerId={customer?.customerId as string} onNotAccessible={onNotAccessible}>
72
- <NewFeedbackExperimentProvider>
73
- <App>
74
- <Outlet />
75
- </App>
76
- </NewFeedbackExperimentProvider>
77
- </CheckoutMiddleware>
78
- </Kameleoon>
79
- </I18n>
80
- </StaticInfoProvider>
81
- </CheckoutAccessibilityMiddleware>
63
+ <StaticInfoProvider customer={customer} kameleoon={kameleoon}>
64
+ <I18n loader={<Spinner />} locale={locale} onError={onI18nError}>
65
+ <Kameleoon loader={<Spinner />} siteCode={kameleoon.siteCode}>
66
+ <CheckoutMiddleware customerId={customer?.customerId as string} onNotAccessible={onNotAccessible}>
67
+ <NewFeedbackExperimentProvider>
68
+ <App>
69
+ <Outlet />
70
+ </App>
71
+ </NewFeedbackExperimentProvider>
72
+ </CheckoutMiddleware>
73
+ </Kameleoon>
74
+ </I18n>
75
+ </StaticInfoProvider>
82
76
  </BasePathProvider>
83
77
  ),
84
78
  children: [
@@ -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
- });
@@ -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
- };