@lookiero/checkout 3.10.1 → 4.0.0-beta.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/dist/domain/checkoutBooking/event/createNotificationWhenCheckoutBookingExpired.d.ts +6 -0
- package/dist/domain/checkoutBooking/event/createNotificationWhenCheckoutBookingExpired.js +13 -0
- 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/pricing/react/useViewPricingByCheckoutId.d.ts +4 -0
- package/dist/infrastructure/projection/pricing/react/useViewPricingByCheckoutId.js +5 -2
- 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/Root.d.ts +2 -0
- package/dist/infrastructure/ui/Root.js +2 -2
- package/dist/infrastructure/ui/components/templates/SafeAreaScrollView.d.ts +13 -0
- package/dist/infrastructure/ui/components/templates/SafeAreaScrollView.js +19 -0
- package/dist/infrastructure/ui/components/templates/SafeAreaScrollView.style.ts.d.ts +6 -0
- package/dist/infrastructure/ui/components/templates/SafeAreaScrollView.style.ts.js +7 -0
- package/dist/infrastructure/ui/components/templates/header/header/Header.d.ts +3 -0
- package/dist/infrastructure/ui/components/templates/header/header/Header.js +10 -0
- package/dist/infrastructure/ui/components/templates/header/header/Header.style.d.ts +9 -0
- package/dist/infrastructure/ui/components/templates/header/header/Header.style.js +12 -0
- package/dist/infrastructure/ui/components/templates/safeAreaScrollView/SafeAreaScrollView.d.ts +13 -0
- package/dist/infrastructure/ui/components/templates/safeAreaScrollView/SafeAreaScrollView.js +19 -0
- package/dist/infrastructure/ui/components/templates/safeAreaScrollView/SafeAreaScrollView.style.ts.d.ts +6 -0
- package/dist/infrastructure/ui/components/templates/safeAreaScrollView/SafeAreaScrollView.style.ts.js +7 -0
- package/dist/infrastructure/ui/hooks/usePaymentInstrumentUpdateEvents.d.ts +2 -0
- package/dist/infrastructure/ui/hooks/usePaymentInstrumentUpdateEvents.js +28 -0
- package/dist/infrastructure/ui/hooks/useToast.d.ts +11 -0
- package/dist/infrastructure/ui/hooks/useToast.js +49 -0
- package/dist/infrastructure/ui/routing/Routing.d.ts +2 -0
- package/dist/infrastructure/ui/routing/Routing.js +2 -2
- package/dist/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.d.ts +4 -0
- package/dist/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.js +49 -4
- package/dist/infrastructure/ui/views/checkout/components/checkoutSuccessModal/CheckoutSuccessModal.d.ts +7 -0
- package/dist/infrastructure/ui/views/checkout/components/checkoutSuccessModal/CheckoutSuccessModal.js +25 -0
- package/dist/infrastructure/ui/views/checkout/components/checkoutSuccessModal/CheckoutSuccessModal.style.d.ts +16 -0
- package/dist/infrastructure/ui/views/checkout/components/checkoutSuccessModal/CheckoutSuccessModal.style.js +19 -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/Item.style.d.ts +15 -0
- package/dist/infrastructure/ui/views/item/Item.style.js +18 -0
- package/dist/infrastructure/ui/views/item/components/productVariant/ProductVariant.d.ts +26 -0
- package/dist/infrastructure/ui/views/item/components/productVariant/ProductVariant.js +44 -0
- package/dist/infrastructure/ui/views/item/components/productVariant/ProductVariant.style.d.ts +45 -0
- package/dist/infrastructure/ui/views/item/components/productVariant/ProductVariant.style.js +53 -0
- package/dist/infrastructure/ui/views/item/components/sizeChangeModal/SizeChangeModal.d.ts +7 -0
- package/dist/infrastructure/ui/views/item/components/sizeChangeModal/SizeChangeModal.js +25 -0
- package/dist/infrastructure/ui/views/item/components/sizeChangeModal/SizeChangeModal.style.d.ts +16 -0
- package/dist/infrastructure/ui/views/item/components/sizeChangeModal/SizeChangeModal.style.js +19 -0
- package/dist/infrastructure/ui/views/navigation/Navigation.d.ts +21 -0
- package/dist/infrastructure/ui/views/navigation/Navigation.js +45 -0
- package/dist/infrastructure/ui/views/navigation/Navigation.style.d.ts +5 -0
- package/dist/infrastructure/ui/views/navigation/Navigation.style.js +30 -0
- package/dist/infrastructure/ui/views/navigation/components/header/Header.d.ts +46 -0
- package/dist/infrastructure/ui/views/navigation/components/header/Header.js +120 -0
- package/dist/infrastructure/ui/views/navigation/components/header/Header.style.d.ts +31 -0
- package/dist/infrastructure/ui/views/navigation/components/header/Header.style.js +34 -0
- package/dist/infrastructure/ui/views/navigation/components/header/Logo.d.ts +7 -0
- package/dist/infrastructure/ui/views/navigation/components/header/Logo.js +11 -0
- package/dist/infrastructure/ui/views/navigation/components/header/Logo.style.d.ts +7 -0
- package/dist/infrastructure/ui/views/navigation/components/header/Logo.style.js +8 -0
- package/dist/infrastructure/ui/views/summary/components/checkoutItemsTabs/CheckoutItemsTabs.d.ts +12 -0
- package/dist/infrastructure/ui/views/summary/components/checkoutItemsTabs/CheckoutItemsTabs.js +24 -0
- package/dist/infrastructure/ui/views/summary/components/checkoutItemsTabs/CheckoutItemsTabs.style.d.ts +15 -0
- package/dist/infrastructure/ui/views/summary/components/checkoutItemsTabs/CheckoutItemsTabs.style.js +18 -0
- package/dist/projection/shared/order.d.ts +5 -0
- package/dist/projection/shared/order.js +1 -0
- package/dist/shared/notifications/domain/notification/command/createNotification.d.ts +17 -0
- package/dist/shared/notifications/domain/notification/command/createNotification.js +7 -0
- package/dist/shared/notifications/infrastructure/domain/notification/react/useCreateNotification.d.ts +21 -0
- package/dist/shared/notifications/infrastructure/domain/notification/react/useCreateNotification.js +22 -0
- package/dist/shared/notifications/infrastructure/ui/components/NotificationItem.d.ts +12 -0
- package/dist/shared/notifications/infrastructure/ui/components/NotificationItem.js +24 -0
- package/dist/shared/notifications/infrastructure/ui/components/Notifications.d.ts +9 -0
- package/dist/shared/notifications/infrastructure/ui/components/Notifications.js +20 -0
- package/dist/shared/notifications/infrastructure/ui/components/Notifications.style.d.ts +36 -0
- package/dist/shared/notifications/infrastructure/ui/components/Notifications.style.js +31 -0
- package/dist/shared/tracking/infrastructure/usePageView.d.ts +13 -0
- package/dist/shared/tracking/infrastructure/usePageView.js +27 -0
- package/dist/shared/tracking/infrastructure/useTrackCheckout.d.ts +25 -0
- package/dist/shared/tracking/infrastructure/useTrackCheckout.js +30 -0
- package/dist/shared/tracking/tracking.d.ts +15 -3
- package/dist/shared/tracking/tracking.js +2 -0
- package/dist/shared/ui/components/atoms/error/Error.style.d.ts +6 -0
- package/dist/shared/ui/components/atoms/error/Error.style.js +9 -0
- package/dist/shared/ui/components/layouts/slider/Bullets.d.ts +10 -0
- package/dist/shared/ui/components/layouts/slider/Bullets.js +29 -0
- package/dist/shared/ui/components/layouts/slider/Bullets.style.d.ts +12 -0
- package/dist/shared/ui/components/layouts/slider/Bullets.style.js +15 -0
- package/dist/shared/ui/components/layouts/slider/Pagination.d.ts +14 -0
- package/dist/shared/ui/components/layouts/slider/Pagination.js +11 -0
- package/dist/shared/ui/components/layouts/slider/Pagination.style.d.ts +23 -0
- package/dist/shared/ui/components/layouts/slider/Pagination.style.js +27 -0
- package/dist/shared/ui/components/layouts/slider/Slider.d.ts +15 -0
- package/dist/shared/ui/components/layouts/slider/Slider.js +132 -0
- package/dist/shared/ui/components/layouts/slider/Slider.style.d.ts +11 -0
- package/dist/shared/ui/components/layouts/slider/Slider.style.js +12 -0
- package/package.json +1 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ProcessManagerFunction } from "@lookiero/messaging";
|
|
2
|
+
import { CheckoutBookingExpired } from "../model/checkoutBookingExpired";
|
|
3
|
+
interface CreateNotificationWhenCheckoutBookingExpiredFunction extends ProcessManagerFunction<CheckoutBookingExpired> {
|
|
4
|
+
}
|
|
5
|
+
declare const createNotificationWhenCheckoutBookingExpired: CreateNotificationWhenCheckoutBookingExpiredFunction;
|
|
6
|
+
export { createNotificationWhenCheckoutBookingExpired };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { v4 as uuid } from "uuid";
|
|
2
|
+
import { I18nMessages } from "../../../infrastructure/ui/i18n/i18n";
|
|
3
|
+
import { createNotification } from "../../../shared/notifications/domain/notification/command/createNotification";
|
|
4
|
+
import { NotificationLevel } from "../../../shared/notifications/domain/notification/model/notification";
|
|
5
|
+
const createNotificationWhenCheckoutBookingExpired = ({ commandBus }) => async () => {
|
|
6
|
+
await commandBus(createNotification({
|
|
7
|
+
aggregateId: uuid(),
|
|
8
|
+
level: NotificationLevel.ERROR,
|
|
9
|
+
titleI18nKey: undefined,
|
|
10
|
+
bodyI18nKey: I18nMessages.CHECKOUT_TOAST_BOOKING_EXPIRED,
|
|
11
|
+
}));
|
|
12
|
+
};
|
|
13
|
+
export { createNotificationWhenCheckoutBookingExpired };
|
|
@@ -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 };
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { UseQueryFunctionResult } from "@lookiero/messaging-react";
|
|
2
2
|
import { PricingProjection } from "../../../../projection/pricing/pricing";
|
|
3
|
+
interface QueryOptions {
|
|
4
|
+
readonly refetchOnMount?: boolean | "always";
|
|
5
|
+
}
|
|
3
6
|
interface UseViewPricingByCheckoutIdFunctionArgs {
|
|
4
7
|
readonly checkoutId: string;
|
|
8
|
+
readonly queryOptions?: QueryOptions;
|
|
5
9
|
}
|
|
6
10
|
interface UseViewPricingByCheckoutIdFunction {
|
|
7
11
|
(args: UseViewPricingByCheckoutIdFunctionArgs): UseQueryFunctionResult<PricingProjection>;
|
|
@@ -9,12 +9,15 @@ const shouldInvalidate = (event) => isCheckoutItemKept(event) ||
|
|
|
9
9
|
isCheckoutItemReplaced(event) ||
|
|
10
10
|
isCheckoutItemReturned(event) ||
|
|
11
11
|
isCheckoutItemReset(event);
|
|
12
|
-
const
|
|
12
|
+
const DEFAULT_QUERY_OPTIONS = {
|
|
13
|
+
refetchOnMount: "always",
|
|
14
|
+
};
|
|
15
|
+
const useViewPricingByCheckoutId = ({ checkoutId, queryOptions = DEFAULT_QUERY_OPTIONS, }) => useQuery({
|
|
13
16
|
query: viewPricingByCheckoutId({ checkoutId }),
|
|
14
17
|
contextId: MESSAGING_CONTEXT_ID,
|
|
15
18
|
invalidation: shouldInvalidate,
|
|
16
19
|
options: {
|
|
17
|
-
refetchOnMount:
|
|
20
|
+
refetchOnMount: queryOptions.refetchOnMount,
|
|
18
21
|
staleTime: Infinity,
|
|
19
22
|
retry: false,
|
|
20
23
|
refetchOnWindowFocus: false,
|
|
@@ -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 };
|
|
@@ -3,6 +3,7 @@ import { MessagingRoot } from "@lookiero/messaging-react/bootstrap";
|
|
|
3
3
|
import { ComponentType } from "react";
|
|
4
4
|
import { useRoutes as reactRouterUseRoutes } from "react-router-native";
|
|
5
5
|
import { Customer } from "../../projection/shared/customer";
|
|
6
|
+
import { Order } from "../../projection/shared/order";
|
|
6
7
|
import { SentryEnvironment } from "../../shared/logging/SentryLogger";
|
|
7
8
|
import { Layout } from "./components/layouts/layout/Layout";
|
|
8
9
|
interface RootFunctionArgs {
|
|
@@ -19,6 +20,7 @@ interface RootProps {
|
|
|
19
20
|
readonly basePath: string;
|
|
20
21
|
readonly locale?: string;
|
|
21
22
|
readonly customer: Customer | undefined;
|
|
23
|
+
readonly order: Order | undefined;
|
|
22
24
|
readonly layout: Layout;
|
|
23
25
|
readonly onNotAccessible: () => void;
|
|
24
26
|
readonly onCheckoutSubmitted?: () => void;
|
|
@@ -7,10 +7,10 @@ import { Routing } from "./routing/Routing";
|
|
|
7
7
|
const root = ({ Messaging, I18n, getAuthToken, development, sentry }) => {
|
|
8
8
|
const logger = sentryLogger(sentry);
|
|
9
9
|
// eslint-disable-next-line react/display-name, react/prop-types
|
|
10
|
-
const Root = ({ basePath, locale = "en", customer, layout, onNotAccessible, onCheckoutSubmitted, useRedirect, useRoutes = reactRouterUseRoutes, }) => {
|
|
10
|
+
const Root = ({ basePath, locale = "en", customer, order, layout, onNotAccessible, onCheckoutSubmitted, useRedirect, useRoutes = reactRouterUseRoutes, }) => {
|
|
11
11
|
const handleOnI18nError = useCallback((error) => logger.captureException(error), []);
|
|
12
12
|
return (React.createElement(Messaging, { includeReactQueryDevTools: Platform.OS === "web" },
|
|
13
|
-
React.createElement(Routing, { I18n: I18n, basePath: basePath, customer: customer, getAuthToken: getAuthToken, layout: layout, locale: locale, useRedirect: useRedirect, useRoutes: useRoutes, onCheckoutSubmitted: onCheckoutSubmitted, onI18nError: development ? undefined : handleOnI18nError, onNotAccessible: onNotAccessible })));
|
|
13
|
+
React.createElement(Routing, { I18n: I18n, basePath: basePath, customer: customer, getAuthToken: getAuthToken, layout: layout, locale: locale, order: order, useRedirect: useRedirect, useRoutes: useRoutes, onCheckoutSubmitted: onCheckoutSubmitted, onI18nError: development ? undefined : handleOnI18nError, onNotAccessible: onNotAccessible })));
|
|
14
14
|
};
|
|
15
15
|
return sentryLoggerHOC({ logger })(Root);
|
|
16
16
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FC, ReactNode } from "react";
|
|
2
|
+
import { StyleProp, ViewStyle } from "react-native";
|
|
3
|
+
import { Edge } from "react-native-safe-area-context";
|
|
4
|
+
type SafeAreaScrollViewStyle = "safeAreaView" | "scrollView";
|
|
5
|
+
interface SafeAreaScrollViewProps {
|
|
6
|
+
readonly children: ReactNode;
|
|
7
|
+
readonly footer?: ReactNode;
|
|
8
|
+
readonly scrollerPaddingTop?: number;
|
|
9
|
+
readonly edges?: Edge[];
|
|
10
|
+
readonly style?: Partial<Record<SafeAreaScrollViewStyle, StyleProp<ViewStyle>>>;
|
|
11
|
+
}
|
|
12
|
+
declare const SafeAreaScrollView: FC<SafeAreaScrollViewProps>;
|
|
13
|
+
export { SafeAreaScrollView };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ScrollView } from "react-native";
|
|
3
|
+
import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
|
|
4
|
+
import { theme } from "../../theme/theme";
|
|
5
|
+
import { style } from "./SafeAreaScrollView.style.ts";
|
|
6
|
+
const { spaceXXL } = theme();
|
|
7
|
+
const SafeAreaScrollView = ({ children, footer, edges = ["top", "left", "right"], style: customStyle, scrollerPaddingTop = 0, }) => {
|
|
8
|
+
const { bottom: safeAreaInsetBottom } = useSafeAreaInsets();
|
|
9
|
+
return (React.createElement(SafeAreaView, { edges: edges, style: [style.safeAreaView, customStyle?.safeAreaView] },
|
|
10
|
+
React.createElement(ScrollView, { contentContainerStyle: [
|
|
11
|
+
{
|
|
12
|
+
paddingTop: scrollerPaddingTop,
|
|
13
|
+
paddingBottom: safeAreaInsetBottom + spaceXXL,
|
|
14
|
+
},
|
|
15
|
+
customStyle?.scrollView,
|
|
16
|
+
] }, children),
|
|
17
|
+
footer));
|
|
18
|
+
};
|
|
19
|
+
export { SafeAreaScrollView };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ButtonIcon } from "../../../../../../shared/ui/components/molecules/buttonIcon/ButtonIcon";
|
|
3
|
+
import { ButtonIconPlaceholder } from "../buttonIconPlaceholder/ButtonIconPlaceholder";
|
|
4
|
+
import { Logo } from "../logo/Logo";
|
|
5
|
+
import { style } from "./Header.style";
|
|
6
|
+
const Header = () => (React.createElement(React.Fragment, null,
|
|
7
|
+
React.createElement(Logo, { style: style.logo }),
|
|
8
|
+
React.createElement(ButtonIconPlaceholder, null),
|
|
9
|
+
React.createElement(ButtonIcon, { name: "menu", testID: "menu-button-icon", onPress: () => void 0 })));
|
|
10
|
+
export { Header };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { theme } from "../../../../theme/theme";
|
|
3
|
+
const { spaceXXXL } = theme();
|
|
4
|
+
const HEADER_HEIGHT = spaceXXXL;
|
|
5
|
+
const style = StyleSheet.create({
|
|
6
|
+
logo: {
|
|
7
|
+
left: 0,
|
|
8
|
+
position: "absolute",
|
|
9
|
+
top: 0,
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
export { style, HEADER_HEIGHT };
|
package/dist/infrastructure/ui/components/templates/safeAreaScrollView/SafeAreaScrollView.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FC, ReactNode } from "react";
|
|
2
|
+
import { StyleProp, ViewStyle } from "react-native";
|
|
3
|
+
import { Edge } from "react-native-safe-area-context";
|
|
4
|
+
type SafeAreaScrollViewStyle = "safeAreaView" | "scrollView";
|
|
5
|
+
interface SafeAreaScrollViewProps {
|
|
6
|
+
readonly children: ReactNode;
|
|
7
|
+
readonly footer?: ReactNode;
|
|
8
|
+
readonly scrollerPaddingTop?: number;
|
|
9
|
+
readonly edges?: Edge[];
|
|
10
|
+
readonly style?: Partial<Record<SafeAreaScrollViewStyle, StyleProp<ViewStyle>>>;
|
|
11
|
+
}
|
|
12
|
+
declare const SafeAreaScrollView: FC<SafeAreaScrollViewProps>;
|
|
13
|
+
export { SafeAreaScrollView };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ScrollView } from "react-native";
|
|
3
|
+
import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
|
|
4
|
+
import { theme } from "../../../theme/theme.js";
|
|
5
|
+
import { style } from "./SafeAreaScrollView.style.ts";
|
|
6
|
+
const { spaceXXL } = theme();
|
|
7
|
+
const SafeAreaScrollView = ({ children, footer, edges = ["top", "left", "right"], style: customStyle, scrollerPaddingTop = 0, }) => {
|
|
8
|
+
const { bottom: safeAreaInsetBottom } = useSafeAreaInsets();
|
|
9
|
+
return (React.createElement(SafeAreaView, { edges: edges, style: [style.safeAreaView, customStyle?.safeAreaView] },
|
|
10
|
+
React.createElement(ScrollView, { contentContainerStyle: [
|
|
11
|
+
{
|
|
12
|
+
paddingTop: scrollerPaddingTop,
|
|
13
|
+
paddingBottom: safeAreaInsetBottom + spaceXXL,
|
|
14
|
+
},
|
|
15
|
+
customStyle?.scrollView,
|
|
16
|
+
] }, children),
|
|
17
|
+
footer));
|
|
18
|
+
};
|
|
19
|
+
export { SafeAreaScrollView };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useEvent } from "@lookiero/event";
|
|
2
|
+
import { useCallback, useEffect } from "react";
|
|
3
|
+
import { useCreateNotification } from "../../../shared/notifications";
|
|
4
|
+
import { MESSAGING_CONTEXT_ID } from "../../delivery/baseBootstrap";
|
|
5
|
+
import { I18nMessages } from "../i18n/i18n";
|
|
6
|
+
import { useToast } from "./useToast";
|
|
7
|
+
const PAYMENT_ERROR = "ERROR";
|
|
8
|
+
const PAYMENT_SUCCESS = "PAYMENT_INSTRUMENT_UPDATED";
|
|
9
|
+
const usePaymentInstrumentUpdateEvents = () => {
|
|
10
|
+
const { subscribe, unsubscribe } = useEvent();
|
|
11
|
+
const { showError, showSuccess } = useToast();
|
|
12
|
+
const [createNotification] = useCreateNotification({ contextId: MESSAGING_CONTEXT_ID });
|
|
13
|
+
const onSuccess = useCallback(({ message }) => showSuccess({ message: message.id }), [showSuccess]);
|
|
14
|
+
const onError = useCallback(({ error }) => {
|
|
15
|
+
if (error.toaster) {
|
|
16
|
+
showError({ message: error.toaster.id || I18nMessages.CHECKOUT_TOAST_PAYMENT_ERROR });
|
|
17
|
+
}
|
|
18
|
+
}, [showError]);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
subscribe({ event: PAYMENT_ERROR }, onError);
|
|
21
|
+
subscribe({ event: PAYMENT_SUCCESS }, onSuccess);
|
|
22
|
+
return () => {
|
|
23
|
+
unsubscribe({ event: PAYMENT_ERROR }, onError);
|
|
24
|
+
unsubscribe({ event: PAYMENT_SUCCESS }, onSuccess);
|
|
25
|
+
};
|
|
26
|
+
}, [subscribe, unsubscribe, createNotification, onError, onSuccess]);
|
|
27
|
+
};
|
|
28
|
+
export { usePaymentInstrumentUpdateEvents };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface ShowErrorFunctionArgs {
|
|
2
|
+
readonly message: string;
|
|
3
|
+
}
|
|
4
|
+
interface ShowErrorFunction {
|
|
5
|
+
(args: ShowErrorFunctionArgs): void;
|
|
6
|
+
}
|
|
7
|
+
declare const useToast: () => {
|
|
8
|
+
showError: ShowErrorFunction;
|
|
9
|
+
showSuccess: ShowErrorFunction;
|
|
10
|
+
};
|
|
11
|
+
export { useToast };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Notification, useStack } from "@lookiero/aurora";
|
|
2
|
+
import { useIntl } from "@lookiero/i18n-react";
|
|
3
|
+
import { useCallback } from "react";
|
|
4
|
+
import { StyleSheet } from "react-native";
|
|
5
|
+
import { v4 as uuid } from "uuid";
|
|
6
|
+
import { theme } from "../theme/theme";
|
|
7
|
+
const { layoutXXS, elevationColor, elevationOffset, elevationOpacityM, elevationRadius } = theme();
|
|
8
|
+
const style = StyleSheet.create({
|
|
9
|
+
container: {
|
|
10
|
+
marginHorizontal: layoutXXS,
|
|
11
|
+
marginTop: layoutXXS,
|
|
12
|
+
shadowColor: elevationColor,
|
|
13
|
+
shadowOffset: elevationOffset,
|
|
14
|
+
shadowOpacity: elevationOpacityM,
|
|
15
|
+
shadowRadius: elevationRadius,
|
|
16
|
+
},
|
|
17
|
+
inAppContainer: {
|
|
18
|
+
top: 75,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
const NOTIFICATION_DEFAULTS = {
|
|
22
|
+
motion: "top",
|
|
23
|
+
timeoutClose: 10000,
|
|
24
|
+
style: style.container,
|
|
25
|
+
};
|
|
26
|
+
const IN_APP_NOTIFICATION_DEFAULTS = {
|
|
27
|
+
...NOTIFICATION_DEFAULTS,
|
|
28
|
+
style: [style.container, style.inAppContainer],
|
|
29
|
+
};
|
|
30
|
+
const iOSInAppBrowser = window.screen?.height > 667 && /FBIOS/.test(navigator.userAgent);
|
|
31
|
+
const getNotificationDefaults = () => (iOSInAppBrowser ? IN_APP_NOTIFICATION_DEFAULTS : NOTIFICATION_DEFAULTS);
|
|
32
|
+
const useToast = () => {
|
|
33
|
+
const Stack = useStack();
|
|
34
|
+
const intl = useIntl();
|
|
35
|
+
const translate = useCallback((message) => intl.formatMessage({ id: message, defaultMessage: message }), [intl]);
|
|
36
|
+
const showError = useCallback(({ message }) => Stack.alert(uuid(),
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
Notification, { ...getNotificationDefaults(), text: translate(message) }), [Stack, translate]);
|
|
40
|
+
const showSuccess = useCallback(({ message }) => Stack.success(uuid(),
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
Notification, { ...getNotificationDefaults(), text: translate(message) }), [Stack, translate]);
|
|
44
|
+
return {
|
|
45
|
+
showError,
|
|
46
|
+
showSuccess,
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export { useToast };
|
|
@@ -2,10 +2,12 @@ import { I18n } from "@lookiero/i18n-react";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { useRoutes as reactRouterUseRoutes } from "react-router-native";
|
|
4
4
|
import { Customer } from "../../../projection/shared/customer";
|
|
5
|
+
import { Order } from "../../../projection/shared/order";
|
|
5
6
|
import { Layout } from "../components/layouts/layout/Layout";
|
|
6
7
|
interface RoutingProps {
|
|
7
8
|
readonly basePath?: string;
|
|
8
9
|
readonly customer: Customer | undefined;
|
|
10
|
+
readonly order: Order | undefined;
|
|
9
11
|
readonly locale: string;
|
|
10
12
|
readonly I18n: I18n;
|
|
11
13
|
readonly layout: Layout;
|
|
@@ -12,7 +12,7 @@ const Summary = lazy(() => import("../views/summary/Summary").then((module) => (
|
|
|
12
12
|
const SummaryTabs = lazy(() => import("../views/summaryTabs/SummaryTabs").then((module) => ({ default: module.SummaryTabs })));
|
|
13
13
|
const Checkout = lazy(() => import("../views/checkout/Checkout").then((module) => ({ default: module.Checkout })));
|
|
14
14
|
const Feedback = lazy(() => import("../views/feedback/Feedback").then((module) => ({ default: module.Feedback })));
|
|
15
|
-
const Routing = ({ basePath = "", customer, locale, I18n, layout, getAuthToken, onI18nError, onNotAccessible, onCheckoutSubmitted, useRedirect, useRoutes = reactRouterUseRoutes, }) => {
|
|
15
|
+
const Routing = ({ basePath = "", customer, order, locale, I18n, layout, getAuthToken, onI18nError, onNotAccessible, onCheckoutSubmitted, useRedirect, useRoutes = reactRouterUseRoutes, }) => {
|
|
16
16
|
return useRoutes([
|
|
17
17
|
{
|
|
18
18
|
path: "",
|
|
@@ -54,7 +54,7 @@ const Routing = ({ basePath = "", customer, locale, I18n, layout, getAuthToken,
|
|
|
54
54
|
children: [
|
|
55
55
|
{
|
|
56
56
|
path: Routes.CHECKOUT_PAYMENT,
|
|
57
|
-
element: (React.createElement(CheckoutPaymentModal, { customerId: customer?.customerId, getAuthToken: getAuthToken, onCheckoutSubmitted: onCheckoutSubmitted })),
|
|
57
|
+
element: (React.createElement(CheckoutPaymentModal, { country: customer?.country, customerId: customer?.customerId, getAuthToken: getAuthToken, isFirstOrder: order?.isFirstOrder, orderNumber: order?.orderNumber, onCheckoutSubmitted: onCheckoutSubmitted })),
|
|
58
58
|
},
|
|
59
59
|
],
|
|
60
60
|
},
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
|
+
import { Country } from "../../../../../../projection/shared/country";
|
|
2
3
|
interface CheckoutPaymentModalProps {
|
|
3
4
|
readonly customerId: string;
|
|
5
|
+
readonly country: Country;
|
|
6
|
+
readonly orderNumber: number;
|
|
7
|
+
readonly isFirstOrder: boolean;
|
|
4
8
|
readonly getAuthToken: () => Promise<string>;
|
|
5
9
|
readonly onCheckoutSubmitted?: () => void;
|
|
6
10
|
}
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
+
import { useIntl } from "@lookiero/i18n-react";
|
|
1
2
|
import { QueryStatus } from "@lookiero/messaging-react";
|
|
2
3
|
import { PaymentFlow } from "@lookiero/payments-front";
|
|
3
4
|
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
4
5
|
import { useNavigate } from "react-router-native";
|
|
6
|
+
import { CheckoutItemStatus } from "../../../../../../domain/checkoutItem/model/checkoutItem";
|
|
5
7
|
import { useLogger } from "../../../../../../shared/logging/useLogger";
|
|
8
|
+
import { useTrackCheckout } from "../../../../../../shared/tracking/infrastructure/useTrackCheckout";
|
|
6
9
|
import { useViewFirstAvailableCheckoutByCustomerId } from "../../../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
|
|
7
10
|
import { useViewIsSizeChangeEnabledByCheckoutId } from "../../../../../projection/checkout/react/useViewIsSizeChangeEnabledByCheckoutId";
|
|
8
11
|
import { useViewPaymentFlowPayloadByCheckoutId } from "../../../../../projection/payment/react/useViewPaymentFlowPayloadByCheckoutId";
|
|
12
|
+
import { useViewPricingByCheckoutId } from "../../../../../projection/pricing/react/useViewPricingByCheckoutId";
|
|
13
|
+
import { TrackingPage } from "../../../../../tracking/tracking";
|
|
9
14
|
import { useSubmitCheckout } from "../../../../hooks/useSubmitCheckout";
|
|
10
15
|
import { Routes } from "../../../../routing/routes";
|
|
11
16
|
import { useBasePath } from "../../../../routing/useBasePath";
|
|
12
|
-
const CheckoutPaymentModal = ({ customerId, getAuthToken, onCheckoutSubmitted }) => {
|
|
17
|
+
const CheckoutPaymentModal = ({ customerId, country, isFirstOrder, orderNumber, getAuthToken, onCheckoutSubmitted, }) => {
|
|
13
18
|
const paymentFlowRef = useRef(null);
|
|
14
19
|
const logger = useLogger();
|
|
15
20
|
const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
|
|
@@ -17,6 +22,10 @@ const CheckoutPaymentModal = ({ customerId, getAuthToken, onCheckoutSubmitted })
|
|
|
17
22
|
checkoutId: checkout?.id,
|
|
18
23
|
});
|
|
19
24
|
const [sizeChangeEnabled] = useViewIsSizeChangeEnabledByCheckoutId({ checkoutId: checkout?.id });
|
|
25
|
+
const [pricing] = useViewPricingByCheckoutId({
|
|
26
|
+
checkoutId: checkout?.id,
|
|
27
|
+
queryOptions: { refetchOnMount: true },
|
|
28
|
+
});
|
|
20
29
|
const [authToken, setAuthToken] = useState();
|
|
21
30
|
useEffect(() => {
|
|
22
31
|
const loadAuthToken = async () => setAuthToken(await getAuthToken());
|
|
@@ -24,20 +33,56 @@ const CheckoutPaymentModal = ({ customerId, getAuthToken, onCheckoutSubmitted })
|
|
|
24
33
|
}, [getAuthToken]);
|
|
25
34
|
const basePath = useBasePath();
|
|
26
35
|
const navigate = useNavigate();
|
|
36
|
+
const intl = useIntl();
|
|
37
|
+
const translateNumber = useCallback((value) => intl.formatNumber(value.amount / 100, { style: "currency", currency: value.currency }), [intl]);
|
|
38
|
+
const trackCheckout = useTrackCheckout({
|
|
39
|
+
checkoutId: checkout?.id,
|
|
40
|
+
country,
|
|
41
|
+
page: TrackingPage.CHECKOUT,
|
|
42
|
+
});
|
|
27
43
|
const handleOnSubmitCheckoutError = useCallback(() => navigate(`${basePath}/${Routes.CHECKOUT}`, { replace: true }), [basePath, navigate]);
|
|
44
|
+
const handleOnSubmitCheckoutSuccess = useCallback(() => {
|
|
45
|
+
const checkoutItemsKept = checkout?.items.filter((checkoutItem) => checkoutItem.status === CheckoutItemStatus.KEPT || checkoutItem.status === CheckoutItemStatus.REPLACED);
|
|
46
|
+
const checkoutItems = checkoutItemsKept?.length || 0;
|
|
47
|
+
const checkoutItemId = checkout?.items.map((checkoutItem) => checkoutItem.id) || [];
|
|
48
|
+
const pendingToPay = pricing?.pendingToPay;
|
|
49
|
+
const checkoutValue = translateNumber(pendingToPay);
|
|
50
|
+
const productVariantId = checkoutItemsKept?.map(({ productVariant }) => productVariant.id) || [];
|
|
51
|
+
const sizeChange = checkoutItemsKept?.filter(({ replacedFor }) => Boolean(replacedFor)).map(({ id }) => id) || [];
|
|
52
|
+
trackCheckout({
|
|
53
|
+
checkoutItems,
|
|
54
|
+
checkoutItemId,
|
|
55
|
+
checkoutValue,
|
|
56
|
+
isFirstOrder,
|
|
57
|
+
orderNumber,
|
|
58
|
+
productVariantId,
|
|
59
|
+
sizeChange,
|
|
60
|
+
userId: customerId,
|
|
61
|
+
});
|
|
62
|
+
onCheckoutSubmitted?.();
|
|
63
|
+
}, [
|
|
64
|
+
checkout?.items,
|
|
65
|
+
customerId,
|
|
66
|
+
isFirstOrder,
|
|
67
|
+
onCheckoutSubmitted,
|
|
68
|
+
orderNumber,
|
|
69
|
+
pricing?.pendingToPay,
|
|
70
|
+
trackCheckout,
|
|
71
|
+
translateNumber,
|
|
72
|
+
]);
|
|
28
73
|
const [submitCheckout] = useSubmitCheckout({
|
|
29
74
|
checkoutId: checkout?.id,
|
|
30
75
|
checkoutBookingId: checkout?.checkoutBookingId,
|
|
31
76
|
paymentFlowRef,
|
|
32
77
|
onError: handleOnSubmitCheckoutError,
|
|
33
|
-
onSuccess:
|
|
78
|
+
onSuccess: handleOnSubmitCheckoutSuccess,
|
|
34
79
|
logger,
|
|
35
80
|
});
|
|
36
81
|
useEffect(() => {
|
|
37
|
-
if (paymentFlowPayload && sizeChangeEnabled !== undefined) {
|
|
82
|
+
if (paymentFlowPayload && sizeChangeEnabled !== undefined && pricing !== undefined) {
|
|
38
83
|
submitCheckout({ paymentFlowPayload, sizeChangeEnabled });
|
|
39
84
|
}
|
|
40
|
-
}, [paymentFlowPayload, sizeChangeEnabled, submitCheckout]);
|
|
85
|
+
}, [paymentFlowPayload, pricing, sizeChangeEnabled, submitCheckout]);
|
|
41
86
|
const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
|
|
42
87
|
const dependenciesLoaded = (dependenciesLoadedStatuses.includes(checkoutStatus) || checkout) && authToken;
|
|
43
88
|
if (!dependenciesLoaded)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Button } from "@lookiero/aurora-next/build/components/atoms/Button/Button";
|
|
2
|
+
import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
|
|
3
|
+
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { View } from "react-native";
|
|
6
|
+
import { Modal } from "../../../../../../shared/ui/components/layouts/modal/Modal";
|
|
7
|
+
import { I18nMessages } from "../../../../i18n/i18n";
|
|
8
|
+
import { style } from "./CheckoutSuccessModal.style";
|
|
9
|
+
const CheckoutSuccessModal = ({ visible, onDismiss }) => {
|
|
10
|
+
const titleText = useI18nMessage({ id: I18nMessages.CHECKOUT_SUCCESS_MODAL_TITLE });
|
|
11
|
+
const descriptionText = useI18nMessage({ id: I18nMessages.CHECKOUT_SUCCESS_MODAL_DESCRIPTION });
|
|
12
|
+
const buttonText = useI18nMessage({ id: I18nMessages.CHECKOUT_SUCCESS_MODAL_BUTTON });
|
|
13
|
+
return (React.createElement(Modal, { visible: visible, onClose: onDismiss },
|
|
14
|
+
React.createElement(View, { style: style.modal },
|
|
15
|
+
React.createElement(Text, { level: 1, style: style.modalTitle, body: true }, titleText),
|
|
16
|
+
React.createElement(Text, { level: 3, style: style.modalDescription, body: true }, descriptionText),
|
|
17
|
+
React.createElement(Button
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
, {
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
style: style.button, onPress: onDismiss }, buttonText))));
|
|
24
|
+
};
|
|
25
|
+
export { CheckoutSuccessModal };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { theme } from "../../../../theme/theme";
|
|
3
|
+
const { spaceXL } = theme();
|
|
4
|
+
const style = StyleSheet.create({
|
|
5
|
+
button: {
|
|
6
|
+
flex: 0,
|
|
7
|
+
},
|
|
8
|
+
modal: {
|
|
9
|
+
padding: spaceXL,
|
|
10
|
+
},
|
|
11
|
+
modalDescription: {
|
|
12
|
+
marginVertical: spaceXL,
|
|
13
|
+
textAlign: "center",
|
|
14
|
+
},
|
|
15
|
+
modalTitle: {
|
|
16
|
+
textAlign: "center",
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
export { style };
|