@lookiero/checkout 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/.eslintignore +7 -0
  2. package/.eslintrc +72 -0
  3. package/.expo-shared/assets.json +4 -0
  4. package/.github/CODEOWNERS +1 -0
  5. package/.github/actions/version/action.yaml +32 -0
  6. package/.github/dependabot.yaml +10 -0
  7. package/.github/workflows/build.yaml +71 -0
  8. package/.github/workflows/publish.yaml +52 -0
  9. package/.husky/pre-commit +4 -0
  10. package/.husky/prepare-commit-msg +26 -0
  11. package/.husky/prepush +12 -0
  12. package/.lintstagedrc.json +4 -0
  13. package/.nvmrc +1 -0
  14. package/.prettierignore +2 -0
  15. package/.prettierrc.json +6 -0
  16. package/@types/aurora-next.d.ts +1 -0
  17. package/README.md +19 -0
  18. package/app.config.js +4 -0
  19. package/app.json +31 -0
  20. package/assets/adaptive-icon.png +0 -0
  21. package/assets/favicon.png +0 -0
  22. package/assets/icon.png +0 -0
  23. package/assets/splash.png +0 -0
  24. package/babel.config.js +6 -0
  25. package/dist/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.d.ts +15 -0
  26. package/dist/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.js +6 -0
  27. package/dist/domain/checkoutBooking/model/checkoutBooking.d.ts +8 -0
  28. package/dist/domain/checkoutBooking/model/checkoutBooking.js +16 -0
  29. package/dist/domain/checkoutBooking/model/checkoutBookingBooked.d.ts +15 -0
  30. package/dist/domain/checkoutBooking/model/checkoutBookingBooked.js +6 -0
  31. package/dist/domain/checkoutBooking/model/checkoutBookings.d.ts +6 -0
  32. package/dist/domain/checkoutBooking/model/checkoutBookings.js +1 -0
  33. package/dist/domain/uiSetting/command/updateUiSetting.d.ts +14 -0
  34. package/dist/domain/uiSetting/command/updateUiSetting.js +9 -0
  35. package/dist/domain/uiSetting/model/uiSetting.d.ts +8 -0
  36. package/dist/domain/uiSetting/model/uiSetting.js +10 -0
  37. package/dist/domain/uiSetting/model/uiSettingUpdated.d.ts +13 -0
  38. package/dist/domain/uiSetting/model/uiSettingUpdated.js +6 -0
  39. package/dist/domain/uiSetting/model/uiSettings.d.ts +6 -0
  40. package/dist/domain/uiSetting/model/uiSettings.js +1 -0
  41. package/dist/index.d.ts +22 -0
  42. package/dist/index.js +13 -0
  43. package/dist/infrastructure/delivery/_mock/bootstrap.mock.d.ts +6 -0
  44. package/dist/infrastructure/delivery/_mock/bootstrap.mock.js +17 -0
  45. package/dist/infrastructure/delivery/_mock/checkout.mock.d.ts +9 -0
  46. package/dist/infrastructure/delivery/_mock/checkout.mock.js +45 -0
  47. package/dist/infrastructure/delivery/bootstrap.d.ts +10 -0
  48. package/dist/infrastructure/delivery/bootstrap.js +21 -0
  49. package/dist/infrastructure/delivery/http/fetchHttpClient.d.ts +14 -0
  50. package/dist/infrastructure/delivery/http/fetchHttpClient.js +18 -0
  51. package/dist/infrastructure/delivery/http/httpClient.d.ts +14 -0
  52. package/dist/infrastructure/delivery/http/httpClient.js +1 -0
  53. package/dist/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.d.ts +10 -0
  54. package/dist/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.js +19 -0
  55. package/dist/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.d.ts +15 -0
  56. package/dist/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.js +17 -0
  57. package/dist/infrastructure/domain/react/useUpdateUiSetting.d.ts +17 -0
  58. package/dist/infrastructure/domain/react/useUpdateUiSetting.js +16 -0
  59. package/dist/infrastructure/domain/uiSetting/model/storageUiSettings.d.ts +18 -0
  60. package/dist/infrastructure/domain/uiSetting/model/storageUiSettings.js +19 -0
  61. package/dist/infrastructure/persistence/asyncStorageStorage.d.ts +4 -0
  62. package/dist/infrastructure/persistence/asyncStorageStorage.js +6 -0
  63. package/dist/infrastructure/persistence/storage.d.ts +6 -0
  64. package/dist/infrastructure/persistence/storage.js +1 -0
  65. package/dist/infrastructure/persistence/uiSettingData.d.ts +5 -0
  66. package/dist/infrastructure/persistence/uiSettingData.js +1 -0
  67. package/dist/infrastructure/projection/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.d.ts +36 -0
  68. package/dist/infrastructure/projection/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.js +30 -0
  69. package/dist/infrastructure/projection/httpFirstAvailableCheckoutByCustomerIdView.d.ts +60 -0
  70. package/dist/infrastructure/projection/httpFirstAvailableCheckoutByCustomerIdView.js +54 -0
  71. package/dist/infrastructure/projection/httpIsCheckoutEnabledByCustomerIdView.d.ts +12 -0
  72. package/dist/infrastructure/projection/httpIsCheckoutEnabledByCustomerIdView.js +7 -0
  73. package/dist/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.d.ts +10 -0
  74. package/dist/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.js +8 -0
  75. package/dist/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.d.ts +10 -0
  76. package/dist/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.js +8 -0
  77. package/dist/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.d.ts +10 -0
  78. package/dist/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.js +8 -0
  79. package/dist/infrastructure/projection/react/useViewIsCheckoutIntroVisible.d.ts +3 -0
  80. package/dist/infrastructure/projection/react/useViewIsCheckoutIntroVisible.js +3 -0
  81. package/dist/infrastructure/projection/react/useViewUiSettingByKey.d.ts +10 -0
  82. package/dist/infrastructure/projection/react/useViewUiSettingByKey.js +8 -0
  83. package/dist/infrastructure/projection/storageUiSettingByKeyView.d.ts +13 -0
  84. package/dist/infrastructure/projection/storageUiSettingByKeyView.js +14 -0
  85. package/dist/infrastructure/ui/Root.d.ts +15 -0
  86. package/dist/infrastructure/ui/Root.js +25 -0
  87. package/dist/infrastructure/ui/components/atoms/spiner/Spinner.d.ts +3 -0
  88. package/dist/infrastructure/ui/components/atoms/spiner/Spinner.js +11 -0
  89. package/dist/infrastructure/ui/components/atoms/spiner/Spinner.style.d.ts +9 -0
  90. package/dist/infrastructure/ui/components/atoms/spiner/Spinner.style.js +10 -0
  91. package/dist/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.d.ts +8 -0
  92. package/dist/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.js +16 -0
  93. package/dist/infrastructure/ui/routing/CheckoutMiddleware.d.ts +7 -0
  94. package/dist/infrastructure/ui/routing/CheckoutMiddleware.js +34 -0
  95. package/dist/infrastructure/ui/routing/Routing.d.ts +7 -0
  96. package/dist/infrastructure/ui/routing/Routing.js +49 -0
  97. package/dist/infrastructure/ui/routing/router/Router.d.ts +1 -0
  98. package/dist/infrastructure/ui/routing/router/Router.js +1 -0
  99. package/dist/infrastructure/ui/routing/router/Router.native.d.ts +1 -0
  100. package/dist/infrastructure/ui/routing/router/Router.native.js +1 -0
  101. package/dist/infrastructure/ui/routing/routes.d.ts +6 -0
  102. package/dist/infrastructure/ui/routing/routes.js +7 -0
  103. package/dist/infrastructure/ui/test/render.d.ts +19 -0
  104. package/dist/infrastructure/ui/test/render.js +14 -0
  105. package/dist/infrastructure/ui/views/intro/Intro.d.ts +3 -0
  106. package/dist/infrastructure/ui/views/intro/Intro.js +20 -0
  107. package/dist/infrastructure/ui/views/item/Item.d.ts +3 -0
  108. package/dist/infrastructure/ui/views/item/Item.js +23 -0
  109. package/dist/infrastructure/ui/views/summary/Summary.d.ts +3 -0
  110. package/dist/infrastructure/ui/views/summary/Summary.js +20 -0
  111. package/dist/projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem.d.ts +43 -0
  112. package/dist/projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem.js +8 -0
  113. package/dist/projection/checkout/viewFirstAvailableCheckoutByCustomerId.d.ts +104 -0
  114. package/dist/projection/checkout/viewFirstAvailableCheckoutByCustomerId.js +43 -0
  115. package/dist/projection/checkout/viewIsCheckoutAccessibleByCustomerId.d.ts +16 -0
  116. package/dist/projection/checkout/viewIsCheckoutAccessibleByCustomerId.js +13 -0
  117. package/dist/projection/checkout/viewIsCheckoutEnabledByCustomerId.d.ts +23 -0
  118. package/dist/projection/checkout/viewIsCheckoutEnabledByCustomerId.js +8 -0
  119. package/dist/projection/uiSetting/viewUiSettingByKey.d.ts +28 -0
  120. package/dist/projection/uiSetting/viewUiSettingByKey.js +7 -0
  121. package/jest.config.js +9 -0
  122. package/jest.setup.js +3 -0
  123. package/package.json +75 -0
  124. package/src/Expo.tsx +59 -0
  125. package/src/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.test.ts +26 -0
  126. package/src/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.ts +27 -0
  127. package/src/domain/checkoutBooking/model/checkoutBooking.test.ts +30 -0
  128. package/src/domain/checkoutBooking/model/checkoutBooking.ts +31 -0
  129. package/src/domain/checkoutBooking/model/checkoutBookingBooked.test.ts +23 -0
  130. package/src/domain/checkoutBooking/model/checkoutBookingBooked.ts +23 -0
  131. package/src/domain/checkoutBooking/model/checkoutBookings.ts +6 -0
  132. package/src/domain/uiSetting/command/updateUiSetting.test.ts +19 -0
  133. package/src/domain/uiSetting/command/updateUiSetting.ts +23 -0
  134. package/src/domain/uiSetting/model/uiSetting.test.ts +26 -0
  135. package/src/domain/uiSetting/model/uiSetting.ts +22 -0
  136. package/src/domain/uiSetting/model/uiSettingUpdated.test.ts +17 -0
  137. package/src/domain/uiSetting/model/uiSettingUpdated.ts +19 -0
  138. package/src/domain/uiSetting/model/uiSettings.ts +6 -0
  139. package/src/index.ts +44 -0
  140. package/src/infrastructure/delivery/_mock/bootstrap.mock.ts +38 -0
  141. package/src/infrastructure/delivery/_mock/checkout.mock.ts +81 -0
  142. package/src/infrastructure/delivery/bootstrap.ts +42 -0
  143. package/src/infrastructure/delivery/http/fetchHttpClient.test.ts +51 -0
  144. package/src/infrastructure/delivery/http/fetchHttpClient.ts +41 -0
  145. package/src/infrastructure/delivery/http/httpClient.ts +18 -0
  146. package/src/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.test.ts +45 -0
  147. package/src/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.ts +32 -0
  148. package/src/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.test.ts +38 -0
  149. package/src/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.ts +44 -0
  150. package/src/infrastructure/domain/react/useUpdateUiSetting.test.ts +31 -0
  151. package/src/infrastructure/domain/react/useUpdateUiSetting.ts +43 -0
  152. package/src/infrastructure/domain/uiSetting/model/storageUiSettings.test.ts +50 -0
  153. package/src/infrastructure/domain/uiSetting/model/storageUiSettings.ts +50 -0
  154. package/src/infrastructure/persistence/asyncStorageStorage.ts +12 -0
  155. package/src/infrastructure/persistence/storage.ts +7 -0
  156. package/src/infrastructure/persistence/uiSettingData.ts +5 -0
  157. package/src/infrastructure/projection/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.test.ts +65 -0
  158. package/src/infrastructure/projection/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.ts +102 -0
  159. package/src/infrastructure/projection/httpFirstAvailableCheckoutByCustomerIdView.test.ts +99 -0
  160. package/src/infrastructure/projection/httpFirstAvailableCheckoutByCustomerIdView.ts +128 -0
  161. package/src/infrastructure/projection/httpIsCheckoutEnabledByCustomerIdView.test.ts +32 -0
  162. package/src/infrastructure/projection/httpIsCheckoutEnabledByCustomerIdView.ts +27 -0
  163. package/src/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.test.ts +51 -0
  164. package/src/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.ts +25 -0
  165. package/src/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.test.ts +28 -0
  166. package/src/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.ts +22 -0
  167. package/src/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.test.ts +44 -0
  168. package/src/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.ts +24 -0
  169. package/src/infrastructure/projection/react/useViewIsCheckoutIntroVisible.ts +5 -0
  170. package/src/infrastructure/projection/react/useViewUiSettingByKey.test.ts +30 -0
  171. package/src/infrastructure/projection/react/useViewUiSettingByKey.ts +18 -0
  172. package/src/infrastructure/projection/storageUiSettingByKeyView.test.ts +32 -0
  173. package/src/infrastructure/projection/storageUiSettingByKeyView.ts +35 -0
  174. package/src/infrastructure/ui/Root.tsx +53 -0
  175. package/src/infrastructure/ui/components/atoms/spiner/Spinner.style.ts +12 -0
  176. package/src/infrastructure/ui/components/atoms/spiner/Spinner.tsx +35 -0
  177. package/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.test.tsx +70 -0
  178. package/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.tsx +31 -0
  179. package/src/infrastructure/ui/routing/CheckoutMiddleware.test.tsx +100 -0
  180. package/src/infrastructure/ui/routing/CheckoutMiddleware.tsx +52 -0
  181. package/src/infrastructure/ui/routing/Routing.tsx +64 -0
  182. package/src/infrastructure/ui/routing/router/Router.native.ts +1 -0
  183. package/src/infrastructure/ui/routing/router/Router.ts +1 -0
  184. package/src/infrastructure/ui/routing/routes.ts +6 -0
  185. package/src/infrastructure/ui/test/render.tsx +47 -0
  186. package/src/infrastructure/ui/views/intro/Intro.test.tsx +15 -0
  187. package/src/infrastructure/ui/views/intro/Intro.tsx +27 -0
  188. package/src/infrastructure/ui/views/item/Item.tsx +31 -0
  189. package/src/infrastructure/ui/views/summary/Summary.tsx +27 -0
  190. package/src/projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem.test.ts +40 -0
  191. package/src/projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem.ts +85 -0
  192. package/src/projection/checkout/viewFirstAvailableCheckoutByCustomerId.test.ts +22 -0
  193. package/src/projection/checkout/viewFirstAvailableCheckoutByCustomerId.ts +149 -0
  194. package/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.test.ts +54 -0
  195. package/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.ts +46 -0
  196. package/src/projection/checkout/viewIsCheckoutEnabledByCustomerId.test.ts +20 -0
  197. package/src/projection/checkout/viewIsCheckoutEnabledByCustomerId.ts +51 -0
  198. package/src/projection/uiSetting/viewUiSettingByKey.test.ts +22 -0
  199. package/src/projection/uiSetting/viewUiSettingByKey.ts +47 -0
  200. package/tsconfig.build.json +16 -0
  201. package/tsconfig.json +19 -0
  202. package/webpack.config.js +17 -0
