@lookiero/checkout 0.2.30 → 0.2.31

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,6 +1,9 @@
1
1
  import { FC, ReactNode } from "react";
2
+ import { StyleProp, ViewStyle } from "react-native";
3
+ declare type BodyStyle = "row" | "column";
2
4
  interface BodyProps {
3
5
  readonly children: ReactNode;
6
+ readonly style?: Partial<Record<BodyStyle, StyleProp<ViewStyle>>>;
4
7
  }
5
8
  declare const Body: FC<BodyProps>;
6
9
  export { Body };
@@ -2,6 +2,6 @@ import React from "react";
2
2
  import { Column } from "../../../shared/components/layouts/column/Column";
3
3
  import { Row } from "../../../shared/components/layouts/row/Row";
4
4
  import { style } from "./Body.style";
5
- const Body = ({ children }) => (React.createElement(Row, { style: style.row },
6
- React.createElement(Column, { style: style.column }, children)));
5
+ const Body = ({ children, style: customStyle }) => (React.createElement(Row, { style: [style.row, customStyle?.row] },
6
+ React.createElement(Column, { style: customStyle?.column }, children)));
7
7
  export { Body };
@@ -1,7 +1,4 @@
1
1
  declare const style: {
2
- column: {
3
- paddingHorizontal: number;
4
- };
5
2
  row: {
6
3
  flex: number;
7
4
  justifyContent: "center";
@@ -1,10 +1,5 @@
1
1
  import { StyleSheet } from "react-native";
2
- import { theme } from "../../../theme/theme";
3
- const { spaceXL } = theme();
4
2
  const style = StyleSheet.create({
5
- column: {
6
- paddingHorizontal: spaceXL,
7
- },
8
3
  row: {
9
4
  flex: 1,
10
5
  justifyContent: "center",
@@ -2,6 +2,7 @@ import { QueryStatus } from "@lookiero/messaging-react";
2
2
  import React, { useCallback, useState } from "react";
3
3
  import { Text, TouchableHighlight, View } from "react-native";
4
4
  import { useParams } from "react-router-native";
5
+ import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
5
6
  import "../../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
6
7
  import { bookedSizeReplaceableProductVariants as bookedSizeReplaceableProductVariantsMock } from "../../../projection/bookedSizeReplaceableProductVariants/bookedSizeReplaceableProductVariants.mock";
7
8
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
@@ -10,9 +11,9 @@ import { returnQuestions as returnQuestionsMock } from "../../../projection/retu
10
11
  import { Body } from "../../components/layouts/body/Body";
11
12
  import { SafeAreaScrollView } from "../../components/templates/SafeAreaScrollView";
12
13
  import { Spinner } from "../../shared/components/atoms/spinner/Spinner";
13
- import { Sticky } from "../../shared/components/layouts/sticky/Sticky";
14
14
  import { style } from "./Item.style";
15
- import { ProductVariantActions } from "./components/productVariantActions/ProductVariantActions";
15
+ import { CustomerDecissionBanner } from "./components/banner/CustomerDecissionBanner";
16
+ import { ItemActions } from "./components/itemActions/ItemActions";
16
17
  import { ProductVariantDescription } from "./components/productVariantDescription/ProductVariantDescription";
17
18
  import { ProductVariantSlider } from "./components/productVariantSlider/ProductVariantSlider";
18
19
  import { ReturnQuestionsFeedback } from "./components/returnQuestionsFeedback/ReturnQuestionsFeedback";
@@ -31,10 +32,12 @@ const Item = ({ customerId }) => {
31
32
  const handleOnKeep = useCallback(() => void 0, []);
32
33
  const handleOnReplace = useCallback(() => void 0, []);
33
34
  const handleOnReturn = useCallback(() => void 0, []);
35
+ const handleOnBannerPress = useCallback(() => void 0, []);
34
36
  if (status === QueryStatus.LOADING)
35
37
  return React.createElement(Spinner, null);
36
38
  const { price } = checkoutItem;
37
39
  const { media, brand, name, size, color } = checkoutItem.productVariant;
40
+ const customerDecissionMade = checkoutItem.status === CheckoutItemStatus.INITIAL || checkoutItem.status === CheckoutItemStatus.EXPIRED;
38
41
  const returnQuestions = returnQuestionsMock;
39
42
  const feedback = feedbackMock;
40
43
  const sizes = bookedSizeReplaceableProductVariantsMock.productVariants
@@ -43,7 +46,8 @@ const Item = ({ customerId }) => {
43
46
  return (React.createElement(React.Fragment, null,
44
47
  React.createElement(SafeAreaScrollView, null,
45
48
  React.createElement(Body, null,
46
- React.createElement(View, { style: { paddingBottom: stickyHeight } },
49
+ !customerDecissionMade && (React.createElement(CustomerDecissionBanner, { checkoutItemStatus: checkoutItem.status, onPress: handleOnBannerPress })),
50
+ React.createElement(View, { style: [style.container, { paddingBottom: stickyHeight }] },
47
51
  React.createElement(View, { style: style.sliderContainer },
48
52
  React.createElement(ProductVariantSlider, { producVariantMedia: media })),
49
53
  React.createElement(ProductVariantDescription, { brand: brand, color: color, name: name, price: price, size: size }),
@@ -52,9 +56,7 @@ const Item = ({ customerId }) => {
52
56
  React.createElement(View, { style: { flexDirection: "row", justifyContent: "center" } },
53
57
  React.createElement(TouchableHighlight, { onPress: handleOnShowReturnQuestions },
54
58
  React.createElement(Text, { style: { padding: 16 } }, "show return questions")))))),
55
- React.createElement(Sticky, { onLayout: handleOnStickyLayout },
56
- React.createElement(Body, null,
57
- React.createElement(ProductVariantActions, { size: checkoutItem.productVariant.size, sizes: sizes, onKeep: handleOnKeep, onReplace: handleOnReplace, onReturn: handleOnReturn }))),
59
+ customerDecissionMade && (React.createElement(ItemActions, { size: checkoutItem.productVariant.size, sizes: sizes, onKeep: handleOnKeep, onLayout: handleOnStickyLayout, onReplace: handleOnReplace, onReturn: handleOnReturn })),
58
60
  React.createElement(ReturnQuestionsForm, { checkoutItemPrice: checkoutItem.price, feedback: feedback, productVariant: checkoutItem.productVariant, returnQuestions: returnQuestions, visible: returnQuestionsVisible, onClose: handleOnHideReturnQuestions, onSubmit: handleOnSubmit })));
59
61
  };
60
62
  export { Item };
@@ -1,4 +1,7 @@
1
1
  declare const style: {
2
+ container: {
3
+ paddingHorizontal: number;
4
+ };
2
5
  feedbackContainer: {
3
6
  borderTopColor: string;
4
7
  borderTopWidth: number;
@@ -2,6 +2,9 @@ import { StyleSheet } from "react-native";
2
2
  import { theme } from "../../theme/theme";
3
3
  const { borderSize, colorGrayscaleM, spaceXL } = theme();
4
4
  const style = StyleSheet.create({
5
+ container: {
6
+ paddingHorizontal: spaceXL,
7
+ },
5
8
  feedbackContainer: {
6
9
  borderTopColor: colorGrayscaleM,
7
10
  borderTopWidth: borderSize,
@@ -1,11 +1,13 @@
1
1
  import { FC } from "react";
2
2
  import { SizeProjection } from "../../../../../../projection/shared/size";
3
- interface ProductVariantActionsProps {
3
+ import { Layout } from "../../../../shared/components/layouts/sticky/Sticky";
4
+ interface ItemActionsProps {
4
5
  readonly sizes: SizeProjection[];
5
6
  readonly size: SizeProjection;
6
7
  readonly onKeep: (value: string) => void;
7
8
  readonly onReturn: () => void;
8
9
  readonly onReplace: () => void;
10
+ readonly onLayout?: ({ width, height }: Layout) => void;
9
11
  }
10
- declare const ProductVariantActions: FC<ProductVariantActionsProps>;
11
- export { ProductVariantActions };
12
+ declare const ItemActions: FC<ItemActionsProps>;
13
+ export { ItemActions };
@@ -0,0 +1,25 @@
1
+ import { Button } from "@lookiero/aurora-next/build/components/atoms/Button/Button";
2
+ import { BUTTON_VARIANT } from "@lookiero/aurora-next/build/components/atoms/Button/Button.definition";
3
+ import { useI18nMessage } from "@lookiero/i18n-react";
4
+ import React, { useMemo } from "react";
5
+ import { View } from "react-native";
6
+ import { Body } from "../../../../components/layouts/body/Body";
7
+ import { I18nMessages } from "../../../../i18n/i18n";
8
+ import { Sticky } from "../../../../shared/components/layouts/sticky/Sticky";
9
+ import { SelectField } from "../../../../shared/components/molecules/selectField/SelectField";
10
+ import { style } from "./ItemActions.style";
11
+ const ItemActions = ({ sizes, size, onKeep, onReplace, onReturn, onLayout }) => {
12
+ const sizeSelectorLabelText = useI18nMessage({ id: I18nMessages.ITEM_SIZES_LABEL });
13
+ const keepButtonText = useI18nMessage({ id: I18nMessages.ITEM_KEEP_BUTTON });
14
+ const returnButtonText = useI18nMessage({ id: I18nMessages.ITEM_RETURN_BUTTON });
15
+ const sizeSelectorOptions = useMemo(() => sizes.map((size) => ({ label: size.lookiero, value: size.id })), [sizes]);
16
+ const disabledSizeSelector = useMemo(() => sizeSelectorOptions.length === 1 && sizeSelectorOptions[0]?.value === size.id, [sizeSelectorOptions, size.id]);
17
+ return (React.createElement(Sticky, { onLayout: onLayout },
18
+ React.createElement(Body, { style: { column: style.container } },
19
+ React.createElement(Button, { onPress: onKeep }, keepButtonText),
20
+ React.createElement(View, { style: style.row },
21
+ !size.unique && (React.createElement(SelectField, { disabled: disabledSizeSelector, options: sizeSelectorOptions, placeholder: sizeSelectorLabelText || "", style: { selectField: style.sizeSelector }, testID: "size-selector", value: size.id, onChange: onReplace })),
22
+ React.createElement(View, { style: style.returnButtonContainer },
23
+ React.createElement(Button, { variant: BUTTON_VARIANT.SECONDARY, onPress: onReturn }, returnButtonText))))));
24
+ };
25
+ export { ItemActions };
@@ -1,6 +1,6 @@
1
1
  declare const style: {
2
2
  container: {
3
- width: string;
3
+ paddingHorizontal: number;
4
4
  };
5
5
  returnButtonContainer: {
6
6
  flex: number;
@@ -1,9 +1,9 @@
1
1
  import { StyleSheet } from "react-native";
2
2
  import { theme } from "../../../../theme/theme";
3
- const { spaceL } = theme();
3
+ const { spaceL, spaceXL } = theme();
4
4
  const style = StyleSheet.create({
5
5
  container: {
6
- width: "100%",
6
+ paddingHorizontal: spaceXL,
7
7
  },
8
8
  returnButtonContainer: {
9
9
  flex: 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.2.30",
3
+ "version": "0.2.31",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -1,22 +0,0 @@
1
- import { Button } from "@lookiero/aurora-next/build/components/atoms/Button/Button";
2
- import { BUTTON_VARIANT } from "@lookiero/aurora-next/build/components/atoms/Button/Button.definition";
3
- import { useI18nMessage } from "@lookiero/i18n-react";
4
- import React, { useMemo } from "react";
5
- import { View } from "react-native";
6
- import { I18nMessages } from "../../../../i18n/i18n";
7
- import { SelectField } from "../../../../shared/components/molecules/selectField/SelectField";
8
- import { style } from "./ProductVariantActions.style";
9
- const ProductVariantActions = ({ sizes, size, onKeep, onReplace, onReturn }) => {
10
- const sizeSelectorLabelText = useI18nMessage({ id: I18nMessages.ITEM_SIZES_LABEL });
11
- const keepButtonText = useI18nMessage({ id: I18nMessages.ITEM_KEEP_BUTTON });
12
- const returnButtonText = useI18nMessage({ id: I18nMessages.ITEM_RETURN_BUTTON });
13
- const sizeSelectorOptions = useMemo(() => sizes.map((size) => ({ label: size.lookiero, value: size.id })), [sizes]);
14
- const disabledSizeSelector = useMemo(() => sizeSelectorOptions.length === 1 && sizeSelectorOptions[0]?.value === size.id, [sizeSelectorOptions, size.id]);
15
- return (React.createElement(View, { style: style.container },
16
- React.createElement(Button, { onPress: onKeep }, keepButtonText),
17
- React.createElement(View, { style: style.row },
18
- !size.unique && (React.createElement(SelectField, { disabled: disabledSizeSelector, options: sizeSelectorOptions, placeholder: sizeSelectorLabelText || "", style: { selectField: style.sizeSelector }, testID: "size-selector", value: size.id, onChange: onReplace })),
19
- React.createElement(View, { style: style.returnButtonContainer },
20
- React.createElement(Button, { variant: BUTTON_VARIANT.SECONDARY, onPress: onReturn }, returnButtonText)))));
21
- };
22
- export { ProductVariantActions };