@lookiero/checkout 0.1.2 â 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.
- package/dist/infrastructure/delivery/_mock/bootstrap.mock.js +2 -1
- package/dist/infrastructure/delivery/bootstrap.d.ts +2 -1
- package/dist/infrastructure/delivery/bootstrap.js +3 -2
- package/dist/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.js +2 -1
- package/dist/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.js +2 -1
- package/dist/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.js +2 -1
- package/dist/infrastructure/projection/react/useViewUiSettingByKey.js +3 -1
- package/dist/infrastructure/ui/Root.js +8 -10
- package/dist/infrastructure/ui/components/atoms/spinner/Spinner.js +9 -0
- package/dist/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.js +4 -4
- package/dist/infrastructure/ui/routing/CheckoutMiddleware.js +12 -9
- package/dist/infrastructure/ui/routing/Routing.js +11 -14
- package/dist/infrastructure/ui/views/intro/Intro.js +5 -7
- package/dist/infrastructure/ui/views/item/Item.js +6 -8
- package/dist/infrastructure/ui/views/summary/Summary.js +5 -7
- package/package.json +6 -3
- package/.eslintignore +0 -7
- package/.eslintrc +0 -72
- package/.expo-shared/assets.json +0 -4
- package/.github/CODEOWNERS +0 -1
- package/.github/actions/version/action.yaml +0 -32
- package/.github/dependabot.yaml +0 -10
- package/.github/workflows/build.yaml +0 -71
- package/.github/workflows/publish.yaml +0 -52
- package/.husky/pre-commit +0 -4
- package/.husky/prepare-commit-msg +0 -26
- package/.husky/prepush +0 -12
- package/.lintstagedrc.json +0 -4
- package/.nvmrc +0 -1
- package/.prettierignore +0 -2
- package/.prettierrc.json +0 -6
- package/@types/aurora-next.d.ts +0 -1
- package/app.config.js +0 -4
- package/app.json +0 -31
- 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 +0 -6
- package/dist/infrastructure/ui/components/atoms/spiner/Spinner.js +0 -11
- package/dist/infrastructure/ui/test/render.d.ts +0 -19
- package/dist/infrastructure/ui/test/render.js +0 -14
- package/jest.config.js +0 -9
- package/jest.setup.js +0 -3
- package/src/Expo.tsx +0 -59
- package/src/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.test.ts +0 -26
- package/src/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.ts +0 -35
- package/src/domain/checkoutBooking/model/checkoutBooking.test.ts +0 -30
- package/src/domain/checkoutBooking/model/checkoutBooking.ts +0 -33
- package/src/domain/checkoutBooking/model/checkoutBookingBooked.test.ts +0 -23
- package/src/domain/checkoutBooking/model/checkoutBookingBooked.ts +0 -23
- package/src/domain/checkoutBooking/model/checkoutBookings.ts +0 -8
- package/src/domain/uiSetting/command/updateUiSetting.test.ts +0 -19
- package/src/domain/uiSetting/command/updateUiSetting.ts +0 -25
- package/src/domain/uiSetting/model/uiSetting.test.ts +0 -26
- package/src/domain/uiSetting/model/uiSetting.ts +0 -24
- package/src/domain/uiSetting/model/uiSettingUpdated.test.ts +0 -17
- package/src/domain/uiSetting/model/uiSettingUpdated.ts +0 -21
- package/src/domain/uiSetting/model/uiSettings.ts +0 -8
- package/src/index.ts +0 -44
- package/src/infrastructure/delivery/_mock/bootstrap.mock.ts +0 -38
- package/src/infrastructure/delivery/_mock/checkout.mock.ts +0 -81
- package/src/infrastructure/delivery/bootstrap.ts +0 -42
- package/src/infrastructure/delivery/http/fetchHttpClient.test.ts +0 -51
- package/src/infrastructure/delivery/http/fetchHttpClient.ts +0 -41
- package/src/infrastructure/delivery/http/httpClient.ts +0 -18
- package/src/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.test.ts +0 -45
- package/src/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.ts +0 -34
- package/src/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.test.ts +0 -38
- package/src/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.ts +0 -46
- package/src/infrastructure/domain/react/useSetCheckoutIntroShown.test.ts +0 -34
- package/src/infrastructure/domain/react/useSetCheckoutIntroShown.ts +0 -30
- package/src/infrastructure/domain/react/useUpdateUiSetting.test.ts +0 -31
- package/src/infrastructure/domain/react/useUpdateUiSetting.ts +0 -45
- package/src/infrastructure/domain/uiSetting/model/storageUiSettings.test.ts +0 -50
- package/src/infrastructure/domain/uiSetting/model/storageUiSettings.ts +0 -52
- package/src/infrastructure/persistence/asyncStorageStorage.ts +0 -13
- package/src/infrastructure/persistence/storage.ts +0 -9
- package/src/infrastructure/persistence/uiSettingData.ts +0 -7
- package/src/infrastructure/projection/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.test.ts +0 -65
- package/src/infrastructure/projection/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.ts +0 -102
- package/src/infrastructure/projection/httpFirstAvailableCheckoutByCustomerIdView.test.ts +0 -99
- package/src/infrastructure/projection/httpFirstAvailableCheckoutByCustomerIdView.ts +0 -128
- package/src/infrastructure/projection/httpIsCheckoutEnabledByCustomerIdView.test.ts +0 -32
- package/src/infrastructure/projection/httpIsCheckoutEnabledByCustomerIdView.ts +0 -27
- package/src/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.test.ts +0 -51
- package/src/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.ts +0 -25
- package/src/infrastructure/projection/react/useViewCheckoutIntroShown.test.ts +0 -41
- package/src/infrastructure/projection/react/useViewCheckoutIntroShown.ts +0 -9
- package/src/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.test.ts +0 -28
- package/src/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.ts +0 -22
- package/src/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.test.ts +0 -44
- package/src/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.ts +0 -24
- package/src/infrastructure/projection/react/useViewUiSettingByKey.test.ts +0 -30
- package/src/infrastructure/projection/react/useViewUiSettingByKey.ts +0 -24
- package/src/infrastructure/projection/storageUiSettingByKeyView.test.ts +0 -32
- package/src/infrastructure/projection/storageUiSettingByKeyView.ts +0 -37
- package/src/infrastructure/ui/Root.tsx +0 -53
- package/src/infrastructure/ui/components/atoms/spiner/Spinner.style.ts +0 -12
- package/src/infrastructure/ui/components/atoms/spiner/Spinner.tsx +0 -35
- package/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.test.tsx +0 -70
- package/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.tsx +0 -31
- package/src/infrastructure/ui/routing/CheckoutMiddleware.test.tsx +0 -100
- package/src/infrastructure/ui/routing/CheckoutMiddleware.tsx +0 -52
- package/src/infrastructure/ui/routing/Routing.tsx +0 -64
- package/src/infrastructure/ui/routing/router/Router.native.ts +0 -1
- package/src/infrastructure/ui/routing/router/Router.ts +0 -1
- package/src/infrastructure/ui/routing/routes.ts +0 -6
- package/src/infrastructure/ui/settings/UISettings.ts +0 -5
- package/src/infrastructure/ui/test/render.tsx +0 -47
- package/src/infrastructure/ui/views/intro/Intro.test.tsx +0 -15
- package/src/infrastructure/ui/views/intro/Intro.tsx +0 -27
- package/src/infrastructure/ui/views/item/Item.tsx +0 -31
- package/src/infrastructure/ui/views/summary/Summary.tsx +0 -27
- package/src/projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem.test.ts +0 -40
- package/src/projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem.ts +0 -85
- package/src/projection/checkout/viewFirstAvailableCheckoutByCustomerId.test.ts +0 -22
- package/src/projection/checkout/viewFirstAvailableCheckoutByCustomerId.ts +0 -149
- package/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.test.ts +0 -54
- package/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.ts +0 -46
- package/src/projection/checkout/viewIsCheckoutEnabledByCustomerId.test.ts +0 -20
- package/src/projection/checkout/viewIsCheckoutEnabledByCustomerId.ts +0 -51
- package/src/projection/uiSetting/viewUiSettingByKey.test.ts +0 -22
- package/src/projection/uiSetting/viewUiSettingByKey.ts +0 -55
- package/tsconfig.build.json +0 -16
- package/tsconfig.json +0 -19
- package/webpack.config.js +0 -17
- /package/dist/infrastructure/ui/components/atoms/{spiner â spinner}/Spinner.d.ts +0 -0
- /package/dist/infrastructure/ui/components/atoms/{spiner â spinner}/Spinner.style.d.ts +0 -0
- /package/dist/infrastructure/ui/components/atoms/{spiner â spinner}/Spinner.style.js +0 -0
|
@@ -2,10 +2,11 @@ import { bootstrap as messagingBootstrap } from "@lookiero/messaging-react";
|
|
|
2
2
|
import { CheckoutItemStatus, viewFirstAvailableCheckoutByCustomerIdHandler, VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID, } from "../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
|
|
3
3
|
import { viewIsCheckoutAccessibleByCustomerIdHandler, VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, } from "../../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
|
|
4
4
|
import { viewIsCheckoutEnabledByCustomerIdHandler, VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID, } from "../../../projection/checkout/viewIsCheckoutEnabledByCustomerId";
|
|
5
|
+
import { CHECKOUT_MESSAGING_REACT_ID } from "../bootstrap";
|
|
5
6
|
import { startedCheckoutWithItems } from "./checkout.mock";
|
|
6
7
|
const firstAvailableCheckoutByCustomerIdView = async () => startedCheckoutWithItems({ status: [CheckoutItemStatus.KEPT, CheckoutItemStatus.INITIAL] });
|
|
7
8
|
const isCheckoutEnabledByCustomerIdView = async () => true;
|
|
8
|
-
const bootstrap = () => messagingBootstrap({ id:
|
|
9
|
+
const bootstrap = () => messagingBootstrap({ id: CHECKOUT_MESSAGING_REACT_ID })
|
|
9
10
|
.query(VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID, viewFirstAvailableCheckoutByCustomerIdHandler, {
|
|
10
11
|
view: firstAvailableCheckoutByCustomerIdView,
|
|
11
12
|
})
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BuildBootstrapFunctionReturn } from "@lookiero/messaging-react";
|
|
2
|
+
declare const CHECKOUT_MESSAGING_REACT_ID = "Checkout";
|
|
2
3
|
interface BootstrapFunctionArgs {
|
|
3
4
|
readonly getAuthToken: () => string;
|
|
4
5
|
readonly apiUrl: string;
|
|
@@ -7,4 +8,4 @@ interface BootstrapFunction {
|
|
|
7
8
|
(args: BootstrapFunctionArgs): BuildBootstrapFunctionReturn;
|
|
8
9
|
}
|
|
9
10
|
declare const bootstrap: BootstrapFunction;
|
|
10
|
-
export { bootstrap };
|
|
11
|
+
export { bootstrap, CHECKOUT_MESSAGING_REACT_ID };
|
|
@@ -5,10 +5,11 @@ import { viewIsCheckoutEnabledByCustomerIdHandler, VIEW_IS_CHECKOUT_ENABLED_BY_C
|
|
|
5
5
|
import { httpFirstAvailableCheckoutByCustomerIdView } from "../projection/httpFirstAvailableCheckoutByCustomerIdView";
|
|
6
6
|
import { httpIsCheckoutEnabledByCustomerIdView } from "../projection/httpIsCheckoutEnabledByCustomerIdView";
|
|
7
7
|
import { fetchHttpGet, fetchHttpPost } from "./http/fetchHttpClient";
|
|
8
|
+
const CHECKOUT_MESSAGING_REACT_ID = "Checkout";
|
|
8
9
|
const bootstrap = ({ apiUrl, getAuthToken }) => {
|
|
9
10
|
const httpGet = fetchHttpGet({ apiUrl, getAuthToken });
|
|
10
11
|
const httpPost = fetchHttpPost({ apiUrl, getAuthToken });
|
|
11
|
-
return messagingBootstrap({ id:
|
|
12
|
+
return messagingBootstrap({ id: CHECKOUT_MESSAGING_REACT_ID })
|
|
12
13
|
.query(VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID, viewFirstAvailableCheckoutByCustomerIdHandler, {
|
|
13
14
|
view: httpFirstAvailableCheckoutByCustomerIdView({ httpPost }),
|
|
14
15
|
})
|
|
@@ -18,4 +19,4 @@ const bootstrap = ({ apiUrl, getAuthToken }) => {
|
|
|
18
19
|
.query(VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, viewIsCheckoutAccessibleByCustomerIdHandler, {})
|
|
19
20
|
.build();
|
|
20
21
|
};
|
|
21
|
-
export { bootstrap };
|
|
22
|
+
export { bootstrap, CHECKOUT_MESSAGING_REACT_ID };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { useQuery } from "@lookiero/messaging-react";
|
|
2
2
|
import { viewBookedSizeReplaceableProductVariantsForCheckoutItem, } from "../../../projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem";
|
|
3
|
+
import { CHECKOUT_MESSAGING_REACT_ID } from "../../delivery/bootstrap";
|
|
3
4
|
const useViewBookedSizeReplaceableProductVariantsForCheckoutItem = ({ checkoutItemId }) => useQuery({
|
|
4
5
|
query: viewBookedSizeReplaceableProductVariantsForCheckoutItem({ checkoutItemId }),
|
|
5
|
-
contextId:
|
|
6
|
+
contextId: CHECKOUT_MESSAGING_REACT_ID,
|
|
6
7
|
options: { staleTime: Infinity },
|
|
7
8
|
});
|
|
8
9
|
export { useViewBookedSizeReplaceableProductVariantsForCheckoutItem };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { useQuery } from "@lookiero/messaging-react";
|
|
2
2
|
import { viewFirstAvailableCheckoutByCustomerId, } from "../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
|
|
3
|
+
import { CHECKOUT_MESSAGING_REACT_ID } from "../../delivery/bootstrap";
|
|
3
4
|
const useViewFirstAvailableCheckoutByCustomerId = ({ customerId }) => useQuery({
|
|
4
5
|
query: viewFirstAvailableCheckoutByCustomerId({ customerId }),
|
|
5
|
-
contextId:
|
|
6
|
+
contextId: CHECKOUT_MESSAGING_REACT_ID,
|
|
6
7
|
options: { staleTime: Infinity, retry: false },
|
|
7
8
|
});
|
|
8
9
|
export { useViewFirstAvailableCheckoutByCustomerId };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { useQuery } from "@lookiero/messaging-react";
|
|
2
2
|
import { viewIsCheckoutAccessibleByCustomerId, } from "../../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
|
|
3
|
+
import { CHECKOUT_MESSAGING_REACT_ID } from "../../delivery/bootstrap";
|
|
3
4
|
const useViewIsCheckoutAccessibleByCustomerId = ({ customerId }) => useQuery({
|
|
4
5
|
query: viewIsCheckoutAccessibleByCustomerId({ customerId }),
|
|
5
|
-
contextId:
|
|
6
|
+
contextId: CHECKOUT_MESSAGING_REACT_ID,
|
|
6
7
|
options: { staleTime: Infinity },
|
|
7
8
|
});
|
|
8
9
|
export { useViewIsCheckoutAccessibleByCustomerId };
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { useQuery } from "@lookiero/messaging-react";
|
|
2
2
|
import { UI_SETTING_UPDATED } from "../../../domain/uiSetting/model/uiSettingUpdated";
|
|
3
3
|
import { viewUiSettingByKey } from "../../../projection/uiSetting/viewUiSettingByKey";
|
|
4
|
+
import { CHECKOUT_MESSAGING_REACT_ID } from "../../delivery/bootstrap";
|
|
4
5
|
const isUiSettingUpdated = (event) => event.name === UI_SETTING_UPDATED;
|
|
5
6
|
const useViewUiSettingByKey = ({ key }) => useQuery({
|
|
6
7
|
query: viewUiSettingByKey({ key }),
|
|
8
|
+
contextId: CHECKOUT_MESSAGING_REACT_ID,
|
|
7
9
|
invalidation: isUiSettingUpdated,
|
|
8
|
-
options: { staleTime: Infinity },
|
|
10
|
+
options: { staleTime: Infinity, retry: false },
|
|
9
11
|
});
|
|
10
12
|
export { useViewUiSettingByKey };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { inMemoryFetchTranslation } from "@lookiero/i18n";
|
|
2
|
-
import {
|
|
3
|
-
import { useCallback } from "react";
|
|
2
|
+
import { i18n } from "@lookiero/i18n-react";
|
|
3
|
+
import React, { useCallback } from "react";
|
|
4
4
|
import { Platform } from "react-native";
|
|
5
|
-
import { Spinner } from "./components/atoms/
|
|
5
|
+
import { Spinner } from "./components/atoms/spinner/Spinner";
|
|
6
6
|
import { Router } from "./routing/router/Router";
|
|
7
7
|
import { Routing } from "./routing/Routing";
|
|
8
8
|
const translationData = {
|
|
@@ -10,16 +10,14 @@ const translationData = {
|
|
|
10
10
|
es: { intro: "TĂtulo de la vista Intro" },
|
|
11
11
|
};
|
|
12
12
|
const fetchTranslation = inMemoryFetchTranslation({ translationData });
|
|
13
|
+
const I18n = i18n({ fetchTranslation, contextId: "CheckoutI18n" });
|
|
13
14
|
const root = ({ Messaging }) =>
|
|
14
15
|
// eslint-disable-next-line react/display-name, react/prop-types
|
|
15
16
|
({ locale = "en", customerId, onNotAccessible }) => {
|
|
16
17
|
const handleOnI18nError = useCallback(() => void 0, []);
|
|
17
|
-
return (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
</Router>
|
|
22
|
-
</Messaging>
|
|
23
|
-
</ReactIntl.I18n>);
|
|
18
|
+
return (React.createElement(I18n, { locale: locale, loader: React.createElement(Spinner, null), onError: handleOnI18nError },
|
|
19
|
+
React.createElement(Messaging, { includeReactQueryDevTools: Platform.OS === "web" },
|
|
20
|
+
React.createElement(Router, null,
|
|
21
|
+
React.createElement(Routing, { customerId: customerId, onNotAccessible: onNotAccessible })))));
|
|
24
22
|
};
|
|
25
23
|
export { root };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import { style } from "./Spinner.style";
|
|
4
|
+
const Spinner = () => (React.createElement(View, { style: style.container },
|
|
5
|
+
React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "30px", height: "30px", viewBox: "0 0 100 100", preserveAspectRatio: "xMidYMid" },
|
|
6
|
+
React.createElement("circle", { cx: "50", cy: "50", r: "32", stroke: "#000000", strokeWidth: "6", strokeLinecap: "round", fill: "none" },
|
|
7
|
+
React.createElement("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" }),
|
|
8
|
+
React.createElement("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" })))));
|
|
9
|
+
export { Spinner };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { useEffect, useRef } from "react";
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
2
|
import { Outlet } from "react-router-native";
|
|
3
3
|
import { useViewIsCheckoutAccessibleByCustomerId } from "../../projection/react/useViewIsCheckoutAccessibleByCustomerId";
|
|
4
|
-
import { Spinner } from "../components/atoms/
|
|
5
|
-
const CheckoutAccessibilityMiddleware = ({ customerId, onNotAccessible, loader =
|
|
4
|
+
import { Spinner } from "../components/atoms/spinner/Spinner";
|
|
5
|
+
const CheckoutAccessibilityMiddleware = ({ customerId, onNotAccessible, loader = React.createElement(Spinner, null), }) => {
|
|
6
6
|
const [accessible] = useViewIsCheckoutAccessibleByCustomerId({ customerId });
|
|
7
7
|
const onNotAccessibleRef = useRef(onNotAccessible);
|
|
8
8
|
onNotAccessibleRef.current = onNotAccessible;
|
|
@@ -11,6 +11,6 @@ const CheckoutAccessibilityMiddleware = ({ customerId, onNotAccessible, loader =
|
|
|
11
11
|
onNotAccessibleRef.current();
|
|
12
12
|
}
|
|
13
13
|
}, [accessible, onNotAccessible]);
|
|
14
|
-
return accessible === undefined ? loader : accessible ?
|
|
14
|
+
return accessible === undefined ? loader : accessible ? React.createElement(Outlet, null) : null;
|
|
15
15
|
};
|
|
16
16
|
export { CheckoutAccessibilityMiddleware };
|
|
@@ -1,34 +1,37 @@
|
|
|
1
1
|
import { QueryStatus } from "@lookiero/messaging-react";
|
|
2
|
+
import React from "react";
|
|
2
3
|
import { generatePath, Navigate, Outlet, useMatch } from "react-router";
|
|
3
4
|
import { CheckoutItemStatus, } from "../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
|
|
4
|
-
import { useViewFirstAvailableCheckoutByCustomerId } from "../../projection/react/useViewFirstAvailableCheckoutByCustomerId";
|
|
5
5
|
import { useViewCheckoutIntroShown } from "../../projection/react/useViewCheckoutIntroShown";
|
|
6
|
-
import {
|
|
6
|
+
import { useViewFirstAvailableCheckoutByCustomerId } from "../../projection/react/useViewFirstAvailableCheckoutByCustomerId";
|
|
7
|
+
import { Spinner } from "../components/atoms/spinner/Spinner";
|
|
7
8
|
import { Routes } from "./routes";
|
|
8
|
-
const CheckoutMiddleware = ({ customerId, loader =
|
|
9
|
+
const CheckoutMiddleware = ({ customerId, loader = React.createElement(Spinner, null) }) => {
|
|
9
10
|
const [checkoutIntroShown, checkoutIntroShownStatus] = useViewCheckoutIntroShown();
|
|
10
11
|
const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
|
|
11
12
|
const firstItemWithoutCustomerDecision = checkout?.items.find((item) => [CheckoutItemStatus.EXPIRED, CheckoutItemStatus.INITIAL].includes(item.status));
|
|
12
13
|
const isIntroRoute = useMatch(Routes.INTRO);
|
|
13
14
|
const isItemRoute = useMatch(Routes.ITEM);
|
|
14
15
|
const isSummaryRoute = useMatch(Routes.SUMMARY);
|
|
15
|
-
const
|
|
16
|
+
const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
|
|
17
|
+
const dependenciesLoaded = dependenciesLoadedStatuses.includes(checkoutIntroShownStatus) &&
|
|
18
|
+
dependenciesLoadedStatuses.includes(checkoutStatus);
|
|
16
19
|
if (!dependenciesLoaded) {
|
|
17
20
|
return loader;
|
|
18
21
|
}
|
|
19
|
-
if (checkoutIntroShown) {
|
|
22
|
+
if (!checkoutIntroShown) {
|
|
20
23
|
if (!isIntroRoute) {
|
|
21
|
-
return
|
|
24
|
+
return React.createElement(Navigate, { replace: true, to: Routes.INTRO });
|
|
22
25
|
}
|
|
23
26
|
}
|
|
24
27
|
else {
|
|
25
28
|
if (firstItemWithoutCustomerDecision && !isItemRoute) {
|
|
26
|
-
return
|
|
29
|
+
return React.createElement(Navigate, { replace: true, to: generatePath(Routes.ITEM, { id: firstItemWithoutCustomerDecision.id }) });
|
|
27
30
|
}
|
|
28
31
|
if (firstItemWithoutCustomerDecision === undefined && !isSummaryRoute) {
|
|
29
|
-
return
|
|
32
|
+
return React.createElement(Navigate, { replace: true, to: Routes.SUMMARY });
|
|
30
33
|
}
|
|
31
34
|
}
|
|
32
|
-
return
|
|
35
|
+
return React.createElement(Outlet, null);
|
|
33
36
|
};
|
|
34
37
|
export { CheckoutMiddleware };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { lazy, Suspense } from "react";
|
|
1
|
+
import React, { lazy, Suspense } from "react";
|
|
2
2
|
import { Navigate, useRoutes } from "react-router-native";
|
|
3
|
-
import { Spinner } from "../components/atoms/
|
|
3
|
+
import { Spinner } from "../components/atoms/spinner/Spinner";
|
|
4
4
|
import { CheckoutAccessibilityMiddleware } from "./CheckoutAccessibilityMiddleware";
|
|
5
5
|
import { CheckoutMiddleware } from "./CheckoutMiddleware";
|
|
6
6
|
import { Routes } from "./routes";
|
|
@@ -11,29 +11,26 @@ const Routing = ({ customerId, onNotAccessible }) => {
|
|
|
11
11
|
const routes = useRoutes([
|
|
12
12
|
{
|
|
13
13
|
path: Routes.CHECKOUT,
|
|
14
|
-
element:
|
|
14
|
+
element: React.createElement(CheckoutAccessibilityMiddleware, { customerId: customerId, onNotAccessible: onNotAccessible }),
|
|
15
15
|
children: [
|
|
16
16
|
{
|
|
17
17
|
path: Routes.CHECKOUT,
|
|
18
|
-
element:
|
|
18
|
+
element: React.createElement(CheckoutMiddleware, { customerId: customerId }),
|
|
19
19
|
children: [
|
|
20
20
|
{
|
|
21
21
|
path: Routes.INTRO,
|
|
22
|
-
element: (
|
|
23
|
-
|
|
24
|
-
</Suspense>),
|
|
22
|
+
element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
|
|
23
|
+
React.createElement(Intro, null))),
|
|
25
24
|
},
|
|
26
25
|
{
|
|
27
26
|
path: Routes.ITEM,
|
|
28
|
-
element: (
|
|
29
|
-
|
|
30
|
-
</Suspense>),
|
|
27
|
+
element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
|
|
28
|
+
React.createElement(Item, null))),
|
|
31
29
|
},
|
|
32
30
|
{
|
|
33
31
|
path: Routes.SUMMARY,
|
|
34
|
-
element: (
|
|
35
|
-
|
|
36
|
-
</Suspense>),
|
|
32
|
+
element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
|
|
33
|
+
React.createElement(Summary, null))),
|
|
37
34
|
},
|
|
38
35
|
],
|
|
39
36
|
},
|
|
@@ -41,7 +38,7 @@ const Routing = ({ customerId, onNotAccessible }) => {
|
|
|
41
38
|
},
|
|
42
39
|
{
|
|
43
40
|
path: "*",
|
|
44
|
-
element:
|
|
41
|
+
element: React.createElement(Navigate, { replace: true, to: Routes.CHECKOUT }),
|
|
45
42
|
},
|
|
46
43
|
]);
|
|
47
44
|
return routes;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
|
|
2
|
-
import {
|
|
2
|
+
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
3
|
+
import React from "react";
|
|
3
4
|
import { StyleSheet, View } from "react-native";
|
|
4
5
|
const Intro = () => {
|
|
5
|
-
const introText =
|
|
6
|
-
return (
|
|
7
|
-
|
|
8
|
-
{introText}
|
|
9
|
-
</Text>
|
|
10
|
-
</View>);
|
|
6
|
+
const introText = useI18nMessage({ id: "intro" });
|
|
7
|
+
return (React.createElement(View, { style: styles.container },
|
|
8
|
+
React.createElement(Text, { heading: true, level: 3 }, introText)));
|
|
11
9
|
};
|
|
12
10
|
const styles = StyleSheet.create({
|
|
13
11
|
container: {
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
|
|
2
|
-
import {
|
|
2
|
+
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
3
|
+
import React from "react";
|
|
3
4
|
import { StyleSheet, View } from "react-native";
|
|
4
5
|
import { useParams } from "react-router-native";
|
|
5
6
|
const Item = () => {
|
|
6
7
|
const { id } = useParams();
|
|
7
|
-
const itemText =
|
|
8
|
-
return (
|
|
9
|
-
|
|
10
|
-
{
|
|
11
|
-
</Text>
|
|
12
|
-
<Text level={2}>{id}</Text>
|
|
13
|
-
</View>);
|
|
8
|
+
const itemText = useI18nMessage({ id: "item" });
|
|
9
|
+
return (React.createElement(View, { style: styles.container },
|
|
10
|
+
React.createElement(Text, { heading: true, level: 3 }, itemText),
|
|
11
|
+
React.createElement(Text, { level: 2 }, id)));
|
|
14
12
|
};
|
|
15
13
|
const styles = StyleSheet.create({
|
|
16
14
|
container: {
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
|
|
2
|
-
import {
|
|
2
|
+
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
3
|
+
import React from "react";
|
|
3
4
|
import { StyleSheet, View } from "react-native";
|
|
4
5
|
const Summary = () => {
|
|
5
|
-
const summaryText =
|
|
6
|
-
return (
|
|
7
|
-
|
|
8
|
-
{summaryText}
|
|
9
|
-
</Text>
|
|
10
|
-
</View>);
|
|
6
|
+
const summaryText = useI18nMessage({ id: "summary" });
|
|
7
|
+
return (React.createElement(View, { style: styles.container },
|
|
8
|
+
React.createElement(Text, { heading: true, level: 3 }, summaryText)));
|
|
11
9
|
};
|
|
12
10
|
const styles = StyleSheet.create({
|
|
13
11
|
container: {
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lookiero/checkout",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
6
9
|
"engines": {
|
|
7
10
|
"node": ">=14.19.3"
|
|
8
11
|
},
|
|
@@ -19,8 +22,8 @@
|
|
|
19
22
|
"publish": "npm publish"
|
|
20
23
|
},
|
|
21
24
|
"dependencies": {
|
|
22
|
-
"@lookiero/i18n": "^0.
|
|
23
|
-
"@lookiero/i18n-react": "^0.
|
|
25
|
+
"@lookiero/i18n": "^0.7.0",
|
|
26
|
+
"@lookiero/i18n-react": "^0.7.0",
|
|
24
27
|
"@lookiero/messaging": "^6.2.1",
|
|
25
28
|
"@lookiero/messaging-react": "^6.2.1",
|
|
26
29
|
"react-router-dom": "^6.3.0",
|
package/.eslintignore
DELETED
package/.eslintrc
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"plugins": ["@typescript-eslint"],
|
|
3
|
-
"parser": "@typescript-eslint/parser",
|
|
4
|
-
"overrides": [
|
|
5
|
-
{
|
|
6
|
-
"files": ["*.ts", "*.tsx"],
|
|
7
|
-
"extends": [
|
|
8
|
-
"plugin:prettier/recommended",
|
|
9
|
-
"plugin:@typescript-eslint/recommended",
|
|
10
|
-
"plugin:react/recommended",
|
|
11
|
-
"plugin:react-hooks/recommended",
|
|
12
|
-
"plugin:react/jsx-runtime"
|
|
13
|
-
]
|
|
14
|
-
}
|
|
15
|
-
],
|
|
16
|
-
"settings": {
|
|
17
|
-
"react": {
|
|
18
|
-
"version": "detect"
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"rules": {
|
|
22
|
-
"no-console": "off",
|
|
23
|
-
"no-var": "error",
|
|
24
|
-
"@typescript-eslint/no-unused-vars": "error",
|
|
25
|
-
"@typescript-eslint/no-explicit-any": "error",
|
|
26
|
-
"@typescript-eslint/no-empty-interface": [
|
|
27
|
-
"error",
|
|
28
|
-
{
|
|
29
|
-
"allowSingleExtends": true
|
|
30
|
-
}
|
|
31
|
-
],
|
|
32
|
-
"@typescript-eslint/naming-convention": [
|
|
33
|
-
"error",
|
|
34
|
-
{
|
|
35
|
-
"selector": "default",
|
|
36
|
-
"format": ["camelCase"]
|
|
37
|
-
},
|
|
38
|
-
// PascalCase for Classes, Interfaces, Types, ...
|
|
39
|
-
{
|
|
40
|
-
"selector": "typeLike",
|
|
41
|
-
"format": ["PascalCase"]
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"selector": "enumMember",
|
|
45
|
-
"format": ["UPPER_CASE"]
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
"selector": "variable",
|
|
49
|
-
"format": ["camelCase", "UPPER_CASE", "PascalCase"]
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
"selector": "parameter",
|
|
53
|
-
"format": ["camelCase", "PascalCase"]
|
|
54
|
-
},
|
|
55
|
-
// camelCase | snake_case | PascalCase for regular properties
|
|
56
|
-
{
|
|
57
|
-
"selector": "property",
|
|
58
|
-
"format": ["camelCase", "snake_case", "PascalCase"]
|
|
59
|
-
},
|
|
60
|
-
// properties with single or double leading-underscores will be camelCase (__html, _id, ...)
|
|
61
|
-
{
|
|
62
|
-
"selector": "property",
|
|
63
|
-
"format": ["camelCase"],
|
|
64
|
-
"prefix": ["__", "_"],
|
|
65
|
-
"filter": {
|
|
66
|
-
"regex": "^_+",
|
|
67
|
-
"match": true
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
]
|
|
71
|
-
}
|
|
72
|
-
}
|
package/.expo-shared/assets.json
DELETED
package/.github/CODEOWNERS
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
* @lookiero/squad-box
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
name: "Version Check"
|
|
2
|
-
|
|
3
|
-
inputs:
|
|
4
|
-
github-token:
|
|
5
|
-
required: true
|
|
6
|
-
|
|
7
|
-
outputs:
|
|
8
|
-
version:
|
|
9
|
-
description: "Defined version"
|
|
10
|
-
value: ${{ steps.set-version.outputs.version }}
|
|
11
|
-
is-publishable:
|
|
12
|
-
description: "Boolean determines when the new version is publishable or not"
|
|
13
|
-
value: ${{ steps.set-is-publishable.outputs.is-publishable }}
|
|
14
|
-
|
|
15
|
-
runs:
|
|
16
|
-
using: "composite"
|
|
17
|
-
steps:
|
|
18
|
-
- name: Check if checkout-front version has been updated
|
|
19
|
-
id: checkout-front-version-check
|
|
20
|
-
uses: EndBug/version-check@v1
|
|
21
|
-
with:
|
|
22
|
-
diff-search: true
|
|
23
|
-
file-name: package.json
|
|
24
|
-
token: ${{ inputs.github-token }}
|
|
25
|
-
|
|
26
|
-
- id: set-is-publishable
|
|
27
|
-
shell: bash
|
|
28
|
-
run: echo "::set-output name=is-publishable::${{ steps.checkout-front-version-check.outputs.changed == 'true' }}"
|
|
29
|
-
|
|
30
|
-
- id: set-version
|
|
31
|
-
shell: bash
|
|
32
|
-
run: echo "::set-output name=version::v${{ steps.checkout-front-version-check.outputs.version }}"
|
package/.github/dependabot.yaml
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
name: đ
|
|
2
|
-
|
|
3
|
-
on: [pull_request]
|
|
4
|
-
|
|
5
|
-
jobs:
|
|
6
|
-
lint:
|
|
7
|
-
name: đ Linting
|
|
8
|
-
runs-on: ubuntu-latest
|
|
9
|
-
steps:
|
|
10
|
-
- name: đ Cancel Previous Runs
|
|
11
|
-
uses: styfle/cancel-workflow-action@0.9.1
|
|
12
|
-
|
|
13
|
-
- name: âŹď¸ Checkout repo
|
|
14
|
-
uses: actions/checkout@v3
|
|
15
|
-
|
|
16
|
-
- name: â Setup node 14.19.3
|
|
17
|
-
uses: actions/setup-node@v3
|
|
18
|
-
with:
|
|
19
|
-
node-version: 14.19.3
|
|
20
|
-
|
|
21
|
-
- name: đĽ Download deps
|
|
22
|
-
shell: bash
|
|
23
|
-
run: npm install -g npm && npm ci --legacy-peer-deps
|
|
24
|
-
env:
|
|
25
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
26
|
-
|
|
27
|
-
- name: ⏣ ESLint
|
|
28
|
-
run: node_modules/.bin/eslint --max-warnings 0 --ext ts,tsx .
|
|
29
|
-
env:
|
|
30
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
31
|
-
|
|
32
|
-
- name: ĘŚ Prettier
|
|
33
|
-
run: node_modules/.bin/prettier --check "**/*.+(json|css|ts|tsx|md)"
|
|
34
|
-
env:
|
|
35
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
36
|
-
|
|
37
|
-
jest:
|
|
38
|
-
name: ⥠Jest
|
|
39
|
-
runs-on: ubuntu-latest
|
|
40
|
-
strategy:
|
|
41
|
-
matrix:
|
|
42
|
-
node-version: [14.19.3, 16.x, 18.x, latest]
|
|
43
|
-
steps:
|
|
44
|
-
- name: đ Cancel Previous Runs
|
|
45
|
-
uses: styfle/cancel-workflow-action@0.9.1
|
|
46
|
-
|
|
47
|
-
- name: âŹď¸ Checkout repo
|
|
48
|
-
uses: actions/checkout@v3
|
|
49
|
-
|
|
50
|
-
- name: â Setup node ${{ matrix.node-version }}
|
|
51
|
-
uses: actions/setup-node@v3
|
|
52
|
-
with:
|
|
53
|
-
node-version: ${{ matrix.node-version }}
|
|
54
|
-
|
|
55
|
-
- name: đĽ Download deps
|
|
56
|
-
shell: bash
|
|
57
|
-
run: npm install -g npm && npm ci --legacy-peer-deps
|
|
58
|
-
env:
|
|
59
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
60
|
-
|
|
61
|
-
- name: âď¸ Build
|
|
62
|
-
run: npm run build
|
|
63
|
-
env:
|
|
64
|
-
node-version: ${{ matrix.node-version }}
|
|
65
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
66
|
-
|
|
67
|
-
- name: ⥠Jest
|
|
68
|
-
run: npm run test
|
|
69
|
-
env:
|
|
70
|
-
node-version: ${{ matrix.node-version }}
|
|
71
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
name: đ°
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- master
|
|
7
|
-
|
|
8
|
-
jobs:
|
|
9
|
-
publish:
|
|
10
|
-
name: đ Publish
|
|
11
|
-
runs-on: ubuntu-latest
|
|
12
|
-
steps:
|
|
13
|
-
- name: đ Cancel Previous Runs
|
|
14
|
-
uses: styfle/cancel-workflow-action@0.9.1
|
|
15
|
-
|
|
16
|
-
- name: âŹď¸ Checkout repo
|
|
17
|
-
uses: actions/checkout@v3
|
|
18
|
-
|
|
19
|
-
- name: â Setup node 14.19.3
|
|
20
|
-
uses: actions/setup-node@v3
|
|
21
|
-
with:
|
|
22
|
-
node-version: 14.19.3
|
|
23
|
-
|
|
24
|
-
- name: đĽ Download deps
|
|
25
|
-
shell: bash
|
|
26
|
-
run: npm install -g npm && npm ci --legacy-peer-deps
|
|
27
|
-
env:
|
|
28
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
29
|
-
|
|
30
|
-
- name: âď¸ Build
|
|
31
|
-
run: npm run build
|
|
32
|
-
env:
|
|
33
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
34
|
-
|
|
35
|
-
- name: đ Check Version
|
|
36
|
-
id: check-version
|
|
37
|
-
uses: ./.github/actions/version
|
|
38
|
-
with:
|
|
39
|
-
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
40
|
-
|
|
41
|
-
- name: đ Publish Github release
|
|
42
|
-
if: steps.check-version.outputs.is-publishable == 'true'
|
|
43
|
-
uses: ncipollo/release-action@v1
|
|
44
|
-
with:
|
|
45
|
-
tag: ${{ steps.check-version.outputs.version }}
|
|
46
|
-
name: ${{ steps.check-version.outputs.version }}
|
|
47
|
-
|
|
48
|
-
- name: đ Publish packages in NPM
|
|
49
|
-
if: steps.check-version.outputs.is-publishable == 'true'
|
|
50
|
-
run: npm run publish
|
|
51
|
-
env:
|
|
52
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/.husky/pre-commit
DELETED