@lookiero/checkout 0.2.43 → 0.2.45
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.
|
@@ -6,6 +6,7 @@ import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checko
|
|
|
6
6
|
import "../../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
|
|
7
7
|
import { useBookCheckouBookingForCheckoutItem } from "../../../domain/checkoutBooking/react/useBookCheckouBookingForCheckoutItem";
|
|
8
8
|
import { useKeepCheckoutItem } from "../../../domain/checkoutItem/react/useKeepCheckoutItem";
|
|
9
|
+
import { useReplaceCheckoutItem } from "../../../domain/checkoutItem/react/useReplaceCheckoutItem";
|
|
9
10
|
import { useReturnCheckoutItem } from "../../../domain/checkoutItem/react/useReturnCheckoutItem";
|
|
10
11
|
import { useViewBookedSizeChangeProductsVariantsForCheckoutItem } from "../../../projection/bookedSizeChangeProductsVariants/react/useViewBookedSizeChangeProductsVariantsForCheckoutItem";
|
|
11
12
|
import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
|
|
@@ -49,6 +50,9 @@ const Item = ({ customerId }) => {
|
|
|
49
50
|
const [returnCheckoutItem, returnCheckoutItemStatus] = useReturnCheckoutItem({
|
|
50
51
|
checkoutItemId: checkoutItem.id,
|
|
51
52
|
});
|
|
53
|
+
const [replaceCheckoutItem, replaceCheckoutItemStatus] = useReplaceCheckoutItem({
|
|
54
|
+
checkoutItemId: checkoutItem.id,
|
|
55
|
+
});
|
|
52
56
|
const [stickyHeight, setStickyHeight] = useState(0);
|
|
53
57
|
const handleOnStickyLayout = useCallback(({ height }) => setStickyHeight(height), []);
|
|
54
58
|
useEffect(() => {
|
|
@@ -62,7 +66,10 @@ const Item = ({ customerId }) => {
|
|
|
62
66
|
handleOnHideReturnQuestions();
|
|
63
67
|
returnCheckoutItem({ feedbacks: feedback });
|
|
64
68
|
}, [handleOnHideReturnQuestions, returnCheckoutItem]);
|
|
65
|
-
const handleOnReplace = useCallback(() =>
|
|
69
|
+
const handleOnReplace = useCallback((replacedFor) => {
|
|
70
|
+
handleOnShowSizeChangeModal();
|
|
71
|
+
replaceCheckoutItem({ replacedFor });
|
|
72
|
+
}, [handleOnShowSizeChangeModal, replaceCheckoutItem]);
|
|
66
73
|
const handleOnReturn = useCallback(() => handleOnShowReturnQuestions(), [handleOnShowReturnQuestions]);
|
|
67
74
|
const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
|
|
68
75
|
const dependenciesLoaded = dependenciesLoadedStatuses.includes(returnQuestionsStatus) &&
|
|
@@ -72,9 +79,6 @@ const Item = ({ customerId }) => {
|
|
|
72
79
|
return React.createElement(Spinner, null);
|
|
73
80
|
const { price } = checkoutItem;
|
|
74
81
|
const { media, brand, name, size, color } = checkoutItem.productVariant;
|
|
75
|
-
const sizes = bookedSizeChangeProductsVariants?.productVariants
|
|
76
|
-
.map((productVariant) => productVariant.size)
|
|
77
|
-
.concat(checkoutItem.productVariant.size) || [];
|
|
78
82
|
return (React.createElement(React.Fragment, null,
|
|
79
83
|
React.createElement(SizeWithoutStockModal, { visible: sizeWithoutStockModalVisible, onDismiss: handleOnHideSizeWithoutStockModal }),
|
|
80
84
|
React.createElement(SizeChangeModal, { visible: sizeChangeModalVisible, onDismiss: handleOnHideSizeChangeModal }),
|
|
@@ -87,7 +91,7 @@ const Item = ({ customerId }) => {
|
|
|
87
91
|
React.createElement(ProductVariantDescription, { brand: brand, color: color, name: name, price: price, size: size }),
|
|
88
92
|
checkoutItem.feedback && (React.createElement(View, { style: style.feedbackContainer },
|
|
89
93
|
React.createElement(ReturnQuestionsFeedback, { feedback: checkoutItem.feedback || {}, returnQuestions: returnQuestions || [], onEditFeedback: handleOnEditFeedback })))))),
|
|
90
|
-
customerDecissionMade && (React.createElement(ItemActions, { keepButtonLoading: keepCheckoutItemStatus === CommandStatus.LOADING, returnButtonLoading: returnCheckoutItemStatus === CommandStatus.LOADING,
|
|
94
|
+
customerDecissionMade && (React.createElement(ItemActions, { keepButtonLoading: keepCheckoutItemStatus === CommandStatus.LOADING, productVariantSelected: checkoutItem.productVariant, productVariants: bookedSizeChangeProductsVariants?.productVariants || [], returnButtonLoading: returnCheckoutItemStatus === CommandStatus.LOADING, sizeSelectorDisabled: replaceCheckoutItemStatus === CommandStatus.LOADING, onKeep: keepCheckoutItem, onLayout: handleOnStickyLayout, onReplace: handleOnReplace, onReturn: handleOnReturn, onSizeSelectorPress: handleOnShowSizeWithoutStockModal })),
|
|
91
95
|
React.createElement(ReturnQuestionsForm, { checkoutItemPrice: checkoutItem.price, feedback: checkoutItem.feedback || {}, productVariant: checkoutItem.productVariant, returnQuestions: returnQuestions || [], visible: returnQuestionsVisible, onClose: handleOnHideReturnQuestions, onSubmit: handleOnSubmit })));
|
|
92
96
|
};
|
|
93
97
|
export { Item };
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { ProductVariantProjection } from "../../../../../../projection/bookedSizeChangeProductsVariants/bookedSizeChangeProductsVariants";
|
|
3
|
+
import { CheckoutItemProductVariantProjection } from "../../../../../../projection/checkoutItem/checkoutItem";
|
|
3
4
|
import { Layout } from "../../../../shared/components/layouts/sticky/Sticky";
|
|
4
5
|
interface ItemActionsProps {
|
|
5
|
-
readonly
|
|
6
|
-
readonly
|
|
6
|
+
readonly productVariants: ProductVariantProjection[];
|
|
7
|
+
readonly productVariantSelected: CheckoutItemProductVariantProjection;
|
|
7
8
|
readonly keepButtonLoading?: boolean;
|
|
8
9
|
readonly returnButtonLoading?: boolean;
|
|
10
|
+
readonly sizeSelectorDisabled?: boolean;
|
|
9
11
|
readonly onSizeSelectorPress?: () => void;
|
|
10
|
-
readonly onKeep: (
|
|
12
|
+
readonly onKeep: () => void;
|
|
11
13
|
readonly onReturn: () => void;
|
|
12
|
-
readonly onReplace: () => void;
|
|
14
|
+
readonly onReplace: (value: string) => void;
|
|
13
15
|
readonly onLayout?: ({ width, height }: Layout) => void;
|
|
14
16
|
}
|
|
15
17
|
declare const ItemActions: FC<ItemActionsProps>;
|
|
@@ -8,22 +8,24 @@ import { I18nMessages } from "../../../../i18n/i18n";
|
|
|
8
8
|
import { Sticky } from "../../../../shared/components/layouts/sticky/Sticky";
|
|
9
9
|
import { SelectField } from "../../../../shared/components/molecules/selectField/SelectField";
|
|
10
10
|
import { style } from "./ItemActions.style";
|
|
11
|
-
const ItemActions = ({
|
|
11
|
+
const ItemActions = ({ productVariants, productVariantSelected, keepButtonLoading = false, returnButtonLoading = false, sizeSelectorDisabled = false, onSizeSelectorPress = () => void 0, onKeep, onReplace, onReturn, onLayout, }) => {
|
|
12
12
|
const sizeSelectorLabelText = useI18nMessage({ id: I18nMessages.ITEM_SIZES_LABEL });
|
|
13
13
|
const keepButtonText = useI18nMessage({ id: I18nMessages.ITEM_KEEP_BUTTON });
|
|
14
14
|
const returnButtonText = useI18nMessage({ id: I18nMessages.ITEM_RETURN_BUTTON });
|
|
15
|
-
const sizeSelectorOptions = useMemo(() =>
|
|
16
|
-
|
|
15
|
+
const sizeSelectorOptions = useMemo(() => productVariants
|
|
16
|
+
.map((productVariant) => ({ label: productVariant.size.lookiero, value: productVariant.id }))
|
|
17
|
+
.concat({ label: productVariantSelected.size.lookiero, value: productVariantSelected.id }), [productVariantSelected.id, productVariantSelected.size.lookiero, productVariants]);
|
|
18
|
+
const disabledSizeSelector = useMemo(() => sizeSelectorOptions.length === 1 && sizeSelectorOptions[0]?.value === productVariantSelected.id, [sizeSelectorOptions, productVariantSelected.id]);
|
|
17
19
|
const handleOnPressSizeSelector = useCallback(() => onSizeSelectorPress(), [onSizeSelectorPress]);
|
|
18
20
|
return (React.createElement(Sticky, { onLayout: onLayout },
|
|
19
21
|
React.createElement(Body, { style: { column: style.container } },
|
|
20
22
|
React.createElement(Button, { busy: keepButtonLoading, onPress: onKeep }, keepButtonText),
|
|
21
23
|
React.createElement(View, { style: style.row },
|
|
22
|
-
!size.unique && (React.createElement(SelectField, { ...(disabledSizeSelector && {
|
|
24
|
+
!productVariantSelected.size.unique && (React.createElement(SelectField, { ...(disabledSizeSelector && {
|
|
23
25
|
onPress: handleOnPressSizeSelector,
|
|
24
|
-
}), options: sizeSelectorOptions, placeholder: sizeSelectorLabelText || "", testID: "size-selector", value:
|
|
26
|
+
}), disabled: sizeSelectorDisabled, options: sizeSelectorOptions, placeholder: sizeSelectorLabelText || "", testID: "size-selector", value: productVariantSelected.id, style: {
|
|
25
27
|
selectField: style.sizeSelector,
|
|
26
|
-
inputField: { input: disabledSizeSelector && style.inputDisabled },
|
|
28
|
+
inputField: { input: (disabledSizeSelector || sizeSelectorDisabled) && style.inputDisabled },
|
|
27
29
|
}, onChange: onReplace })),
|
|
28
30
|
React.createElement(View, { style: style.returnButtonContainer },
|
|
29
31
|
React.createElement(Button, { busy: returnButtonLoading, variant: BUTTON_VARIANT.SECONDARY, onPress: onReturn }, returnButtonText))))));
|