@lookiero/checkout 0.1.1 → 0.2.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 (165) hide show
  1. package/dist/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.d.ts +4 -4
  2. package/dist/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.js +3 -2
  3. package/dist/domain/checkoutBooking/model/checkoutBooking.d.ts +3 -2
  4. package/dist/domain/checkoutBooking/model/checkoutBooking.js +2 -1
  5. package/dist/domain/checkoutBooking/model/checkoutBookingBooked.d.ts +4 -4
  6. package/dist/domain/checkoutBooking/model/checkoutBookingBooked.js +3 -2
  7. package/dist/domain/checkoutBooking/model/checkoutBookings.d.ts +3 -2
  8. package/dist/domain/uiSetting/command/updateUiSetting.d.ts +4 -4
  9. package/dist/domain/uiSetting/command/updateUiSetting.js +3 -2
  10. package/dist/domain/uiSetting/model/uiSetting.d.ts +3 -2
  11. package/dist/domain/uiSetting/model/uiSetting.js +2 -1
  12. package/dist/domain/uiSetting/model/uiSettingUpdated.d.ts +4 -4
  13. package/dist/domain/uiSetting/model/uiSettingUpdated.js +3 -2
  14. package/dist/domain/uiSetting/model/uiSettings.d.ts +3 -2
  15. package/dist/infrastructure/delivery/_mock/bootstrap.mock.js +2 -1
  16. package/dist/infrastructure/delivery/bootstrap.d.ts +2 -1
  17. package/dist/infrastructure/delivery/bootstrap.js +3 -2
  18. package/dist/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.d.ts +2 -2
  19. package/dist/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.js +2 -1
  20. package/dist/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.d.ts +2 -2
  21. package/dist/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.js +2 -1
  22. package/dist/infrastructure/domain/react/useSetCheckoutIntroShown.d.ts +13 -0
  23. package/dist/infrastructure/domain/react/useSetCheckoutIntroShown.js +9 -0
  24. package/dist/infrastructure/domain/react/useUpdateUiSetting.d.ts +2 -2
  25. package/dist/infrastructure/domain/react/useUpdateUiSetting.js +2 -1
  26. package/dist/infrastructure/domain/uiSetting/model/storageUiSettings.d.ts +3 -3
  27. package/dist/infrastructure/domain/uiSetting/model/storageUiSettings.js +3 -2
  28. package/dist/infrastructure/persistence/asyncStorageStorage.d.ts +3 -2
  29. package/dist/infrastructure/persistence/asyncStorageStorage.js +3 -2
  30. package/dist/infrastructure/persistence/storage.d.ts +3 -2
  31. package/dist/infrastructure/persistence/uiSettingData.d.ts +2 -1
  32. package/dist/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.js +2 -1
  33. package/dist/infrastructure/projection/react/useViewCheckoutIntroShown.d.ts +2 -0
  34. package/dist/infrastructure/projection/react/useViewCheckoutIntroShown.js +6 -0
  35. package/dist/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.js +2 -1
  36. package/dist/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.js +2 -1
  37. package/dist/infrastructure/projection/react/useViewUiSettingByKey.d.ts +3 -3
  38. package/dist/infrastructure/projection/react/useViewUiSettingByKey.js +9 -5
  39. package/dist/infrastructure/projection/storageUiSettingByKeyView.d.ts +2 -2
  40. package/dist/infrastructure/projection/storageUiSettingByKeyView.js +2 -1
  41. package/dist/infrastructure/ui/Root.js +8 -10
  42. package/dist/infrastructure/ui/components/atoms/spinner/Spinner.js +9 -0
  43. package/dist/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.js +4 -4
  44. package/dist/infrastructure/ui/routing/CheckoutMiddleware.js +13 -10
  45. package/dist/infrastructure/ui/routing/Routing.js +11 -14
  46. package/dist/infrastructure/ui/settings/UISettings.d.ts +4 -0
  47. package/dist/infrastructure/ui/settings/UISettings.js +5 -0
  48. package/dist/infrastructure/ui/views/intro/Intro.js +5 -7
  49. package/dist/infrastructure/ui/views/item/Item.js +6 -8
  50. package/dist/infrastructure/ui/views/summary/Summary.js +5 -7
  51. package/dist/projection/uiSetting/viewUiSettingByKey.d.ts +6 -6
  52. package/dist/projection/uiSetting/viewUiSettingByKey.js +4 -3
  53. package/package.json +6 -3
  54. package/.eslintignore +0 -7
  55. package/.eslintrc +0 -72
  56. package/.expo-shared/assets.json +0 -4
  57. package/.github/CODEOWNERS +0 -1
  58. package/.github/actions/version/action.yaml +0 -32
  59. package/.github/dependabot.yaml +0 -10
  60. package/.github/workflows/build.yaml +0 -71
  61. package/.github/workflows/publish.yaml +0 -52
  62. package/.husky/pre-commit +0 -4
  63. package/.husky/prepare-commit-msg +0 -26
  64. package/.husky/prepush +0 -12
  65. package/.lintstagedrc.json +0 -4
  66. package/.nvmrc +0 -1
  67. package/.prettierignore +0 -2
  68. package/.prettierrc.json +0 -6
  69. package/@types/aurora-next.d.ts +0 -1
  70. package/app.config.js +0 -4
  71. package/app.json +0 -31
  72. package/assets/adaptive-icon.png +0 -0
  73. package/assets/favicon.png +0 -0
  74. package/assets/icon.png +0 -0
  75. package/assets/splash.png +0 -0
  76. package/babel.config.js +0 -6
  77. package/dist/infrastructure/projection/react/useViewIsCheckoutIntroVisible.d.ts +0 -3
  78. package/dist/infrastructure/projection/react/useViewIsCheckoutIntroVisible.js +0 -3
  79. package/dist/infrastructure/ui/components/atoms/spiner/Spinner.js +0 -11
  80. package/dist/infrastructure/ui/test/render.d.ts +0 -19
  81. package/dist/infrastructure/ui/test/render.js +0 -14
  82. package/jest.config.js +0 -9
  83. package/jest.setup.js +0 -3
  84. package/src/Expo.tsx +0 -59
  85. package/src/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.test.ts +0 -26
  86. package/src/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.ts +0 -27
  87. package/src/domain/checkoutBooking/model/checkoutBooking.test.ts +0 -30
  88. package/src/domain/checkoutBooking/model/checkoutBooking.ts +0 -31
  89. package/src/domain/checkoutBooking/model/checkoutBookingBooked.test.ts +0 -23
  90. package/src/domain/checkoutBooking/model/checkoutBookingBooked.ts +0 -23
  91. package/src/domain/checkoutBooking/model/checkoutBookings.ts +0 -6
  92. package/src/domain/uiSetting/command/updateUiSetting.test.ts +0 -19
  93. package/src/domain/uiSetting/command/updateUiSetting.ts +0 -23
  94. package/src/domain/uiSetting/model/uiSetting.test.ts +0 -26
  95. package/src/domain/uiSetting/model/uiSetting.ts +0 -22
  96. package/src/domain/uiSetting/model/uiSettingUpdated.test.ts +0 -17
  97. package/src/domain/uiSetting/model/uiSettingUpdated.ts +0 -19
  98. package/src/domain/uiSetting/model/uiSettings.ts +0 -6
  99. package/src/index.ts +0 -44
  100. package/src/infrastructure/delivery/_mock/bootstrap.mock.ts +0 -38
  101. package/src/infrastructure/delivery/_mock/checkout.mock.ts +0 -81
  102. package/src/infrastructure/delivery/bootstrap.ts +0 -42
  103. package/src/infrastructure/delivery/http/fetchHttpClient.test.ts +0 -51
  104. package/src/infrastructure/delivery/http/fetchHttpClient.ts +0 -41
  105. package/src/infrastructure/delivery/http/httpClient.ts +0 -18
  106. package/src/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.test.ts +0 -45
  107. package/src/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.ts +0 -32
  108. package/src/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.test.ts +0 -38
  109. package/src/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.ts +0 -44
  110. package/src/infrastructure/domain/react/useUpdateUiSetting.test.ts +0 -31
  111. package/src/infrastructure/domain/react/useUpdateUiSetting.ts +0 -43
  112. package/src/infrastructure/domain/uiSetting/model/storageUiSettings.test.ts +0 -50
  113. package/src/infrastructure/domain/uiSetting/model/storageUiSettings.ts +0 -50
  114. package/src/infrastructure/persistence/asyncStorageStorage.ts +0 -12
  115. package/src/infrastructure/persistence/storage.ts +0 -7
  116. package/src/infrastructure/persistence/uiSettingData.ts +0 -5
  117. package/src/infrastructure/projection/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.test.ts +0 -65
  118. package/src/infrastructure/projection/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.ts +0 -102
  119. package/src/infrastructure/projection/httpFirstAvailableCheckoutByCustomerIdView.test.ts +0 -99
  120. package/src/infrastructure/projection/httpFirstAvailableCheckoutByCustomerIdView.ts +0 -128
  121. package/src/infrastructure/projection/httpIsCheckoutEnabledByCustomerIdView.test.ts +0 -32
  122. package/src/infrastructure/projection/httpIsCheckoutEnabledByCustomerIdView.ts +0 -27
  123. package/src/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.test.ts +0 -51
  124. package/src/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.ts +0 -25
  125. package/src/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.test.ts +0 -28
  126. package/src/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.ts +0 -22
  127. package/src/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.test.ts +0 -44
  128. package/src/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.ts +0 -24
  129. package/src/infrastructure/projection/react/useViewIsCheckoutIntroVisible.ts +0 -5
  130. package/src/infrastructure/projection/react/useViewUiSettingByKey.test.ts +0 -30
  131. package/src/infrastructure/projection/react/useViewUiSettingByKey.ts +0 -18
  132. package/src/infrastructure/projection/storageUiSettingByKeyView.test.ts +0 -32
  133. package/src/infrastructure/projection/storageUiSettingByKeyView.ts +0 -35
  134. package/src/infrastructure/ui/Root.tsx +0 -53
  135. package/src/infrastructure/ui/components/atoms/spiner/Spinner.style.ts +0 -12
  136. package/src/infrastructure/ui/components/atoms/spiner/Spinner.tsx +0 -35
  137. package/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.test.tsx +0 -70
  138. package/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.tsx +0 -31
  139. package/src/infrastructure/ui/routing/CheckoutMiddleware.test.tsx +0 -100
  140. package/src/infrastructure/ui/routing/CheckoutMiddleware.tsx +0 -52
  141. package/src/infrastructure/ui/routing/Routing.tsx +0 -64
  142. package/src/infrastructure/ui/routing/router/Router.native.ts +0 -1
  143. package/src/infrastructure/ui/routing/router/Router.ts +0 -1
  144. package/src/infrastructure/ui/routing/routes.ts +0 -6
  145. package/src/infrastructure/ui/test/render.tsx +0 -47
  146. package/src/infrastructure/ui/views/intro/Intro.test.tsx +0 -15
  147. package/src/infrastructure/ui/views/intro/Intro.tsx +0 -27
  148. package/src/infrastructure/ui/views/item/Item.tsx +0 -31
  149. package/src/infrastructure/ui/views/summary/Summary.tsx +0 -27
  150. package/src/projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem.test.ts +0 -40
  151. package/src/projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem.ts +0 -85
  152. package/src/projection/checkout/viewFirstAvailableCheckoutByCustomerId.test.ts +0 -22
  153. package/src/projection/checkout/viewFirstAvailableCheckoutByCustomerId.ts +0 -149
  154. package/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.test.ts +0 -54
  155. package/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.ts +0 -46
  156. package/src/projection/checkout/viewIsCheckoutEnabledByCustomerId.test.ts +0 -20
  157. package/src/projection/checkout/viewIsCheckoutEnabledByCustomerId.ts +0 -51
  158. package/src/projection/uiSetting/viewUiSettingByKey.test.ts +0 -22
  159. package/src/projection/uiSetting/viewUiSettingByKey.ts +0 -47
  160. package/tsconfig.build.json +0 -16
  161. package/tsconfig.json +0 -19
  162. package/webpack.config.js +0 -17
  163. /package/dist/infrastructure/ui/components/atoms/{spiner → spinner}/Spinner.d.ts +0 -0
  164. /package/dist/infrastructure/ui/components/atoms/{spiner → spinner}/Spinner.style.d.ts +0 -0
  165. /package/dist/infrastructure/ui/components/atoms/{spiner → spinner}/Spinner.style.js +0 -0
