@lookiero/checkout 0.5.6 → 0.5.7

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.
@@ -0,0 +1,9 @@
1
+ declare const PROJECT = "checkout";
2
+ declare enum TrackingPage {
3
+ ITEM = "item",
4
+ CHECKOUT = "checkout",
5
+ SUMMARY = "summary",
6
+ FEEDBACK = "feedback",
7
+ NOT_FOUND = "not_found"
8
+ }
9
+ export { PROJECT, TrackingPage };
@@ -0,0 +1,10 @@
1
+ const PROJECT = "checkout";
2
+ var TrackingPage;
3
+ (function (TrackingPage) {
4
+ TrackingPage["ITEM"] = "item";
5
+ TrackingPage["CHECKOUT"] = "checkout";
6
+ TrackingPage["SUMMARY"] = "summary";
7
+ TrackingPage["FEEDBACK"] = "feedback";
8
+ TrackingPage["NOT_FOUND"] = "not_found";
9
+ })(TrackingPage || (TrackingPage = {}));
10
+ export { PROJECT, TrackingPage };
@@ -61,12 +61,12 @@ const Routing = ({ basePath = "", customer, locale, I18n, menu, tabBar, getAuthT
61
61
  {
62
62
  path: Routes.FEEDBACK,
63
63
  element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
64
- React.createElement(Feedback, { customerId: customer?.customerId }))),
64
+ React.createElement(Feedback, { country: customer?.country, customerId: customer?.customerId }))),
65
65
  },
66
66
  {
67
67
  path: Routes.NOT_FOUND,
68
68
  element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
69
- React.createElement(NotFound, null))),
69
+ React.createElement(NotFound, { country: customer?.country, customerId: customer?.customerId }))),
70
70
  },
