@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.
- package/.eslintignore +7 -0
- package/.eslintrc +72 -0
- package/.expo-shared/assets.json +4 -0
- package/.github/CODEOWNERS +1 -0
- package/.github/actions/version/action.yaml +32 -0
- package/.github/dependabot.yaml +10 -0
- package/.github/workflows/build.yaml +71 -0
- package/.github/workflows/publish.yaml +52 -0
- package/.husky/pre-commit +4 -0
- package/.husky/prepare-commit-msg +26 -0
- package/.husky/prepush +12 -0
- package/.lintstagedrc.json +4 -0
- package/.nvmrc +1 -0
- package/.prettierignore +2 -0
- package/.prettierrc.json +6 -0
- package/@types/aurora-next.d.ts +1 -0
- package/README.md +19 -0
- package/app.config.js +4 -0
- package/app.json +31 -0
- package/assets/adaptive-icon.png +0 -0
- package/assets/favicon.png +0 -0
- package/assets/icon.png +0 -0
- package/assets/splash.png +0 -0
- package/babel.config.js +6 -0
- package/dist/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.d.ts +15 -0
- package/dist/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.js +6 -0
- package/dist/domain/checkoutBooking/model/checkoutBooking.d.ts +8 -0
- package/dist/domain/checkoutBooking/model/checkoutBooking.js +16 -0
- package/dist/domain/checkoutBooking/model/checkoutBookingBooked.d.ts +15 -0
- package/dist/domain/checkoutBooking/model/checkoutBookingBooked.js +6 -0
- package/dist/domain/checkoutBooking/model/checkoutBookings.d.ts +6 -0
- package/dist/domain/checkoutBooking/model/checkoutBookings.js +1 -0
- package/dist/domain/uiSetting/command/updateUiSetting.d.ts +14 -0
- package/dist/domain/uiSetting/command/updateUiSetting.js +9 -0
- package/dist/domain/uiSetting/model/uiSetting.d.ts +8 -0
- package/dist/domain/uiSetting/model/uiSetting.js +10 -0
- package/dist/domain/uiSetting/model/uiSettingUpdated.d.ts +13 -0
- package/dist/domain/uiSetting/model/uiSettingUpdated.js +6 -0
- package/dist/domain/uiSetting/model/uiSettings.d.ts +6 -0
- package/dist/domain/uiSetting/model/uiSettings.js +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +13 -0
- package/dist/infrastructure/delivery/_mock/bootstrap.mock.d.ts +6 -0
- package/dist/infrastructure/delivery/_mock/bootstrap.mock.js +17 -0
- package/dist/infrastructure/delivery/_mock/checkout.mock.d.ts +9 -0
- package/dist/infrastructure/delivery/_mock/checkout.mock.js +45 -0
- package/dist/infrastructure/delivery/bootstrap.d.ts +10 -0
- package/dist/infrastructure/delivery/bootstrap.js +21 -0
- package/dist/infrastructure/delivery/http/fetchHttpClient.d.ts +14 -0
- package/dist/infrastructure/delivery/http/fetchHttpClient.js +18 -0
- package/dist/infrastructure/delivery/http/httpClient.d.ts +14 -0
- package/dist/infrastructure/delivery/http/httpClient.js +1 -0
- package/dist/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.d.ts +10 -0
- package/dist/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.js +19 -0
- package/dist/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.d.ts +15 -0
- package/dist/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.js +17 -0
- package/dist/infrastructure/domain/react/useUpdateUiSetting.d.ts +17 -0
- package/dist/infrastructure/domain/react/useUpdateUiSetting.js +16 -0
- package/dist/infrastructure/domain/uiSetting/model/storageUiSettings.d.ts +18 -0
- package/dist/infrastructure/domain/uiSetting/model/storageUiSettings.js +19 -0
- package/dist/infrastructure/persistence/asyncStorageStorage.d.ts +4 -0
- package/dist/infrastructure/persistence/asyncStorageStorage.js +6 -0
- package/dist/infrastructure/persistence/storage.d.ts +6 -0
- package/dist/infrastructure/persistence/storage.js +1 -0
- package/dist/infrastructure/persistence/uiSettingData.d.ts +5 -0
- package/dist/infrastructure/persistence/uiSettingData.js +1 -0
- package/dist/infrastructure/projection/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.d.ts +36 -0
- package/dist/infrastructure/projection/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.js +30 -0
- package/dist/infrastructure/projection/httpFirstAvailableCheckoutByCustomerIdView.d.ts +60 -0
- package/dist/infrastructure/projection/httpFirstAvailableCheckoutByCustomerIdView.js +54 -0
- package/dist/infrastructure/projection/httpIsCheckoutEnabledByCustomerIdView.d.ts +12 -0
- package/dist/infrastructure/projection/httpIsCheckoutEnabledByCustomerIdView.js +7 -0
- package/dist/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.d.ts +10 -0
- package/dist/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.js +8 -0
- package/dist/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.d.ts +10 -0
- package/dist/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.js +8 -0
- package/dist/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.d.ts +10 -0
- package/dist/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.js +8 -0
- package/dist/infrastructure/projection/react/useViewIsCheckoutIntroVisible.d.ts +3 -0
- package/dist/infrastructure/projection/react/useViewIsCheckoutIntroVisible.js +3 -0
- package/dist/infrastructure/projection/react/useViewUiSettingByKey.d.ts +10 -0
- package/dist/infrastructure/projection/react/useViewUiSettingByKey.js +8 -0
- package/dist/infrastructure/projection/storageUiSettingByKeyView.d.ts +13 -0
- package/dist/infrastructure/projection/storageUiSettingByKeyView.js +14 -0
- package/dist/infrastructure/ui/Root.d.ts +15 -0
- package/dist/infrastructure/ui/Root.js +25 -0
- package/dist/infrastructure/ui/components/atoms/spiner/Spinner.d.ts +3 -0
- package/dist/infrastructure/ui/components/atoms/spiner/Spinner.js +11 -0
- package/dist/infrastructure/ui/components/atoms/spiner/Spinner.style.d.ts +9 -0
- package/dist/infrastructure/ui/components/atoms/spiner/Spinner.style.js +10 -0
- package/dist/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.d.ts +8 -0
- package/dist/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.js +16 -0
- package/dist/infrastructure/ui/routing/CheckoutMiddleware.d.ts +7 -0
- package/dist/infrastructure/ui/routing/CheckoutMiddleware.js +34 -0
- package/dist/infrastructure/ui/routing/Routing.d.ts +7 -0
- package/dist/infrastructure/ui/routing/Routing.js +49 -0
- package/dist/infrastructure/ui/routing/router/Router.d.ts +1 -0
- package/dist/infrastructure/ui/routing/router/Router.js +1 -0
- package/dist/infrastructure/ui/routing/router/Router.native.d.ts +1 -0
- package/dist/infrastructure/ui/routing/router/Router.native.js +1 -0
- package/dist/infrastructure/ui/routing/routes.d.ts +6 -0
- package/dist/infrastructure/ui/routing/routes.js +7 -0
- package/dist/infrastructure/ui/test/render.d.ts +19 -0
- package/dist/infrastructure/ui/test/render.js +14 -0
- package/dist/infrastructure/ui/views/intro/Intro.d.ts +3 -0
- package/dist/infrastructure/ui/views/intro/Intro.js +20 -0
- package/dist/infrastructure/ui/views/item/Item.d.ts +3 -0
- package/dist/infrastructure/ui/views/item/Item.js +23 -0
- package/dist/infrastructure/ui/views/summary/Summary.d.ts +3 -0
- package/dist/infrastructure/ui/views/summary/Summary.js +20 -0
- package/dist/projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem.d.ts +43 -0
- package/dist/projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem.js +8 -0
- package/dist/projection/checkout/viewFirstAvailableCheckoutByCustomerId.d.ts +104 -0
- package/dist/projection/checkout/viewFirstAvailableCheckoutByCustomerId.js +43 -0
- package/dist/projection/checkout/viewIsCheckoutAccessibleByCustomerId.d.ts +16 -0
- package/dist/projection/checkout/viewIsCheckoutAccessibleByCustomerId.js +13 -0
- package/dist/projection/checkout/viewIsCheckoutEnabledByCustomerId.d.ts +23 -0
- package/dist/projection/checkout/viewIsCheckoutEnabledByCustomerId.js +8 -0
- package/dist/projection/uiSetting/viewUiSettingByKey.d.ts +28 -0
- package/dist/projection/uiSetting/viewUiSettingByKey.js +7 -0
- package/jest.config.js +9 -0
- package/jest.setup.js +3 -0
- package/package.json +75 -0
- package/src/Expo.tsx +59 -0
- package/src/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.test.ts +26 -0
- package/src/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.ts +27 -0
- package/src/domain/checkoutBooking/model/checkoutBooking.test.ts +30 -0
- package/src/domain/checkoutBooking/model/checkoutBooking.ts +31 -0
- package/src/domain/checkoutBooking/model/checkoutBookingBooked.test.ts +23 -0
- package/src/domain/checkoutBooking/model/checkoutBookingBooked.ts +23 -0
- package/src/domain/checkoutBooking/model/checkoutBookings.ts +6 -0
- package/src/domain/uiSetting/command/updateUiSetting.test.ts +19 -0
- package/src/domain/uiSetting/command/updateUiSetting.ts +23 -0
- package/src/domain/uiSetting/model/uiSetting.test.ts +26 -0
- package/src/domain/uiSetting/model/uiSetting.ts +22 -0
- package/src/domain/uiSetting/model/uiSettingUpdated.test.ts +17 -0
- package/src/domain/uiSetting/model/uiSettingUpdated.ts +19 -0
- package/src/domain/uiSetting/model/uiSettings.ts +6 -0
- package/src/index.ts +44 -0
- package/src/infrastructure/delivery/_mock/bootstrap.mock.ts +38 -0
- package/src/infrastructure/delivery/_mock/checkout.mock.ts +81 -0
- package/src/infrastructure/delivery/bootstrap.ts +42 -0
- package/src/infrastructure/delivery/http/fetchHttpClient.test.ts +51 -0
- package/src/infrastructure/delivery/http/fetchHttpClient.ts +41 -0
- package/src/infrastructure/delivery/http/httpClient.ts +18 -0
- package/src/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.test.ts +45 -0
- package/src/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.ts +32 -0
- package/src/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.test.ts +38 -0
- package/src/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.ts +44 -0
- package/src/infrastructure/domain/react/useUpdateUiSetting.test.ts +31 -0
- package/src/infrastructure/domain/react/useUpdateUiSetting.ts +43 -0
- package/src/infrastructure/domain/uiSetting/model/storageUiSettings.test.ts +50 -0
- package/src/infrastructure/domain/uiSetting/model/storageUiSettings.ts +50 -0
- package/src/infrastructure/persistence/asyncStorageStorage.ts +12 -0
- package/src/infrastructure/persistence/storage.ts +7 -0
- package/src/infrastructure/persistence/uiSettingData.ts +5 -0
- package/src/infrastructure/projection/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.test.ts +65 -0
- package/src/infrastructure/projection/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.ts +102 -0
- package/src/infrastructure/projection/httpFirstAvailableCheckoutByCustomerIdView.test.ts +99 -0
- package/src/infrastructure/projection/httpFirstAvailableCheckoutByCustomerIdView.ts +128 -0
- package/src/infrastructure/projection/httpIsCheckoutEnabledByCustomerIdView.test.ts +32 -0
- package/src/infrastructure/projection/httpIsCheckoutEnabledByCustomerIdView.ts +27 -0
- package/src/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.test.ts +51 -0
- package/src/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.ts +25 -0
- package/src/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.test.ts +28 -0
- package/src/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.ts +22 -0
- package/src/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.test.ts +44 -0
- package/src/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.ts +24 -0
- package/src/infrastructure/projection/react/useViewIsCheckoutIntroVisible.ts +5 -0
- package/src/infrastructure/projection/react/useViewUiSettingByKey.test.ts +30 -0
- package/src/infrastructure/projection/react/useViewUiSettingByKey.ts +18 -0
- package/src/infrastructure/projection/storageUiSettingByKeyView.test.ts +32 -0
- package/src/infrastructure/projection/storageUiSettingByKeyView.ts +35 -0
- package/src/infrastructure/ui/Root.tsx +53 -0
- package/src/infrastructure/ui/components/atoms/spiner/Spinner.style.ts +12 -0
- package/src/infrastructure/ui/components/atoms/spiner/Spinner.tsx +35 -0
- package/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.test.tsx +70 -0
- package/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.tsx +31 -0
- package/src/infrastructure/ui/routing/CheckoutMiddleware.test.tsx +100 -0
- package/src/infrastructure/ui/routing/CheckoutMiddleware.tsx +52 -0
- package/src/infrastructure/ui/routing/Routing.tsx +64 -0
- package/src/infrastructure/ui/routing/router/Router.native.ts +1 -0
- package/src/infrastructure/ui/routing/router/Router.ts +1 -0
- package/src/infrastructure/ui/routing/routes.ts +6 -0
- package/src/infrastructure/ui/test/render.tsx +47 -0
- package/src/infrastructure/ui/views/intro/Intro.test.tsx +15 -0
- package/src/infrastructure/ui/views/intro/Intro.tsx +27 -0
- package/src/infrastructure/ui/views/item/Item.tsx +31 -0
- package/src/infrastructure/ui/views/summary/Summary.tsx +27 -0
- package/src/projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem.test.ts +40 -0
- package/src/projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem.ts +85 -0
- package/src/projection/checkout/viewFirstAvailableCheckoutByCustomerId.test.ts +22 -0
- package/src/projection/checkout/viewFirstAvailableCheckoutByCustomerId.ts +149 -0
- package/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.test.ts +54 -0
- package/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.ts +46 -0
- package/src/projection/checkout/viewIsCheckoutEnabledByCustomerId.test.ts +20 -0
- package/src/projection/checkout/viewIsCheckoutEnabledByCustomerId.ts +51 -0
- package/src/projection/uiSetting/viewUiSettingByKey.test.ts +22 -0
- package/src/projection/uiSetting/viewUiSettingByKey.ts +47 -0
- package/tsconfig.build.json +16 -0
- package/tsconfig.json +19 -0
- package/webpack.config.js +17 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { UiSettingByKeyView, UiSettingProjection } from "../../projection/uiSetting/viewUiSettingByKey";
|
|
2
|
+
import { ReadFunction } from "../persistence/storage";
|
|
3
|
+
import { UiSettingDto } from "../persistence/uiSettingData";
|
|
4
|
+
|
|
5
|
+
interface ToUiSettingProjectionFunction {
|
|
6
|
+
(uiSettingDto: UiSettingDto): UiSettingProjection;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const toUiSettingProjection: ToUiSettingProjectionFunction = (uiSettingDto) => ({
|
|
10
|
+
id: uiSettingDto.id,
|
|
11
|
+
key: uiSettingDto.key,
|
|
12
|
+
value: uiSettingDto.value,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
interface StorageUiSettingByKeyView extends UiSettingByKeyView {}
|
|
16
|
+
|
|
17
|
+
interface StorageUiSettingByKeyViewFunctionArgs {
|
|
18
|
+
readonly read: ReadFunction<UiSettingDto>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface StorageUiSettingByKeyViewFunction {
|
|
22
|
+
(args: StorageUiSettingByKeyViewFunctionArgs): StorageUiSettingByKeyView;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const storageUiSettingByKeyView: StorageUiSettingByKeyViewFunction =
|
|
26
|
+
({ read }) =>
|
|
27
|
+
async ({ key }) => {
|
|
28
|
+
try {
|
|
29
|
+
const uiSettingDto = await read(key);
|
|
30
|
+
|
|
31
|
+
return uiSettingDto ? toUiSettingProjection(uiSettingDto) : undefined;
|
|
32
|
+
} catch (ignored) {
|
|
33
|
+
throw new Error("Could not fetch the uiSetting");
|
|
34
|
+
}
|
|
35
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { inMemoryFetchTranslation } from "@lookiero/i18n";
|
|
2
|
+
import { ReactIntl } from "@lookiero/i18n-react";
|
|
3
|
+
import { MessagingRoot } from "@lookiero/messaging-react/bootstrap";
|
|
4
|
+
import { FC, useCallback } from "react";
|
|
5
|
+
import { Platform } from "react-native";
|
|
6
|
+
import { Spinner } from "./components/atoms/spiner/Spinner";
|
|
7
|
+
import { Router } from "./routing/router/Router";
|
|
8
|
+
import { Routing } from "./routing/Routing";
|
|
9
|
+
|
|
10
|
+
const translationData: Record<string, Record<string, string>> = {
|
|
11
|
+
en: { intro: "Intro view's title" },
|
|
12
|
+
es: { intro: "Título de la vista Intro" },
|
|
13
|
+
};
|
|
14
|
+
const fetchTranslation = inMemoryFetchTranslation({ translationData });
|
|
15
|
+
|
|
16
|
+
interface RootFunctionArgs {
|
|
17
|
+
readonly Messaging: MessagingRoot;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface RootFunction {
|
|
21
|
+
(args: RootFunctionArgs): FC<RootProps>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface RootProps {
|
|
25
|
+
readonly locale?: string;
|
|
26
|
+
readonly customerId: string | undefined;
|
|
27
|
+
readonly onNotAccessible: () => void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const root: RootFunction =
|
|
31
|
+
({ Messaging }) =>
|
|
32
|
+
// eslint-disable-next-line react/display-name, react/prop-types
|
|
33
|
+
({ locale = "en", customerId, onNotAccessible }) => {
|
|
34
|
+
const handleOnI18nError = useCallback(() => void 0, []);
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<ReactIntl.I18n
|
|
38
|
+
locale={locale}
|
|
39
|
+
fetchTranslation={fetchTranslation}
|
|
40
|
+
loader={<Spinner />}
|
|
41
|
+
onError={handleOnI18nError}
|
|
42
|
+
contextId="CheckoutI18n"
|
|
43
|
+
>
|
|
44
|
+
<Messaging includeReactQueryDevTools={Platform.OS === "web"}>
|
|
45
|
+
<Router>
|
|
46
|
+
<Routing customerId={customerId} onNotAccessible={onNotAccessible} />
|
|
47
|
+
</Router>
|
|
48
|
+
</Messaging>
|
|
49
|
+
</ReactIntl.I18n>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { RootProps, root };
|
|
@@ -0,0 +1,35 @@
|
|
|
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 };
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
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 };
|
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
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 };
|
|
@@ -0,0 +1,64 @@
|
|
|
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 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NativeRouter as Router } from "react-router-native";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BrowserRouter as Router } from "react-router-dom";
|
|
@@ -0,0 +1,47 @@
|
|
|
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 };
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
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 };
|
|
@@ -0,0 +1,31 @@
|
|
|
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 };
|
|
@@ -0,0 +1,27 @@
|
|
|
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 };
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
});
|