@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.
@@ -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
- // eslint-disable-next-line react/prop-types
10
- const DummyLayout = ({ children, header = React.createElement(DefaultHeader, null), footer = React.createElement(DefaultFooter, null), panel }) => (React.createElement(SafeAreaView, { style: style.safeAreaView },
11
- React.createElement(Header, null, header),
12
- React.createElement(View, { style: style.children }, children),
13
- React.createElement(Footer, null, footer),
14
- panel));
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 };
@@ -5,5 +5,8 @@ declare const style: {
5
5
  safeAreaView: {
6
6
  flex: number;
7
7
  };
8
+ scrollView: {
9
+ flexGrow: number;
10
+ };
8
11
  };
9
12
  export { style };
@@ -6,5 +6,8 @@ const style = StyleSheet.create({
6
6
  safeAreaView: {
7
7
  flex: 1,
8
8
  },
9
+ scrollView: {
10
+ flexGrow: 1,
11
+ },
9
12
  });
10
13
  export { style };
@@ -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 { ScrollView, View } from "react-native";
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(ScrollView, { contentContainerStyle: style.container, showsVerticalScrollIndicator: false },
60
- React.createElement(Body, { style: { column: style.bodyColumn } },
61
- hasReplacedCheckoutItem && (React.createElement(View, { style: style.deliveryBannerContainer },
62
- React.createElement(DeliveryBanner, null))),
63
- React.createElement(PaymentInstrument, { useRedirect: useRedirect }),
64
- React.createElement(Text, { level: 3, style: style.title, heading: true }, titleText),
65
- checkoutItemsKept?.map((checkoutItem) => (React.createElement(View, { key: checkoutItem.id, style: style.checkoutItemKept, testID: "checkout-items-kept" },
66
- 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
67
- ? checkoutItem.replacedFor.size
68
- : checkoutItem.productVariant.size })))),
69
- pricing && (React.createElement(View, { style: style.pricingContainer },
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, null,
78
- React.createElement(ScrollView, { contentContainerStyle: style.container, showsVerticalScrollIndicator: false },
79
- React.createElement(Body, { style: { column: style.bodyColumn } },
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 { ScrollView, View } from "react-native";
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(ScrollView, { contentContainerStyle: style.container, showsVerticalScrollIndicator: false },
38
- React.createElement(Body, null,
39
- React.createElement(CustomerDecissionBanner, { checkoutItemStatus: checkoutItem.status, onPress: resetItem }),
40
- React.createElement(ProductVariant, { checkoutId: checkoutId, checkoutItem: checkoutItem, country: country, currentProductVariant: currentProductVariant }, checkoutItem.status === CheckoutItemStatus.RETURNED && (React.createElement(View, { style: style.feedbackContainer },
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, { contentContainerStyle: style.container, showsVerticalScrollIndicator: false },
61
- React.createElement(Body, null,
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, ScrollView } from "react-native";
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, null,
34
- React.createElement(ScrollView, { contentContainerStyle: style.container, showsVerticalScrollIndicator: false },
35
- React.createElement(Body, { style: { column: style.bodyColumn } },
36
- React.createElement(AspectRatioView, { aspectRatio: 1.25 },
37
- React.createElement(Image, { resizeMode: "contain", source: require("../../../../public/images/not-found.png"), style: style.image, testID: "not-found-image" })),
38
- React.createElement(Text, { level: 1, style: style.description }, descriptionText),
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, null,
85
- React.createElement(ScrollView, { contentContainerStyle: style.container, showsVerticalScrollIndicator: false },
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,7 +1,4 @@
1
1
  declare const style: {
2
- container: {
3
- paddingBottom: number;
4
- };
5
2
  content: {
6
3
  paddingHorizontal: number;
7
4
  };
@@ -1,10 +1,7 @@
1
1
  import { StyleSheet } from "react-native";
2
2
  import { theme } from "../../theme/theme";
3
- const { spaceM, spaceL, spaceXL, spaceXXL } = theme();
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
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "3.0.0-beta.1",
3
+ "version": "3.0.0-beta.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [