@lookiero/checkout 4.0.0-beta.1 → 4.0.0-beta.3
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 -16
- package/dist/projection/shared/order.d.ts +1 -0
- package/dist/shared/tracking/infrastructure/useTrackCheckout.d.ts +5 -4
- package/dist/shared/tracking/infrastructure/useTrackCheckout.js +3 -3
- package/dist/shared/tracking/tracking.d.ts +5 -4
- 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>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { useIntl } from "@lookiero/i18n-react";
|
|
2
1
|
import { QueryStatus } from "@lookiero/messaging-react";
|
|
3
2
|
import { PaymentFlow } from "@lookiero/payments-front";
|
|
4
3
|
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
@@ -14,7 +13,7 @@ import { TrackingPage } from "../../../../../tracking/tracking";
|
|
|
14
13
|
import { useSubmitCheckout } from "../../../../hooks/useSubmitCheckout";
|
|
15
14
|
import { Routes } from "../../../../routing/routes";
|
|
16
15
|
import { useBasePath } from "../../../../routing/useBasePath";
|
|
17
|
-
const CheckoutPaymentModal = ({ customerId, country, isFirstOrder, orderNumber, getAuthToken, onCheckoutSubmitted, }) => {
|
|
16
|
+
const CheckoutPaymentModal = ({ customerId, country, coupon, isFirstOrder, orderNumber, getAuthToken, onCheckoutSubmitted, }) => {
|
|
18
17
|
const paymentFlowRef = useRef(null);
|
|
19
18
|
const logger = useLogger();
|
|
20
19
|
const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
|
|
@@ -33,8 +32,6 @@ const CheckoutPaymentModal = ({ customerId, country, isFirstOrder, orderNumber,
|
|
|
33
32
|
}, [getAuthToken]);
|
|
34
33
|
const basePath = useBasePath();
|
|
35
34
|
const navigate = useNavigate();
|
|
36
|
-
const intl = useIntl();
|
|
37
|
-
const translateNumber = useCallback((value) => intl.formatNumber(value.amount / 100, { style: "currency", currency: value.currency }), [intl]);
|
|
38
35
|
const trackCheckout = useTrackCheckout({
|
|
39
36
|
checkoutId: checkout?.id,
|
|
40
37
|
country,
|
|
@@ -43,32 +40,28 @@ const CheckoutPaymentModal = ({ customerId, country, isFirstOrder, orderNumber,
|
|
|
43
40
|
const handleOnSubmitCheckoutError = useCallback(() => navigate(`${basePath}/${Routes.CHECKOUT}`, { replace: true }), [basePath, navigate]);
|
|
44
41
|
const handleOnSubmitCheckoutSuccess = useCallback(() => {
|
|
45
42
|
const checkoutItemsKept = checkout?.items.filter((checkoutItem) => checkoutItem.status === CheckoutItemStatus.KEPT || checkoutItem.status === CheckoutItemStatus.REPLACED);
|
|
46
|
-
const
|
|
47
|
-
const checkoutItemId = checkout?.items.map((checkoutItem) => checkoutItem.id) || [];
|
|
48
|
-
const pendingToPay = pricing?.pendingToPay;
|
|
49
|
-
const checkoutValue = translateNumber(pendingToPay);
|
|
50
|
-
const productVariantId = checkoutItemsKept?.map(({ productVariant }) => productVariant.id) || [];
|
|
51
|
-
const sizeChange = checkoutItemsKept?.filter(({ replacedFor }) => Boolean(replacedFor)).map(({ id }) => id) || [];
|
|
43
|
+
const sizeChange = checkoutItemsKept?.filter(({ replacedFor }) => Boolean(replacedFor)).length || 0;
|
|
52
44
|
trackCheckout({
|
|
53
|
-
checkoutItems,
|
|
54
|
-
|
|
55
|
-
|
|
45
|
+
checkoutItems: checkoutItemsKept?.length || 0,
|
|
46
|
+
checkoutValue: pricing?.pendingToPay.amount / 100,
|
|
47
|
+
coupon,
|
|
48
|
+
currency: pricing?.pendingToPay.currency,
|
|
56
49
|
isFirstOrder,
|
|
57
50
|
orderNumber,
|
|
58
|
-
productVariantId,
|
|
59
51
|
sizeChange,
|
|
60
52
|
userId: customerId,
|
|
61
53
|
});
|
|
62
54
|
onCheckoutSubmitted?.();
|
|
63
55
|
}, [
|
|
64
56
|
checkout?.items,
|
|
57
|
+
coupon,
|
|
65
58
|
customerId,
|
|
66
59
|
isFirstOrder,
|
|
67
60
|
onCheckoutSubmitted,
|
|
68
61
|
orderNumber,
|
|
69
|
-
pricing?.pendingToPay,
|
|
62
|
+
pricing?.pendingToPay.amount,
|
|
63
|
+
pricing?.pendingToPay.currency,
|
|
70
64
|
trackCheckout,
|
|
71
|
-
translateNumber,
|
|
72
65
|
]);
|
|
73
66
|
const [submitCheckout] = useSubmitCheckout({
|
|
74
67
|
checkoutId: checkout?.id,
|
|
@@ -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
|
|
8
|
-
readonly
|
|
9
|
-
readonly checkoutValue: string;
|
|
10
|
-
readonly sizeChange: string[];
|
|
8
|
+
readonly checkoutValue: number;
|
|
9
|
+
readonly sizeChange: number;
|
|
11
10
|
readonly isFirstOrder: boolean;
|
|
11
|
+
readonly coupon: string;
|
|
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
|
|
92
|
-
readonly
|
|
93
|
-
readonly checkoutValue: string;
|
|
94
|
-
readonly sizeChange: string[];
|
|
92
|
+
readonly checkoutValue: number;
|
|
93
|
+
readonly sizeChange: number;
|
|
95
94
|
readonly isFirstOrder: boolean;
|
|
95
|
+
readonly coupon: string;
|
|
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 };
|