@lookiero/checkout 3.0.0-beta.1 → 3.0.0-beta.2
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/ui/components/layouts/layout/Layout.d.ts +7 -0
- package/dist/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.js +8 -7
- package/dist/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.style.d.ts +3 -0
- package/dist/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.style.js +3 -0
- package/dist/infrastructure/ui/views/checkout/Checkout.js +13 -14
- package/dist/infrastructure/ui/views/feedback/Feedback.js +3 -5
- package/dist/infrastructure/ui/views/item/Item.js +3 -1
- package/dist/infrastructure/ui/views/item/views/itemWithCustomerDecission/ItemWithCustomerDecission.js +5 -6
- package/dist/infrastructure/ui/views/item/views/itemWithoutCustomerDecission/ItemWithoutCustomerDecission.js +2 -2
- package/dist/infrastructure/ui/views/notFound/NotFound.js +7 -8
- package/dist/infrastructure/ui/views/summary/Summary.js +7 -3
- package/dist/infrastructure/ui/views/summary/Summary.style.d.ts +0 -3
- package/dist/infrastructure/ui/views/summary/Summary.style.js +1 -4
- package/package.json +1 -1
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { FC, ReactNode } from "react";
|
|
2
|
+
import { LayoutChangeEvent, StyleProp, ViewStyle } from "react-native";
|
|
3
|
+
interface LayoutStyle {
|
|
4
|
+
readonly safeAreaView: StyleProp<ViewStyle>;
|
|
5
|
+
readonly scrollView: StyleProp<ViewStyle>;
|
|
6
|
+
}
|
|
2
7
|
interface LayoutProps {
|
|
3
8
|
readonly children: ReactNode;
|
|
4
9
|
readonly header?: JSX.Element | null;
|
|
@@ -6,6 +11,8 @@ interface LayoutProps {
|
|
|
6
11
|
readonly panel?: JSX.Element | null;
|
|
7
12
|
readonly stickyHeader?: boolean;
|
|
8
13
|
readonly stickyHeaderHiddenOnScroll?: boolean;
|
|
14
|
+
readonly style?: Partial<LayoutStyle>;
|
|
15
|
+
readonly onLayout?: (event: LayoutChangeEvent) => void;
|
|
9
16
|
}
|
|
10
17
|
type Layout = FC<LayoutProps>;
|
|
11
18
|
export type { Layout };
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
1
2
|
import React from "react";
|
|
2
|
-
import { View } from "react-native";
|
|
3
|
+
import { ScrollView, View } from "react-native";
|
|
3
4
|
import { SafeAreaView } from "react-native-safe-area-context";
|
|
4
5
|
import { Footer as DefaultFooter } from "../../../templates/footer/Footer";
|
|
5
6
|
import { DefaultHeader } from "../../../templates/header/defaultHeader/DefaultHeader";
|
|
6
7
|
import { Footer } from "../components/footer/Footer";
|
|
7
8
|
import { Header } from "../components/header/Header";
|
|
8
9
|
import { style } from "./DummyLayout.style";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
const DummyLayout = ({ children, header = React.createElement(DefaultHeader, null), footer = React.createElement(DefaultFooter, null), panel, style: customStyle, onLayout, }) => (React.createElement(SafeAreaView, { style: [style.safeAreaView, customStyle?.safeAreaView] },
|
|
11
|
+
React.createElement(ScrollView, { contentContainerStyle: [style.scrollView, customStyle?.scrollView], scrollEventThrottle: 16, showsVerticalScrollIndicator: false, stickyHeaderIndices: [0] },
|
|
12
|
+
React.createElement(Header, null, header),
|
|
13
|
+
panel,
|
|
14
|
+
React.createElement(View, { style: style.children, onLayout: onLayout }, children)),
|
|
15
|
+
React.createElement(Footer, null, footer)));
|
|
15
16
|
export { DummyLayout };
|
|
@@ -2,7 +2,7 @@ import { Text } from "@lookiero/aurora";
|
|
|
2
2
|
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
3
3
|
import { QueryStatus } from "@lookiero/messaging-react";
|
|
4
4
|
import React, { useCallback, useMemo } from "react";
|
|
5
|
-
import {
|
|
5
|
+
import { View } from "react-native";
|
|
6
6
|
import { useNavigate } from "react-router-native";
|
|
7
7
|
import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
|
|
8
8
|
import { useTrackPageView } from "../../../../shared/tracking/infrastructure/useTrackPageView";
|
|
@@ -55,19 +55,18 @@ const Checkout = ({ children, customerId, country, layout: Layout, useRedirect }
|
|
|
55
55
|
dependenciesLoadedStatuses.includes(pricingStatus);
|
|
56
56
|
if (!dependenciesLoaded)
|
|
57
57
|
return React.createElement(Spinner, null);
|
|
58
|
-
return (React.createElement(Layout, { header: React.createElement(CheckoutHeader, { onBack: handleOnBack }) },
|
|
59
|
-
React.createElement(
|
|
60
|
-
React.createElement(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
React.createElement(Pricing, { balanceDiscount: pricing.balanceDiscount, collapsible: false, discount: pricing.discount, discountPercentage: pricing.discountPercentage, pendingToPay: pricing.pendingToPay, service: pricing.service, subtotal: pricing.subtotal, totalCheckoutItemsKept: checkoutItemsKept?.length || 0, onSubmit: handleOnSubmit }))))),
|
|
58
|
+
return (React.createElement(Layout, { header: React.createElement(CheckoutHeader, { onBack: handleOnBack }), style: { scrollView: style.container } },
|
|
59
|
+
React.createElement(Body, { style: { column: style.bodyColumn } },
|
|
60
|
+
hasReplacedCheckoutItem && (React.createElement(View, { style: style.deliveryBannerContainer },
|
|
61
|
+
React.createElement(DeliveryBanner, null))),
|
|
62
|
+
React.createElement(PaymentInstrument, { useRedirect: useRedirect }),
|
|
63
|
+
React.createElement(Text, { level: 3, style: style.title, heading: true }, titleText),
|
|
64
|
+
checkoutItemsKept?.map((checkoutItem) => (React.createElement(View, { key: checkoutItem.id, style: style.checkoutItemKept, testID: "checkout-items-kept" },
|
|
65
|
+
React.createElement(ProductVariant, { brand: checkoutItem.productVariant.brand, color: checkoutItem.productVariant.color, country: country, media: checkoutItem.productVariant.media, name: checkoutItem.productVariant.name, price: checkoutItem.price, status: checkoutItem.status, size: checkoutItem.status === CheckoutItemStatus.REPLACED && checkoutItem.replacedFor
|
|
66
|
+
? checkoutItem.replacedFor.size
|
|
67
|
+
: checkoutItem.productVariant.size })))),
|
|
68
|
+
pricing && (React.createElement(View, { style: style.pricingContainer },
|
|
69
|
+
React.createElement(Pricing, { balanceDiscount: pricing.balanceDiscount, collapsible: false, discount: pricing.discount, discountPercentage: pricing.discountPercentage, pendingToPay: pricing.pendingToPay, service: pricing.service, subtotal: pricing.subtotal, totalCheckoutItemsKept: checkoutItemsKept?.length || 0, onSubmit: handleOnSubmit })))),
|
|
71
70
|
children));
|
|
72
71
|
};
|
|
73
72
|
export { Checkout };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
|
|
2
2
|
import React, { useCallback, useEffect, useRef } from "react";
|
|
3
|
-
import { ScrollView } from "react-native";
|
|
4
3
|
import { CheckoutQuestionType } from "../../../../projection/checkoutQuestion/checkoutQuestion";
|
|
5
4
|
import { useLogger } from "../../../../shared/logging/useLogger";
|
|
6
5
|
import { useTrackChangeFeedback } from "../../../../shared/tracking/infrastructure/useTrackChangeFeedback";
|
|
@@ -74,9 +73,8 @@ const Feedback = ({ customerId, country, layout: Layout }) => {
|
|
|
74
73
|
if (!dependenciesLoaded)
|
|
75
74
|
return React.createElement(Spinner, null);
|
|
76
75
|
return (React.createElement(CheckoutQuestionFeedbackProvider, { feedback: {}, onChanged: handleOnChangedFeedback },
|
|
77
|
-
React.createElement(Layout,
|
|
78
|
-
React.createElement(
|
|
79
|
-
React.createElement(
|
|
80
|
-
React.createElement(CheckoutQuestionsForm, { checkoutQuestions: checkoutQuestions || [], submitButtonDisabled: giveCheckoutFeedbackStatus === CommandStatus.LOADING, onSubmit: handleOnSubmit }))))));
|
|
76
|
+
React.createElement(Layout, { style: { scrollView: style.container } },
|
|
77
|
+
React.createElement(Body, { style: { column: style.bodyColumn } },
|
|
78
|
+
React.createElement(CheckoutQuestionsForm, { checkoutQuestions: checkoutQuestions || [], submitButtonDisabled: giveCheckoutFeedbackStatus === CommandStatus.LOADING, onSubmit: handleOnSubmit })))));
|
|
81
79
|
};
|
|
82
80
|
export { Feedback };
|
|
@@ -126,6 +126,8 @@ const Item = ({ customerId, country, layout: Layout }) => {
|
|
|
126
126
|
const basePath = useBasePath();
|
|
127
127
|
const itemDetailRouteMatch = useMatch(`${basePath}/${Routes.ITEM_DETAIL}`);
|
|
128
128
|
const header = useMemo(() => itemDetailRouteMatch ? (React.createElement(ItemDetailHeader, { onBack: handleOnBack })) : (React.createElement(ItemHeader, { item: checkoutItem, items: checkout?.items, onNext: handleOnNext, onPrevious: handleOnPrevious })), [checkout?.items, checkoutItem, handleOnBack, handleOnNext, handleOnPrevious, itemDetailRouteMatch]);
|
|
129
|
+
const [height, setHeight] = useState(0);
|
|
130
|
+
const handleOnLayout = useCallback((event) => setHeight(event.nativeEvent.layout.height), []);
|
|
129
131
|
const dependenciesLoaded = checkoutStatus !== QueryStatus.LOADING &&
|
|
130
132
|
checkout &&
|
|
131
133
|
checkoutItem &&
|
|
@@ -139,7 +141,7 @@ const Item = ({ customerId, country, layout: Layout }) => {
|
|
|
139
141
|
return React.createElement(Spinner, null);
|
|
140
142
|
}
|
|
141
143
|
return (React.createElement(ReturnQuestionFeedbackProvider, { feedback: checkoutItem.feedbacks || {} },
|
|
142
|
-
React.createElement(Layout, { header: header }, checkoutItem.status === CheckoutItemStatus.INITIAL ? (React.createElement(ItemWithoutCustomerDecission, { bookedProductsVariants: bookedProductsVariants, checkoutId: checkout.id, checkoutItem: checkoutItem, country: country, currentProductVariant: currentProductVariant, onReturn: showReturnQuestions })) : (React.createElement(ItemWithCustomerDecission, { checkoutId: checkout.id, checkoutItem: checkoutItem, country: country, currentProductVariant: currentProductVariant, returnQuestions: returnQuestions, onEditFeedback: showReturnQuestions }))),
|
|
144
|
+
React.createElement(Layout, { header: header, style: { scrollView: { height: checkoutItem.status === CheckoutItemStatus.INITIAL ? height : "auto" } }, onLayout: handleOnLayout }, checkoutItem.status === CheckoutItemStatus.INITIAL ? (React.createElement(ItemWithoutCustomerDecission, { bookedProductsVariants: bookedProductsVariants, checkoutId: checkout.id, checkoutItem: checkoutItem, country: country, currentProductVariant: currentProductVariant, onReturn: showReturnQuestions })) : (React.createElement(ItemWithCustomerDecission, { checkoutId: checkout.id, checkoutItem: checkoutItem, country: country, currentProductVariant: currentProductVariant, returnQuestions: returnQuestions, onEditFeedback: showReturnQuestions }))),
|
|
143
145
|
React.createElement(ReturnQuestionsForm, { returnQuestions: returnQuestions, visible: returnQuestionsVisible, onClose: hideReturnQuestions, onSubmit: returnItem })));
|
|
144
146
|
};
|
|
145
147
|
export { Item };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CommandStatus } from "@lookiero/messaging-react";
|
|
2
2
|
import React, { useCallback } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { View } from "react-native";
|
|
4
4
|
import { CheckoutItemStatus } from "../../../../../../domain/checkoutItem/model/checkoutItem";
|
|
5
5
|
import { useLogger } from "../../../../../../shared/logging/useLogger";
|
|
6
6
|
import { useTrackResetItem } from "../../../../../../shared/tracking/infrastructure/useTrackResetItem";
|
|
@@ -34,10 +34,9 @@ const ItemWithCustomerDecission = ({ country, checkoutId, checkoutItem, returnQu
|
|
|
34
34
|
if (!dependenciesLoaded) {
|
|
35
35
|
return React.createElement(Spinner, null);
|
|
36
36
|
}
|
|
37
|
-
return (React.createElement(
|
|
38
|
-
React.createElement(
|
|
39
|
-
|
|
40
|
-
React.createElement(
|
|
41
|
-
React.createElement(ReturnQuestionsFeedback, { returnQuestions: returnQuestions, onEditFeedback: onEditFeedback })))))));
|
|
37
|
+
return (React.createElement(Body, { style: { row: style.container } },
|
|
38
|
+
React.createElement(CustomerDecissionBanner, { checkoutItemStatus: checkoutItem.status, onPress: resetItem }),
|
|
39
|
+
React.createElement(ProductVariant, { checkoutId: checkoutId, checkoutItem: checkoutItem, country: country, currentProductVariant: currentProductVariant }, checkoutItem.status === CheckoutItemStatus.RETURNED && (React.createElement(View, { style: style.feedbackContainer },
|
|
40
|
+
React.createElement(ReturnQuestionsFeedback, { returnQuestions: returnQuestions, onEditFeedback: onEditFeedback }))))));
|
|
42
41
|
};
|
|
43
42
|
export { ItemWithCustomerDecission };
|
|
@@ -57,8 +57,8 @@ const ItemWithoutCustomerDecission = ({ country, checkoutId, checkoutItem, booke
|
|
|
57
57
|
}
|
|
58
58
|
return (React.createElement(React.Fragment, null,
|
|
59
59
|
React.createElement(SizeWithoutStockModal, { visible: sizeWithoutStockModalVisible, onDismiss: handleOnHideSizeWithoutStockModal }),
|
|
60
|
-
React.createElement(ScrollView, {
|
|
61
|
-
React.createElement(Body,
|
|
60
|
+
React.createElement(ScrollView, { showsVerticalScrollIndicator: false },
|
|
61
|
+
React.createElement(Body, { style: { row: style.container } },
|
|
62
62
|
React.createElement(ProductVariant, { checkoutId: checkoutId, checkoutItem: checkoutItem, country: country, currentProductVariant: currentProductVariant, style: { content: { paddingBottom: Platform.OS === "web" ? 0 : stickyHeight } } }))),
|
|
63
63
|
React.createElement(ItemActions, { country: country, currentProductVariant: currentProductVariant, productVariants: bookedProductsVariants?.productVariants, onKeep: handleOnKeep, onLayout: handleOnStickyLayout, onReplace: handleOnReplace, onReturn: onReturn, onSizeSelectorPress: handleOnShowSizeWithoutStockModal })));
|
|
64
64
|
};
|
|
@@ -2,7 +2,7 @@ import { Button, Text } from "@lookiero/aurora";
|
|
|
2
2
|
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
3
3
|
import { QueryStatus } from "@lookiero/messaging-react";
|
|
4
4
|
import React, { useCallback } from "react";
|
|
5
|
-
import { Image
|
|
5
|
+
import { Image } from "react-native";
|
|
6
6
|
import { useNavigate } from "react-router-native";
|
|
7
7
|
import { useTrackPageView } from "../../../../shared/tracking/infrastructure/useTrackPageView";
|
|
8
8
|
import { AspectRatioView } from "../../../../shared/ui/components/atoms/aspectRatioView/AspectRatioView";
|
|
@@ -30,12 +30,11 @@ const NotFound = ({ customerId, country, layout: Layout }) => {
|
|
|
30
30
|
const dependenciesLoaded = dependenciesLoadedStatuses.includes(checkoutStatus);
|
|
31
31
|
if (!dependenciesLoaded)
|
|
32
32
|
return React.createElement(Spinner, null);
|
|
33
|
-
return (React.createElement(Layout,
|
|
34
|
-
React.createElement(
|
|
35
|
-
React.createElement(
|
|
36
|
-
React.createElement(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
React.createElement(Button, { onPress: handleOnPress }, buttonText)))));
|
|
33
|
+
return (React.createElement(Layout, { style: { scrollView: style.container } },
|
|
34
|
+
React.createElement(Body, { style: { column: style.bodyColumn } },
|
|
35
|
+
React.createElement(AspectRatioView, { aspectRatio: 1.25 },
|
|
36
|
+
React.createElement(Image, { resizeMode: "contain", source: require("../../../../public/images/not-found.png"), style: style.image, testID: "not-found-image" })),
|
|
37
|
+
React.createElement(Text, { level: 1, style: style.description }, descriptionText),
|
|
38
|
+
React.createElement(Button, { onPress: handleOnPress }, buttonText))));
|
|
40
39
|
};
|
|
41
40
|
export { NotFound };
|
|
@@ -19,10 +19,12 @@ import { Body } from "../../components/layouts/body/Body";
|
|
|
19
19
|
import { I18nMessages } from "../../i18n/i18n";
|
|
20
20
|
import { Routes } from "../../routing/routes";
|
|
21
21
|
import { useBasePath } from "../../routing/useBasePath";
|
|
22
|
+
import { theme } from "../../theme/theme";
|
|
22
23
|
import { style } from "./Summary.style";
|
|
23
24
|
import { CheckoutItemsTabs } from "./components/checkoutItemsTabs/CheckoutItemsTabs";
|
|
24
25
|
import { FiveItemsDiscountBanner } from "./components/fiveItemsDiscountBanner/FiveItemsDiscountBanner";
|
|
25
26
|
import { StickyPricing } from "./components/stickyPricing/StickyPricing";
|
|
27
|
+
const { spaceXXL } = theme();
|
|
26
28
|
const Summary = ({ customerId, country, layout: Layout }) => {
|
|
27
29
|
const titleText = useI18nMessage({ id: I18nMessages.SUMMARY_TITLE });
|
|
28
30
|
const descriptionText = useI18nMessage({ id: I18nMessages.SUMMARY_DESCRIPTION });
|
|
@@ -75,15 +77,17 @@ const Summary = ({ customerId, country, layout: Layout }) => {
|
|
|
75
77
|
const handleOnChangedTab = useCallback((active) => trackTabView({ tab: active === 0 ? "keep" : "return" }), [trackTabView]);
|
|
76
78
|
const checkoutItemsKept = useMemo(() => checkout?.items.filter((checkoutItem) => checkoutItem.status === CheckoutItemStatus.KEPT || checkoutItem.status === CheckoutItemStatus.REPLACED), [checkout?.items]);
|
|
77
79
|
const checkoutItemsReturned = useMemo(() => checkout?.items.filter((checkoutItem) => checkoutItem.status === CheckoutItemStatus.RETURNED || checkoutItem.status === CheckoutItemStatus.REPLACED), [checkout?.items]);
|
|
80
|
+
const [height, setHeight] = useState(0);
|
|
81
|
+
const handleOnLayout = useCallback((event) => setHeight(event.nativeEvent.layout.height), []);
|
|
78
82
|
const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
|
|
79
83
|
const dependenciesLoaded = dependenciesLoadedStatuses.includes(checkoutStatus) &&
|
|
80
84
|
dependenciesLoadedStatuses.includes(pricingStatus) &&
|
|
81
85
|
dependenciesLoadedStatuses.includes(fiveItemsDiscountStatus);
|
|
82
86
|
if (!dependenciesLoaded)
|
|
83
87
|
return React.createElement(Spinner, null);
|
|
84
|
-
return (React.createElement(Layout,
|
|
85
|
-
React.createElement(ScrollView, {
|
|
86
|
-
React.createElement(Body, { style: { row: { paddingBottom: pricingHeight } } },
|
|
88
|
+
return (React.createElement(Layout, { style: { scrollView: { height } }, onLayout: handleOnLayout },
|
|
89
|
+
React.createElement(ScrollView, { showsVerticalScrollIndicator: false },
|
|
90
|
+
React.createElement(Body, { style: { row: { paddingBottom: pricingHeight + spaceXXL } } },
|
|
87
91
|
fiveItemsDiscount !== 0 && React.createElement(FiveItemsDiscountBanner, { fiveItemsDiscount: fiveItemsDiscount }),
|
|
88
92
|
React.createElement(View, { style: style.content },
|
|
89
93
|
React.createElement(Text, { level: 3, style: style.title, heading: true }, titleText),
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { StyleSheet } from "react-native";
|
|
2
2
|
import { theme } from "../../theme/theme";
|
|
3
|
-
const { spaceM, spaceL, spaceXL
|
|
3
|
+
const { spaceM, spaceL, spaceXL } = theme();
|
|
4
4
|
const style = StyleSheet.create({
|
|
5
|
-
container: {
|
|
6
|
-
paddingBottom: spaceXXL,
|
|
7
|
-
},
|
|
8
5
|
content: {
|
|
9
6
|
paddingHorizontal: spaceXL,
|
|
10
7
|
},
|