71
71
  {
72
72
  path: "*",
@@ -6,9 +6,11 @@ import React, { useCallback, useMemo, useRef } from "react";
6
6
  import { Platform, View } from "react-native";
7
7
  import { useNavigate } from "react-router-native";
8
8
  import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
9
+ import { usePageView } from "../../../../shared/tracking/infrastructure/usePageView";
9
10
  import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
10
11
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
11
12
  import { useViewPricingByCheckoutId } from "../../../projection/pricing/react/useViewPricingByCheckoutId";
13
+ import { TrackingPage } from "../../../tracking/tracking";
12
14
  import { Body } from "../../components/layouts/body/Body";
13
15
  import { SafeAreaScrollView } from "../../components/templates/SafeAreaScrollView";
14
16
  import { I18nMessages } from "../../i18n/i18n";
@@ -24,6 +26,11 @@ const Checkout = ({ children, customerId, country, useRedirect }) => {
24
26
  const paymentInstrumentSelectRef = useRef(null);
25
27
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
26
28
  const [pricing, pricingStatus] = useViewPricingByCheckoutId({ checkoutId: checkout?.id });
29
+ usePageView({
30
+ page: TrackingPage.CHECKOUT,
31
+ country,
32
+ checkoutId: checkout?.id,
33
+ });
27
34
  const navigate = useNavigate();
28
35
  const basePath = useBasePath();
29
36
  const { returnUrl } = useRedirect();
@@ -1,6 +1,8 @@
1
1
  import { FC } from "react";
2
+ import { Country } from "../../../../projection/shared/country";
2
3
  interface FeedbackProps {
3
4
  readonly customerId: string;
5
+ readonly country: Country;
4
6
  }
5
7
  declare const Feedback: FC<FeedbackProps>;
6
8
  export { Feedback };
@@ -1,17 +1,19 @@
1
1
  import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
2
2
  import React, { useCallback } from "react";
3
3
  import { Platform } from "react-native";
4
+ import { usePageView } from "../../../../shared/tracking/infrastructure/usePageView";
4
5
  import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
5
6
  import { useGiveCheckoutFeedback } from "../../../domain/checkoutFeedback/react/useGiveCheckoutFeedback";
6
7
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
7
8
  import { useListCheckoutQuestionsByCheckoutId } from "../../../projection/checkoutQuestion/react/useListCheckoutQuestionsByCheckoutId";
9
+ import { TrackingPage } from "../../../tracking/tracking";
8
10
  import { Body } from "../../components/layouts/body/Body";
9
11
  import { CheckoutQuestionFeedbackProvider } from "../../components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionFeedback";
10
12
  import { SafeAreaScrollView } from "../../components/templates/SafeAreaScrollView";
11
13
  import { HEADER_HEIGHT } from "../navigation/components/header/Header.style";
12
14
  import { style } from "./Feedback.style";
13
15
  import { CheckoutQuestionsForm } from "./components/checkoutQuestionsForm/CheckoutQuestionsForm";
14
- const Feedback = ({ customerId }) => {
16
+ const Feedback = ({ customerId, country }) => {
15
17
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
16
18
  const [checkoutQuestions, checkoutQuestionsStatus] = useListCheckoutQuestionsByCheckoutId({
17
19
  checkoutId: checkout?.id,
@@ -25,6 +27,11 @@ const Feedback = ({ customerId }) => {
25
27
  }
26
28
  catch (e) { }
27
29
  }, [giveCheckoutFeedback]);
30
+ usePageView({
31
+ page: TrackingPage.FEEDBACK,
32
+ country,
33
+ checkoutId: checkout?.id,
34
+ });
28
35
  const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
29
36
  const dependenciesLoaded = dependenciesLoadedStatuses.includes(checkoutStatus) && dependenciesLoadedStatuses.includes(checkoutQuestionsStatus);
30
37
  if (!dependenciesLoaded)
@@ -4,6 +4,7 @@ import { Platform, View } from "react-native";
4
4
  import { generatePath, useMatch, useNavigate, useParams } from "react-router-native";
5
5
  import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
6
6
  import "../../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
7
+ import { usePageView } from "../../../../shared/tracking/infrastructure/usePageView";
7
8
  import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
8
9
  import { useBookCheckoutBookingForCheckoutItem } from "../../../domain/checkoutBooking/react/useBookCheckoutBookingForCheckoutItem";
9
10
  import { useKeepCheckoutItem } from "../../../domain/checkoutItem/react/useKeepCheckoutItem";
@@ -12,6 +13,7 @@ import { useReturnCheckoutItem } from "../../../domain/checkoutItem/react/useRet
12
13
  import { useViewBookedProductsVariantsForCheckoutItem } from "../../../projection/bookedProductsVariants/react/useViewBookedProductsVariantsForCheckoutItem";
13
14
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
14
15
  import { useListReturnQuestionsByCheckoutItemId } from "../../../projection/returnQuestion/react/useListReturnQuestionsByCheckoutItemId";
16
+ import { TrackingPage } from "../../../tracking/tracking";
15
17
  import { Body } from "../../components/layouts/body/Body";
16
18
  import { ReturnQuestionFeedbackProvider } from "../../components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback";
17
19
  import { SafeAreaScrollView } from "../../components/templates/SafeAreaScrollView";
@@ -33,6 +35,12 @@ const Item = ({ customerId, country }) => {
33
35
  const { id } = useParams();
34
36
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
35
37
  const checkoutItem = checkout?.items.find((checkoutItem) => checkoutItem.id === id);
38
+ usePageView({
39
+ page: TrackingPage.ITEM,
40
+ country,
41
+ checkoutId: checkout?.id,
42
+ checkoutItemId: checkoutItem.id,
43
+ });
36
44
  const basePath = useBasePath();
37
45
  const itemRouteMatch = useMatch(`${basePath}/${Routes.ITEM}`);
38
46
  const itemDetailRouteMatch = useMatch(`${basePath}/${Routes.ITEM_DETAIL}`);
@@ -1,3 +1,8 @@
1
1
  import { FC } from "react";
2
- declare const NotFound: FC;
2
+ import { Country } from "../../../../projection/shared/country";
3
+ interface NotFoundProps {
4
+ readonly customerId: string;
5
+ readonly country: Country;
6
+ }
7
+ declare const NotFound: FC<NotFoundProps>;
3
8
  export { NotFound };
@@ -1,10 +1,15 @@
1
1
  import { Button } from "@lookiero/aurora-next/build/components/atoms/Button/Button";
2
2
  import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
3
3
  import { useI18nMessage } from "@lookiero/i18n-react";
4
+ import { QueryStatus } from "@lookiero/messaging-react";
4
5
  import React, { useCallback } from "react";
5
6
  import { Image, Platform } from "react-native";
6
7
  import { useNavigate } from "react-router-native";
8
+ import { usePageView } from "../../../../shared/tracking/infrastructure/usePageView";
7
9
  import { AspectRatioView } from "../../../../shared/ui/components/atoms/aspectRatioView/AspectRatioView";
10
+ import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
11
+ import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
12
+ import { TrackingPage } from "../../../tracking/tracking";
8
13
  import { Body } from "../../components/layouts/body/Body";
9
14
  import { SafeAreaScrollView } from "../../components/templates/SafeAreaScrollView";
10
15
  import { I18nMessages } from "../../i18n/i18n";
@@ -12,12 +17,22 @@ import { Routes } from "../../routing/routes";
12
17
  import { useBasePath } from "../../routing/useBasePath";
13
18
  import { HEADER_HEIGHT } from "../navigation/components/header/Header.style";
14
19
  import { style } from "./NotFound.style";
15
- const NotFound = () => {
20
+ const NotFound = ({ customerId, country }) => {
16
21
  const descriptionText = useI18nMessage({ id: I18nMessages.NOT_FOUND_DESCRIPTION });
17
22
  const buttonText = useI18nMessage({ id: I18nMessages.NOT_FOUND_BUTTON });
23
+ const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
24
+ usePageView({
25
+ page: TrackingPage.NOT_FOUND,
26
+ country,
27
+ checkoutId: checkout?.id,
28
+ });
18
29
  const navigate = useNavigate();
19
30
  const basePath = useBasePath();
20
31
  const handleOnPress = useCallback(() => navigate(`${basePath}/${Routes.HOME}`), [basePath, navigate]);
32
+ const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
33
+ const dependenciesLoaded = dependenciesLoadedStatuses.includes(checkoutStatus);
34
+ if (!dependenciesLoaded)
35
+ return React.createElement(Spinner, null);
21
36
  return (React.createElement(SafeAreaScrollView, { scrollerPaddingTop: Platform.OS === "web" || Platform.OS === "android" ? HEADER_HEIGHT : 0, style: { scrollView: style.container } },
22
37
  React.createElement(Body, { style: { column: style.bodyColumn } },
23
38
  React.createElement(AspectRatioView, { aspectRatio: 1.25 },
@@ -5,10 +5,12 @@ 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
9
  import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
9
10
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
10
11
  import { useViewFiveItemsDiscountByCustomerId } from "../../../projection/checkout/react/useViewFiveItemsDiscountByCustomerId";
11
12
  import { useViewPricingByCheckoutId } from "../../../projection/pricing/react/useViewPricingByCheckoutId";
13
+ import { TrackingPage } from "../../../tracking/tracking";
12
14
  import { Body } from "../../components/layouts/body/Body";
13
15
  import { SafeAreaScrollView } from "../../components/templates/SafeAreaScrollView";
14
16
  import { I18nMessages } from "../../i18n/i18n";
@@ -29,6 +31,11 @@ const Summary = ({ customerId, country }) => {
29
31
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
30
32
  const [pricing, pricingStatus] = useViewPricingByCheckoutId({ checkoutId: checkout?.id });
31
33
  const [fiveItemsDiscount = 0, fiveItemsDiscountStatus] = useViewFiveItemsDiscountByCustomerId({ customerId });
34
+ usePageView({
35
+ page: TrackingPage.SUMMARY,
36
+ country,
37
+ checkoutId: checkout?.id,
38
+ });
32
39
  const navigate = useNavigate();
33
40
  const basePath = useBasePath();
34
41
  const [pricingCollapsed, setPricingCollapsed] = useState(true);
@@ -1,5 +1,5 @@
1
+ import { TrackingPage } from "../../../infrastructure/tracking/tracking";
1
2
  import { Country } from "../../../projection/shared/country";
2
- import { TrackingPage } from "../tracking";
3
3
  interface UsePageViewFunctionArgs {
4
4
  readonly page: TrackingPage;
5
5
  readonly country: Country;
@@ -1,5 +1,6 @@
1
1
  import { useLayoutEffect } from "react";
2
- import { PROJECT, TrackingEvent, TrackingEventCategory } from "../tracking";
2
+ import { PROJECT } from "../../../infrastructure/tracking/tracking";
3
+ import { TrackingEvent, TrackingEventCategory } from "../tracking";
3
4
  import { useEmitUserEvent } from "./useEmitUserEvent";
4
5
  const usePageView = ({ page, country, checkoutId, checkoutItemId }) => {
5
6
  const emitUserEvent = useEmitUserEvent();
@@ -1,14 +1,10 @@
1
1
  import { Country } from "../../projection/shared/country";
2
- declare const PROJECT = "checkout";
3
2
  declare enum TrackingEvent {
4
3
  PAGEVIEW = "pageview"
5
4
  }
6
5
  declare enum TrackingEventCategory {
7
6
  NAVIGATION = "navigation"
8
7
  }
9
- declare enum TrackingPage {
10
- ITEM = "item"
11
- }
12
8
  interface BaseTrackingEvent {
13
9
  readonly event: TrackingEvent;
14
10
  readonly eventCategory: TrackingEventCategory;
@@ -20,4 +16,4 @@ interface PageViewTrackingEvent extends BaseTrackingEvent {
20
16
  readonly checkoutItemId?: string;
21
17
  }
22
18
  export type { BaseTrackingEvent, PageViewTrackingEvent };
23
- export { PROJECT, TrackingEvent, TrackingEventCategory, TrackingPage };
19
+ export { TrackingEvent, TrackingEventCategory };
@@ -1,4 +1,3 @@
1
- const PROJECT = "checkout";
2
1
  var TrackingEvent;
3
2
  (function (TrackingEvent) {
4
3
  TrackingEvent["PAGEVIEW"] = "pageview";
@@ -7,8 +6,4 @@ var TrackingEventCategory;
7
6
  (function (TrackingEventCategory) {
8
7
  TrackingEventCategory["NAVIGATION"] = "navigation";
9
8
  })(TrackingEventCategory || (TrackingEventCategory = {}));
10
- var TrackingPage;
11
- (function (TrackingPage) {
12
- TrackingPage["ITEM"] = "item";
13
- })(TrackingPage || (TrackingPage = {}));
14
- export { PROJECT, TrackingEvent, TrackingEventCategory, TrackingPage };
9
+ export { TrackingEvent, TrackingEventCategory };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.5.6",
3
+ "version": "0.5.7",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [