@lookiero/checkout 0.8.22 → 0.8.24

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.
Files changed (35) hide show
  1. package/dist/infrastructure/delivery/baseBootstrap.d.ts +2 -0
  2. package/dist/infrastructure/delivery/baseBootstrap.js +5 -1
  3. package/dist/infrastructure/delivery/bootstrap.js +2 -0
  4. package/dist/infrastructure/projection/checkout/httpIsSizeChangeEnabledByCheckoutIdView.d.ts +2 -2
  5. package/dist/infrastructure/projection/checkout/httpIsSizeChangeEnabledByCheckoutIdView.js +3 -4
  6. package/dist/infrastructure/ui/hooks/useSubmitCheckout.d.ts +1 -0
  7. package/dist/infrastructure/ui/hooks/useSubmitCheckout.js +3 -3
  8. package/dist/infrastructure/ui/views/checkout/Checkout.js +2 -2
  9. package/dist/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.js +5 -3
  10. package/dist/infrastructure/ui/views/feedback/Feedback.js +2 -2
  11. package/dist/infrastructure/ui/views/item/Item.js +90 -22
  12. package/dist/infrastructure/ui/views/item/components/itemActions/ItemActions.d.ts +1 -1
  13. package/dist/infrastructure/ui/views/item/components/itemActions/ItemActions.js +2 -2
  14. package/dist/infrastructure/ui/views/item/components/productVariantSlider/ProductVariantSlider.d.ts +1 -0
  15. package/dist/infrastructure/ui/views/item/components/productVariantSlider/ProductVariantSlider.js +5 -2
  16. package/dist/infrastructure/ui/views/notFound/NotFound.js +2 -2
  17. package/dist/infrastructure/ui/views/summary/Summary.js +2 -2
  18. package/dist/shared/tracking/infrastructure/useTrackImageView.d.ts +21 -0
  19. package/dist/shared/tracking/infrastructure/useTrackImageView.js +25 -0
  20. package/dist/shared/tracking/infrastructure/useTrackItemPageView.d.ts +16 -0
  21. package/dist/shared/tracking/infrastructure/useTrackItemPageView.js +25 -0
  22. package/dist/shared/tracking/infrastructure/useTrackKeepItem.d.ts +16 -0
  23. package/dist/shared/tracking/infrastructure/useTrackKeepItem.js +23 -0
  24. package/dist/shared/tracking/infrastructure/useTrackPageView.d.ts +12 -0
  25. package/dist/shared/tracking/infrastructure/{usePageView.js → useTrackPageView.js} +4 -10
  26. package/dist/shared/tracking/infrastructure/useTrackReplaceItem.d.ts +20 -0
  27. package/dist/shared/tracking/infrastructure/useTrackReplaceItem.js +25 -0
  28. package/dist/shared/tracking/infrastructure/useTrackResetItem.d.ts +16 -0
  29. package/dist/shared/tracking/infrastructure/useTrackResetItem.js +23 -0
  30. package/dist/shared/tracking/infrastructure/useTrackReturnItem.d.ts +16 -0
  31. package/dist/shared/tracking/infrastructure/useTrackReturnItem.js +23 -0
  32. package/dist/shared/tracking/tracking.d.ts +33 -4
  33. package/dist/shared/tracking/tracking.js +5 -0
  34. package/package.json +1 -1
  35. package/dist/shared/tracking/infrastructure/usePageView.d.ts +0 -13
@@ -15,6 +15,7 @@ import { CheckoutByIdView } from "../../projection/checkout/viewCheckoutById";
15
15
  import { FirstAvailableCheckoutByCustomerIdView } from "../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
16
16
  import { FiveItemsDiscountByCustomerIdView } from "../../projection/checkout/viewFiveItemsDiscountByCustomerId";
17
17
  import { IsCheckoutEnabledByCustomerIdView } from "../../projection/checkout/viewIsCheckoutEnabledByCustomerId";
18
+ import { IsSizeChangeEnabledByCheckoutIdView } from "../../projection/checkout/viewIsSizeChangeEnabledByCheckoutId";
18
19
  import { CheckoutBookingByIdView } from "../../projection/checkoutBooking/viewCheckoutBookingById";
19
20
  import { CheckoutItemByIdView } from "../../projection/checkoutItem/viewCheckoutItemById";
20
21
  import { CheckoutQuestionsByCheckoutIdView } from "../../projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId";
@@ -29,6 +30,7 @@ interface BaseBootstrapFunctionArgs<UiSettingGetFunctionArgs extends RepositoryG
29
30
  readonly checkoutByIdView: CheckoutByIdView;
30
31
  readonly firstAvailableCheckoutByCustomerIdView: FirstAvailableCheckoutByCustomerIdView;
31
32
  readonly isCheckoutEnabledByCustomerIdView: IsCheckoutEnabledByCustomerIdView;
33
+ readonly isSizeChangeEnabledByCheckoutIdView: IsSizeChangeEnabledByCheckoutIdView;
32
34
  readonly fiveItemsDiscountByCustomerIdView: FiveItemsDiscountByCustomerIdView;
33
35
  readonly uiSettingByKeyView: UiSettingByKeyView;
34
36
  readonly checkoutItemByIdView: CheckoutItemByIdView;
