@lookiero/checkout 0.7.2 → 0.8.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/infrastructure/domain/uiSetting/react/useIncrementIntroShownCount.d.ts +10 -0
- package/dist/infrastructure/domain/uiSetting/react/useIncrementIntroShownCount.js +11 -0
- package/dist/infrastructure/projection/uiSetting/react/useShouldIntroBeShown.d.ts +6 -0
- package/dist/infrastructure/projection/uiSetting/react/useShouldIntroBeShown.js +7 -0
- package/dist/infrastructure/projection/uiSetting/react/useViewIntroShownCount.d.ts +6 -0
- package/dist/infrastructure/projection/uiSetting/react/useViewIntroShownCount.js +9 -0
- package/dist/infrastructure/ui/hooks/useSubmitCheckout.js +9 -16
- package/dist/infrastructure/ui/i18n/fetchTranslations.d.ts +9 -0
- package/dist/infrastructure/ui/i18n/fetchTranslations.js +9 -0
- package/dist/infrastructure/ui/i18n/i18n.d.ts +7 -0
- package/dist/infrastructure/ui/i18n/i18n.js +7 -0
- package/dist/infrastructure/ui/i18n/translationEndpoint.d.ts +10 -0
- package/dist/infrastructure/ui/i18n/translationEndpoint.js +2 -0
- package/dist/infrastructure/ui/routing/CheckoutMiddleware.js +29 -13
- package/dist/infrastructure/ui/routing/Routing.js +6 -0
- package/dist/infrastructure/ui/routing/routes.d.ts +1 -0
- package/dist/infrastructure/ui/routing/routes.js +1 -0
- package/dist/infrastructure/ui/settings/UISettings.d.ts +1 -0
- package/dist/infrastructure/ui/settings/UISettings.js +1 -0
- package/dist/infrastructure/ui/views/intro/Intro.d.ts +6 -0
- package/dist/infrastructure/ui/views/intro/Intro.js +52 -0
- package/dist/infrastructure/ui/views/intro/Intro.style.d.ts +52 -0
- package/dist/infrastructure/ui/views/intro/Intro.style.js +55 -0
- package/dist/infrastructure/ui/views/item/components/itemActions/ItemActions.js +4 -3
- package/dist/projection/payment/paymentFlowPayload.d.ts +1 -1
- package/dist/shared/ui/components/molecules/selectField/SelectField.d.ts +0 -1
- package/dist/shared/ui/components/molecules/selectField/SelectField.js +4 -6
- package/dist/shared/ui/components/molecules/selectField/SelectField.style.d.ts +0 -7
- package/dist/shared/ui/components/molecules/selectField/SelectField.style.js +1 -8
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -20,8 +20,8 @@ interface FirstAvailableCheckoutByCustomerIdFunction {
|
|
|
20
20
|
interface BootstrapFunctionArgs {
|
|
21
21
|
readonly getAuthToken: () => Promise<string>;
|
|
22
22
|
readonly apiUrl: string;
|
|
23
|
-
readonly translations: EndpointFunction;
|
|
24
23
|
readonly sentry: SentryLoggerFunctionArgs;
|
|
24
|
+
readonly translations: EndpointFunction[];
|
|
25
25
|
}
|
|
26
26
|
interface BootstrapFunctionReturn {
|
|
27
27
|
readonly Root: ComponentType<RootProps>;
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { fetchFetchTranslation } from "@lookiero/i18n";
|
|
2
1
|
import { i18n } from "@lookiero/i18n-react";
|
|
3
2
|
import { CheckoutStatus } from "./domain/checkout/model/checkout";
|
|
4
3
|
import { bootstrap as checkoutBootstrap } from "./infrastructure/delivery/bootstrap";
|
|
5
4
|
import { root } from "./infrastructure/ui/Root";
|
|
5
|
+
import { fetchTranslations } from "./infrastructure/ui/i18n/fetchTranslations";
|
|
6
6
|
import { viewFirstAvailableCheckoutByCustomerId } from "./projection/checkout/viewFirstAvailableCheckoutByCustomerId";
|
|
7
7
|
import { viewIsCheckoutAccessibleByCustomerId, } from "./projection/checkout/viewIsCheckoutAccessibleByCustomerId";
|
|
8
8
|
const bootstrap = ({ apiUrl, getAuthToken, translations, sentry }) => {
|
|
9
9
|
const { Component: Messaging, queryBus } = checkoutBootstrap({ apiUrl, getAuthToken });
|
|
10
10
|
const I18n = i18n({
|
|
11
|
-
fetchTranslation:
|
|
11
|
+
fetchTranslation: fetchTranslations({ translations }),
|
|
12
12
|
contextId: "CheckoutI18n",
|
|
13
13
|
});
|
|
14
14
|
const Root = root({ Messaging, I18n, getAuthToken, sentry });
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CommandStatus } from "@lookiero/messaging-react";
|
|
2
|
+
interface IncrementIntroShownCountFunction {
|
|
3
|
+
(): Promise<void>;
|
|
4
|
+
}
|
|
5
|
+
type UseIncrementIntroShownCount = [incrementIntroShownCount: IncrementIntroShownCountFunction, status: CommandStatus];
|
|
6
|
+
interface UseIncrementIntroShownCountFunction {
|
|
7
|
+
(): UseIncrementIntroShownCount;
|
|
8
|
+
}
|
|
9
|
+
declare const useIncrementIntroShownCount: UseIncrementIntroShownCountFunction;
|
|
10
|
+
export { useIncrementIntroShownCount };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { useViewIntroShownCount } from "../../../projection/uiSetting/react/useViewIntroShownCount";
|
|
3
|
+
import { UISettings } from "../../../ui/settings/UISettings";
|
|
4
|
+
import { useUpdateUiSetting } from "./useUpdateUiSetting";
|
|
5
|
+
const useIncrementIntroShownCount = () => {
|
|
6
|
+
const [update, status] = useUpdateUiSetting();
|
|
7
|
+
const [introShownCount] = useViewIntroShownCount();
|
|
8
|
+
const incrementIntroShownCount = useCallback(() => update({ key: UISettings.INTRO_SHOWN_COUNT, value: introShownCount + 1 }), [introShownCount, update]);
|
|
9
|
+
return [incrementIntroShownCount, status];
|
|
10
|
+
};
|
|
11
|
+
export { useIncrementIntroShownCount };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { useViewIntroShownCount } from "./useViewIntroShownCount";
|
|
2
|
+
const MAX_INTRO_SHOWN_COUNT = 2;
|
|
3
|
+
const useShouldIntroBeShown = () => {
|
|
4
|
+
const [introShownCount, introShownCountStatus] = useViewIntroShownCount();
|
|
5
|
+
return [introShownCount < MAX_INTRO_SHOWN_COUNT, introShownCountStatus];
|
|
6
|
+
};
|
|
7
|
+
export { useShouldIntroBeShown };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UISettings } from "../../../ui/settings/UISettings";
|
|
2
|
+
import { useViewUiSettingByKey } from "./useViewUiSettingByKey";
|
|
3
|
+
const useViewIntroShownCount = () => {
|
|
4
|
+
const [introShownCount, introShownCountStatus] = useViewUiSettingByKey({
|
|
5
|
+
key: UISettings.INTRO_SHOWN_COUNT,
|
|
6
|
+
});
|
|
7
|
+
return [introShownCount?.value || 0, introShownCountStatus];
|
|
8
|
+
};
|
|
9
|
+
export { useViewIntroShownCount };
|
|
@@ -20,29 +20,22 @@ const useSubmitCheckout = ({ checkoutId, checkoutBookingId, paymentFlowRef, onEr
|
|
|
20
20
|
paymentFlowRef.current?.startLegacyBoxCheckout(
|
|
21
21
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
22
22
|
// @ts-ignore
|
|
23
|
-
paymentFlowPayload, async ({ status }) => {
|
|
23
|
+
paymentFlowPayload, async ({ status, toaster }) => {
|
|
24
24
|
setStartLegacyBoxCheckoutStatus("loading");
|
|
25
|
-
if (status === ChargeStatus.
|
|
26
|
-
createNotification({
|
|
27
|
-
level: NotificationLevel.ERROR,
|
|
28
|
-
bodyI18nKey: I18nMessages.CHECKOUT_TOAST_PAYMENT_REJECTED,
|
|
29
|
-
});
|
|
30
|
-
setStartLegacyBoxCheckoutStatus("error");
|
|
31
|
-
}
|
|
32
|
-
else if (status === ChargeStatus.ERROR) {
|
|
33
|
-
createNotification({
|
|
34
|
-
level: NotificationLevel.ERROR,
|
|
35
|
-
bodyI18nKey: I18nMessages.CHECKOUT_TOAST_PAYMENT_ERROR,
|
|
36
|
-
});
|
|
37
|
-
setStartLegacyBoxCheckoutStatus("error");
|
|
38
|
-
}
|
|
39
|
-
else if (status === ChargeStatus.EXECUTED) {
|
|
25
|
+
if (status === ChargeStatus.EXECUTED) {
|
|
40
26
|
setStartLegacyBoxCheckoutStatus("success");
|
|
41
27
|
try {
|
|
42
28
|
await submitCheckoutCommand();
|
|
43
29
|
}
|
|
44
30
|
catch (error) { }
|
|
45
31
|
}
|
|
32
|
+
else {
|
|
33
|
+
createNotification({
|
|
34
|
+
level: NotificationLevel.ERROR,
|
|
35
|
+
bodyI18nKey: toaster?.id || I18nMessages.CHECKOUT_TOAST_PAYMENT_ERROR,
|
|
36
|
+
});
|
|
37
|
+
setStartLegacyBoxCheckoutStatus("error");
|
|
38
|
+
}
|
|
46
39
|
});
|
|
47
40
|
}, [blockCheckoutBooking, createNotification, submitCheckoutCommand, paymentFlowRef]);
|
|
48
41
|
const status = useMemo(() => {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { EndpointFunction, FetchTranslationFuction } from "@lookiero/i18n";
|
|
2
|
+
interface FetchTranslationsFuntionArgs {
|
|
3
|
+
readonly translations: EndpointFunction[];
|
|
4
|
+
}
|
|
5
|
+
interface FetchTranslationsFuntion {
|
|
6
|
+
(args: FetchTranslationsFuntionArgs): FetchTranslationFuction;
|
|
7
|
+
}
|
|
8
|
+
declare const fetchTranslations: FetchTranslationsFuntion;
|
|
9
|
+
export { fetchTranslations };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { fetchFetchTranslation } from "@lookiero/i18n";
|
|
2
|
+
const fetchTranslations = ({ translations }) => async ({ locale }) => {
|
|
3
|
+
const translationsMessages = await Promise.all(translations.map((endpoint) => fetchFetchTranslation({ endpoint })({ locale })));
|
|
4
|
+
return translationsMessages.reduce((acc, translationMessages) => ({
|
|
5
|
+
...acc,
|
|
6
|
+
...translationMessages,
|
|
7
|
+
}), {});
|
|
8
|
+
};
|
|
9
|
+
export { fetchTranslations };
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
declare const COLOR_I18N_PREFIX = "color.";
|
|
2
2
|
declare enum I18nMessages {
|
|
3
|
+
INTRO_TITLE = "intro.title",
|
|
4
|
+
INTRO_SUBTITLE = "intro.subtitle",
|
|
5
|
+
INTRO_DISCOUNT = "intro.discount",
|
|
6
|
+
INTRO_BULLET_ONE = "intro.bullet_one",
|
|
7
|
+
INTRO_BULLET_TWO = "intro.bullet_two",
|
|
8
|
+
INTRO_BULLET_THREE = "intro.bullet_three",
|
|
9
|
+
INTRO_BUTTON = "intro.button",
|
|
3
10
|
ITEM_SIZE = "item.size",
|
|
4
11
|
ITEM_COLOR = "item.color",
|
|
5
12
|
ITEM_UNIQUE = "item.unique",
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
const COLOR_I18N_PREFIX = "color.";
|
|
2
2
|
var I18nMessages;
|
|
3
3
|
(function (I18nMessages) {
|
|
4
|
+
I18nMessages["INTRO_TITLE"] = "intro.title";
|
|
5
|
+
I18nMessages["INTRO_SUBTITLE"] = "intro.subtitle";
|
|
6
|
+
I18nMessages["INTRO_DISCOUNT"] = "intro.discount";
|
|
7
|
+
I18nMessages["INTRO_BULLET_ONE"] = "intro.bullet_one";
|
|
8
|
+
I18nMessages["INTRO_BULLET_TWO"] = "intro.bullet_two";
|
|
9
|
+
I18nMessages["INTRO_BULLET_THREE"] = "intro.bullet_three";
|
|
10
|
+
I18nMessages["INTRO_BUTTON"] = "intro.button";
|
|
4
11
|
I18nMessages["ITEM_SIZE"] = "item.size";
|
|
5
12
|
I18nMessages["ITEM_COLOR"] = "item.color";
|
|
6
13
|
I18nMessages["ITEM_UNIQUE"] = "item.unique";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EndpointFunction } from "@lookiero/i18n";
|
|
2
|
+
interface TranslationEndpointFunctionArgs {
|
|
3
|
+
readonly translationsUrl: string;
|
|
4
|
+
readonly translationsApiKey: string;
|
|
5
|
+
}
|
|
6
|
+
interface TranslationEndpointFunction {
|
|
7
|
+
(args: TranslationEndpointFunctionArgs): EndpointFunction;
|
|
8
|
+
}
|
|
9
|
+
declare const translationEndpoint: TranslationEndpointFunction;
|
|
10
|
+
export { translationEndpoint };
|
|
@@ -6,10 +6,13 @@ import { CheckoutItemStatus } from "../../../domain/checkoutItem/model/checkoutI
|
|
|
6
6
|
import { Spinner } from "../../../shared/ui/components/atoms/spinner/Spinner";
|
|
7
7
|
import { useStartCheckout } from "../../domain/checkout/react/useStartCheckout";
|
|
8
8
|
import { useViewFirstAvailableCheckoutByCustomerId } from "../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
|
|
9
|
+
import { useShouldIntroBeShown } from "../../projection/uiSetting/react/useShouldIntroBeShown";
|
|
9
10
|
import { Routes } from "./routes";
|
|
10
11
|
import { useBasePath } from "./useBasePath";
|
|
11
12
|
const CheckoutMiddleware = ({ customerId, loader = React.createElement(Spinner, null), children }) => {
|
|
12
13
|
const basePath = useBasePath();
|
|
14
|
+
const introShown = useRef(false);
|
|
15
|
+
const [shouldIntroBeShown, shouldIntroBeShownStatus] = useShouldIntroBeShown();
|
|
13
16
|
const navigatedToFirstItemWithoutCustomerDecision = useRef(false);
|
|
14
17
|
const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
|
|
15
18
|
const firstItemWithoutCustomerDecision = checkout?.items.find((item) => item.status === CheckoutItemStatus.INITIAL);
|
|
@@ -19,6 +22,7 @@ const CheckoutMiddleware = ({ customerId, loader = React.createElement(Spinner,
|
|
|
19
22
|
startCheckout();
|
|
20
23
|
}
|
|
21
24
|
}, [checkout?.id, startCheckout]);
|
|
25
|
+
const introRouteMatch = useMatch(`${basePath}/${Routes.INTRO}`);
|
|
22
26
|
const itemRouteMatch = useMatch(`${basePath}/${Routes.ITEM}`);
|
|
23
27
|
const itemDetailRouteMatch = useMatch(`${basePath}/${Routes.ITEM_DETAIL}`);
|
|
24
28
|
const summaryRouteMatch = useMatch(`${basePath}/${Routes.SUMMARY}`);
|
|
@@ -28,7 +32,8 @@ const CheckoutMiddleware = ({ customerId, loader = React.createElement(Spinner,
|
|
|
28
32
|
const checkoutShown = useRef(false);
|
|
29
33
|
checkoutShown.current = checkoutShown.current || (Boolean(checkoutRouteMatch) && !Boolean(checkoutPaymentRouteMatch));
|
|
30
34
|
const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
|
|
31
|
-
const dependenciesLoaded = dependenciesLoadedStatuses.includes(
|
|
35
|
+
const dependenciesLoaded = dependenciesLoadedStatuses.includes(shouldIntroBeShownStatus) &&
|
|
36
|
+
(dependenciesLoadedStatuses.includes(checkoutStatus) || checkout);
|
|
32
37
|
if (!dependenciesLoaded) {
|
|
33
38
|
return loader;
|
|
34
39
|
}
|
|
@@ -49,20 +54,31 @@ const CheckoutMiddleware = ({ customerId, loader = React.createElement(Spinner,
|
|
|
49
54
|
!(summaryRouteMatch || itemDetailRouteMatch || checkoutRouteMatch || checkoutPaymentRouteMatch)) {
|
|
50
55
|
return React.createElement(Navigate, { to: `${basePath}/${Routes.SUMMARY}`, replace: true });
|
|
51
56
|
}
|
|
52
|
-
/*
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
/* Navigate to the Intro if required */
|
|
58
|
+
if (shouldIntroBeShown && !introShown.current && firstItemWithoutCustomerDecision !== undefined) {
|
|
59
|
+
if (introRouteMatch) {
|
|
60
|
+
introShown.current = true;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
return React.createElement(Navigate, { to: `${basePath}/${Routes.INTRO}`, replace: true });
|
|
57
64
|
}
|
|
58
65
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
else {
|
|
67
|
+
/* Item/ItemDetail 404 - Not found */
|
|
68
|
+
if (itemRouteMatch || itemDetailRouteMatch) {
|
|
69
|
+
const checkoutItem = checkout?.items.find((item) => item.id === itemRouteMatch?.params.id || itemDetailRouteMatch?.params.id);
|
|
70
|
+
if (!checkoutItem) {
|
|
71
|
+
return React.createElement(Navigate, { to: `${basePath}/${Routes.HOME}`, replace: true });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/* Navigate to the first item without customer's decission */
|
|
75
|
+
navigatedToFirstItemWithoutCustomerDecision.current =
|
|
76
|
+
navigatedToFirstItemWithoutCustomerDecision.current ||
|
|
77
|
+
Boolean(itemRouteMatch && itemRouteMatch.params.id === firstItemWithoutCustomerDecision?.id);
|
|
78
|
+
if (firstItemWithoutCustomerDecision && !navigatedToFirstItemWithoutCustomerDecision.current) {
|
|
79
|
+
navigatedToFirstItemWithoutCustomerDecision.current = true;
|
|
80
|
+
return (React.createElement(Navigate, { to: generatePath(`${basePath}/${Routes.ITEM}`, { id: firstItemWithoutCustomerDecision.id }), replace: true }));
|
|
81
|
+
}
|
|
66
82
|
}
|
|
67
83
|
return children;
|
|
68
84
|
};
|
|
@@ -7,6 +7,7 @@ import { CheckoutAccessibilityMiddleware } from "./CheckoutAccessibilityMiddlewa
|
|
|
7
7
|
import { CheckoutMiddleware } from "./CheckoutMiddleware";
|
|
8
8
|
import { Routes } from "./routes";
|
|
9
9
|
import { BasePathProvider } from "./useBasePath";
|
|
10
|
+
const Intro = lazy(() => import("../views/intro/Intro").then((module) => ({ default: module.Intro })));
|
|
10
11
|
const Item = lazy(() => import("../views/item/Item").then((module) => ({ default: module.Item })));
|
|
11
12
|
const Summary = lazy(() => import("../views/summary/Summary").then((module) => ({ default: module.Summary })));
|
|
12
13
|
const Checkout = lazy(() => import("../views/checkout/Checkout").then((module) => ({ default: module.Checkout })));
|
|
@@ -23,6 +24,11 @@ const Routing = ({ basePath = "", customer, locale, I18n, menu, tabBar, getAuthT
|
|
|
23
24
|
React.createElement(App, { customerId: customer?.customerId, menu: menu, tabBar: tabBar },
|
|
24
25
|
React.createElement(Outlet, null))))))),
|
|
25
26
|
children: [
|
|
27
|
+
{
|
|
28
|
+
path: Routes.INTRO,
|
|
29
|
+
element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
|
|
30
|
+
React.createElement(Intro, { customerId: customer?.customerId }))),
|
|
31
|
+
},
|
|
26
32
|
{
|
|
27
33
|
path: Routes.ITEM,
|
|
28
34
|
element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Button } from "@lookiero/aurora-next/build/components/atoms/Button/Button";
|
|
2
|
+
import { Icon } from "@lookiero/aurora-next/build/components/primitives/Icon/Icon";
|
|
3
|
+
import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
|
|
4
|
+
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
5
|
+
import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
|
|
6
|
+
import React from "react";
|
|
7
|
+
import { Platform, View } from "react-native";
|
|
8
|
+
import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
|
|
9
|
+
import { useIncrementIntroShownCount } from "../../../domain/uiSetting/react/useIncrementIntroShownCount";
|
|
10
|
+
import { useViewFiveItemsDiscountByCustomerId } from "../../../projection/checkout/react/useViewFiveItemsDiscountByCustomerId";
|
|
11
|
+
import { Body } from "../../components/layouts/body/Body";
|
|
12
|
+
import { SafeAreaScrollView } from "../../components/templates/SafeAreaScrollView";
|
|
13
|
+
import { I18nMessages } from "../../i18n/i18n";
|
|
14
|
+
import { HEADER_HEIGHT } from "../navigation/components/header/Header.style";
|
|
15
|
+
import { style } from "./Intro.style";
|
|
16
|
+
const Bullet = ({ text }) => (React.createElement(View, { style: style.bullet },
|
|
17
|
+
React.createElement(Icon, { name: "rounded-tick", style: style.tickIcon }),
|
|
18
|
+
React.createElement(Text, { level: 2, detail: true }, text)));
|
|
19
|
+
const Intro = ({ customerId }) => {
|
|
20
|
+
const titleText = useI18nMessage({ id: I18nMessages.INTRO_TITLE });
|
|
21
|
+
const subTitleText = useI18nMessage({ id: I18nMessages.INTRO_SUBTITLE });
|
|
22
|
+
const discountText = useI18nMessage({ id: I18nMessages.INTRO_DISCOUNT });
|
|
23
|
+
const bulletOneText = useI18nMessage({ id: I18nMessages.INTRO_BULLET_ONE });
|
|
24
|
+
const bulletTwoText = useI18nMessage({ id: I18nMessages.INTRO_BULLET_TWO });
|
|
25
|
+
const bulletThreeText = useI18nMessage({ id: I18nMessages.INTRO_BULLET_THREE });
|
|
26
|
+
const buttonText = useI18nMessage({ id: I18nMessages.INTRO_BUTTON });
|
|
27
|
+
const [fiveItemsDiscount, fiveItemsDiscountStatus] = useViewFiveItemsDiscountByCustomerId({
|
|
28
|
+
customerId,
|
|
29
|
+
});
|
|
30
|
+
const [incrementIntroShownCount, incrementIntroShownCountStatus] = useIncrementIntroShownCount();
|
|
31
|
+
if (fiveItemsDiscountStatus === QueryStatus.LOADING)
|
|
32
|
+
return React.createElement(Spinner, null);
|
|
33
|
+
return (React.createElement(SafeAreaScrollView, { scrollerPaddingTop: Platform.OS === "web" || Platform.OS === "android" ? HEADER_HEIGHT : 0 },
|
|
34
|
+
React.createElement(Body, { style: { column: style.bodyColumn } },
|
|
35
|
+
React.createElement(View, { style: style.intro },
|
|
36
|
+
React.createElement(View, { style: style.content },
|
|
37
|
+
React.createElement(Text, { level: 3, style: style.title, heading: true }, titleText),
|
|
38
|
+
React.createElement(Text, { level: 3, style: style.subtitle, body: true }, subTitleText),
|
|
39
|
+
fiveItemsDiscount !== 0 && (React.createElement(View, { style: style.discountContainer },
|
|
40
|
+
React.createElement(View, { style: style.discount },
|
|
41
|
+
React.createElement(Text, { level: 2, heading: true },
|
|
42
|
+
"- ",
|
|
43
|
+
fiveItemsDiscount),
|
|
44
|
+
React.createElement(Text, { level: 3, style: style.percentage, heading: true }, "%")),
|
|
45
|
+
React.createElement(Text, { level: 3, body: true }, discountText))),
|
|
46
|
+
React.createElement(View, { style: style.description },
|
|
47
|
+
React.createElement(Bullet, { text: bulletOneText }),
|
|
48
|
+
React.createElement(Bullet, { text: bulletTwoText }),
|
|
49
|
+
React.createElement(Bullet, { text: bulletThreeText }))),
|
|
50
|
+
React.createElement(Button, { disabled: incrementIntroShownCountStatus === CommandStatus.LOADING, onPress: incrementIntroShownCount }, buttonText)))));
|
|
51
|
+
};
|
|
52
|
+
export { Intro };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
declare const style: {
|
|
2
|
+
bodyColumn: {
|
|
3
|
+
paddingHorizontal: number;
|
|
4
|
+
};
|
|
5
|
+
bullet: {
|
|
6
|
+
alignItems: "center";
|
|
7
|
+
flexDirection: "row";
|
|
8
|
+
marginVertical: number;
|
|
9
|
+
};
|
|
10
|
+
content: {
|
|
11
|
+
alignItems: "center";
|
|
12
|
+
};
|
|
13
|
+
description: {
|
|
14
|
+
borderWidth: number;
|
|
15
|
+
marginBottom: number;
|
|
16
|
+
padding: number;
|
|
17
|
+
width: string;
|
|
18
|
+
};
|
|
19
|
+
discount: {
|
|
20
|
+
alignItems: "flex-end";
|
|
21
|
+
flexDirection: "row";
|
|
22
|
+
justifyContent: "center";
|
|
23
|
+
marginBottom: number;
|
|
24
|
+
};
|
|
25
|
+
discountContainer: {
|
|
26
|
+
alignItems: "center";
|
|
27
|
+
backgroundColor: string;
|
|
28
|
+
marginBottom: number;
|
|
29
|
+
padding: number;
|
|
30
|
+
textAlign: "center";
|
|
31
|
+
width: string;
|
|
32
|
+
};
|
|
33
|
+
intro: {
|
|
34
|
+
flex: number;
|
|
35
|
+
justifyContent: "space-between";
|
|
36
|
+
};
|
|
37
|
+
percentage: {
|
|
38
|
+
marginLeft: number;
|
|
39
|
+
};
|
|
40
|
+
subtitle: {
|
|
41
|
+
marginBottom: number;
|
|
42
|
+
textAlign: "center";
|
|
43
|
+
};
|
|
44
|
+
tickIcon: {
|
|
45
|
+
marginRight: number;
|
|
46
|
+
};
|
|
47
|
+
title: {
|
|
48
|
+
marginBottom: number;
|
|
49
|
+
textAlign: "center";
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export { style };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { theme } from "../../theme/theme";
|
|
3
|
+
const { borderSize, colorAccent, spaceXS, spaceS, spaceM, spaceL, spaceXL } = theme();
|
|
4
|
+
const style = StyleSheet.create({
|
|
5
|
+
bodyColumn: {
|
|
6
|
+
paddingHorizontal: spaceXL,
|
|
7
|
+
},
|
|
8
|
+
bullet: {
|
|
9
|
+
alignItems: "center",
|
|
10
|
+
flexDirection: "row",
|
|
11
|
+
marginVertical: spaceS,
|
|
12
|
+
},
|
|
13
|
+
content: {
|
|
14
|
+
alignItems: "center",
|
|
15
|
+
},
|
|
16
|
+
description: {
|
|
17
|
+
borderWidth: borderSize,
|
|
18
|
+
marginBottom: spaceXL,
|
|
19
|
+
padding: spaceM,
|
|
20
|
+
width: "100%",
|
|
21
|
+
},
|
|
22
|
+
discount: {
|
|
23
|
+
alignItems: "flex-end",
|
|
24
|
+
flexDirection: "row",
|
|
25
|
+
justifyContent: "center",
|
|
26
|
+
marginBottom: spaceS,
|
|
27
|
+
},
|
|
28
|
+
discountContainer: {
|
|
29
|
+
alignItems: "center",
|
|
30
|
+
backgroundColor: colorAccent,
|
|
31
|
+
marginBottom: spaceL,
|
|
32
|
+
padding: spaceM,
|
|
33
|
+
textAlign: "center",
|
|
34
|
+
width: "100%",
|
|
35
|
+
},
|
|
36
|
+
intro: {
|
|
37
|
+
flex: 1,
|
|
38
|
+
justifyContent: "space-between",
|
|
39
|
+
},
|
|
40
|
+
percentage: {
|
|
41
|
+
marginLeft: spaceXS,
|
|
42
|
+
},
|
|
43
|
+
subtitle: {
|
|
44
|
+
marginBottom: spaceXL,
|
|
45
|
+
textAlign: "center",
|
|
46
|
+
},
|
|
47
|
+
tickIcon: {
|
|
48
|
+
marginRight: spaceS,
|
|
49
|
+
},
|
|
50
|
+
title: {
|
|
51
|
+
marginBottom: spaceM,
|
|
52
|
+
textAlign: "center",
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
export { style };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Button } from "@lookiero/aurora-next/build/components/atoms/Button/Button";
|
|
2
2
|
import { BUTTON_VARIANT } from "@lookiero/aurora-next/build/components/atoms/Button/Button.definition";
|
|
3
3
|
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
4
|
-
import React, { useMemo } from "react";
|
|
4
|
+
import React, { useCallback, useMemo } from "react";
|
|
5
5
|
import { View } from "react-native";
|
|
6
6
|
import { size } from "../../../../../../projection/shared/size";
|
|
7
7
|
import { Sticky } from "../../../../../../shared/ui/components/layouts/sticky/Sticky";
|
|
@@ -18,13 +18,14 @@ const ItemActions = ({ productVariants, productVariantSelected, keepButtonLoadin
|
|
|
18
18
|
value: productVariant.id,
|
|
19
19
|
})), [country, productVariants]);
|
|
20
20
|
const disabledSizeSelector = useMemo(() => sizeSelectorOptions.length === 1 && sizeSelectorOptions[0]?.value === productVariantSelected.id, [sizeSelectorOptions, productVariantSelected.id]);
|
|
21
|
+
const handleOnPressSizeSelector = useCallback(() => onSizeSelectorPress(), [onSizeSelectorPress]);
|
|
21
22
|
return (React.createElement(Sticky, { onLayout: onLayout },
|
|
22
23
|
React.createElement(Body, { style: { column: style.container } },
|
|
23
24
|
React.createElement(Button, { busy: keepButtonLoading, onPress: onKeep }, keepButtonText),
|
|
24
25
|
React.createElement(View, { style: style.row },
|
|
25
26
|
!productVariantSelected.size.unique && (React.createElement(SelectField, { ...(disabledSizeSelector && {
|
|
26
|
-
onPress:
|
|
27
|
-
}), disabled: sizeSelectorDisabled, options: sizeSelectorOptions, placeholder: sizeSelectorLabelText || "", testID: "size-selector",
|
|
27
|
+
onPress: handleOnPressSizeSelector,
|
|
28
|
+
}), disabled: sizeSelectorDisabled, options: sizeSelectorOptions, placeholder: sizeSelectorLabelText || "", testID: "size-selector", value: productVariantSelected.id, style: {
|
|
28
29
|
selectField: style.sizeSelector,
|
|
29
30
|
inputField: { input: (disabledSizeSelector || sizeSelectorDisabled) && style.inputDisabled },
|
|
30
31
|
}, onChange: onReplace })),
|
|
@@ -29,7 +29,7 @@ interface PaymentFlowPayloadReplacedItem extends PaymentFlowPayloadItem {
|
|
|
29
29
|
interface PaymentFlowPayloadKeptItem extends PaymentFlowPayloadItem {
|
|
30
30
|
}
|
|
31
31
|
interface PaymentFlowPayloadProjection {
|
|
32
|
-
readonly bookingId: string;
|
|
32
|
+
readonly bookingId: string | undefined;
|
|
33
33
|
readonly orderId: string;
|
|
34
34
|
readonly comment: string;
|
|
35
35
|
readonly items: (PaymentFlowPayloadKeptItem | PaymentFlowPayloadReplacedItem | PaymentFlowPayloadReturnedItem)[];
|
|
@@ -6,7 +6,7 @@ import { Modal } from "../../layouts/modal/Modal";
|
|
|
6
6
|
import { InputField } from "../inputField/InputField";
|
|
7
7
|
import { style } from "./SelectField.style";
|
|
8
8
|
const { colorGrayscaleS } = theme();
|
|
9
|
-
const SelectField = ({
|
|
9
|
+
const SelectField = ({ placeholder, value, options, style: customStyle, onChange = () => void 0, ...touchableRestProps }) => {
|
|
10
10
|
const [modalVisible, setModalVisible] = useState(false);
|
|
11
11
|
const handleOnPressSelectField = useCallback(() => setModalVisible(true), []);
|
|
12
12
|
const handleOnModalClose = useCallback(() => setModalVisible(false), []);
|
|
@@ -19,10 +19,8 @@ const SelectField = ({ title, placeholder, value, options, style: customStyle, o
|
|
|
19
19
|
React.createElement(TouchableHighlight, { style: customStyle?.selectField, underlayColor: colorGrayscaleS, onPress: handleOnPressSelectField, ...touchableRestProps },
|
|
20
20
|
React.createElement(View, { pointerEvents: "none" },
|
|
21
21
|
React.createElement(InputField, { editable: false, icon: "arrow-down", label: placeholder, style: customStyle?.inputField, value: selectedValue?.label }))),
|
|
22
|
-
React.createElement(Modal, { visible: modalVisible, scroll: true,
|
|
23
|
-
React.createElement(View, { style: [style.modalContent, customStyle?.modalContent] },
|
|
24
|
-
|
|
25
|
-
options.map(({ label, value: optionValue }) => (React.createElement(TouchableHighlight, { key: optionValue, disabled: value === optionValue, style: [style.option, customStyle?.option], underlayColor: colorGrayscaleS, onPress: value !== optionValue ? () => handleOnPressOption(optionValue) : undefined },
|
|
26
|
-
React.createElement(Text, { level: 3, style: [style.optionText, value === optionValue && style.selectedOptionText, customStyle?.optionText] }, label))))))));
|
|
22
|
+
React.createElement(Modal, { visible: modalVisible, scroll: true, onClose: handleOnModalClose },
|
|
23
|
+
React.createElement(View, { style: [style.modalContent, customStyle?.modalContent] }, options.map(({ label, value }) => (React.createElement(TouchableHighlight, { key: value, style: [style.option, customStyle?.option], underlayColor: colorGrayscaleS, onPress: () => handleOnPressOption(value) },
|
|
24
|
+
React.createElement(Text, { level: 3, style: [style.optionText, customStyle?.optionText] }, label))))))));
|
|
27
25
|
};
|
|
28
26
|
export { SelectField };
|
|
@@ -3,10 +3,6 @@ declare const style: {
|
|
|
3
3
|
paddingBottom: number;
|
|
4
4
|
paddingHorizontal: number;
|
|
5
5
|
};
|
|
6
|
-
modalTitle: {
|
|
7
|
-
marginBottom: number;
|
|
8
|
-
textAlign: "center";
|
|
9
|
-
};
|
|
10
6
|
option: {
|
|
11
7
|
borderBottomColor: string;
|
|
12
8
|
borderBottomWidth: number;
|
|
@@ -15,8 +11,5 @@ declare const style: {
|
|
|
15
11
|
optionText: {
|
|
16
12
|
lineHeight: number;
|
|
17
13
|
};
|
|
18
|
-
selectedOptionText: {
|
|
19
|
-
color: string;
|
|
20
|
-
};
|
|
21
14
|
};
|
|
22
15
|
export { style };
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { StyleSheet } from "react-native";
|
|
2
2
|
import { theme } from "../../../../../infrastructure/ui/theme/theme";
|
|
3
|
-
const { borderSize, colorGrayscaleS,
|
|
3
|
+
const { borderSize, colorGrayscaleS, spaceM, spaceXL } = theme();
|
|
4
4
|
const style = StyleSheet.create({
|
|
5
5
|
modalContent: {
|
|
6
6
|
paddingBottom: spaceXL,
|
|
7
7
|
paddingHorizontal: spaceXL,
|
|
8
8
|
},
|
|
9
|
-
modalTitle: {
|
|
10
|
-
marginBottom: spaceL,
|
|
11
|
-
textAlign: "center",
|
|
12
|
-
},
|
|
13
9
|
option: {
|
|
14
10
|
borderBottomColor: colorGrayscaleS,
|
|
15
11
|
borderBottomWidth: borderSize,
|
|
@@ -18,8 +14,5 @@ const style = StyleSheet.create({
|
|
|
18
14
|
optionText: {
|
|
19
15
|
lineHeight: 24,
|
|
20
16
|
},
|
|
21
|
-
selectedOptionText: {
|
|
22
|
-
color: colorGrayscaleM,
|
|
23
|
-
},
|
|
24
17
|
});
|
|
25
18
|
export { style };
|