@lookiero/checkout 1.1.4-beta.2 → 1.1.4-beta.4
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/views/item/Item.js +15 -14
- package/dist/infrastructure/ui/views/item/views/itemWithCustomerDecission/ItemWithCustomerDecission.d.ts +2 -0
- package/dist/infrastructure/ui/views/item/views/itemWithCustomerDecission/ItemWithCustomerDecission.js +2 -5
- package/dist/infrastructure/ui/views/item/views/itemWithoutCustomerDecission/ItemWithoutCustomerDecission.d.ts +2 -1
- package/dist/infrastructure/ui/views/item/views/itemWithoutCustomerDecission/ItemWithoutCustomerDecission.js +2 -3
- package/dist/shared/tracking/infrastructure/useTrackItemPageView.d.ts +1 -0
- package/dist/shared/tracking/infrastructure/useTrackItemPageView.js +4 -6
- package/dist/shared/tracking/tracking.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
|
|
2
|
-
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { useParams } from "react-router-native";
|
|
4
4
|
import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
|
|
5
5
|
import { useLogger } from "../../../../shared/logging/useLogger";
|
|
@@ -68,24 +68,25 @@ const Item = ({ customerId, country }) => {
|
|
|
68
68
|
trackReturnItem();
|
|
69
69
|
}, [hideReturnQuestions, returnCheckoutItem, trackReturnItem]);
|
|
70
70
|
/* ReturnCheckoutItem */
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
71
|
+
const currentProductVariant = useMemo(() => checkoutItem.status === CheckoutItemStatus.REPLACED && checkoutItem.replacedFor
|
|
72
|
+
? { id: checkoutItem.replacedFor.id, size: checkoutItem.replacedFor.size }
|
|
73
|
+
: { id: checkoutItem.productVariant.id, size: checkoutItem.productVariant.size }, [checkoutItem.productVariant.id, checkoutItem.productVariant.size, checkoutItem.replacedFor, checkoutItem.status]);
|
|
74
|
+
const replaceableFor = useMemo(() => sizeChangeEnabledStatus === QueryStatus.SUCCESS
|
|
75
|
+
? isSizeChangeEnabled
|
|
76
|
+
? bookedProductsVariants
|
|
77
|
+
? bookedProductsVariants.productVariants
|
|
78
|
+
.filter(({ id }) => id !== currentProductVariant.id)
|
|
79
|
+
.map(({ size }) => size.lookiero)
|
|
80
|
+
: undefined
|
|
81
|
+
: []
|
|
82
|
+
: undefined, [bookedProductsVariants, currentProductVariant.id, isSizeChangeEnabled, sizeChangeEnabledStatus]);
|
|
82
83
|
useTrackItemPageView({
|
|
83
84
|
page: TrackingPage.ITEM,
|
|
84
85
|
country,
|
|
85
86
|
checkoutId: checkout?.id,
|
|
86
87
|
checkoutItemId: checkoutItem.id,
|
|
87
88
|
productVariantId: checkoutItem.productVariant.id,
|
|
88
|
-
|
|
89
|
+
replaceableFor,
|
|
89
90
|
unique: checkoutItem.productVariant.size.unique,
|
|
90
91
|
});
|
|
91
92
|
const dependenciesLoaded = checkoutStatus !== QueryStatus.LOADING &&
|
|
@@ -101,7 +102,7 @@ const Item = ({ customerId, country }) => {
|
|
|
101
102
|
return React.createElement(Spinner, null);
|
|
102
103
|
}
|
|
103
104
|
return (React.createElement(ReturnQuestionFeedbackProvider, { feedback: checkoutItem.feedbacks || {} },
|
|
104
|
-
checkoutItem.status === CheckoutItemStatus.INITIAL ? (React.createElement(ItemWithoutCustomerDecission, { bookedProductsVariants: bookedProductsVariants, checkoutId: checkout.id, checkoutItem: checkoutItem, country: country, onReturn: showReturnQuestions })) : (React.createElement(ItemWithCustomerDecission, { checkoutId: checkout.id, checkoutItem: checkoutItem, country: country, returnQuestions: returnQuestions, onEditFeedback: showReturnQuestions })),
|
|
105
|
+
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 })),
|
|
105
106
|
React.createElement(ReturnQuestionsForm, { checkoutItemPrice: checkoutItem.price, country: country, productVariant: checkoutItem.productVariant, returnQuestions: returnQuestions, visible: returnQuestionsVisible, onClose: hideReturnQuestions, onSubmit: returnItem })));
|
|
106
107
|
};
|
|
107
108
|
export { Item };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
2
|
import { CheckoutItemStatus } from "../../../../../../domain/checkoutItem/model/checkoutItem";
|
|
3
|
+
import { ProductVariantProjection } from "../../../../../../projection/bookedProductsVariants/bookedProductsVariants";
|
|
3
4
|
import { CheckoutItemProjection } from "../../../../../../projection/checkoutItem/checkoutItem";
|
|
4
5
|
import { ReturnQuestionProjection } from "../../../../../../projection/returnQuestion/returnQuestion";
|
|
5
6
|
import { Country } from "../../../../../../projection/shared/country";
|
|
@@ -11,6 +12,7 @@ interface ItemWithCustomerDecissionProps {
|
|
|
11
12
|
readonly checkoutId: string;
|
|
12
13
|
readonly checkoutItem: CheckoutItemWithCustomerDecission;
|
|
13
14
|
readonly returnQuestions: ReturnQuestionProjection[];
|
|
15
|
+
readonly currentProductVariant: ProductVariantProjection;
|
|
14
16
|
readonly onEditFeedback: () => void;
|
|
15
17
|
}
|
|
16
18
|
declare const ItemWithCustomerDecission: FC<ItemWithCustomerDecissionProps>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CommandStatus } from "@lookiero/messaging-react";
|
|
2
|
-
import React, { useCallback
|
|
2
|
+
import React, { useCallback } from "react";
|
|
3
3
|
import { Platform, View } from "react-native";
|
|
4
4
|
import { CheckoutItemStatus } from "../../../../../../domain/checkoutItem/model/checkoutItem";
|
|
5
5
|
import { useLogger } from "../../../../../../shared/logging/useLogger";
|
|
@@ -14,7 +14,7 @@ import { CustomerDecissionBanner, } from "../../components/banner/CustomerDeciss
|
|
|
14
14
|
import { ReturnQuestionsFeedback } from "../../components/returnQuestionsFeedback/ReturnQuestionsFeedback";
|
|
15
15
|
import { ProductVariant } from "../../views/productVariant/ProductVariant";
|
|
16
16
|
import { style } from "./ItemWithCustomerDecission.style";
|
|
17
|
-
const ItemWithCustomerDecission = ({ country, checkoutId, checkoutItem, returnQuestions, onEditFeedback, }) => {
|
|
17
|
+
const ItemWithCustomerDecission = ({ country, checkoutId, checkoutItem, returnQuestions, currentProductVariant, onEditFeedback, }) => {
|
|
18
18
|
const logger = useLogger();
|
|
19
19
|
/* ResetCheckoutItem */
|
|
20
20
|
const [resetCheckoutItem, resetCheckoutItemStatus] = useResetCheckoutItem({
|
|
@@ -32,9 +32,6 @@ const ItemWithCustomerDecission = ({ country, checkoutId, checkoutItem, returnQu
|
|
|
32
32
|
trackResetItem();
|
|
33
33
|
}, [resetCheckoutItem, trackResetItem]);
|
|
34
34
|
/* ResetCheckoutItem */
|
|
35
|
-
const currentProductVariant = useMemo(() => checkoutItem.status === CheckoutItemStatus.REPLACED && checkoutItem.replacedFor
|
|
36
|
-
? { id: checkoutItem.replacedFor.id, size: checkoutItem.replacedFor.size }
|
|
37
|
-
: { id: checkoutItem.productVariant.id, size: checkoutItem.productVariant.size }, [checkoutItem.productVariant.id, checkoutItem.productVariant.size, checkoutItem.replacedFor, checkoutItem.status]);
|
|
38
35
|
const dependenciesLoaded = resetCheckoutItemStatus !== CommandStatus.LOADING;
|
|
39
36
|
if (!dependenciesLoaded) {
|
|
40
37
|
return React.createElement(Spinner, null);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
2
|
import { CheckoutItemStatus } from "../../../../../../domain/checkoutItem/model/checkoutItem";
|
|
3
|
-
import { BookedProductsVariantsProjection } from "../../../../../../projection/bookedProductsVariants/bookedProductsVariants";
|
|
3
|
+
import { BookedProductsVariantsProjection, ProductVariantProjection } from "../../../../../../projection/bookedProductsVariants/bookedProductsVariants";
|
|
4
4
|
import "../../../../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
|
|
5
5
|
import { CheckoutItemProjection } from "../../../../../../projection/checkoutItem/checkoutItem";
|
|
6
6
|
import { Country } from "../../../../../../projection/shared/country";
|
|
@@ -12,6 +12,7 @@ interface ItemWithoutCustomerDecissionProps {
|
|
|
12
12
|
readonly checkoutId: string;
|
|
13
13
|
readonly checkoutItem: CheckoutItemWithoutCustomerDecission;
|
|
14
14
|
readonly bookedProductsVariants: BookedProductsVariantsProjection;
|
|
15
|
+
readonly currentProductVariant: ProductVariantProjection;
|
|
15
16
|
readonly onReturn: () => void;
|
|
16
17
|
}
|
|
17
18
|
declare const ItemWithoutCustomerDecission: FC<ItemWithoutCustomerDecissionProps>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CommandStatus } from "@lookiero/messaging-react";
|
|
2
|
-
import React, { useCallback,
|
|
2
|
+
import React, { useCallback, useState } from "react";
|
|
3
3
|
import { Platform } from "react-native";
|
|
4
4
|
import "../../../../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
|
|
5
5
|
import { useLogger } from "../../../../../../shared/logging/useLogger";
|
|
@@ -17,7 +17,7 @@ import { ItemActions } from "../../components/itemActions/ItemActions";
|
|
|
17
17
|
import { SizeWithoutStockModal } from "../../components/sizeWithoutStockModal/SizeWithoutStockModal";
|
|
18
18
|
import { ProductVariant } from "../productVariant/ProductVariant";
|
|
19
19
|
const { spaceXL } = theme();
|
|
20
|
-
const ItemWithoutCustomerDecission = ({ country, checkoutId, checkoutItem, bookedProductsVariants, onReturn, }) => {
|
|
20
|
+
const ItemWithoutCustomerDecission = ({ country, checkoutId, checkoutItem, bookedProductsVariants, currentProductVariant, onReturn, }) => {
|
|
21
21
|
const logger = useLogger();
|
|
22
22
|
/* KeepCheckoutItem */
|
|
23
23
|
const [keepCheckoutItem, keepCheckoutItemStatus] = useKeepCheckoutItem({ checkoutItemId: checkoutItem.id, logger });
|
|
@@ -54,7 +54,6 @@ const ItemWithoutCustomerDecission = ({ country, checkoutId, checkoutItem, booke
|
|
|
54
54
|
const handleOnHideSizeWithoutStockModal = useCallback(() => setSizeWithoutStockModalVisible(false), []);
|
|
55
55
|
const [stickyHeight, setStickyHeight] = useState(0);
|
|
56
56
|
const handleOnStickyLayout = useCallback(({ height }) => setStickyHeight(height), []);
|
|
57
|
-
const currentProductVariant = useMemo(() => ({ id: checkoutItem.productVariant.id, size: checkoutItem.productVariant.size }), [checkoutItem.productVariant.id, checkoutItem.productVariant.size]);
|
|
58
57
|
const dependenciesLoaded = keepCheckoutItemStatus !== CommandStatus.LOADING && replaceCheckoutItemStatus !== CommandStatus.LOADING;
|
|
59
58
|
if (!dependenciesLoaded) {
|
|
60
59
|
return React.createElement(Spinner, null);
|
|
@@ -6,6 +6,7 @@ interface UseTrackItemPageViewFunctionArgs {
|
|
|
6
6
|
readonly checkoutId?: string;
|
|
7
7
|
readonly checkoutItemId: string;
|
|
8
8
|
readonly productVariantId: string;
|
|
9
|
+
readonly replaceableFor: string[] | undefined;
|
|
9
10
|
readonly unique: boolean;
|
|
10
11
|
}
|
|
11
12
|
interface UseTrackItemPageViewFunction {
|
|
@@ -2,12 +2,10 @@ import { useLayoutEffect } from "react";
|
|
|
2
2
|
import { PROJECT } from "../../../infrastructure/tracking/tracking";
|
|
3
3
|
import { TrackingEvent, TrackingEventCategory } from "../tracking";
|
|
4
4
|
import { useEmitUserEvent } from "./useEmitUserEvent";
|
|
5
|
-
const useTrackItemPageView = ({ page, country, checkoutId, checkoutItemId, productVariantId,
|
|
6
|
-
// replaceableFor,
|
|
7
|
-
unique, }) => {
|
|
5
|
+
const useTrackItemPageView = ({ page, country, checkoutId, checkoutItemId, productVariantId, replaceableFor, unique, }) => {
|
|
8
6
|
const emitUserEvent = useEmitUserEvent();
|
|
9
7
|
useLayoutEffect(() => {
|
|
10
|
-
if (!checkoutId) {
|
|
8
|
+
if (!(checkoutId && replaceableFor)) {
|
|
11
9
|
return;
|
|
12
10
|
}
|
|
13
11
|
const itemPageViewTrackingEvent = {
|
|
@@ -18,10 +16,10 @@ unique, }) => {
|
|
|
18
16
|
checkoutId,
|
|
19
17
|
checkoutItemId,
|
|
20
18
|
productVariantId,
|
|
21
|
-
|
|
19
|
+
replaceableFor: replaceableFor.toString(),
|
|
22
20
|
unique,
|
|
23
21
|
};
|
|
24
22
|
emitUserEvent(itemPageViewTrackingEvent);
|
|
25
|
-
}, [checkoutId, checkoutItemId, country, emitUserEvent, page, productVariantId, unique]);
|
|
23
|
+
}, [checkoutId, checkoutItemId, country, emitUserEvent, page, productVariantId, replaceableFor, unique]);
|
|
26
24
|
};
|
|
27
25
|
export { useTrackItemPageView };
|
|
@@ -31,6 +31,7 @@ type PageViewTrackingEvent = BaseTrackingEvent;
|
|
|
31
31
|
interface ItemPageViewTrackingEvent extends BaseTrackingEvent {
|
|
32
32
|
readonly checkoutItemId: string;
|
|
33
33
|
readonly productVariantId: string;
|
|
34
|
+
readonly replaceableFor: string;
|
|
34
35
|
readonly unique: boolean;
|
|
35
36
|
}
|
|
36
37
|
interface KeepItemTrackingEvent extends BaseTrackingEvent {
|