@@ -0,0 +1,14 @@
1
+ const toUiSettingProjection = (uiSettingDto) => ({
2
+ id: uiSettingDto.id,
3
+ key: uiSettingDto.key,
4
+ value: uiSettingDto.value,
5
+ });
6
+ export const storageUiSettingByKeyView = ({ read }) => async ({ key }) => {
7
+ try {
8
+ const uiSettingDto = await read(key);
9
+ return uiSettingDto ? toUiSettingProjection(uiSettingDto) : undefined;
10
+ }
11
+ catch (ignored) {
12
+ throw new Error("Could not fetch the uiSetting");
13
+ }
14
+ };
@@ -0,0 +1,15 @@
1
+ import { MessagingRoot } from "@lookiero/messaging-react/bootstrap";
2
+ import { FC } from "react";
3
+ interface RootFunctionArgs {
4
+ readonly Messaging: MessagingRoot;
5
+ }
6
+ interface RootFunction {
7
+ (args: RootFunctionArgs): FC<RootProps>;
8
+ }
9
+ interface RootProps {
10
+ readonly locale?: string;
11
+ readonly customerId: string | undefined;
12
+ readonly onNotAccessible: () => void;
13
+ }
14
+ declare const root: RootFunction;
15
+ export { RootProps, root };
@@ -0,0 +1,25 @@
1
+ import { inMemoryFetchTranslation } from "@lookiero/i18n";
2
+ import { ReactIntl } from "@lookiero/i18n-react";
3
+ import { useCallback } from "react";
4
+ import { Platform } from "react-native";
5
+ import { Spinner } from "./components/atoms/spiner/Spinner";
6
+ import { Router } from "./routing/router/Router";
7
+ import { Routing } from "./routing/Routing";
8
+ const translationData = {
9
+ en: { intro: "Intro view's title" },
10
+ es: { intro: "Título de la vista Intro" },
11
+ };
12
+ const fetchTranslation = inMemoryFetchTranslation({ translationData });
13
+ const root = ({ Messaging }) =>
14
+ // eslint-disable-next-line react/display-name, react/prop-types
15
+ ({ locale = "en", customerId, onNotAccessible }) => {
16
+ const handleOnI18nError = useCallback(() => void 0, []);
17
+ return (<ReactIntl.I18n locale={locale} fetchTranslation={fetchTranslation} loader={<Spinner />} onError={handleOnI18nError} contextId="CheckoutI18n">
18
+ <Messaging includeReactQueryDevTools={Platform.OS === "web"}>
19
+ <Router>
20
+ <Routing customerId={customerId} onNotAccessible={onNotAccessible}/>
21
+ </Router>
22
+ </Messaging>
23
+ </ReactIntl.I18n>);
24
+ };
25
+ export { root };
@@ -0,0 +1,3 @@
1
+ import { FC } from "react";
2
+ declare const Spinner: FC;
3
+ export { Spinner };
@@ -0,0 +1,11 @@
1
+ import { View } from "react-native";
2
+ import { style } from "./Spinner.style";
3
+ const Spinner = () => (<View style={style.container}>
4
+ <svg xmlns="http://www.w3.org/2000/svg" width="30px" height="30px" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid">
5
+ <circle cx="50" cy="50" r="32" stroke="#000000" strokeWidth="6" strokeLinecap="round" fill="none">
6
+ <animateTransform attributeName="transform" type="rotate" repeatCount="indefinite" dur="1.5384615384615383s" values="0 50 50;180 50 50;720 50 50" keyTimes="0;0.5;1"></animateTransform>
7
+ <animate attributeName="stroke-dasharray" repeatCount="indefinite" dur="1.5384615384615383s" values="42.22300526424682 158.83892456549995;176.93449825017714 24.127431579569617;42.22300526424682 158.83892456549995" keyTimes="0;0.5;1"></animate>
8
+ </circle>
9
+ </svg>
10
+ </View>);
11
+ export { Spinner };
@@ -0,0 +1,9 @@
1
+ declare const style: {
2
+ container: {
3
+ display: "flex";
4
+ flex: number;
5
+ alignItems: "center";
6
+ justifyContent: "center";
7
+ };
8
+ };
9
+ export { style };
@@ -0,0 +1,10 @@
1
+ import { StyleSheet } from "react-native";
2
+ const style = StyleSheet.create({
3
+ container: {
4
+ display: "flex",
5
+ flex: 1,
6
+ alignItems: "center",
7
+ justifyContent: "center",
8
+ },
9
+ });
10
+ export { style };
@@ -0,0 +1,8 @@
1
+ import { FC } from "react";
2
+ interface CheckoutAccessibilityMiddlewareProps {
3
+ readonly customerId: string | undefined;
4
+ readonly onNotAccessible: () => void;
5
+ readonly loader?: JSX.Element;
6
+ }
7
+ declare const CheckoutAccessibilityMiddleware: FC<CheckoutAccessibilityMiddlewareProps>;
8
+ export { CheckoutAccessibilityMiddleware };
@@ -0,0 +1,16 @@
1
+ import { useEffect, useRef } from "react";
2
+ import { Outlet } from "react-router-native";
3
+ import { useViewIsCheckoutAccessibleByCustomerId } from "../../projection/react/useViewIsCheckoutAccessibleByCustomerId";
4
+ import { Spinner } from "../components/atoms/spiner/Spinner";
5
+ const CheckoutAccessibilityMiddleware = ({ customerId, onNotAccessible, loader = <Spinner />, }) => {
6
+ const [accessible] = useViewIsCheckoutAccessibleByCustomerId({ customerId });
7
+ const onNotAccessibleRef = useRef(onNotAccessible);
8
+ onNotAccessibleRef.current = onNotAccessible;
9
+ useEffect(() => {
10
+ if (accessible === false) {
11
+ onNotAccessibleRef.current();
12
+ }
13
+ }, [accessible, onNotAccessible]);
14
+ return accessible === undefined ? loader : accessible ? <Outlet /> : null;
15
+ };
16
+ export { CheckoutAccessibilityMiddleware };
@@ -0,0 +1,7 @@
1
+ import { FC } from "react";
2
+ interface CheckoutMiddlewareProps {
3
+ readonly customerId: string;
4
+ readonly loader?: JSX.Element;
5
+ }
6
+ declare const CheckoutMiddleware: FC<CheckoutMiddlewareProps>;
7
+ export { CheckoutMiddleware };
@@ -0,0 +1,34 @@
1
+ import { QueryStatus } from "@lookiero/messaging-react";
2
+ import { generatePath, Navigate, Outlet, useMatch } from "react-router";
3
+ import { CheckoutItemStatus, } from "../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
4
+ import { useViewFirstAvailableCheckoutByCustomerId } from "../../projection/react/useViewFirstAvailableCheckoutByCustomerId";
5
+ import { useViewIsCheckoutIntroVisible } from "../../projection/react/useViewIsCheckoutIntroVisible";
6
+ import { Spinner } from "../components/atoms/spiner/Spinner";
7
+ import { Routes } from "./routes";
8
+ const CheckoutMiddleware = ({ customerId, loader = <Spinner /> }) => {
9
+ const [isIntroVisible, isIntroVisibleStatus] = useViewIsCheckoutIntroVisible();
10
+ const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
11
+ const firstItemWithoutCustomerDecision = checkout?.items.find((item) => [CheckoutItemStatus.EXPIRED, CheckoutItemStatus.INITIAL].includes(item.status));
12
+ const isIntroRoute = useMatch(Routes.INTRO);
13
+ const isItemRoute = useMatch(Routes.ITEM);
14
+ const isSummaryRoute = useMatch(Routes.SUMMARY);
15
+ const dependenciesLoaded = isIntroVisibleStatus === QueryStatus.SUCCESS && checkoutStatus === QueryStatus.SUCCESS;
16
+ if (!dependenciesLoaded) {
17
+ return loader;
18
+ }
19
+ if (isIntroVisible) {
20
+ if (!isIntroRoute) {
21
+ return <Navigate replace to={Routes.INTRO}/>;
22
+ }
23
+ }
24
+ else {
25
+ if (firstItemWithoutCustomerDecision && !isItemRoute) {
26
+ return <Navigate replace to={generatePath(Routes.ITEM, { id: firstItemWithoutCustomerDecision.id })}/>;
27
+ }
28
+ if (firstItemWithoutCustomerDecision === undefined && !isSummaryRoute) {
29
+ return <Navigate replace to={Routes.SUMMARY}/>;
30
+ }
31
+ }
32
+ return <Outlet />;
33
+ };
34
+ export { CheckoutMiddleware };
@@ -0,0 +1,7 @@
1
+ import { FC } from "react";
2
+ interface RoutingProps {
3
+ readonly customerId: string | undefined;
4
+ readonly onNotAccessible: () => void;
5
+ }
6
+ declare const Routing: FC<RoutingProps>;
7
+ export { Routing };
@@ -0,0 +1,49 @@
1
+ import { lazy, Suspense } from "react";
2
+ import { Navigate, useRoutes } from "react-router-native";
3
+ import { Spinner } from "../components/atoms/spiner/Spinner";
4
+ import { CheckoutAccessibilityMiddleware } from "./CheckoutAccessibilityMiddleware";
5
+ import { CheckoutMiddleware } from "./CheckoutMiddleware";
6
+ import { Routes } from "./routes";
7
+ const Intro = lazy(() => import("../views/intro/Intro").then((module) => ({ default: module.Intro })));
8
+ const Item = lazy(() => import("../views/item/Item").then((module) => ({ default: module.Item })));
9
+ const Summary = lazy(() => import("../views/summary/Summary").then((module) => ({ default: module.Summary })));
10
+ const Routing = ({ customerId, onNotAccessible }) => {
11
+ const routes = useRoutes([
12
+ {
13
+ path: Routes.CHECKOUT,
14
+ element: <CheckoutAccessibilityMiddleware customerId={customerId} onNotAccessible={onNotAccessible}/>,
15
+ children: [
16
+ {
17
+ path: Routes.CHECKOUT,
18
+ element: <CheckoutMiddleware customerId={customerId}/>,
19
+ children: [
20
+ {
21
+ path: Routes.INTRO,
22
+ element: (<Suspense fallback={<Spinner />}>
23
+ <Intro />
24
+ </Suspense>),
25
+ },
26
+ {
27
+ path: Routes.ITEM,
28
+ element: (<Suspense fallback={<Spinner />}>
29
+ <Item />
30
+ </Suspense>),
31
+ },
32
+ {
33
+ path: Routes.SUMMARY,
34
+ element: (<Suspense fallback={<Spinner />}>
35
+ <Summary />
36
+ </Suspense>),
37
+ },
38
+ ],
39
+ },
40
+ ],
41
+ },
42
+ {
43
+ path: "*",
44
+ element: <Navigate replace to={Routes.CHECKOUT}/>,
45
+ },
46
+ ]);
47
+ return routes;
48
+ };
49
+ export { Routing };
@@ -0,0 +1 @@
1
+ export { BrowserRouter as Router } from "react-router-dom";
@@ -0,0 +1 @@
1
+ export { BrowserRouter as Router } from "react-router-dom";
@@ -0,0 +1 @@
1
+ export { NativeRouter as Router } from "react-router-native";
@@ -0,0 +1 @@
1
+ export { NativeRouter as Router } from "react-router-native";
@@ -0,0 +1,6 @@
1
+ export declare enum Routes {
2
+ CHECKOUT = "/checkout",
3
+ INTRO = "/checkout/intro",
4
+ ITEM = "/checkout/item/:id",
5
+ SUMMARY = "/checkout/summary"
6
+ }
@@ -0,0 +1,7 @@
1
+ export var Routes;
2
+ (function (Routes) {
3
+ Routes["CHECKOUT"] = "/checkout";
4
+ Routes["INTRO"] = "/checkout/intro";
5
+ Routes["ITEM"] = "/checkout/item/:id";
6
+ Routes["SUMMARY"] = "/checkout/summary";
7
+ })(Routes || (Routes = {}));
@@ -0,0 +1,19 @@
1
+ import { ReactElement } from "react";
2
+ import { RenderAPI } from "@testing-library/react-native";
3
+ import { TranslationMessages } from "@lookiero/i18n/domain/translation/model/translationMessages";
4
+ import { MessagingRoot } from "@lookiero/messaging-react/bootstrap";
5
+ interface Viewport {
6
+ readonly height: number;
7
+ readonly width: number;
8
+ }
9
+ interface RenderArgs {
10
+ readonly locale?: string;
11
+ readonly viewport?: Viewport;
12
+ readonly messages?: TranslationMessages;
13
+ readonly messaging?: MessagingRoot;
14
+ }
15
+ interface RenderWithProvidersFunction {
16
+ (ui: ReactElement, args?: RenderArgs): RenderAPI;
17
+ }
18
+ declare const renderWithProviders: RenderWithProvidersFunction;
19
+ export { renderWithProviders as render };
@@ -0,0 +1,14 @@
1
+ import { Aurora } from "@lookiero/aurora-next/build/components/primitives/Aurora/Aurora";
2
+ import { Fragment } from "react";
3
+ import { render } from "@testing-library/react-native";
4
+ import { IntlProvider } from "react-intl";
5
+ const defaultViewport = { width: 1200, height: 800 };
6
+ const renderWrapper = ({ locale, viewport, messages = {}, messaging: Messaging = Fragment }) =>
7
+ // eslint-disable-next-line react/display-name, react/prop-types
8
+ ({ children }) => (<Aurora forceViewport={viewport}>
9
+ <IntlProvider messages={messages} locale={locale} onError={() => void 0}>
10
+ <Messaging>{children}</Messaging>
11
+ </IntlProvider>
12
+ </Aurora>);
13
+ const renderWithProviders = (ui, { locale, viewport, messages, messaging } = { locale: "en", viewport: defaultViewport }) => render(ui, { wrapper: renderWrapper({ locale, viewport, messages, messaging }) });
14
+ export { renderWithProviders as render };
@@ -0,0 +1,3 @@
1
+ import { FC } from "react";
2
+ declare const Intro: FC;
3
+ export { Intro };
@@ -0,0 +1,20 @@
1
+ import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
2
+ import { ReactIntl } from "@lookiero/i18n-react";
3
+ import { StyleSheet, View } from "react-native";
4
+ const Intro = () => {
5
+ const introText = ReactIntl.useI18nMessage({ id: "intro" });
6
+ return (<View style={styles.container}>
7
+ <Text heading={true} level={3}>
8
+ {introText}
9
+ </Text>
10
+ </View>);
11
+ };
12
+ const styles = StyleSheet.create({
13
+ container: {
14
+ flex: 1,
15
+ backgroundColor: "#fff",
16
+ alignItems: "center",
17
+ justifyContent: "center",
18
+ },
19
+ });
20
+ export { Intro };
@@ -0,0 +1,3 @@
1
+ import { FC } from "react";
2
+ declare const Item: FC;
3
+ export { Item };
@@ -0,0 +1,23 @@
1
+ import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
2
+ import { ReactIntl } from "@lookiero/i18n-react";
3
+ import { StyleSheet, View } from "react-native";
4
+ import { useParams } from "react-router-native";
5
+ const Item = () => {
6
+ const { id } = useParams();
7
+ const itemText = ReactIntl.useI18nMessage({ id: "item" });
8
+ return (<View style={styles.container}>
9
+ <Text heading={true} level={3}>
10
+ {itemText}
11
+ </Text>
12
+ <Text level={2}>{id}</Text>
13
+ </View>);
14
+ };
15
+ const styles = StyleSheet.create({
16
+ container: {
17
+ flex: 1,
18
+ backgroundColor: "#fff",
19
+ alignItems: "center",
20
+ justifyContent: "center",
21
+ },
22
+ });
23
+ export { Item };
@@ -0,0 +1,3 @@
1
+ import { FC } from "react";
2
+ declare const Summary: FC;
3
+ export { Summary };
@@ -0,0 +1,20 @@
1
+ import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
2
+ import { ReactIntl } from "@lookiero/i18n-react";
3
+ import { StyleSheet, View } from "react-native";
4
+ const Summary = () => {
5
+ const summaryText = ReactIntl.useI18nMessage({ id: "summary" });
6
+ return (<View style={styles.container}>
7
+ <Text heading={true} level={3}>
8
+ {summaryText}
9
+ </Text>
10
+ </View>);
11
+ };
12
+ const styles = StyleSheet.create({
13
+ container: {
14
+ flex: 1,
15
+ backgroundColor: "#fff",
16
+ alignItems: "center",
17
+ justifyContent: "center",
18
+ },
19
+ });
20
+ export { Summary };
@@ -0,0 +1,43 @@
1
+ import { Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
2
+ interface SizeFormat {
3
+ readonly format: string;
4
+ readonly length?: string;
5
+ readonly size: string;
6
+ }
7
+ interface Size {
8
+ readonly id: string;
9
+ readonly europe: SizeFormat;
10
+ readonly it: SizeFormat;
11
+ readonly lookiero: SizeFormat;
12
+ readonly uk: SizeFormat;
13
+ }
14
+ interface ProductVariant {
15
+ readonly id: string;
16
+ readonly size: Size;
17
+ }
18
+ interface BookedSizeReplaceableProductVariantsProjection {
19
+ readonly booking: string | null;
20
+ readonly productVariants: ProductVariant[];
21
+ }
22
+ declare const VIEW_BOOKED_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM = "view_booked_size_replaceable_product_variants_for_checkout_item";
23
+ interface ViewBookedSizeReplaceableProductVariantsForCheckoutItemPayload {
24
+ readonly checkoutItemId: string;
25
+ }
26
+ interface ViewBookedSizeReplaceableProductVariantsForCheckoutItem extends Query<typeof VIEW_BOOKED_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM>, ViewBookedSizeReplaceableProductVariantsForCheckoutItemPayload {
27
+ }
28
+ interface ViewBookedSizeReplaceableProductVariantsForCheckoutItemFunction {
29
+ (payload: ViewBookedSizeReplaceableProductVariantsForCheckoutItemPayload): ViewBookedSizeReplaceableProductVariantsForCheckoutItem;
30
+ }
31
+ declare const viewBookedSizeReplaceableProductVariantsForCheckoutItem: ViewBookedSizeReplaceableProductVariantsForCheckoutItemFunction;
32
+ declare type ViewBookedSizeReplaceableProductVariantsForCheckoutItemResult = BookedSizeReplaceableProductVariantsProjection | undefined;
33
+ interface BookedSizeReplaceableProductVariantsForCheckoutItemViewArgs {
34
+ readonly checkoutItemId: string;
35
+ }
36
+ interface BookedSizeReplaceableProductVariantsForCheckoutItemView {
37
+ (args: BookedSizeReplaceableProductVariantsForCheckoutItemViewArgs): Promise<ViewBookedSizeReplaceableProductVariantsForCheckoutItemResult>;
38
+ }
39
+ interface ViewBookedSizeReplaceableProductVariantsForCheckoutItemHandlerFunctionArgs extends QueryHandlerFunctionArgs {
40
+ readonly view: BookedSizeReplaceableProductVariantsForCheckoutItemView;
41
+ }
42
+ declare const viewBookedSizeReplaceableProductVariantsForCheckoutItemHandler: QueryHandlerFunction<ViewBookedSizeReplaceableProductVariantsForCheckoutItem, ViewBookedSizeReplaceableProductVariantsForCheckoutItemResult, ViewBookedSizeReplaceableProductVariantsForCheckoutItemHandlerFunctionArgs>;
43
+ export { Size, ProductVariant, BookedSizeReplaceableProductVariantsProjection, VIEW_BOOKED_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM, viewBookedSizeReplaceableProductVariantsForCheckoutItem, BookedSizeReplaceableProductVariantsForCheckoutItemView, viewBookedSizeReplaceableProductVariantsForCheckoutItemHandler, };
@@ -0,0 +1,8 @@
1
+ import { query } from "@lookiero/messaging";
2
+ const VIEW_BOOKED_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM = "view_booked_size_replaceable_product_variants_for_checkout_item";
3
+ const viewBookedSizeReplaceableProductVariantsForCheckoutItem = (payload) => ({
4
+ ...query({ name: VIEW_BOOKED_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM }),
5
+ ...payload,
6
+ });
7
+ const viewBookedSizeReplaceableProductVariantsForCheckoutItemHandler = ({ view }) => async ({ checkoutItemId }) => view({ checkoutItemId });
8
+ export { VIEW_BOOKED_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM, viewBookedSizeReplaceableProductVariantsForCheckoutItem, viewBookedSizeReplaceableProductVariantsForCheckoutItemHandler, };
@@ -0,0 +1,104 @@
1
+ import { Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
2
+ declare enum MediaPerspective {
3
+ BACK = "BACK",
4
+ BOTTOM_UP = "BOTTOM_UP",
5
+ COLLAGE = "COLLAGE",
6
+ DETAIL = "DETAIL",
7
+ FLAT_BACK = "FLAT_BACK",
8
+ FRONT = "FRONT",
9
+ FRONT_FAR = "FRONT_FAR",
10
+ LABEL = "LABEL",
11
+ MAIN = "MAIN",
12
+ MAIN_TRANSPARENT = "MAIN_TRANSPARENT",
13
+ OTHER = "OTHER",
14
+ SIDE = "SIDE"
15
+ }
16
+ interface MediaProjection {
17
+ readonly id: string;
18
+ readonly url: string;
19
+ readonly perspective: MediaPerspective;
20
+ }
21
+ declare enum Currency {
22
+ EUR = "EUR",
23
+ GBP = "GBP"
24
+ }
25
+ interface PriceProjection {
26
+ readonly amount: number;
27
+ readonly currency: Currency;
28
+ readonly discountedPrice?: {
29
+ readonly amount: number;
30
+ readonly percentage: number;
31
+ };
32
+ }
33
+ interface SizeProjection {
34
+ readonly id: string;
35
+ readonly lookiero: string;
36
+ readonly uk: string;
37
+ readonly it: string;
38
+ readonly europe: string;
39
+ readonly unique: boolean;
40
+ readonly visualOrder?: number;
41
+ }
42
+ interface ColorProjection {
43
+ readonly id: string;
44
+ readonly label: string;
45
+ }
46
+ interface CheckoutItemProductVariantProjection {
47
+ readonly id: string;
48
+ readonly media: MediaProjection[];
49
+ readonly brand: string;
50
+ readonly name: string;
51
+ readonly price: PriceProjection;
52
+ readonly size: SizeProjection;
53
+ readonly color: ColorProjection;
54
+ }
55
+ declare enum CheckoutItemStatus {
56
+ INITIAL = "INITIAL",
57
+ KEPT = "KEPT",
58
+ RETURNED = "RETURNED",
59
+ REPLACED = "REPLACED",
60
+ EXPIRED = "EXPIRED"
61
+ }
62
+ interface CheckoutItemProjection {
63
+ readonly id: string;
64
+ readonly status: CheckoutItemStatus;
65
+ readonly replacedFor?: string;
66
+ readonly productVariant: CheckoutItemProductVariantProjection;
67
+ }
68
+ declare enum CheckoutStatus {
69
+ AVAILABLE = "AVAILABLE",
70
+ NOTIFIED = "NOTIFIED",
71
+ STARTED = "STARTED",
72
+ COMPLETED = "COMPLETED"
73
+ }
74
+ interface CheckoutProjection {
75
+ readonly id: string;
76
+ readonly customerId: string;
77
+ readonly boxId: string;
78
+ readonly bookingId: string;
79
+ readonly status: CheckoutStatus;
80
+ readonly expiresOn: Date;
81
+ readonly items: CheckoutItemProjection[];
82
+ }
83
+ declare const VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID = "view_first_available_checkout_by_customer_id";
84
+ interface ViewFirstAvailableCheckoutByCustomerIdPayload {
85
+ readonly customerId: string;
86
+ }
87
+ interface ViewFirstAvailableCheckoutByCustomerId extends Query<typeof VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID>, ViewFirstAvailableCheckoutByCustomerIdPayload {
88
+ }
89
+ interface ViewFirstAvailableCheckoutByCustomerIdFunction {
90
+ (payload: ViewFirstAvailableCheckoutByCustomerIdPayload): ViewFirstAvailableCheckoutByCustomerId;
91
+ }
92
+ declare const viewFirstAvailableCheckoutByCustomerId: ViewFirstAvailableCheckoutByCustomerIdFunction;
93
+ declare type ViewFirstAvailableCheckoutByCustomerIdResult = CheckoutProjection | undefined;
94
+ interface FirstAvailableCheckoutByCustomerIdViewArgs {
95
+ readonly customerId: string;
96
+ }
97
+ interface FirstAvailableCheckoutByCustomerIdView {
98
+ (args: FirstAvailableCheckoutByCustomerIdViewArgs): Promise<ViewFirstAvailableCheckoutByCustomerIdResult>;
99
+ }
100
+ interface ViewFirstAvailableCheckoutByCustomerIdHandlerFunctionArgs extends QueryHandlerFunctionArgs {
101
+ readonly view: FirstAvailableCheckoutByCustomerIdView;
102
+ }
103
+ declare const viewFirstAvailableCheckoutByCustomerIdHandler: QueryHandlerFunction<ViewFirstAvailableCheckoutByCustomerId, ViewFirstAvailableCheckoutByCustomerIdResult, ViewFirstAvailableCheckoutByCustomerIdHandlerFunctionArgs>;
104
+ export { CheckoutProjection, CheckoutStatus, CheckoutItemProjection, CheckoutItemStatus, MediaPerspective, Currency, VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID, viewFirstAvailableCheckoutByCustomerId, FirstAvailableCheckoutByCustomerIdView, viewFirstAvailableCheckoutByCustomerIdHandler, };
@@ -0,0 +1,43 @@
1
+ import { query } from "@lookiero/messaging";
2
+ var MediaPerspective;
3
+ (function (MediaPerspective) {
4
+ MediaPerspective["BACK"] = "BACK";
5
+ MediaPerspective["BOTTOM_UP"] = "BOTTOM_UP";
6
+ MediaPerspective["COLLAGE"] = "COLLAGE";
7
+ MediaPerspective["DETAIL"] = "DETAIL";
8
+ MediaPerspective["FLAT_BACK"] = "FLAT_BACK";
9
+ MediaPerspective["FRONT"] = "FRONT";
10
+ MediaPerspective["FRONT_FAR"] = "FRONT_FAR";
11
+ MediaPerspective["LABEL"] = "LABEL";
12
+ MediaPerspective["MAIN"] = "MAIN";
13
+ MediaPerspective["MAIN_TRANSPARENT"] = "MAIN_TRANSPARENT";
14
+ MediaPerspective["OTHER"] = "OTHER";
15
+ MediaPerspective["SIDE"] = "SIDE";
16
+ })(MediaPerspective || (MediaPerspective = {}));
17
+ var Currency;
18
+ (function (Currency) {
19
+ Currency["EUR"] = "EUR";
20
+ Currency["GBP"] = "GBP";
21
+ })(Currency || (Currency = {}));
22
+ var CheckoutItemStatus;
23
+ (function (CheckoutItemStatus) {
24
+ CheckoutItemStatus["INITIAL"] = "INITIAL";
25
+ CheckoutItemStatus["KEPT"] = "KEPT";
26
+ CheckoutItemStatus["RETURNED"] = "RETURNED";
27
+ CheckoutItemStatus["REPLACED"] = "REPLACED";
28
+ CheckoutItemStatus["EXPIRED"] = "EXPIRED";
29
+ })(CheckoutItemStatus || (CheckoutItemStatus = {}));
30
+ var CheckoutStatus;
31
+ (function (CheckoutStatus) {
32
+ CheckoutStatus["AVAILABLE"] = "AVAILABLE";
33
+ CheckoutStatus["NOTIFIED"] = "NOTIFIED";
34
+ CheckoutStatus["STARTED"] = "STARTED";
35
+ CheckoutStatus["COMPLETED"] = "COMPLETED";
36
+ })(CheckoutStatus || (CheckoutStatus = {}));
37
+ const VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID = "view_first_available_checkout_by_customer_id";
38
+ const viewFirstAvailableCheckoutByCustomerId = (payload) => ({
39
+ ...query({ name: VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID }),
40
+ ...payload,
41
+ });
42
+ const viewFirstAvailableCheckoutByCustomerIdHandler = ({ view }) => async ({ customerId }) => view({ customerId });
43
+ export { CheckoutStatus, CheckoutItemStatus, MediaPerspective, Currency, VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID, viewFirstAvailableCheckoutByCustomerId, viewFirstAvailableCheckoutByCustomerIdHandler, };
@@ -0,0 +1,16 @@
1
+ import { Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
2
+ declare 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 { IsCheckoutAccessibleByCustomerIdProjection, VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, viewIsCheckoutAccessibleByCustomerId, viewIsCheckoutAccessibleByCustomerIdHandler, };
@@ -0,0 +1,13 @@
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, };
@@ -0,0 +1,23 @@
1
+ import { Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
2
+ declare type IsCheckoutEnabledByCustomerIdProjection = boolean;
3
+ declare const VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID = "view_is_checkout_enabled_by_customer_id";
4
+ interface ViewIsCheckoutEnabledByCustomerIdPayload {
5
+ readonly customerId: string;
6
+ }
7
+ interface ViewIsCheckoutEnabledByCustomerId extends Query<typeof VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID>, ViewIsCheckoutEnabledByCustomerIdPayload {
8
+ }
9
+ interface ViewIsCheckoutEnabledByCustomerIdFunction {
10
+ (payload: ViewIsCheckoutEnabledByCustomerIdPayload): ViewIsCheckoutEnabledByCustomerId;
11
+ }
12
+ declare const viewIsCheckoutEnabledByCustomerId: ViewIsCheckoutEnabledByCustomerIdFunction;
13
+ interface IsCheckoutEnabledByCustomerIdViewArgs {
14
+ readonly customerId: string;
15
+ }
16
+ interface IsCheckoutEnabledByCustomerIdView {
17
+ (args: IsCheckoutEnabledByCustomerIdViewArgs): Promise<IsCheckoutEnabledByCustomerIdProjection>;
18
+ }
19
+ interface ViewIsCheckoutEnabledByCustomerIdHandlerFunctionArgs extends QueryHandlerFunctionArgs {
20
+ readonly view: IsCheckoutEnabledByCustomerIdView;
21
+ }
22
+ declare const viewIsCheckoutEnabledByCustomerIdHandler: QueryHandlerFunction<ViewIsCheckoutEnabledByCustomerId, IsCheckoutEnabledByCustomerIdProjection, ViewIsCheckoutEnabledByCustomerIdHandlerFunctionArgs>;
23
+ export { IsCheckoutEnabledByCustomerIdProjection, VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID, viewIsCheckoutEnabledByCustomerId, IsCheckoutEnabledByCustomerIdView, viewIsCheckoutEnabledByCustomerIdHandler, };