@@ -1,12 +0,0 @@
1
- import { StyleSheet } from "react-native";
2
-
3
- const style = StyleSheet.create({
4
- container: {
5
- display: "flex",
6
- flex: 1,
7
- alignItems: "center",
8
- justifyContent: "center",
9
- },
10
- });
11
-
12
- export { style };
@@ -1,35 +0,0 @@
1
- import { FC } from "react";
2
- import { View } from "react-native";
3
- import { style } from "./Spinner.style";
4
-
5
- const Spinner: FC = () => (
6
- <View style={style.container}>
7
- <svg
8
- xmlns="http://www.w3.org/2000/svg"
9
- width="30px"
10
- height="30px"
11
- viewBox="0 0 100 100"
12
- preserveAspectRatio="xMidYMid"
13
- >
14
- <circle cx="50" cy="50" r="32" stroke="#000000" strokeWidth="6" strokeLinecap="round" fill="none">
15
- <animateTransform
16
- attributeName="transform"
17
- type="rotate"
18
- repeatCount="indefinite"
19
- dur="1.5384615384615383s"
20
- values="0 50 50;180 50 50;720 50 50"
21
- keyTimes="0;0.5;1"
22
- ></animateTransform>
23
- <animate
24
- attributeName="stroke-dasharray"
25
- repeatCount="indefinite"
26
- dur="1.5384615384615383s"
27
- values="42.22300526424682 158.83892456549995;176.93449825017714 24.127431579569617;42.22300526424682 158.83892456549995"
28
- keyTimes="0;0.5;1"
29
- ></animate>
30
- </circle>
31
- </svg>
32
- </View>
33
- );
34
-
35
- export { Spinner };
@@ -1,70 +0,0 @@
1
- import { render, RenderResult } from "@testing-library/react-native";
2
- import { Text } from "react-native";
3
- import { MemoryRouter, Route, Routes } from "react-router-native";
4
- import { useViewIsCheckoutAccessibleByCustomerId } from "../../projection/react/useViewIsCheckoutAccessibleByCustomerId";
5
- import { CheckoutAccessibilityMiddleware } from "./CheckoutAccessibilityMiddleware";
6
-
7
- jest.mock("../../projection/react/useViewIsCheckoutAccessibleByCustomerId", () => ({
8
- useViewIsCheckoutAccessibleByCustomerId: jest.fn(),
9
- }));
10
-
11
- const customerId = "29790d24-b139-4ab8-b618-d796d101e974";
12
- const checkoutRouteText = "checkout-route-component";
13
- const loaderText = "loader-component";
14
-
15
- interface RenderCheckoutAccessibilityMiddlewareArgs {
16
- readonly onNotAccessible?: () => void;
17
- }
18
-
19
- interface RenderCheckoutAccessibilityMiddlewareFunction {
20
- (args?: RenderCheckoutAccessibilityMiddlewareArgs): RenderResult;
21
- }
22
-
23
- const renderCheckoutAccessibilityMiddleware: RenderCheckoutAccessibilityMiddlewareFunction = ({
24
- onNotAccessible = () => void 0,
25
- } = {}) =>
26
- render(
27
- <MemoryRouter initialEntries={["/"]}>
28
- <Routes>
29
- <Route
30
- path="/"
31
- element={
32
- <CheckoutAccessibilityMiddleware
33
- customerId={customerId}
34
- onNotAccessible={onNotAccessible}
35
- loader={<Text>{loaderText}</Text>}
36
- />
37
- }
38
- >
39
- <Route path="/" element={<Text>{checkoutRouteText}</Text>} />
40
- </Route>
41
- </Routes>
42
- </MemoryRouter>,
43
- );
44
-
45
- describe("CheckoutAccessibilityMiddleware component", () => {
46
- it("renders a loader while processing viewIsCheckoutAccessibleByCustomerId use-case", async () => {
47
- (useViewIsCheckoutAccessibleByCustomerId as jest.Mock).mockReturnValue([undefined, "loading"]);
48
- const { findByText } = renderCheckoutAccessibilityMiddleware();
49
- const loader = await findByText(loaderText);
50
-
51
- expect(loader).toBeTruthy();
52
- });
53
-
54
- it("renders its Outlet's content if it is accessible", async () => {
55
- (useViewIsCheckoutAccessibleByCustomerId as jest.Mock).mockReturnValue([true, "success"]);
56
- const { findByText } = renderCheckoutAccessibilityMiddleware();
57
- const checkoutContent = await findByText(checkoutRouteText);
58
-
59
- expect(checkoutContent).toBeTruthy();
60
- });
61
-
62
- it("calls onNotAccessible callback if it is not accessible", async () => {
63
- (useViewIsCheckoutAccessibleByCustomerId as jest.Mock).mockReturnValue([false, "success"]);
64
- const onNotAccessibleFn = jest.fn();
65
- const { toJSON } = renderCheckoutAccessibilityMiddleware({ onNotAccessible: onNotAccessibleFn });
66
-
67
- expect(toJSON()).toBeNull();
68
- expect(onNotAccessibleFn).toHaveBeenCalled();
69
- });
70
- });
@@ -1,31 +0,0 @@
1
- import { FC, 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
-
6
- interface CheckoutAccessibilityMiddlewareProps {
7
- readonly customerId: string | undefined;
8
- readonly onNotAccessible: () => void;
9
- readonly loader?: JSX.Element;
10
- }
11
-
12
- const CheckoutAccessibilityMiddleware: FC<CheckoutAccessibilityMiddlewareProps> = ({
13
- customerId,
14
- onNotAccessible,
15
- loader = <Spinner />,
16
- }) => {
17
- const [accessible] = useViewIsCheckoutAccessibleByCustomerId({ customerId });
18
-
19
- const onNotAccessibleRef = useRef(onNotAccessible);
20
- onNotAccessibleRef.current = onNotAccessible;
21
-
22
- useEffect(() => {
23
- if (accessible === false) {
24
- onNotAccessibleRef.current();
25
- }
26
- }, [accessible, onNotAccessible]);
27
-
28
- return accessible === undefined ? loader : accessible ? <Outlet /> : null;
29
- };
30
-
31
- export { CheckoutAccessibilityMiddleware };
@@ -1,100 +0,0 @@
1
- import { render, RenderResult } from "@testing-library/react-native";
2
- import { Text } from "react-native";
3
- import { generatePath, MemoryRouter, Route, Routes } from "react-router-native";
4
- import { v4 as uuid } from "uuid";
5
- import { CheckoutItemStatus } from "../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
6
- import { startedCheckoutWithItems } from "../../delivery/_mock/checkout.mock";
7
- import { useViewFirstAvailableCheckoutByCustomerId } from "../../projection/react/useViewFirstAvailableCheckoutByCustomerId";
8
- import { useViewIsCheckoutIntroVisible } from "../../projection/react/useViewIsCheckoutIntroVisible";
9
- import { CheckoutMiddleware } from "./CheckoutMiddleware";
10
-
11
- import { Routes as CheckoutRoutes } from "./routes";
12
-
13
- jest.mock("../../projection/react/useViewIsCheckoutIntroVisible", () => ({
14
- useViewIsCheckoutIntroVisible: jest.fn(),
15
- }));
16
- jest.mock("../../projection/react/useViewFirstAvailableCheckoutByCustomerId", () => ({
17
- useViewFirstAvailableCheckoutByCustomerId: jest.fn(),
18
- }));
19
-
20
- const customerId = "29790d24-b139-4ab8-b618-d796d101e974";
21
- const loaderText = "loader-component";
22
- const introRouteText = "intro-route-component";
23
- const itemRouteText = "item-route-component";
24
- const summaryRouteText = "summary-route-component";
25
-
26
- interface RenderCheckoutMiddlewareArgs {
27
- readonly route: string;
28
- }
29
-
30
- interface RenderCheckoutMiddlewareFunction {
31
- (args: RenderCheckoutMiddlewareArgs): RenderResult;
32
- }
33
-
34
- const renderCheckoutMiddleware: RenderCheckoutMiddlewareFunction = ({ route }) =>
35
- render(
36
- <MemoryRouter initialEntries={[route]}>
37
- <Routes>
38
- <Route
39
- path={CheckoutRoutes.CHECKOUT}
40
- element={<CheckoutMiddleware customerId={customerId} loader={<Text>{loaderText}</Text>} />}
41
- >
42
- <Route path={CheckoutRoutes.INTRO} element={<Text>{introRouteText}</Text>} />
43
- <Route path={CheckoutRoutes.ITEM} element={<Text>{itemRouteText}</Text>} />
44
- <Route path={CheckoutRoutes.SUMMARY} element={<Text>{summaryRouteText}</Text>} />
45
- </Route>
46
- </Routes>
47
- </MemoryRouter>,
48
- );
49
-
50
- const routes: string[] = [
51
- CheckoutRoutes.CHECKOUT,
52
- CheckoutRoutes.INTRO,
53
- generatePath(CheckoutRoutes.ITEM, { id: uuid() }),
54
- CheckoutRoutes.SUMMARY,
55
- ];
56
-
57
- describe("CheckoutMiddleware component", () => {
58
- test.each(routes)("renders a loader while processing dependant use-cases in route: %s", async (route) => {
59
- (useViewIsCheckoutIntroVisible as jest.Mock).mockReturnValue([undefined, "loading"]);
60
- (useViewFirstAvailableCheckoutByCustomerId as jest.Mock).mockReturnValue([undefined, "loading"]);
61
-
62
- const { findByText } = renderCheckoutMiddleware({ route });
63
- const loader = await findByText(loaderText);
64
-
65
- expect(loader).toBeTruthy();
66
- });
67
-
68
- test.each(routes)("renders the intro view if it should be visible with initial route: %s", async (route) => {
69
- const checkoutMock = startedCheckoutWithItems({ status: [CheckoutItemStatus.INITIAL, CheckoutItemStatus.INITIAL] });
70
- (useViewIsCheckoutIntroVisible as jest.Mock).mockReturnValue([true, "success"]);
71
- (useViewFirstAvailableCheckoutByCustomerId as jest.Mock).mockReturnValue([checkoutMock, "success"]);
72
-
73
- const { findByText } = renderCheckoutMiddleware({ route });
74
- const intro = await findByText(introRouteText);
75
-
76
- expect(intro).toBeTruthy();
77
- });
78
-
79
- test.each(routes)("renders the item view if it should be visible with initial route: %s", async (route) => {
80
- const checkoutMock = startedCheckoutWithItems({ status: [CheckoutItemStatus.KEPT, CheckoutItemStatus.INITIAL] });
81
- (useViewIsCheckoutIntroVisible as jest.Mock).mockReturnValue([false, "success"]);
82
- (useViewFirstAvailableCheckoutByCustomerId as jest.Mock).mockReturnValue([checkoutMock, "success"]);
83
-
84
- const { findByText } = renderCheckoutMiddleware({ route });
85
- const item = await findByText(itemRouteText);
86
-
87
- expect(item).toBeTruthy();
88
- });
89
-
90
- test.each(routes)("renders the summary view if it should be visible with initial route: %s", async (route) => {
91
- const checkoutMock = startedCheckoutWithItems({ status: [CheckoutItemStatus.KEPT, CheckoutItemStatus.RETURNED] });
92
- (useViewIsCheckoutIntroVisible as jest.Mock).mockReturnValue([false, "success"]);
93
- (useViewFirstAvailableCheckoutByCustomerId as jest.Mock).mockReturnValue([checkoutMock, "success"]);
94
-
95
- const { findByText } = renderCheckoutMiddleware({ route });
96
- const summary = await findByText(summaryRouteText);
97
-
98
- expect(summary).toBeTruthy();
99
- });
100
- });
@@ -1,52 +0,0 @@
1
- import { QueryStatus } from "@lookiero/messaging-react";
2
- import { FC } from "react";
3
- import { generatePath, Navigate, Outlet, useMatch } from "react-router";
4
- import {
5
- CheckoutItemProjection,
6
- CheckoutItemStatus,
7
- } from "../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
8
- import { useViewFirstAvailableCheckoutByCustomerId } from "../../projection/react/useViewFirstAvailableCheckoutByCustomerId";
9
- import { useViewIsCheckoutIntroVisible } from "../../projection/react/useViewIsCheckoutIntroVisible";
10
- import { Spinner } from "../components/atoms/spiner/Spinner";
11
- import { Routes } from "./routes";
12
-
13
- interface CheckoutMiddlewareProps {
14
- readonly customerId: string;
15
- readonly loader?: JSX.Element;
16
- }
17
-
18
- const CheckoutMiddleware: FC<CheckoutMiddlewareProps> = ({ customerId, loader = <Spinner /> }) => {
19
- const [isIntroVisible, isIntroVisibleStatus] = useViewIsCheckoutIntroVisible();
20
- const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
21
- const firstItemWithoutCustomerDecision: CheckoutItemProjection | undefined = checkout?.items.find((item) =>
22
- [CheckoutItemStatus.EXPIRED, CheckoutItemStatus.INITIAL].includes(item.status),
23
- );
24
-
25
- const isIntroRoute = useMatch(Routes.INTRO);
26
- const isItemRoute = useMatch(Routes.ITEM);
27
- const isSummaryRoute = useMatch(Routes.SUMMARY);
28
-
29
- const dependenciesLoaded = isIntroVisibleStatus === QueryStatus.SUCCESS && checkoutStatus === QueryStatus.SUCCESS;
30
-
31
- if (!dependenciesLoaded) {
32
- return loader;
33
- }
34
-
35
- if (isIntroVisible) {
36
- if (!isIntroRoute) {
37
- return <Navigate replace to={Routes.INTRO} />;
38
- }
39
- } else {
40
- if (firstItemWithoutCustomerDecision && !isItemRoute) {
41
- return <Navigate replace to={generatePath(Routes.ITEM, { id: firstItemWithoutCustomerDecision.id })} />;
42
- }
43
-
44
- if (firstItemWithoutCustomerDecision === undefined && !isSummaryRoute) {
45
- return <Navigate replace to={Routes.SUMMARY} />;
46
- }
47
- }
48
-
49
- return <Outlet />;
50
- };
51
-
52
- export { CheckoutMiddleware };
@@ -1,64 +0,0 @@
1
- import { FC, 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
-
8
- const Intro = lazy(() => import("../views/intro/Intro").then((module) => ({ default: module.Intro })));
9
- const Item = lazy(() => import("../views/item/Item").then((module) => ({ default: module.Item })));
10
- const Summary = lazy(() => import("../views/summary/Summary").then((module) => ({ default: module.Summary })));
11
-
12
- interface RoutingProps {
13
- readonly customerId: string | undefined;
14
- readonly onNotAccessible: () => void;
15
- }
16
-
17
- const Routing: FC<RoutingProps> = ({ customerId, onNotAccessible }) => {
18
- const routes = useRoutes([
19
- {
20
- path: Routes.CHECKOUT,
21
- element: <CheckoutAccessibilityMiddleware customerId={customerId} onNotAccessible={onNotAccessible} />,
22
- children: [
23
- {
24
- path: Routes.CHECKOUT,
25
- element: <CheckoutMiddleware customerId={customerId as string} />,
26
- children: [
27
- {
28
- path: Routes.INTRO,
29
- element: (
30
- <Suspense fallback={<Spinner />}>
31
- <Intro />
32
- </Suspense>
33
- ),
34
- },
35
- {
36
- path: Routes.ITEM,
37
- element: (
38
- <Suspense fallback={<Spinner />}>
39
- <Item />
40
- </Suspense>
41
- ),
42
- },
43
- {
44
- path: Routes.SUMMARY,
45
- element: (
46
- <Suspense fallback={<Spinner />}>
47
- <Summary />
48
- </Suspense>
49
- ),
50
- },
51
- ],
52
- },
53
- ],
54
- },
55
- {
56
- path: "*",
57
- element: <Navigate replace to={Routes.CHECKOUT} />,
58
- },
59
- ]);
60
-
61
- return routes;
62
- };
63
-
64
- export { Routing };
@@ -1 +0,0 @@
1
- export { NativeRouter as Router } from "react-router-native";
@@ -1 +0,0 @@
1
- export { BrowserRouter as Router } from "react-router-dom";
@@ -1,6 +0,0 @@
1
- export enum Routes {
2
- CHECKOUT = "/checkout",
3
- INTRO = "/checkout/intro",
4
- ITEM = "/checkout/item/:id",
5
- SUMMARY = "/checkout/summary",
6
- }
@@ -1,47 +0,0 @@
1
- import { Aurora } from "@lookiero/aurora-next/build/components/primitives/Aurora/Aurora";
2
- import { FC, Fragment, ReactElement } from "react";
3
- import { render, RenderAPI } from "@testing-library/react-native";
4
- import { IntlProvider } from "react-intl";
5
- import { TranslationMessages } from "@lookiero/i18n/domain/translation/model/translationMessages";
6
- import { MessagingRoot } from "@lookiero/messaging-react/bootstrap";
7
-
8
- interface Viewport {
9
- readonly height: number;
10
- readonly width: number;
11
- }
12
-
13
- const defaultViewport: Viewport = { width: 1200, height: 800 };
14
-
15
- interface RenderArgs {
16
- readonly locale?: string;
17
- readonly viewport?: Viewport;
18
- readonly messages?: TranslationMessages;
19
- readonly messaging?: MessagingRoot;
20
- }
21
-
22
- interface RenderWrapperFunction {
23
- (args: RenderArgs): FC<{ children: ReactElement }>;
24
- }
25
-
26
- const renderWrapper: RenderWrapperFunction =
27
- ({ locale, viewport, messages = {}, messaging: Messaging = Fragment }) =>
28
- // eslint-disable-next-line react/display-name, react/prop-types
29
- ({ children }) =>
30
- (
31
- <Aurora forceViewport={viewport}>
32
- <IntlProvider messages={messages} locale={locale as string} onError={() => void 0}>
33
- <Messaging>{children}</Messaging>
34
- </IntlProvider>
35
- </Aurora>
36
- );
37
-
38
- interface RenderWithProvidersFunction {
39
- (ui: ReactElement, args?: RenderArgs): RenderAPI;
40
- }
41
-
42
- const renderWithProviders: RenderWithProvidersFunction = (
43
- ui: ReactElement,
44
- { locale, viewport, messages, messaging } = { locale: "en", viewport: defaultViewport },
45
- ): RenderAPI => render(ui, { wrapper: renderWrapper({ locale, viewport, messages, messaging }) });
46
-
47
- export { renderWithProviders as render };
@@ -1,15 +0,0 @@
1
- import { screen } from "@testing-library/react-native";
2
- import { render } from "../../test/render";
3
- import { Intro } from "./Intro";
4
-
5
- const messages = { intro: "Intro text" };
6
-
7
- describe("Intro component", () => {
8
- it("renders Intro component", async () => {
9
- render(<Intro />, { messages });
10
-
11
- const text = await screen.findByText(messages.intro);
12
-
13
- expect(text).toBeTruthy();
14
- });
15
- });
@@ -1,27 +0,0 @@
1
- import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
2
- import { ReactIntl } from "@lookiero/i18n-react";
3
- import { FC } from "react";
4
- import { StyleSheet, View } from "react-native";
5
-
6
- const Intro: FC = () => {
7
- const introText = ReactIntl.useI18nMessage({ id: "intro" });
8
-
9
- return (
10
- <View style={styles.container}>
11
- <Text heading={true} level={3}>
12
- {introText}
13
- </Text>
14
- </View>
15
- );
16
- };
17
-
18
- const styles = StyleSheet.create({
19
- container: {
20
- flex: 1,
21
- backgroundColor: "#fff",
22
- alignItems: "center",
23
- justifyContent: "center",
24
- },
25
- });
26
-
27
- export { Intro };
@@ -1,31 +0,0 @@
1
- import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
2
- import { ReactIntl } from "@lookiero/i18n-react";
3
- import { FC } from "react";
4
- import { StyleSheet, View } from "react-native";
5
- import { useParams } from "react-router-native";
6
-
7
- const Item: FC = () => {
8
- const { id } = useParams();
9
-
10
- const itemText = ReactIntl.useI18nMessage({ id: "item" });
11
-
12
- return (
13
- <View style={styles.container}>
14
- <Text heading={true} level={3}>
15
- {itemText}
16
- </Text>
17
- <Text level={2}>{id}</Text>
18
- </View>
19
- );
20
- };
21
-
22
- const styles = StyleSheet.create({
23
- container: {
24
- flex: 1,
25
- backgroundColor: "#fff",
26
- alignItems: "center",
27
- justifyContent: "center",
28
- },
29
- });
30
-
31
- export { Item };
@@ -1,27 +0,0 @@
1
- import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
2
- import { ReactIntl } from "@lookiero/i18n-react";
3
- import { FC } from "react";
4
- import { StyleSheet, View } from "react-native";
5
-
6
- const Summary: FC = () => {
7
- const summaryText = ReactIntl.useI18nMessage({ id: "summary" });
8
-
9
- return (
10
- <View style={styles.container}>
11
- <Text heading={true} level={3}>
12
- {summaryText}
13
- </Text>
14
- </View>
15
- );
16
- };
17
-
18
- const styles = StyleSheet.create({
19
- container: {
20
- flex: 1,
21
- backgroundColor: "#fff",
22
- alignItems: "center",
23
- justifyContent: "center",
24
- },
25
- });
26
-
27
- export { Summary };
@@ -1,40 +0,0 @@
1
- import { QueryBus } from "@lookiero/messaging";
2
- import { mock } from "jest-mock-extended";
3
- import {
4
- BookedSizeReplaceableProductVariantsProjection,
5
- viewBookedSizeReplaceableProductVariantsForCheckoutItem,
6
- viewBookedSizeReplaceableProductVariantsForCheckoutItemHandler,
7
- } from "./viewBookedSizeReplaceableProductVariantsForCheckoutItem";
8
-
9
- const checkoutItemId = "6f720954-8039-4bed-9596-34fc5a02131b";
10
- const bookedSizeReplaceableProductVariants: BookedSizeReplaceableProductVariantsProjection = {
11
- booking: "b00e2c2d-7d9c-4808-88a4-e1c845ae6889",
12
- productVariants: [
13
- {
14
- id: "383fab95-56eb-4639-bb18-530ab792b4d3",
15
- size: {
16
- id: "4f8a26b8-8d2d-4012-b49a-7d2820095598",
17
- europe: { size: "36", format: "36" },
18
- lookiero: { size: "S", format: "S" },
19
- uk: { size: "8", format: "8" },
20
- it: { size: "M", format: "M" },
21
- },
22
- },
23
- ],
24
- };
25
- const queryBus = mock<QueryBus>();
26
-
27
- describe("viewBookedSizeReplaceableProductVariantsForCheckoutItem", () => {
28
- it("returns booked size replaceable product variants for checkout item", async () => {
29
- const query = viewBookedSizeReplaceableProductVariantsForCheckoutItem({ checkoutItemId });
30
- const view = jest.fn(() => Promise.resolve(bookedSizeReplaceableProductVariants));
31
-
32
- const bookedSizeReplaceableProductVariantsResult =
33
- await viewBookedSizeReplaceableProductVariantsForCheckoutItemHandler({
34
- view,
35
- queryBus,
36
- })(query);
37
-
38
- expect(bookedSizeReplaceableProductVariantsResult).toBe(bookedSizeReplaceableProductVariants);
39
- });
40
- });
@@ -1,85 +0,0 @@
1
- import { query, Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
2
-
3
- interface SizeFormat {
4
- readonly format: string;
5
- readonly length?: string;
6
- readonly size: string;
7
- }
8
-
9
- interface Size {
10
- readonly id: string;
11
- readonly europe: SizeFormat;
12
- readonly it: SizeFormat;
13
- readonly lookiero: SizeFormat;
14
- readonly uk: SizeFormat;
15
- }
16
-
17
- interface ProductVariant {
18
- readonly id: string;
19
- readonly size: Size;
20
- }
21
-
22
- interface BookedSizeReplaceableProductVariantsProjection {
23
- readonly booking: string | null;
24
- readonly productVariants: ProductVariant[];
25
- }
26
-
27
- const VIEW_BOOKED_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM =
28
- "view_booked_size_replaceable_product_variants_for_checkout_item";
29
-
30
- interface ViewBookedSizeReplaceableProductVariantsForCheckoutItemPayload {
31
- readonly checkoutItemId: string;
32
- }
33
-
34
- interface ViewBookedSizeReplaceableProductVariantsForCheckoutItem
35
- extends Query<typeof VIEW_BOOKED_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM>,
36
- ViewBookedSizeReplaceableProductVariantsForCheckoutItemPayload {}
37
-
38
- interface ViewBookedSizeReplaceableProductVariantsForCheckoutItemFunction {
39
- (
40
- payload: ViewBookedSizeReplaceableProductVariantsForCheckoutItemPayload,
41
- ): ViewBookedSizeReplaceableProductVariantsForCheckoutItem;
42
- }
43
-
44
- const viewBookedSizeReplaceableProductVariantsForCheckoutItem: ViewBookedSizeReplaceableProductVariantsForCheckoutItemFunction =
45
- (payload) => ({
46
- ...query({ name: VIEW_BOOKED_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM }),
47
- ...payload,
48
- });
49
-
50
- type ViewBookedSizeReplaceableProductVariantsForCheckoutItemResult =
51
- | BookedSizeReplaceableProductVariantsProjection
52
- | undefined;
53
-
54
- interface BookedSizeReplaceableProductVariantsForCheckoutItemViewArgs {
55
- readonly checkoutItemId: string;
56
- }
57
-
58
- interface BookedSizeReplaceableProductVariantsForCheckoutItemView {
59
- (
60
- args: BookedSizeReplaceableProductVariantsForCheckoutItemViewArgs,
61
- ): Promise<ViewBookedSizeReplaceableProductVariantsForCheckoutItemResult>;
62
- }
63
-
64
- interface ViewBookedSizeReplaceableProductVariantsForCheckoutItemHandlerFunctionArgs extends QueryHandlerFunctionArgs {
65
- readonly view: BookedSizeReplaceableProductVariantsForCheckoutItemView;
66
- }
67
-
68
- const viewBookedSizeReplaceableProductVariantsForCheckoutItemHandler: QueryHandlerFunction<
69
- ViewBookedSizeReplaceableProductVariantsForCheckoutItem,
70
- ViewBookedSizeReplaceableProductVariantsForCheckoutItemResult,
71
- ViewBookedSizeReplaceableProductVariantsForCheckoutItemHandlerFunctionArgs
72
- > =
73
- ({ view }) =>
74
- async ({ checkoutItemId }) =>
75
- view({ checkoutItemId });
76
-
77
- export {
78
- Size,
79
- ProductVariant,
80
- BookedSizeReplaceableProductVariantsProjection,
81
- VIEW_BOOKED_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM,
82
- viewBookedSizeReplaceableProductVariantsForCheckoutItem,
83
- BookedSizeReplaceableProductVariantsForCheckoutItemView,
84
- viewBookedSizeReplaceableProductVariantsForCheckoutItemHandler,
85
- };