@@ -26,6 +26,7 @@ import { viewFirstAvailableCheckoutByCustomerIdHandler, VIEW_FIRST_AVAILABLE_CHE
26
26
  import { viewFiveItemsDiscountByCustomerIdHandler, VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID, } from "../../projection/checkout/viewFiveItemsDiscountByCustomerId";
27
27
  import { viewIsCheckoutAccessibleByCustomerIdHandler, VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, } from "../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
28
28
  import { viewIsCheckoutEnabledByCustomerIdHandler, VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID, } from "../../projection/checkout/viewIsCheckoutEnabledByCustomerId";
29
+ import { viewIsSizeChangeEnabledByCheckoutIdHandler, VIEW_IS_SIZE_CHANGE_ENABLED_BY_CHECKOUT_ID, } from "../../projection/checkout/viewIsSizeChangeEnabledByCheckoutId";
29
30
  import { viewCheckoutBookingByIdHandler, VIEW_CHECKOUT_BOOKING_BY_ID, } from "../../projection/checkoutBooking/viewCheckoutBookingById";
30
31
  import { viewCheckoutItemByIdHandler, VIEW_CHECKOUT_ITEM_BY_ID, } from "../../projection/checkoutItem/viewCheckoutItemById";
31
32
  import { listCheckoutQuestionsByCheckoutIdHandler, LIST_CHECKOUT_QUESTIONS_BY_CHECKOUT_ID, } from "../../projection/checkoutQuestion/listCheckoutQuestionsByCheckoutId";
@@ -36,7 +37,7 @@ import { viewUiSettingByKeyHandler, VIEW_UI_SETTING_BY_KEY, } from "../../projec
36
37
  import { bootstrapWithBuilder as bootstrapNotifications } from "../../shared/notifications/infrastructure/delivery/bootstrap";
37
38
  import { inMemoryStorageNotifications } from "../../shared/notifications/infrastructure/persistence/inMemoryStorageNotifications";
38
39
  const MESSAGING_CONTEXT_ID = "Checkout";
39
- const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdView, isCheckoutEnabledByCustomerIdView, fiveItemsDiscountByCustomerIdView, checkoutItemByIdView, returnQuestionsByCheckoutItemIdView, bookedProductsVariantsForCheckoutItemView, checkoutBookingByIdView, pricingByCheckoutIdView, paymentFlowPayloadByCheckoutIdView, checkoutQuestionsByCheckoutIdView, uiSettingByKeyView, getUiSetting, saveUiSetting, uiSettingsDependencies, getCheckout, saveCheckout, checkoutsDependencies, getCheckoutItem, saveCheckoutItem, checkoutItemsDependencies, getCheckoutBooking, saveCheckoutBooking, checkoutBookingsDependencies, getCheckoutFeedback, saveCheckoutFeedback, checkoutFeedbacksDependencies, }) => {
40
+ const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdView, isCheckoutEnabledByCustomerIdView, isSizeChangeEnabledByCheckoutIdView, fiveItemsDiscountByCustomerIdView, checkoutItemByIdView, returnQuestionsByCheckoutItemIdView, bookedProductsVariantsForCheckoutItemView, checkoutBookingByIdView, pricingByCheckoutIdView, paymentFlowPayloadByCheckoutIdView, checkoutQuestionsByCheckoutIdView, uiSettingByKeyView, getUiSetting, saveUiSetting, uiSettingsDependencies, getCheckout, saveCheckout, checkoutsDependencies, getCheckoutItem, saveCheckoutItem, checkoutItemsDependencies, getCheckoutBooking, saveCheckoutBooking, checkoutBookingsDependencies, getCheckoutFeedback, saveCheckoutFeedback, checkoutFeedbacksDependencies, }) => {
40
41
  let messaging = messagingBootstrap({ id: MESSAGING_CONTEXT_ID })
41
42
  .query(VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID, viewFiveItemsDiscountByCustomerIdHandler, {
42
43
  view: fiveItemsDiscountByCustomerIdView,
@@ -49,6 +50,9 @@ const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdVie
49
50
  })
50
51
  .query(VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID, viewIsCheckoutEnabledByCustomerIdHandler, {
51
52
  view: isCheckoutEnabledByCustomerIdView,
53
+ })
54
+ .query(VIEW_IS_SIZE_CHANGE_ENABLED_BY_CHECKOUT_ID, viewIsSizeChangeEnabledByCheckoutIdHandler, {
55
+ view: isSizeChangeEnabledByCheckoutIdView,
52
56
  })
53
57
  .query(VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, viewIsCheckoutAccessibleByCustomerIdHandler)
54
58
  .command(START_CHECKOUT, startCheckoutHandler)(getCheckout, saveCheckout, ...checkoutsDependencies)
@@ -9,6 +9,7 @@ import { httpCheckoutByIdView } from "../projection/checkout/httpCheckoutByIdVie
9
9
  import { httpFirstAvailableCheckoutByCustomerIdView } from "../projection/checkout/httpFirstAvailableCheckoutByCustomerIdView";
10
10
  import { httpFiveItemsDiscountByCustomerIdView } from "../projection/checkout/httpFiveItemsDiscountByCustomerIdView";
11
11
  import { httpIsCheckoutEnabledByCustomerIdView } from "../projection/checkout/httpIsCheckoutEnabledByCustomerIdView";
12
+ import { httpIsSizeChangeEnabledByCheckoutIdView } from "../projection/checkout/httpIsSizeChangeEnabledByCheckoutIdView";
12
13
  import { httpCheckoutBookingByIdView } from "../projection/checkoutBooking/httpCheckoutBookingByIdView";
13
14
  import { httpCheckoutItemByIdView } from "../projection/checkoutItem/httpCheckoutItemByIdView";
14
15
  import { httpCheckoutQuestionsByCheckoutIdView } from "../projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView";
@@ -25,6 +26,7 @@ const bootstrap = ({ apiUrl, getAuthToken }) => {
25
26
  checkoutByIdView: httpCheckoutByIdView({ httpPost }),
26
27
  firstAvailableCheckoutByCustomerIdView: httpFirstAvailableCheckoutByCustomerIdView({ httpPost }),
27
28
  isCheckoutEnabledByCustomerIdView: httpIsCheckoutEnabledByCustomerIdView({ httpGet }),
29
+ isSizeChangeEnabledByCheckoutIdView: httpIsSizeChangeEnabledByCheckoutIdView({ httpGet }),
28
30
  fiveItemsDiscountByCustomerIdView: httpFiveItemsDiscountByCustomerIdView({ httpGet }),
29
31
  uiSettingByKeyView: storageUiSettingByKeyView({ read }),
30
32
  checkoutItemByIdView: httpCheckoutItemByIdView({ httpPost }),
@@ -1,9 +1,9 @@
1
1
  import { IsSizeChangeEnabledByCheckoutIdView } from "../../../projection/checkout/viewIsSizeChangeEnabledByCheckoutId";
2
- import { HttpPostFunction } from "../../delivery/http/httpClient";
2
+ import { HttpGetFunction } from "../../delivery/http/httpClient";
3
3
  interface HttpIsSizeChangeEnabledByCheckoutIdView extends IsSizeChangeEnabledByCheckoutIdView {
4
4
  }
5
5
  interface HttpIsSizeChangeEnabledByCheckoutIdViewFunctionArgs {
6
- readonly httpPost: HttpPostFunction;
6
+ readonly httpGet: HttpGetFunction;
7
7
  }
8
8
  interface HttpIsSizeChangeEnabledByCheckoutIdViewFunction {
9
9
  (args: HttpIsSizeChangeEnabledByCheckoutIdViewFunctionArgs): HttpIsSizeChangeEnabledByCheckoutIdView;
@@ -1,10 +1,9 @@
1
- const httpIsSizeChangeEnabledByCheckoutIdView = ({ httpPost }) => async ({ checkoutId, signal }) => await httpPost({
2
- endpoint: "/is-size-change-enabled",
1
+ const httpIsSizeChangeEnabledByCheckoutIdView = ({ httpGet }) => async ({ checkoutId, signal }) => await httpGet({
2
+ endpoint: `/is-size-change-enabled-by-checkout-id/${checkoutId}`,
3
3
  signal,
4
- body: { checkoutId },
5
4
  result: {
6
5
  error: false,
7
- success: (response) => response.result,
6
+ success: (response) => response,
8
7
  },
9
8
  });
10
9
  export { httpIsSizeChangeEnabledByCheckoutIdView };
@@ -5,6 +5,7 @@ import { Logger } from "../../../shared/logging/Logger";
5
5
  type Status = "idle" | "loading" | "success" | "error";
6
6
  interface SubmitCheckoutFunctionArgs {
7
7
  readonly paymentFlowPayload: PaymentFlowPayloadProjection;
8
+ readonly sizeChangeEnabled: boolean;
8
9
  }
9
10
  interface SubmitCheckoutFunction {
10
11
  (args: SubmitCheckoutFunctionArgs): Promise<void>;
@@ -12,9 +12,9 @@ const useSubmitCheckout = ({ checkoutId, checkoutBookingId, paymentFlowRef, onEr
12
12
  const [blockCheckoutBooking, blockCheckoutBookingStatus] = useBlockCheckoutBooking({ checkoutBookingId, logger });
13
13
  const [createNotification] = useCreateToastNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
14
14
  const [startLegacyBoxCheckoutStatus, setStartLegacyBoxCheckoutStatus] = useState("idle");
15
- const submitCheckout = useCallback(async ({ paymentFlowPayload }) => {
15
+ const submitCheckout = useCallback(async ({ paymentFlowPayload, sizeChangeEnabled }) => {
16
16
  try {
17
- await blockCheckoutBooking();
17
+ sizeChangeEnabled && (await blockCheckoutBooking());
18
18
  }
19
19
  catch (error) {
20
20
  return;
@@ -38,7 +38,7 @@ const useSubmitCheckout = ({ checkoutId, checkoutBookingId, paymentFlowRef, onEr
38
38
  }
39
39
  }
40
40
  });
41
- }, [paymentFlowRef, blockCheckoutBooking, createNotification, submitCheckoutCommand]);
41
+ }, [paymentFlowRef, blockCheckoutBooking, submitCheckoutCommand, createNotification]);
42
42
  const status = useMemo(() => {
43
43
  if (blockCheckoutBookingStatus === CommandStatus.LOADING ||
44
44
  startLegacyBoxCheckoutStatus === "loading" ||
@@ -5,7 +5,7 @@ import React, { useCallback, useMemo } from "react";
5
5
  import { Platform, View } from "react-native";
6
6
  import { useNavigate } from "react-router-native";
7
7
  import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
8
- import { usePageView } from "../../../../shared/tracking/infrastructure/usePageView";
8
+ import { useTrackPageView } from "../../../../shared/tracking/infrastructure/useTrackPageView";
9
9
  import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
10
10
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
11
11
  import { useViewPricingByCheckoutId } from "../../../projection/pricing/react/useViewPricingByCheckoutId";
@@ -25,7 +25,7 @@ const Checkout = ({ children, customerId, country, useRedirect }) => {
25
25
  const titleText = useI18nMessage({ id: I18nMessages.CHECKOUT_TITLE });
26
26
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
27
27
  const [pricing, pricingStatus] = useViewPricingByCheckoutId({ checkoutId: checkout?.id });
28
- usePageView({
28
+ useTrackPageView({
29
29
  page: TrackingPage.CHECKOUT,
30
30
  country,
31
31
  checkoutId: checkout?.id,
@@ -4,6 +4,7 @@ import React, { useCallback, useEffect, useRef, useState } from "react";
4
4
  import { useNavigate } from "react-router-native";
5
5
  import { useLogger } from "../../../../../../shared/logging/useLogger";
6
6
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
7
+ import { useViewIsSizeChangeEnabledByCheckoutId } from "../../../../../projection/checkout/react/useViewIsSizeChangeEnabledByCheckoutId";
7
8
  import { useViewPaymentFlowPayloadByCheckoutId } from "../../../../../projection/payment/react/useViewPaymentFlowPayloadByCheckoutId";
8
9
  import { useSubmitCheckout } from "../../../../hooks/useSubmitCheckout";
9
10
  import { Routes } from "../../../../routing/routes";
@@ -15,6 +16,7 @@ const CheckoutPaymentModal = ({ customerId, getAuthToken }) => {
15
16
  const [paymentFlowPayload] = useViewPaymentFlowPayloadByCheckoutId({
16
17
  checkoutId: checkout?.id,
17
18
  });
19
+ const [sizeChangeEnabled] = useViewIsSizeChangeEnabledByCheckoutId({ checkoutId: checkout?.id });
18
20
  const [authToken, setAuthToken] = useState();
19
21
  useEffect(() => {
20
22
  const loadAuthToken = async () => setAuthToken(await getAuthToken());
@@ -31,10 +33,10 @@ const CheckoutPaymentModal = ({ customerId, getAuthToken }) => {
31
33
  logger,
32
34
  });
33
35
  useEffect(() => {
34
- if (paymentFlowPayload) {
35
- submitCheckout({ paymentFlowPayload });
36
+ if (paymentFlowPayload && sizeChangeEnabled !== undefined) {
37
+ submitCheckout({ paymentFlowPayload, sizeChangeEnabled });
36
38
  }
37
- }, [paymentFlowPayload, submitCheckout]);
39
+ }, [paymentFlowPayload, sizeChangeEnabled, submitCheckout]);
38
40
  const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
39
41
  const dependenciesLoaded = (dependenciesLoadedStatuses.includes(checkoutStatus) || checkout) && authToken;
40
42
  if (!dependenciesLoaded)
@@ -2,7 +2,7 @@ import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
2
2
  import React, { useCallback, useEffect, useRef } from "react";
3
3
  import { Platform } from "react-native";
4
4
  import { useLogger } from "../../../../shared/logging/useLogger";
5
- import { usePageView } from "../../../../shared/tracking/infrastructure/usePageView";
5
+ import { useTrackPageView } from "../../../../shared/tracking/infrastructure/useTrackPageView";
6
6
  import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
7
7
  import { useGiveCheckoutFeedback } from "../../../domain/checkoutFeedback/react/useGiveCheckoutFeedback";
8
8
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
@@ -32,7 +32,7 @@ const Feedback = ({ customerId, country }) => {
32
32
  }
33
33
  catch (e) { }
34
34
  }, [giveCheckoutFeedback]);
35
- usePageView({
35
+ useTrackPageView({
36
36
  page: TrackingPage.FEEDBACK,
37
37
  country,
38
38
  checkoutId: checkout?.id,
@@ -5,7 +5,12 @@ import { useParams } from "react-router-native";
5
5
  import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
6
6
  import "../../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
7
7
  import { useLogger } from "../../../../shared/logging/useLogger";
8
- import { usePageView } from "../../../../shared/tracking/infrastructure/usePageView";
8
+ import { useTrackImageView } from "../../../../shared/tracking/infrastructure/useTrackImageView";
9
+ import { useTrackItemPageView } from "../../../../shared/tracking/infrastructure/useTrackItemPageView";
10
+ import { useTrackKeepItem } from "../../../../shared/tracking/infrastructure/useTrackKeepItem";
11
+ import { useTrackReplaceItem } from "../../../../shared/tracking/infrastructure/useTrackReplaceItem";
12
+ import { useTrackResetItem } from "../../../../shared/tracking/infrastructure/useTrackResetItem";
13
+ import { useTrackReturnItem } from "../../../../shared/tracking/infrastructure/useTrackReturnItem";
9
14
  import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
10
15
  import { useBookCheckoutBookingForCheckoutItem } from "../../../domain/checkoutBooking/react/useBookCheckoutBookingForCheckoutItem";
11
16
  import { useKeepCheckoutItem } from "../../../domain/checkoutItem/react/useKeepCheckoutItem";
@@ -14,6 +19,7 @@ import { useResetCheckoutItem } from "../../../domain/checkoutItem/react/useRese
14
19
  import { useReturnCheckoutItem } from "../../../domain/checkoutItem/react/useReturnCheckoutItem";
15
20
  import { useViewBookedProductsVariantsForCheckoutItem } from "../../../projection/bookedProductsVariants/react/useViewBookedProductsVariantsForCheckoutItem";
16
21
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
22
+ import { useViewIsSizeChangeEnabledByCheckoutId } from "../../../projection/checkout/react/useViewIsSizeChangeEnabledByCheckoutId";
17
23
  import { useListReturnQuestionsByCheckoutItemId } from "../../../projection/returnQuestion/react/useListReturnQuestionsByCheckoutItemId";
18
24
  import { TrackingPage } from "../../../tracking/tracking";
19
25
  import { Body } from "../../components/layouts/body/Body";
@@ -34,13 +40,73 @@ const Item = ({ customerId, country }) => {
34
40
  const logger = useLogger();
35
41
  const { id } = useParams();
36
42
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
43
+ const [isSizeChangeEnabled, sizeChangeEnabledStatus] = useViewIsSizeChangeEnabledByCheckoutId({
44
+ checkoutId: checkout?.id,
45
+ });
37
46
  const checkoutItem = checkout?.items.find((checkoutItem) => checkoutItem.id === id);
38
- usePageView({
47
+ const [bookedProductsVariants] = useViewBookedProductsVariantsForCheckoutItem({
48
+ checkoutItemId: checkoutItem.id,
49
+ });
50
+ const [bookCheckoutBooking] = useBookCheckoutBookingForCheckoutItem({
51
+ checkoutItemId: checkoutItem.id,
52
+ checkoutBookingId: checkout?.checkoutBookingId,
53
+ logger,
54
+ });
55
+ const isBookingRequired = bookedProductsVariants === null && isSizeChangeEnabled;
56
+ useEffect(() => {
57
+ isBookingRequired && bookCheckoutBooking();
58
+ }, [bookCheckoutBooking, isBookingRequired]);
59
+ const replaceableFor = useMemo(() => sizeChangeEnabledStatus === QueryStatus.SUCCESS
60
+ ? isSizeChangeEnabled
61
+ ? bookedProductsVariants
62
+ ? bookedProductsVariants?.productVariants.map(({ id }) => id)
63
+ : undefined
64
+ : []
65
+ : undefined, [bookedProductsVariants, isSizeChangeEnabled, sizeChangeEnabledStatus]);
66
+ useTrackItemPageView({
67
+ page: TrackingPage.ITEM,
68
+ country,
69
+ checkoutId: checkout?.id,
70
+ checkoutItemId: checkoutItem.id,
71
+ productVariantId: checkoutItem.productVariant.id,
72
+ replaceableFor,
73
+ unique: checkoutItem.productVariant.size.unique,
74
+ });
75
+ const trackKeepItem = useTrackKeepItem({
39
76
  page: TrackingPage.ITEM,
40
77
  country,
41
78
  checkoutId: checkout?.id,
42
79
  checkoutItemId: checkoutItem.id,
43
80
  });
81
+ const trackReturnItem = useTrackReturnItem({
82
+ page: TrackingPage.ITEM,
83
+ country,
84
+ checkoutId: checkout?.id,
85
+ checkoutItemId: checkoutItem.id,
86
+ });
87
+ const trackReplaceItem = useTrackReplaceItem({
88
+ page: TrackingPage.ITEM,
89
+ country,
90
+ checkoutId: checkout?.id,
91
+ checkoutItemId: checkoutItem.id,
92
+ productVariantId: checkoutItem.productVariant.id,
93
+ });
94
+ const trackResetItem = useTrackResetItem({
95
+ page: TrackingPage.ITEM,
96
+ country,
97
+ checkoutId: checkout?.id,
98
+ checkoutItemId: checkoutItem.id,
99
+ });
100
+ const trackImageView = useTrackImageView({
101
+ page: TrackingPage.ITEM,
102
+ country,
103
+ checkoutId: checkout?.id,
104
+ checkoutItemId: checkoutItem.id,
105
+ productVariantId: checkoutItem.productVariant.id,
106
+ });
107
+ useEffect(() => trackImageView({
108
+ perspective: checkoutItem.productVariant.media[0]?.perspective,
109
+ }), [checkoutItem.productVariant.media, trackImageView]);
44
110
  const customerDecissionMade = checkoutItem.status !== CheckoutItemStatus.INITIAL;
45
111
  const [resetCheckoutItem, resetCheckoutItemStatus] = useResetCheckoutItem({
46
112
  checkoutItemId: checkoutItem.id,
@@ -58,17 +124,6 @@ const Item = ({ customerId, country }) => {
58
124
  const [sizeWithoutStockModalVisible, setSizeWithoutStockModalVisible] = useState(false);
59
125
  const handleOnShowSizeWithoutStockModal = useCallback(() => setSizeWithoutStockModalVisible(true), []);
60
126
  const handleOnHideSizeWithoutStockModal = useCallback(() => setSizeWithoutStockModalVisible(false), []);
61
- const [bookedProductsVariants, bookedProductsVariantsStatus] = useViewBookedProductsVariantsForCheckoutItem({
62
- checkoutItemId: checkoutItem.id,
63
- });
64
- const [bookCheckoutBooking] = useBookCheckoutBookingForCheckoutItem({
65
- checkoutItemId: checkoutItem.id,
66
- checkoutBookingId: checkout?.checkoutBookingId,
67
- logger,
68
- });
69
- useEffect(() => {
70
- bookedProductsVariants === null && bookCheckoutBooking();
71
- }, [bookCheckoutBooking, bookedProductsVariants]);
72
127
  const [returnQuestions, returnQuestionsStatus] = useListReturnQuestionsByCheckoutItemId({
73
128
  checkoutItemId: checkoutItem.id,
74
129
  });
@@ -81,30 +136,43 @@ const Item = ({ customerId, country }) => {
81
136
  const handleOnSubmit = useCallback((feedbacks) => {
82
137
  handleOnHideReturnQuestions();
83
138
  returnCheckoutItem({ feedbacks });
84
- }, [handleOnHideReturnQuestions, returnCheckoutItem]);
85
- const handleOnReplace = useCallback((replacedForId) => replaceCheckoutItem({ replacedForId }), [replaceCheckoutItem]);
139
+ trackReturnItem();
140
+ }, [handleOnHideReturnQuestions, returnCheckoutItem, trackReturnItem]);
141
+ const handleOnReplace = useCallback((replacedForId) => {
142
+ replaceCheckoutItem({ replacedForId });
143
+ trackReplaceItem({ replaceFor: replacedForId });
144
+ }, [replaceCheckoutItem, trackReplaceItem]);
86
145
  const handleOnReturn = useCallback(() => handleOnShowReturnQuestions(), [handleOnShowReturnQuestions]);
146
+ const handleOnKeep = useCallback(() => {
147
+ keepCheckoutItem();
148
+ trackKeepItem();
149
+ }, [keepCheckoutItem, trackKeepItem]);
150
+ const handleOnPressCustomerDecissionBanner = useCallback(() => {
151
+ resetCheckoutItem();
152
+ trackResetItem();
153
+ }, [resetCheckoutItem, trackResetItem]);
154
+ const handleOnChangedProductVariantSlider = useCallback((active) => trackImageView({ perspective: checkoutItem.productVariant.media[active]?.perspective }), [checkoutItem.productVariant.media, trackImageView]);
87
155
  const productVariantSelected = useMemo(() => checkoutItem.status === CheckoutItemStatus.REPLACED && checkoutItem.replacedFor
88
156
  ? { id: checkoutItem.replacedFor.id, size: checkoutItem.replacedFor.size }
89
157
  : { id: checkoutItem.productVariant.id, size: checkoutItem.productVariant.size }, [checkoutItem.productVariant.id, checkoutItem.productVariant.size, checkoutItem.replacedFor, checkoutItem.status]);
90
158
  const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
91
159
  const dependenciesLoaded = dependenciesLoadedStatuses.includes(returnQuestionsStatus) &&
92
- // This will ensure that the view is not shown until bookCheckoutBooking use-case is dispatched
93
- (dependenciesLoadedStatuses.includes(checkoutStatus) || (checkout && checkout.checkoutBookingId)) &&
94
- dependenciesLoadedStatuses.includes(bookedProductsVariantsStatus) &&
95
- bookedProductsVariants;
160
+ dependenciesLoadedStatuses.includes(sizeChangeEnabledStatus) &&
161
+ // This will ensure that the view is not shown until bookCheckoutBooking use-case is dispatched (if required)
162
+ (isBookingRequired ? checkout?.checkoutBookingId && bookedProductsVariants : true) &&
163
+ (dependenciesLoadedStatuses.includes(checkoutStatus) || checkout);
96
164
  if (!dependenciesLoaded)
97
165
  return React.createElement(Spinner, null);
98
166
  const { price } = checkoutItem;
99
167
  const { media, brand, name, color } = checkoutItem.productVariant;
100
168
  return (React.createElement(ReturnQuestionFeedbackProvider, { feedback: checkoutItem.feedbacks || {} },
101
169
  React.createElement(SizeWithoutStockModal, { visible: sizeWithoutStockModalVisible, onDismiss: handleOnHideSizeWithoutStockModal }),
102
- React.createElement(SafeAreaScrollView, { scrollerPaddingTop: Platform.OS === "web" || Platform.OS === "android" ? HEADER_HEIGHT : 0, footer: !customerDecissionMade && (React.createElement(ItemActions, { country: country, keepButtonLoading: keepCheckoutItemStatus === CommandStatus.LOADING, productVariantSelected: productVariantSelected, productVariants: bookedProductsVariants?.productVariants || [], returnButtonLoading: returnCheckoutItemStatus === CommandStatus.LOADING, sizeSelectorDisabled: replaceCheckoutItemStatus === CommandStatus.LOADING, onKeep: keepCheckoutItem, onLayout: handleOnStickyLayout, onReplace: handleOnReplace, onReturn: handleOnReturn, onSizeSelectorPress: handleOnShowSizeWithoutStockModal })) },
170
+ React.createElement(SafeAreaScrollView, { scrollerPaddingTop: Platform.OS === "web" || Platform.OS === "android" ? HEADER_HEIGHT : 0, footer: !customerDecissionMade && (React.createElement(ItemActions, { country: country, keepButtonLoading: keepCheckoutItemStatus === CommandStatus.LOADING, productVariantSelected: productVariantSelected, productVariants: bookedProductsVariants?.productVariants, returnButtonLoading: returnCheckoutItemStatus === CommandStatus.LOADING, sizeSelectorDisabled: replaceCheckoutItemStatus === CommandStatus.LOADING, onKeep: handleOnKeep, onLayout: handleOnStickyLayout, onReplace: handleOnReplace, onReturn: handleOnReturn, onSizeSelectorPress: handleOnShowSizeWithoutStockModal })) },
103
171
  React.createElement(Body, null,
104
- customerDecissionMade && (React.createElement(CustomerDecissionBanner, { changingDecission: resetCheckoutItemStatus === CommandStatus.LOADING, checkoutItemStatus: checkoutItem.status, onPress: resetCheckoutItem })),
172
+ customerDecissionMade && (React.createElement(CustomerDecissionBanner, { changingDecission: resetCheckoutItemStatus === CommandStatus.LOADING, checkoutItemStatus: checkoutItem.status, onPress: handleOnPressCustomerDecissionBanner })),
105
173
  React.createElement(View, { style: [style.content, { paddingBottom: Platform.OS === "web" ? spaceXL : stickyHeight }] },
106
174
  React.createElement(View, { style: style.sliderContainer },
107
- React.createElement(ProductVariantSlider, { producVariantMedia: media })),
175
+ React.createElement(ProductVariantSlider, { producVariantMedia: media, onChanged: handleOnChangedProductVariantSlider })),
108
176
  React.createElement(ProductVariantDescription, { brand: brand, color: color, country: country, name: name, price: price, size: productVariantSelected.size }),
109
177
  checkoutItem.status === CheckoutItemStatus.RETURNED && (React.createElement(View, { style: style.feedbackContainer },
110
178
  React.createElement(ReturnQuestionsFeedback, { returnQuestions: returnQuestions || [], onEditFeedback: handleOnEditFeedback })))))),
@@ -3,7 +3,7 @@ import { ProductVariantProjection } from "../../../../../../projection/bookedPro
3
3
  import { Country } from "../../../../../../projection/shared/country";
4
4
  import { Layout } from "../../../../../../shared/ui/components/layouts/sticky/Sticky";
5
5
  interface ItemActionsProps {
6
- readonly productVariants: ProductVariantProjection[];
6
+ readonly productVariants?: ProductVariantProjection[];
7
7
  readonly productVariantSelected: ProductVariantProjection;
8
8
  readonly keepButtonLoading?: boolean;
9
9
  readonly returnButtonLoading?: boolean;
@@ -13,7 +13,7 @@ const ItemActions = ({ productVariants, productVariantSelected, keepButtonLoadin
13
13
  const sizeSelectorLabelText = useI18nMessage({ id: I18nMessages.ITEM_SIZES_LABEL });
14
14
  const keepButtonText = useI18nMessage({ id: I18nMessages.ITEM_KEEP_BUTTON });
15
15
  const returnButtonText = useI18nMessage({ id: I18nMessages.ITEM_RETURN_BUTTON });
16
- const sizeSelectorOptions = useMemo(() => productVariants.map((productVariant) => ({
16
+ const sizeSelectorOptions = useMemo(() => (productVariants || []).map((productVariant) => ({
17
17
  label: size({ size: productVariant.size, country }),
18
18
  value: productVariant.id,
19
19
  })), [country, productVariants]);
@@ -23,7 +23,7 @@ const ItemActions = ({ productVariants, productVariantSelected, keepButtonLoadin
23
23
  React.createElement(Body, { style: { column: style.container } },
24
24
  React.createElement(Button, { busy: keepButtonLoading, onPress: onKeep }, keepButtonText),
25
25
  React.createElement(View, { style: style.row },
26
- !productVariantSelected.size.unique && (React.createElement(SelectField, { ...(disabledSizeSelector && {
26
+ !productVariantSelected.size.unique && productVariants && (React.createElement(SelectField, { ...(disabledSizeSelector && {
27
27
  onPress: onSizeSelectorPress,
28
28
  }), disabled: sizeSelectorDisabled, options: sizeSelectorOptions, placeholder: sizeSelectorLabelText || "", testID: "size-selector", title: sizeSelectorLabelText || "", value: productVariantSelected.id, style: {
29
29
  selectField: style.sizeSelector,
@@ -2,6 +2,7 @@ import { FC } from "react";
2
2
  import { MediaProjection } from "../../../../../../projection/checkoutItem/checkoutItem";
3
3
  interface ProductVariantSlider {
4
4
  readonly producVariantMedia: MediaProjection[];
5
+ readonly onChanged?: (active: number) => void;
5
6
  }
6
7
  declare const ProductVariantSlider: FC<ProductVariantSlider>;
7
8
  export { ProductVariantSlider };
@@ -3,10 +3,13 @@ import { Image } from "react-native";
3
3
  import { Slider } from "../../../../../../shared/ui/components/layouts/slider/Slider";
4
4
  import { useMediaImage } from "../../../../hooks/useMediaImage";
5
5
  import { style } from "./ProductVariantSlider.style";
6
- const ProductVariantSlider = ({ producVariantMedia }) => {
6
+ const ProductVariantSlider = ({ producVariantMedia, onChanged }) => {
7
7
  const cdnImageUrl = useMediaImage();
8
8
  const [active, setActive] = useState(0);
9
- const handleOnActiveChanged = useCallback((activeIndex) => setActive(activeIndex), []);
9
+ const handleOnActiveChanged = useCallback((activeIndex) => {
10
+ setActive(activeIndex);
11
+ onChanged?.(activeIndex);
12
+ }, [onChanged]);
10
13
  return (React.createElement(Slider, { active: active, paginationActiveItemStyle: style.paginationActiveItemStyle, paginationItemStyle: style.paginationItemStyle, paginationStyle: style.paginationStyle, paginationRenderItem: (index) => (React.createElement(Image, { key: producVariantMedia[index]?.perspective, resizeMode: "contain", style: style.paginationImage, testID: "product-variant-pagination-image", source: {
11
14
  uri: cdnImageUrl({
12
15
  url: producVariantMedia[index]?.url,
@@ -5,7 +5,7 @@ import { QueryStatus } from "@lookiero/messaging-react";
5
5
  import React, { useCallback } from "react";
6
6
  import { Image, Platform } from "react-native";
7
7
  import { useNavigate } from "react-router-native";
8
- import { usePageView } from "../../../../shared/tracking/infrastructure/usePageView";
8
+ import { useTrackPageView } from "../../../../shared/tracking/infrastructure/useTrackPageView";
9
9
  import { AspectRatioView } from "../../../../shared/ui/components/atoms/aspectRatioView/AspectRatioView";
10
10
  import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
11
11
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
@@ -21,7 +21,7 @@ const NotFound = ({ customerId, country }) => {
21
21
  const descriptionText = useI18nMessage({ id: I18nMessages.NOT_FOUND_DESCRIPTION });
22
22
  const buttonText = useI18nMessage({ id: I18nMessages.NOT_FOUND_BUTTON });
23
23
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
24
- usePageView({
24
+ useTrackPageView({
25
25
  page: TrackingPage.NOT_FOUND,
26
26
  country,
27
27
  checkoutId: checkout?.id,
@@ -5,7 +5,7 @@ import React, { useCallback, useMemo, useState } from "react";
5
5
  import { Platform, View } from "react-native";
6
6
  import { generatePath, useNavigate } from "react-router-native";
7
7
  import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
8
- import { usePageView } from "../../../../shared/tracking/infrastructure/usePageView";
8
+ import { useTrackPageView } from "../../../../shared/tracking/infrastructure/useTrackPageView";
9
9
  import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
10
10
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
11
11
  import { useViewFiveItemsDiscountByCustomerId } from "../../../projection/checkout/react/useViewFiveItemsDiscountByCustomerId";
@@ -31,7 +31,7 @@ const Summary = ({ customerId, country }) => {
31
31
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
32
32
  const [pricing, pricingStatus] = useViewPricingByCheckoutId({ checkoutId: checkout?.id });
33
33
  const [fiveItemsDiscount = 0, fiveItemsDiscountStatus] = useViewFiveItemsDiscountByCustomerId({ customerId });
34
- usePageView({
34
+ useTrackPageView({
35
35
  page: TrackingPage.SUMMARY,
36
36
  country,
37
37
  checkoutId: checkout?.id,
@@ -0,0 +1,21 @@
1
+ import { TrackingPage } from "../../../infrastructure/tracking/tracking";
2
+ import { MediaPerspective } from "../../../projection/checkoutItem/checkoutItem";
3
+ import { Country } from "../../../projection/shared/country";
4
+ interface ImageViewFunctionArgs {
5
+ readonly perspective: MediaPerspective;
6
+ }
7
+ interface ImageViewFunction {
8
+ (args: ImageViewFunctionArgs): void;
9
+ }
10
+ interface UseTrackImageViewFunctionArgs {
11
+ readonly page: TrackingPage;
12
+ readonly country: Country;
13
+ readonly checkoutId: string | undefined;
14
+ readonly checkoutItemId: string;
15
+ readonly productVariantId: string;
16
+ }
17
+ interface UseTrackImageViewFunction {
18
+ (agrs: UseTrackImageViewFunctionArgs): ImageViewFunction;
19
+ }
20
+ declare const useTrackImageView: UseTrackImageViewFunction;
21
+ export { useTrackImageView };
@@ -0,0 +1,25 @@
1
+ import { useCallback } from "react";
2
+ import { PROJECT } from "../../../infrastructure/tracking/tracking";
3
+ import { TrackingEvent, TrackingEventCategory } from "../tracking";
4
+ import { useEmitUserEvent } from "./useEmitUserEvent";
5
+ const useTrackImageView = ({ page, country, checkoutId, checkoutItemId, productVariantId, }) => {
6
+ const emitUserEvent = useEmitUserEvent();
7
+ const imageView = useCallback(({ perspective }) => {
8
+ if (!checkoutId) {
9
+ return;
10
+ }
11
+ const imageViewTrackingEvent = {
12
+ event: TrackingEvent.IMAGE_VIEW,
13
+ eventCategory: TrackingEventCategory.NAVIGATION,
14
+ section: `${PROJECT}_${page}`,
15
+ store: country,
16
+ checkoutId,
17
+ checkoutItemId,
18
+ productVariantId,
19
+ perspective,
20
+ };
21
+ emitUserEvent(imageViewTrackingEvent);
22
+ }, [checkoutId, checkoutItemId, country, emitUserEvent, page, productVariantId]);
23
+ return imageView;
24
+ };
25
+ export { useTrackImageView };
@@ -0,0 +1,16 @@
1
+ import { TrackingPage } from "../../../infrastructure/tracking/tracking";
2
+ import { Country } from "../../../projection/shared/country";
3
+ interface UseTrackItemPageViewFunctionArgs {
4
+ readonly page: TrackingPage;
5
+ readonly country: Country;
6
+ readonly checkoutId?: string;
7
+ readonly checkoutItemId: string;
8
+ readonly productVariantId: string;
9
+ readonly replaceableFor: string[] | undefined;
10
+ readonly unique: boolean;
11
+ }
12
+ interface UseTrackItemPageViewFunction {
13
+ (agrs: UseTrackItemPageViewFunctionArgs): void;
14
+ }
15
+ declare const useTrackItemPageView: UseTrackItemPageViewFunction;
16
+ export { useTrackItemPageView };
@@ -0,0 +1,25 @@
1
+ import { useLayoutEffect } from "react";
2
+ import { PROJECT } from "../../../infrastructure/tracking/tracking";
3
+ import { TrackingEvent, TrackingEventCategory } from "../tracking";
4
+ import { useEmitUserEvent } from "./useEmitUserEvent";
5
+ const useTrackItemPageView = ({ page, country, checkoutId, checkoutItemId, productVariantId, replaceableFor, unique, }) => {
6
+ const emitUserEvent = useEmitUserEvent();
7
+ useLayoutEffect(() => {
8
+ if (!(checkoutId && replaceableFor)) {
9
+ return;
10
+ }
11
+ const itemPageViewTrackingEvent = {
12
+ event: TrackingEvent.PAGEVIEW,
13
+ eventCategory: TrackingEventCategory.NAVIGATION,
14
+ section: `${PROJECT}_${page}`,
15
+ store: country,
16
+ checkoutId,
17
+ checkoutItemId,
18
+ productVariantId,
19
+ replaceableFor,
20
+ unique,
21
+ };
22
+ emitUserEvent(itemPageViewTrackingEvent);
23
+ }, [checkoutId, checkoutItemId, country, emitUserEvent, page, productVariantId, replaceableFor, unique]);
24
+ };
25
+ export { useTrackItemPageView };
@@ -0,0 +1,16 @@
1
+ import { TrackingPage } from "../../../infrastructure/tracking/tracking";
2
+ import { Country } from "../../../projection/shared/country";
3
+ interface KeepItemFunction {
4
+ (): void;
5
+ }
6
+ interface UseTrackKeepItemFunctionArgs {
7
+ readonly page: TrackingPage;
8
+ readonly country: Country;
9
+ readonly checkoutId: string | undefined;
10
+ readonly checkoutItemId: string;
11
+ }
12
+ interface UseTrackKeepItemFunction {
13
+ (agrs: UseTrackKeepItemFunctionArgs): KeepItemFunction;
14
+ }
15
+ declare const useTrackKeepItem: UseTrackKeepItemFunction;
16
+ export { useTrackKeepItem };
@@ -0,0 +1,23 @@
1
+ import { useCallback } from "react";
2
+ import { PROJECT } from "../../../infrastructure/tracking/tracking";
3
+ import { TrackingEvent, TrackingEventCategory } from "../tracking";
4
+ import { useEmitUserEvent } from "./useEmitUserEvent";
5
+ const useTrackKeepItem = ({ page, country, checkoutId, checkoutItemId }) => {
6
+ const emitUserEvent = useEmitUserEvent();
7
+ const keepItem = useCallback(() => {
8
+ if (!checkoutId) {
9
+ return;
10
+ }
11
+ const keepItemTrackingEvent = {
12
+ event: TrackingEvent.KEEP_ITEM,
13
+ eventCategory: TrackingEventCategory.NAVIGATION,
14
+ section: `${PROJECT}_${page}`,
15
+ store: country,
16
+ checkoutId,
17
+ checkoutItemId,
18
+ };
19
+ emitUserEvent(keepItemTrackingEvent);
20
+ }, [checkoutId, checkoutItemId, country, emitUserEvent, page]);
21
+ return keepItem;
22
+ };
23
+ export { useTrackKeepItem };
@@ -0,0 +1,12 @@
1
+ import { TrackingPage } from "../../../infrastructure/tracking/tracking";
2
+ import { Country } from "../../../projection/shared/country";
3
+ interface UseTrackPageViewFunctionArgs {
4
+ readonly page: TrackingPage;
5
+ readonly country: Country;
6
+ readonly checkoutId: string | undefined;
7
+ }
8
+ interface UseTrackPageViewFunction {
9
+ (agrs: UseTrackPageViewFunctionArgs): void;
10
+ }
11
+ declare const useTrackPageView: UseTrackPageViewFunction;
12
+ export { useTrackPageView };
@@ -2,26 +2,20 @@ 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 usePageView = ({ page, country, checkoutId, checkoutItemId }) => {
5
+ const useTrackPageView = ({ page, country, checkoutId }) => {
6
6
  const emitUserEvent = useEmitUserEvent();
7
7
  useLayoutEffect(() => {
8
8
  if (!checkoutId) {
9
9
  return;
10
10
  }
11
- const baseTrackingEvent = {
11
+ const pageViewTrackingEvent = {
12
12
  event: TrackingEvent.PAGEVIEW,
13
13
  eventCategory: TrackingEventCategory.NAVIGATION,
14
14
  section: `${PROJECT}_${page}`,
15
15
  store: country,
16
16
  checkoutId,
17
17
  };
18
- const pageViewTrackingEvent = checkoutItemId
19
- ? {
20
- ...baseTrackingEvent,
21
- checkoutItemId,
22
- }
23
- : baseTrackingEvent;
24
18
  emitUserEvent(pageViewTrackingEvent);
25
- }, [checkoutId, checkoutItemId, country, emitUserEvent, page]);
19
+ }, [checkoutId, country, emitUserEvent, page]);
26
20
  };
27
- export { usePageView };
21
+ export { useTrackPageView };
@@ -0,0 +1,20 @@
1
+ import { TrackingPage } from "../../../infrastructure/tracking/tracking";
2
+ import { Country } from "../../../projection/shared/country";
3
+ interface ReplaceItemFunctionArgs {
4
+ readonly replaceFor: string;
5
+ }
6
+ interface ReplaceItemFunction {
7
+ (args: ReplaceItemFunctionArgs): void;
8
+ }
9
+ interface UseTrackReplaceItemFunctionArgs {
10
+ readonly page: TrackingPage;
11
+ readonly country: Country;
12
+ readonly checkoutId: string | undefined;
13
+ readonly checkoutItemId: string;
14
+ readonly productVariantId: string;
15
+ }
16
+ interface UseTrackReplaceItemFunction {
17
+ (agrs: UseTrackReplaceItemFunctionArgs): ReplaceItemFunction;
18
+ }
19
+ declare const useTrackReplaceItem: UseTrackReplaceItemFunction;
20
+ export { useTrackReplaceItem };
@@ -0,0 +1,25 @@
1
+ import { useCallback } from "react";
2
+ import { PROJECT } from "../../../infrastructure/tracking/tracking";
3
+ import { TrackingEvent, TrackingEventCategory } from "../tracking";
4
+ import { useEmitUserEvent } from "./useEmitUserEvent";
5
+ const useTrackReplaceItem = ({ page, country, checkoutId, checkoutItemId, productVariantId, }) => {
6
+ const emitUserEvent = useEmitUserEvent();
7
+ const replaceItem = useCallback(({ replaceFor }) => {
8
+ if (!checkoutId) {
9
+ return;
10
+ }
11
+ const replaceItemTrackingEvent = {
12
+ event: TrackingEvent.REPLACE_ITEM,
13
+ eventCategory: TrackingEventCategory.NAVIGATION,
14
+ section: `${PROJECT}_${page}`,
15
+ store: country,
16
+ checkoutId,
17
+ checkoutItemId,
18
+ productVariantId,
19
+ replaceFor,
20
+ };
21
+ emitUserEvent(replaceItemTrackingEvent);
22
+ }, [checkoutId, checkoutItemId, country, emitUserEvent, page, productVariantId]);
23
+ return replaceItem;
24
+ };
25
+ export { useTrackReplaceItem };
@@ -0,0 +1,16 @@
1
+ import { TrackingPage } from "../../../infrastructure/tracking/tracking";
2
+ import { Country } from "../../../projection/shared/country";
3
+ interface ResetItemFunction {
4
+ (): void;
5
+ }
6
+ interface UseTrackResetItemFunctionArgs {
7
+ readonly page: TrackingPage;
8
+ readonly country: Country;
9
+ readonly checkoutId: string | undefined;
10
+ readonly checkoutItemId: string;
11
+ }
12
+ interface UseTrackResetItemFunction {
13
+ (agrs: UseTrackResetItemFunctionArgs): ResetItemFunction;
14
+ }
15
+ declare const useTrackResetItem: UseTrackResetItemFunction;
16
+ export { useTrackResetItem };
@@ -0,0 +1,23 @@
1
+ import { useCallback } from "react";
2
+ import { PROJECT } from "../../../infrastructure/tracking/tracking";
3
+ import { TrackingEvent, TrackingEventCategory } from "../tracking";
4
+ import { useEmitUserEvent } from "./useEmitUserEvent";
5
+ const useTrackResetItem = ({ page, country, checkoutId, checkoutItemId }) => {
6
+ const emitUserEvent = useEmitUserEvent();
7
+ const resetItem = useCallback(() => {
8
+ if (!checkoutId) {
9
+ return;
10
+ }
11
+ const resetItemTrackingEvent = {
12
+ event: TrackingEvent.RESET_ITEM,
13
+ eventCategory: TrackingEventCategory.NAVIGATION,
14
+ section: `${PROJECT}_${page}`,
15
+ store: country,
16
+ checkoutId,
17
+ checkoutItemId,
18
+ };
19
+ emitUserEvent(resetItemTrackingEvent);
20
+ }, [checkoutId, checkoutItemId, country, emitUserEvent, page]);
21
+ return resetItem;
22
+ };
23
+ export { useTrackResetItem };
@@ -0,0 +1,16 @@
1
+ import { TrackingPage } from "../../../infrastructure/tracking/tracking";
2
+ import { Country } from "../../../projection/shared/country";
3
+ interface ReturnItemFunction {
4
+ (): void;
5
+ }
6
+ interface UseTrackReturnItemFunctionArgs {
7
+ readonly page: TrackingPage;
8
+ readonly country: Country;
9
+ readonly checkoutId: string | undefined;
10
+ readonly checkoutItemId: string;
11
+ }
12
+ interface UseTrackReturnItemFunction {
13
+ (agrs: UseTrackReturnItemFunctionArgs): ReturnItemFunction;
14
+ }
15
+ declare const useTrackReturnItem: UseTrackReturnItemFunction;
16
+ export { useTrackReturnItem };
@@ -0,0 +1,23 @@
1
+ import { useCallback } from "react";
2
+ import { PROJECT } from "../../../infrastructure/tracking/tracking";
3
+ import { TrackingEvent, TrackingEventCategory } from "../tracking";
4
+ import { useEmitUserEvent } from "./useEmitUserEvent";
5
+ const useTrackReturnItem = ({ page, country, checkoutId, checkoutItemId }) => {
6
+ const emitUserEvent = useEmitUserEvent();
7
+ const returnItem = useCallback(() => {
8
+ if (!checkoutId) {
9
+ return;
10
+ }
11
+ const returnItemTrackingEvent = {
12
+ event: TrackingEvent.RETURN_ITEM,
13
+ eventCategory: TrackingEventCategory.NAVIGATION,
14
+ section: `${PROJECT}_${page}`,
15
+ store: country,
16
+ checkoutId,
17
+ checkoutItemId,
18
+ };
19
+ emitUserEvent(returnItemTrackingEvent);
20
+ }, [checkoutId, checkoutItemId, country, emitUserEvent, page]);
21
+ return returnItem;
22
+ };
23
+ export { useTrackReturnItem };
@@ -1,6 +1,12 @@
1
+ import { MediaPerspective } from "../../projection/checkoutItem/checkoutItem";
1
2
  import { Country } from "../../projection/shared/country";
2
3
  declare enum TrackingEvent {
3
- PAGEVIEW = "pageview"
4
+ PAGEVIEW = "pageview",
5
+ KEEP_ITEM = "keep-item",
6
+ RETURN_ITEM = "return-item",
7
+ REPLACE_ITEM = "replace-item",
8
+ RESET_ITEM = "reset-item",
9
+ IMAGE_VIEW = "image-view"
4
10
  }
5
11
  declare enum TrackingEventCategory {
6
12
  NAVIGATION = "navigation"
@@ -12,8 +18,31 @@ interface BaseTrackingEvent {
12
18
  readonly store: Country;
13
19
  readonly checkoutId: string;
14
20
  }
15
- interface PageViewTrackingEvent extends BaseTrackingEvent {
16
- readonly checkoutItemId?: string;
21
+ type PageViewTrackingEvent = BaseTrackingEvent;
22
+ interface ItemPageViewTrackingEvent extends BaseTrackingEvent {
23
+ readonly checkoutItemId: string;
24
+ readonly productVariantId: string;
25
+ readonly replaceableFor: string[] | undefined;
26
+ readonly unique: boolean;
17
27
  }
18
- export type { BaseTrackingEvent, PageViewTrackingEvent };
28
+ interface KeepItemTrackingEvent extends BaseTrackingEvent {
29
+ readonly checkoutItemId: string;
30
+ }
31
+ interface ReturnItemTrackingEvent extends BaseTrackingEvent {
32
+ readonly checkoutItemId: string;
33
+ }
34
+ interface ReplaceItemTrackingEvent extends BaseTrackingEvent {
35
+ readonly checkoutItemId: string;
36
+ readonly productVariantId: string;
37
+ readonly replaceFor: string;
38
+ }
39
+ interface ResetItemTrackingEvent extends BaseTrackingEvent {
40
+ readonly checkoutItemId: string;
41
+ }
42
+ interface ImageViewTrackingEvent extends BaseTrackingEvent {
43
+ readonly checkoutItemId: string;
44
+ readonly productVariantId: string;
45
+ readonly perspective: MediaPerspective;
46
+ }
47
+ export type { BaseTrackingEvent, ImageViewTrackingEvent, ItemPageViewTrackingEvent, KeepItemTrackingEvent, PageViewTrackingEvent, ReplaceItemTrackingEvent, ResetItemTrackingEvent, ReturnItemTrackingEvent, };
19
48
  export { TrackingEvent, TrackingEventCategory };
@@ -1,6 +1,11 @@
1
1
  var TrackingEvent;
2
2
  (function (TrackingEvent) {
3
3
  TrackingEvent["PAGEVIEW"] = "pageview";
4
+ TrackingEvent["KEEP_ITEM"] = "keep-item";
5
+ TrackingEvent["RETURN_ITEM"] = "return-item";
6
+ TrackingEvent["REPLACE_ITEM"] = "replace-item";
7
+ TrackingEvent["RESET_ITEM"] = "reset-item";
8
+ TrackingEvent["IMAGE_VIEW"] = "image-view";
4
9
  })(TrackingEvent || (TrackingEvent = {}));
5
10
  var TrackingEventCategory;
6
11
  (function (TrackingEventCategory) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.8.22",
3
+ "version": "0.8.24",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -1,13 +0,0 @@
1
- import { TrackingPage } from "../../../infrastructure/tracking/tracking";
2
- import { Country } from "../../../projection/shared/country";
3
- interface UsePageViewFunctionArgs {
4
- readonly page: TrackingPage;
5
- readonly country: Country;
6
- readonly checkoutId?: string;
7
- readonly checkoutItemId?: string;
8
- }
9
- interface UsePageViewFunction {
10
- (agrs: UsePageViewFunctionArgs): void;
11
- }
12
- declare const usePageView: UsePageViewFunction;
13
- export { usePageView };