@lookiero/checkout 4.0.0-beta.2 → 4.0.0-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/routing/Routing.js +1 -1
- package/dist/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.d.ts +1 -0
- package/dist/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.js +9 -11
- package/dist/projection/shared/order.d.ts +1 -0
- package/dist/shared/tracking/infrastructure/useTrackCheckout.d.ts +4 -3
- package/dist/shared/tracking/infrastructure/useTrackCheckout.js +3 -3
- package/dist/shared/tracking/tracking.d.ts +4 -3
- package/package.json +1 -1
|
@@ -54,7 +54,7 @@ const Routing = ({ basePath = "", customer, order, locale, I18n, layout, getAuth
|
|
|
54
54
|
children: [
|
|
55
55
|
{
|
|
56
56
|
path: Routes.CHECKOUT_PAYMENT,
|
|
57
|
-
element: (React.createElement(CheckoutPaymentModal, { country: customer?.country, customerId: customer?.customerId, getAuthToken: getAuthToken, isFirstOrder: order?.isFirstOrder, orderNumber: order?.orderNumber, onCheckoutSubmitted: onCheckoutSubmitted })),
|
|
57
|
+
element: (React.createElement(CheckoutPaymentModal, { country: customer?.country, coupon: order?.coupon, customerId: customer?.customerId, getAuthToken: getAuthToken, isFirstOrder: order?.isFirstOrder, orderNumber: order?.orderNumber, onCheckoutSubmitted: onCheckoutSubmitted })),
|
|
58
58
|
},
|
|
59
59
|
],
|
|
60
60
|
},
|
|
@@ -3,6 +3,7 @@ import { Country } from "../../../../../../projection/shared/country";
|
|
|
3
3
|
interface CheckoutPaymentModalProps {
|
|
4
4
|
readonly customerId: string;
|
|
5
5
|
readonly country: Country;
|
|
6
|
+
readonly coupon: string;
|
|
6
7
|
readonly orderNumber: number;
|
|
7
8
|
readonly isFirstOrder: boolean;
|
|
8
9
|
readonly getAuthToken: () => Promise<string>;
|
|
@@ -13,7 +13,7 @@ import { TrackingPage } from "../../../../../tracking/tracking";
|
|
|
13
13
|
import { useSubmitCheckout } from "../../../../hooks/useSubmitCheckout";
|
|
14
14
|
import { Routes } from "../../../../routing/routes";
|
|
15
15
|
import { useBasePath } from "../../../../routing/useBasePath";
|
|
16
|
-
const CheckoutPaymentModal = ({ customerId, country, isFirstOrder, orderNumber, getAuthToken, onCheckoutSubmitted, }) => {
|
|
16
|
+
const CheckoutPaymentModal = ({ customerId, country, coupon, isFirstOrder, orderNumber, getAuthToken, onCheckoutSubmitted, }) => {
|
|
17
17
|
const paymentFlowRef = useRef(null);
|
|
18
18
|
const logger = useLogger();
|
|
19
19
|
const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
|
|
@@ -40,29 +40,27 @@ const CheckoutPaymentModal = ({ customerId, country, isFirstOrder, orderNumber,
|
|
|
40
40
|
const handleOnSubmitCheckoutError = useCallback(() => navigate(`${basePath}/${Routes.CHECKOUT}`, { replace: true }), [basePath, navigate]);
|
|
41
41
|
const handleOnSubmitCheckoutSuccess = useCallback(() => {
|
|
42
42
|
const checkoutItemsKept = checkout?.items.filter((checkoutItem) => checkoutItem.status === CheckoutItemStatus.KEPT || checkoutItem.status === CheckoutItemStatus.REPLACED);
|
|
43
|
-
const
|
|
44
|
-
const checkoutItemId = checkout?.items.map((checkoutItem) => checkoutItem.id) || [];
|
|
45
|
-
const checkoutValue = pricing?.pendingToPay.amount / 100;
|
|
46
|
-
const productVariantId = checkoutItemsKept?.map(({ productVariant }) => productVariant.id) || [];
|
|
47
|
-
const sizeChange = checkoutItemsKept?.filter(({ replacedFor }) => Boolean(replacedFor)).map(({ id }) => id) || [];
|
|
43
|
+
const sizeChange = checkoutItemsKept?.filter(({ replacedFor }) => Boolean(replacedFor)).length || 0;
|
|
48
44
|
trackCheckout({
|
|
49
|
-
checkoutItems,
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
checkoutItems: checkoutItemsKept?.length || 0,
|
|
46
|
+
checkoutValue: pricing?.pendingToPay.amount / 100,
|
|
47
|
+
coupon,
|
|
48
|
+
currency: pricing?.pendingToPay.currency,
|
|
52
49
|
isFirstOrder,
|
|
53
50
|
orderNumber,
|
|
54
|
-
productVariantId,
|
|
55
51
|
sizeChange,
|
|
56
52
|
userId: customerId,
|
|
57
53
|
});
|
|
58
54
|
onCheckoutSubmitted?.();
|
|
59
55
|
}, [
|
|
60
56
|
checkout?.items,
|
|
57
|
+
coupon,
|
|
61
58
|
customerId,
|
|
62
59
|
isFirstOrder,
|
|
63
60
|
onCheckoutSubmitted,
|
|
64
61
|
orderNumber,
|
|
65
|
-
pricing?.pendingToPay,
|
|
62
|
+
pricing?.pendingToPay.amount,
|
|
63
|
+
pricing?.pendingToPay.currency,
|
|
66
64
|
trackCheckout,
|
|
67
65
|
]);
|
|
68
66
|
const [submitCheckout] = useSubmitCheckout({
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import { Currency } from "../../../domain/checkoutItem/model/currency";
|
|
1
2
|
import { TrackingPage } from "../../../infrastructure/tracking/tracking";
|
|
2
3
|
import { Country } from "../../../projection/shared/country";
|
|
3
4
|
interface TrackCheckoutFunctionArgs {
|
|
4
5
|
readonly userId: string;
|
|
5
6
|
readonly orderNumber: number;
|
|
6
7
|
readonly checkoutItems: number;
|
|
7
|
-
readonly productVariantId: string[];
|
|
8
|
-
readonly checkoutItemId: string[];
|
|
9
8
|
readonly checkoutValue: number;
|
|
10
|
-
readonly sizeChange:
|
|
9
|
+
readonly sizeChange: number;
|
|
11
10
|
readonly isFirstOrder: boolean;
|
|
11
|
+
readonly coupon: string | null;
|
|
12
|
+
readonly currency: Currency;
|
|
12
13
|
}
|
|
13
14
|
interface TrackCheckoutFunction {
|
|
14
15
|
(args: TrackCheckoutFunctionArgs): void;
|
|
@@ -4,7 +4,7 @@ import { TrackingEvent, TrackingEventCategory } from "../tracking";
|
|
|
4
4
|
import { useEmitUserEvent } from "./useEmitUserEvent";
|
|
5
5
|
const useTrackCheckout = ({ page, country, checkoutId }) => {
|
|
6
6
|
const emitUserEvent = useEmitUserEvent();
|
|
7
|
-
const trackCheckout = useCallback(({ checkoutItems,
|
|
7
|
+
const trackCheckout = useCallback(({ checkoutItems, checkoutValue, coupon, currency, isFirstOrder, orderNumber, sizeChange, userId }) => {
|
|
8
8
|
if (!checkoutId) {
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
@@ -15,11 +15,11 @@ const useTrackCheckout = ({ page, country, checkoutId }) => {
|
|
|
15
15
|
store: country,
|
|
16
16
|
checkoutId,
|
|
17
17
|
checkoutItems,
|
|
18
|
-
checkoutItemId,
|
|
19
18
|
checkoutValue,
|
|
19
|
+
coupon,
|
|
20
|
+
currency,
|
|
20
21
|
isFirstOrder,
|
|
21
22
|
orderNumber,
|
|
22
|
-
productVariantId,
|
|
23
23
|
sizeChange,
|
|
24
24
|
userId,
|
|
25
25
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CheckoutItemStatus } from "../../domain/checkoutItem/model/checkoutItem";
|
|
2
|
+
import { Currency } from "../../domain/checkoutItem/model/currency";
|
|
2
3
|
import { MediaPerspective } from "../../projection/checkoutItem/checkoutItem";
|
|
3
4
|
import { Country } from "../../projection/shared/country";
|
|
4
5
|
declare enum TrackingEvent {
|
|
@@ -88,11 +89,11 @@ interface CheckoutTrackingEvent extends BaseTrackingEvent {
|
|
|
88
89
|
readonly userId: string;
|
|
89
90
|
readonly orderNumber: number;
|
|
90
91
|
readonly checkoutItems: number;
|
|
91
|
-
readonly productVariantId: string[];
|
|
92
|
-
readonly checkoutItemId: string[];
|
|
93
92
|
readonly checkoutValue: number;
|
|
94
|
-
readonly sizeChange:
|
|
93
|
+
readonly sizeChange: number;
|
|
95
94
|
readonly isFirstOrder: boolean;
|
|
95
|
+
readonly coupon: string | null;
|
|
96
|
+
readonly currency: Currency;
|
|
96
97
|
}
|
|
97
98
|
export type { BaseTrackingEvent, ChangeFeedbackTrackingEvent, CheckoutTrackingEvent, ImageViewTrackingEvent, ItemPageViewTrackingEvent, KeepItemTrackingEvent, PageViewTrackingEvent, PressContinueTrackingEvent, PressItemTrackingEvent, PressPricingTrackingEvent, ReplaceItemTrackingEvent, ResetItemTrackingEvent, ReturnItemTrackingEvent, TabViewTrackingEvent, PressMenuTrackingEvent, PressBackTrackingEvent, PressNextTrackingEvent, PressPreviousTrackingEvent, };
|
|
98
99
|
export { TrackingEvent, TrackingEventCategory };
|