@lookiero/checkout 0.2.3 → 0.2.5

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 (33) hide show
  1. package/dist/infrastructure/delivery/_mock/bootstrap.mock.js +5 -0
  2. package/dist/infrastructure/delivery/bootstrap.js +5 -0
  3. package/dist/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.d.ts +3 -3
  4. package/dist/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.js +1 -4
  5. package/dist/infrastructure/domain/react/useSetCheckoutIntroShown.d.ts +1 -4
  6. package/dist/infrastructure/domain/react/useSetCheckoutIntroShown.js +2 -2
  7. package/dist/infrastructure/domain/react/useUpdateUiSetting.d.ts +1 -4
  8. package/dist/infrastructure/domain/react/useUpdateUiSetting.js +1 -4
  9. package/dist/infrastructure/projection/httpFiveItemsDiscountByCustomerIdView.d.ts +12 -0
  10. package/dist/infrastructure/projection/httpFiveItemsDiscountByCustomerIdView.js +7 -0
  11. package/dist/infrastructure/projection/react/useViewFiveItemsDiscountByCustomerId.d.ts +10 -0
  12. package/dist/infrastructure/projection/react/useViewFiveItemsDiscountByCustomerId.js +9 -0
  13. package/dist/infrastructure/ui/components/layouts/slider/Pagination.d.ts +14 -0
  14. package/dist/infrastructure/ui/components/layouts/slider/Pagination.js +11 -0
  15. package/dist/infrastructure/ui/components/layouts/slider/Pagination.style.d.ts +23 -0
  16. package/dist/infrastructure/ui/components/layouts/slider/Pagination.style.js +27 -0
  17. package/dist/infrastructure/ui/components/layouts/slider/Slider.d.ts +20 -0
  18. package/dist/infrastructure/ui/components/layouts/slider/Slider.js +140 -0
  19. package/dist/infrastructure/ui/components/layouts/slider/Slider.style.d.ts +9 -0
  20. package/dist/infrastructure/ui/components/layouts/slider/Slider.style.js +10 -0
  21. package/dist/infrastructure/ui/hooks/useMediaImage.d.ts +7 -0
  22. package/dist/infrastructure/ui/hooks/useMediaImage.js +12 -0
  23. package/dist/infrastructure/ui/routing/Routing.js +1 -1
  24. package/dist/infrastructure/ui/views/intro/Intro.d.ts +4 -1
  25. package/dist/infrastructure/ui/views/intro/Intro.js +17 -8
  26. package/dist/infrastructure/ui/views/item/components/productVariantSlider/ProductVariantSlider.d.ts +7 -0
  27. package/dist/infrastructure/ui/views/item/components/productVariantSlider/ProductVariantSlider.js +22 -0
  28. package/dist/infrastructure/ui/views/item/components/productVariantSlider/ProductVariantSlider.style.d.ts +26 -0
  29. package/dist/infrastructure/ui/views/item/components/productVariantSlider/ProductVariantSlider.style.js +30 -0
  30. package/dist/projection/checkout/viewFirstAvailableCheckoutByCustomerId.d.ts +1 -1
  31. package/dist/projection/checkout/viewFiveItemsDiscountByCustomerId.d.ts +23 -0
  32. package/dist/projection/checkout/viewFiveItemsDiscountByCustomerId.js +8 -0
  33. package/package.json +1 -1
@@ -10,8 +10,10 @@ import { getUiSetting, saveUiSetting } from "../../domain/uiSetting/model/storag
10
10
  import { storageUiSettingByKeyView } from "../../projection/storageUiSettingByKeyView";
11
11
  import { startedCheckoutWithItems } from "./checkout.mock";
12
12
  import { read, write } from "../../persistence/asyncStorageStorage";
13
+ import { viewFiveItemsDiscountByCustomerIdHandler, VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID, } from "../../../projection/checkout/viewFiveItemsDiscountByCustomerId";
13
14
  const firstAvailableCheckoutByCustomerIdView = async () => startedCheckoutWithItems({ status: [CheckoutItemStatus.KEPT, CheckoutItemStatus.INITIAL] });
14
15
  const isCheckoutEnabledByCustomerIdView = async () => true;
16
+ const fiveItemsDiscountByCustomerIdView = async () => 25;
15
17
  const bootstrap = () => messagingBootstrap({ id: CHECKOUT_MESSAGING_REACT_ID })
16
18
  .query(VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID, viewFirstAvailableCheckoutByCustomerIdHandler, {
17
19
  view: firstAvailableCheckoutByCustomerIdView,
@@ -20,6 +22,9 @@ const bootstrap = () => messagingBootstrap({ id: CHECKOUT_MESSAGING_REACT_ID })
20
22
  view: isCheckoutEnabledByCustomerIdView,
21
23
  })
22
24
  .query(VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, viewIsCheckoutAccessibleByCustomerIdHandler, {})
25
+ .query(VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID, viewFiveItemsDiscountByCustomerIdHandler, {
26
+ view: fiveItemsDiscountByCustomerIdView,
27
+ })
23
28
  .query(VIEW_UI_SETTING_BY_KEY, viewUiSettingByKeyHandler, {
24
29
  view: storageUiSettingByKeyView({ read }),
25
30
  })
@@ -2,12 +2,14 @@ import { bootstrap as messagingBootstrap } from "@lookiero/messaging-react";
2
2
  import { UPDATE_UI_SETTING } from "../../domain/uiSetting/command/updateUiSetting";
3
3
  import { updateUiSettingHandler } from "../../domain/uiSetting/model/uiSetting";
4
4
  import { viewFirstAvailableCheckoutByCustomerIdHandler, VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID, } from "../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
5
+ import { viewFiveItemsDiscountByCustomerIdHandler, VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID, } from "../../projection/checkout/viewFiveItemsDiscountByCustomerId";
5
6
  import { viewIsCheckoutAccessibleByCustomerIdHandler, VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, } from "../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
6
7
  import { viewIsCheckoutEnabledByCustomerIdHandler, VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID, } from "../../projection/checkout/viewIsCheckoutEnabledByCustomerId";
7
8
  import { viewUiSettingByKeyHandler, VIEW_UI_SETTING_BY_KEY } from "../../projection/uiSetting/viewUiSettingByKey";
8
9
  import { getUiSetting, saveUiSetting } from "../domain/uiSetting/model/storageUiSettings";
9
10
  import { read, write } from "../persistence/asyncStorageStorage";
10
11
  import { httpFirstAvailableCheckoutByCustomerIdView } from "../projection/httpFirstAvailableCheckoutByCustomerIdView";
12
+ import { httpFiveItemsDiscountByCustomerIdView } from "../projection/httpFiveItemsDiscountByCustomerIdView";
11
13
  import { httpIsCheckoutEnabledByCustomerIdView } from "../projection/httpIsCheckoutEnabledByCustomerIdView";
12
14
  import { storageUiSettingByKeyView } from "../projection/storageUiSettingByKeyView";
13
15
  import { fetchHttpGet, fetchHttpPost } from "./http/fetchHttpClient";
@@ -23,6 +25,9 @@ const bootstrap = ({ apiUrl, getAuthToken }) => {
23
25
  view: httpIsCheckoutEnabledByCustomerIdView({ httpGet }),
24
26
  })
25
27
  .query(VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, viewIsCheckoutAccessibleByCustomerIdHandler, {})
28
+ .query(VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID, viewFiveItemsDiscountByCustomerIdHandler, {
29
+ view: httpFiveItemsDiscountByCustomerIdView({ httpGet }),
30
+ })
26
31
  .query(VIEW_UI_SETTING_BY_KEY, viewUiSettingByKeyHandler, {
27
32
  view: storageUiSettingByKeyView({ read }),
28
33
  })
@@ -1,8 +1,8 @@
1
1
  import { CommandStatus } from "@lookiero/messaging-react";
2
- interface UseBookSizeReplaceableProductVariantsForCheckoutItem {
3
- readonly book: () => Promise<void>;
4
- readonly status: CommandStatus;
2
+ interface BookFunction {
3
+ (): Promise<void>;
5
4
  }
5
+ declare type UseBookSizeReplaceableProductVariantsForCheckoutItem = [book: BookFunction, status: CommandStatus];
6
6
  interface UseBookSizeReplaceableProductVariantsForCheckoutItemFunctionArgs {
7
7
  readonly checkoutId: string;
8
8
  readonly checkoutItemId: string;
@@ -10,9 +10,6 @@ const useBookSizeReplaceableProductVariantsForCheckoutItem = ({ checkoutId, chec
10
10
  checkoutItemId,
11
11
  checkoutBookingId,
12
12
  })), [checkoutBookingId, checkoutId, checkoutItemId, commandBus]);
13
- return {
14
- book,
15
- status,
16
- };
13
+ return [book, status];
17
14
  };
18
15
  export { useBookSizeReplaceableProductVariantsForCheckoutItem };
@@ -2,10 +2,7 @@ import { CommandStatus } from "@lookiero/messaging-react";
2
2
  interface SetCheckoutIntroShownFunction {
3
3
  (): Promise<void>;
4
4
  }
5
- interface UseSetCheckoutIntroShown {
6
- readonly setCheckoutIntroShown: SetCheckoutIntroShownFunction;
7
- readonly status: CommandStatus;
8
- }
5
+ declare type UseSetCheckoutIntroShown = [setCheckoutIntroShown: SetCheckoutIntroShownFunction, status: CommandStatus];
9
6
  interface UseSetCheckoutIntroShownFunction {
10
7
  (): UseSetCheckoutIntroShown;
11
8
  }
@@ -2,8 +2,8 @@ import { useCallback } from "react";
2
2
  import { UISettings } from "../../ui/settings/UISettings";
3
3
  import { useUpdateUiSetting } from "./useUpdateUiSetting";
4
4
  const useSetCheckoutIntroShown = () => {
5
- const { update, status } = useUpdateUiSetting();
5
+ const [update, status] = useUpdateUiSetting();
6
6
  const setCheckoutIntroShown = useCallback(() => update({ key: UISettings.CHECKOUT_INTRO_SHOWN, value: true }), [update]);
7
- return { setCheckoutIntroShown, status };
7
+ return [setCheckoutIntroShown, status];
8
8
  };
9
9
  export { useSetCheckoutIntroShown };
@@ -6,10 +6,7 @@ interface UpdateFunctionArgs {
6
6
  interface UpdateFunction {
7
7
  (args: UpdateFunctionArgs): Promise<void>;
8
8
  }
9
- interface UseUpdateUiSetting {
10
- readonly update: UpdateFunction;
11
- readonly status: CommandStatus;
12
- }
9
+ declare type UseUpdateUiSetting = [update: UpdateFunction, status: CommandStatus];
13
10
  interface UseUpdateUiSettingFunction {
14
11
  (): UseUpdateUiSetting;
15
12
  }
@@ -10,9 +10,6 @@ const useUpdateUiSetting = () => {
10
10
  key,
11
11
  value,
12
12
  })), [commandBus]);
13
- return {
14
- update,
15
- status,
16
- };
13
+ return [update, status];
17
14
  };
18
15
  export { useUpdateUiSetting };
@@ -0,0 +1,12 @@
1
+ import { FiveItemsDiscountByCustomerIdView } from "../../projection/checkout/viewFiveItemsDiscountByCustomerId";
2
+ import { HttpGetFunction } from "../delivery/http/httpClient";
3
+ interface HttpFiveItemsDiscountByCustomerIdView extends FiveItemsDiscountByCustomerIdView {
4
+ }
5
+ interface HttpFiveItemsDiscountByCustomerIdViewFunctionArgs {
6
+ readonly httpGet: HttpGetFunction;
7
+ }
8
+ interface HttpFiveItemsDiscountByCustomerIdViewFunction {
9
+ (args: HttpFiveItemsDiscountByCustomerIdViewFunctionArgs): HttpFiveItemsDiscountByCustomerIdView;
10
+ }
11
+ declare const httpFiveItemsDiscountByCustomerIdView: HttpFiveItemsDiscountByCustomerIdViewFunction;
12
+ export { httpFiveItemsDiscountByCustomerIdView };
@@ -0,0 +1,7 @@
1
+ const httpFiveItemsDiscountByCustomerIdView = ({ httpGet }) => async ({ customerId }) => {
2
+ const response = await httpGet({
3
+ endpoint: `/view-five-items-discount-by-customer-id/${customerId}`,
4
+ });
5
+ return !response.ok ? 0 : await response.json();
6
+ };
7
+ export { httpFiveItemsDiscountByCustomerIdView };
@@ -0,0 +1,10 @@
1
+ import { UseQueryFunctionResult } from "@lookiero/messaging-react";
2
+ import { FiveItemsDiscountByCustomerIdProjection } from "../../../projection/checkout/viewFiveItemsDiscountByCustomerId";
3
+ interface UseViewFiveItemsDiscountByCustomerIdFunctionArgs {
4
+ readonly customerId: string;
5
+ }
6
+ interface UseViewFiveItemsDiscountByCustomerIdFunction {
7
+ (args: UseViewFiveItemsDiscountByCustomerIdFunctionArgs): UseQueryFunctionResult<FiveItemsDiscountByCustomerIdProjection>;
8
+ }
9
+ declare const useViewFiveItemsDiscountByCustomerId: UseViewFiveItemsDiscountByCustomerIdFunction;
10
+ export { useViewFiveItemsDiscountByCustomerId };
@@ -0,0 +1,9 @@
1
+ import { useQuery } from "@lookiero/messaging-react";
2
+ import { viewFiveItemsDiscountByCustomerId, } from "../../../projection/checkout/viewFiveItemsDiscountByCustomerId";
3
+ import { CHECKOUT_MESSAGING_REACT_ID } from "../../delivery/bootstrap";
4
+ const useViewFiveItemsDiscountByCustomerId = ({ customerId }) => useQuery({
5
+ query: viewFiveItemsDiscountByCustomerId({ customerId }),
6
+ contextId: CHECKOUT_MESSAGING_REACT_ID,
7
+ options: { staleTime: Infinity },
8
+ });
9
+ export { useViewFiveItemsDiscountByCustomerId };
@@ -0,0 +1,14 @@
1
+ import { FC } from "react";
2
+ import { StyleProp, ViewStyle } from "react-native";
3
+ interface PaginationProps {
4
+ readonly touchable?: boolean;
5
+ readonly paginationStyle?: StyleProp<ViewStyle>;
6
+ readonly paginationItemStyle?: StyleProp<ViewStyle>;
7
+ readonly paginationActiveItemStyle?: StyleProp<ViewStyle>;
8
+ readonly count?: number;
9
+ readonly activeIndex?: number;
10
+ readonly onChange: (index: number) => void;
11
+ readonly renderItem?: (index: number) => JSX.Element;
12
+ }
13
+ declare const Pagination: FC<PaginationProps>;
14
+ export { Pagination };
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import { Pressable, View } from "react-native";
3
+ import { style } from "./Pagination.style";
4
+ const Pagination = ({ touchable = true, paginationStyle, paginationItemStyle, paginationActiveItemStyle, count = 0, activeIndex = 0, renderItem, onChange, }) => (React.createElement(View, { style: [style.paginationWrapper, paginationStyle], testID: "slider-pagination" }, Array.from(Array(count).keys()).map((index) => (React.createElement(View, { key: index, style: style.paginationContainer },
5
+ React.createElement(Pressable, { onPress: !touchable ? undefined : () => onChange(index), style: [
6
+ style.paginationItem,
7
+ activeIndex === index && style.active,
8
+ paginationItemStyle,
9
+ activeIndex === index && paginationActiveItemStyle,
10
+ ], testID: "slider-pagination-item" }, renderItem?.(index)))))));
11
+ export { Pagination };
@@ -0,0 +1,23 @@
1
+ declare const style: {
2
+ paginationWrapper: {
3
+ alignItems: "center";
4
+ bottom: number;
5
+ flexDirection: "row";
6
+ justifyContent: "center";
7
+ position: "absolute";
8
+ width: string;
9
+ };
10
+ paginationContainer: {
11
+ margin: number;
12
+ };
13
+ paginationItem: {
14
+ width: number;
15
+ height: number;
16
+ borderRadius: number;
17
+ backgroundColor: string;
18
+ };
19
+ active: {
20
+ backgroundColor: string;
21
+ };
22
+ };
23
+ export { style };
@@ -0,0 +1,27 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { theme } from "../../../theme/theme";
3
+ const { colorGrayscaleS, colorGrayscaleXL } = theme();
4
+ const DOT_SIZE = 8;
5
+ const style = StyleSheet.create({
6
+ paginationWrapper: {
7
+ alignItems: "center",
8
+ bottom: 10,
9
+ flexDirection: "row",
10
+ justifyContent: "center",
11
+ position: "absolute",
12
+ width: "100%",
13
+ },
14
+ paginationContainer: {
15
+ margin: 3,
16
+ },
17
+ paginationItem: {
18
+ width: DOT_SIZE,
19
+ height: DOT_SIZE,
20
+ borderRadius: DOT_SIZE / 2,
21
+ backgroundColor: colorGrayscaleS,
22
+ },
23
+ active: {
24
+ backgroundColor: colorGrayscaleXL,
25
+ },
26
+ });
27
+ export { style };
@@ -0,0 +1,20 @@
1
+ import { FC, ReactNode } from "react";
2
+ import { StyleProp, ViewStyle } from "react-native";
3
+ interface SliderProps {
4
+ readonly children: ReactNode[];
5
+ readonly active?: number;
6
+ readonly loop?: boolean;
7
+ readonly minDistanceToCapture?: number;
8
+ readonly minDistanceForAction?: number;
9
+ readonly gesturesEnabled?: boolean;
10
+ readonly paginationEnabled?: boolean;
11
+ readonly paginationStyle?: StyleProp<ViewStyle>;
12
+ readonly paginationItemStyle?: StyleProp<ViewStyle>;
13
+ readonly paginationActiveItemStyle?: StyleProp<ViewStyle>;
14
+ readonly onSliderStart?: () => void;
15
+ readonly onSliderEnd?: () => void;
16
+ readonly onChanged?: (index: number) => void;
17
+ readonly paginationRenderItem?: (index: number) => JSX.Element;
18
+ }
19
+ declare const Slider: FC<SliderProps>;
20
+ export { Slider };
@@ -0,0 +1,140 @@
1
+ import React, { useCallback, useEffect, useRef, useState } from "react";
2
+ import { Animated, I18nManager, PanResponder, StyleSheet, View, } from "react-native";
3
+ import { Pagination } from "./Pagination";
4
+ import { style } from "./Slider.style";
5
+ const DEFAULT_WIDTH = 200;
6
+ const Slider = ({ children, active = 0, loop = false, minDistanceToCapture = 5, minDistanceForAction = 0.2, gesturesEnabled = true, paginationEnabled = true, paginationStyle, paginationItemStyle, paginationActiveItemStyle, onSliderStart, onSliderEnd, onChanged, paginationRenderItem, }) => {
7
+ const flatennedChildren = children.flat();
8
+ const count = flatennedChildren.length;
9
+ const [width, setWidth] = useState(0);
10
+ const widthRef = useRef(width);
11
+ const activeIndex = useRef(active);
12
+ const animatedValueX = useRef(0);
13
+ const animatedValueY = useRef(0);
14
+ const pan = useRef(new Animated.ValueXY()).current;
15
+ const started = useRef(false);
16
+ const panResponder = useRef(PanResponder.create({
17
+ onPanResponderTerminationRequest: () => false,
18
+ onMoveShouldSetPanResponder: () => gesturesEnabled,
19
+ // eslint-disable-next-line @typescript-eslint/naming-convention
20
+ onMoveShouldSetPanResponderCapture: (_e, gestureState) => {
21
+ if (!gesturesEnabled) {
22
+ return false;
23
+ }
24
+ startAnimation();
25
+ const allow = Math.abs(gestureState.dx) > minDistanceToCapture;
26
+ return allow;
27
+ },
28
+ onPanResponderGrant: () => fixState(),
29
+ onPanResponderMove: Animated.event([null, { dx: pan.x }], {
30
+ useNativeDriver: false,
31
+ }),
32
+ // eslint-disable-next-line @typescript-eslint/naming-convention
33
+ onPanResponderRelease: (_e, gesture) => {
34
+ const correction = gesture.moveX - gesture.x0;
35
+ if (Math.abs(correction) < widthRef.current * minDistanceForAction) {
36
+ spring({ x: 0, y: 0 });
37
+ }
38
+ else {
39
+ changeIndex(correction > 0 ? (I18nManager.isRTL ? 1 : -1) : I18nManager.isRTL ? -1 : 1);
40
+ }
41
+ },
42
+ onPanResponderEnd: () => endAnimation(),
43
+ })).current;
44
+ const startAnimation = useCallback(() => {
45
+ if (!started.current) {
46
+ onSliderStart?.();
47
+ started.current = true;
48
+ }
49
+ }, [onSliderStart]);
50
+ const endAnimation = useCallback(() => {
51
+ if (started.current) {
52
+ onSliderEnd?.();
53
+ started.current = false;
54
+ }
55
+ }, [onSliderEnd]);
56
+ const fixState = useCallback(() => {
57
+ animatedValueX.current = widthRef.current * activeIndex.current * (I18nManager.isRTL ? 1 : -1);
58
+ animatedValueY.current = 0;
59
+ pan.setOffset({
60
+ x: animatedValueX.current,
61
+ y: animatedValueY.current,
62
+ });
63
+ pan.setValue({ x: 0, y: 0 });
64
+ }, [pan]);
65
+ const spring = useCallback((toValue) => {
66
+ Animated.spring(pan, {
67
+ toValue,
68
+ useNativeDriver: false,
69
+ }).start();
70
+ }, [pan]);
71
+ const changeIndex = useCallback((delta = 1) => {
72
+ const toValue = { x: 0, y: 0 };
73
+ let skipChanges = !delta;
74
+ let calcDelta = delta;
75
+ if (activeIndex.current <= 0 && delta < 0) {
76
+ skipChanges = !loop;
77
+ calcDelta = count + delta;
78
+ }
79
+ else if (activeIndex.current + 1 >= count && delta > 0) {
80
+ skipChanges = !loop;
81
+ calcDelta = -1 * activeIndex.current + delta - 1;
82
+ }
83
+ if (skipChanges) {
84
+ return spring(toValue);
85
+ }
86
+ const index = activeIndex.current + calcDelta;
87
+ activeIndex.current = index;
88
+ toValue.x = widthRef.current * (I18nManager.isRTL ? 1 : -1) * calcDelta;
89
+ spring(toValue);
90
+ onChanged?.(index);
91
+ }, [count, loop, onChanged, spring]);
92
+ const fixAndGo = useCallback((delta) => {
93
+ fixState();
94
+ startAnimation();
95
+ changeIndex(delta);
96
+ }, [changeIndex, fixState, startAnimation]);
97
+ const goTo = useCallback((index = 0) => {
98
+ const delta = index - activeIndex.current;
99
+ if (delta) {
100
+ fixAndGo(delta);
101
+ }
102
+ }, [fixAndGo]);
103
+ const getActiveIndex = useCallback(() => activeIndex.current, []);
104
+ useEffect(() => {
105
+ pan.x.addListener(({ value }) => (animatedValueX.current = value));
106
+ pan.y.addListener(({ value }) => (animatedValueY.current = value));
107
+ return () => {
108
+ pan.x.removeAllListeners();
109
+ pan.y.removeAllListeners();
110
+ };
111
+ }, [pan.x, pan.y]);
112
+ useEffect(() => {
113
+ if (activeIndex.current !== active) {
114
+ goTo(active);
115
+ }
116
+ }, [active, goTo]);
117
+ const onLayoutWrapper = useCallback(({ nativeEvent: { layout: { width: wrapperWidth }, }, }) => {
118
+ const width = wrapperWidth || DEFAULT_WIDTH;
119
+ setWidth(width);
120
+ widthRef.current = width;
121
+ fixState();
122
+ }, [fixState]);
123
+ return (React.createElement(View, { onLayout: onLayoutWrapper, testID: "slider" },
124
+ React.createElement(View, { style: StyleSheet.flatten([
125
+ {
126
+ width,
127
+ },
128
+ style.container,
129
+ ]) },
130
+ React.createElement(Animated.View, { style: StyleSheet.flatten([
131
+ {
132
+ width: width * count,
133
+ transform: [{ translateX: pan.x }, { translateY: pan.y }],
134
+ },
135
+ style.sliderAreaStyle,
136
+ ]), ...panResponder.panHandlers }, flatennedChildren.map((child, index) => (React.createElement(View, { key: index, style: { width } },
137
+ React.createElement(View, { testID: "slider-child" }, child))))),
138
+ paginationEnabled && (React.createElement(Pagination, { count: count, activeIndex: getActiveIndex(), onChange: (index) => goTo(index), paginationStyle: paginationStyle, paginationItemStyle: paginationItemStyle, paginationActiveItemStyle: paginationActiveItemStyle, renderItem: paginationRenderItem })))));
139
+ };
140
+ export { Slider };
@@ -0,0 +1,9 @@
1
+ declare const style: {
2
+ container: {
3
+ overflow: "hidden";
4
+ };
5
+ sliderAreaStyle: {
6
+ flexDirection: "row";
7
+ };
8
+ };
9
+ export { style };
@@ -0,0 +1,10 @@
1
+ import { StyleSheet } from "react-native";
2
+ const style = StyleSheet.create({
3
+ container: {
4
+ overflow: "hidden",
5
+ },
6
+ sliderAreaStyle: {
7
+ flexDirection: "row",
8
+ },
9
+ });
10
+ export { style };
@@ -0,0 +1,7 @@
1
+ interface CdnImageUrlParameters {
2
+ url: string;
3
+ width: number;
4
+ dpi?: number;
5
+ }
6
+ declare const useMediaImage: () => ({ url, width, dpi }: CdnImageUrlParameters) => string;
7
+ export { useMediaImage };
@@ -0,0 +1,12 @@
1
+ import { useCallback } from "react";
2
+ import { PixelRatio } from "react-native";
3
+ const DEFAULT_DPI = 1;
4
+ const HIGHDPI = 2;
5
+ const useMediaImage = () => {
6
+ const cdnImageUrl = useCallback(({ url, width, dpi = PixelRatio.get() }) => {
7
+ const imageDpi = dpi > DEFAULT_DPI ? HIGHDPI : DEFAULT_DPI;
8
+ return `${url}?w=${Math.ceil(width * imageDpi)}&f=auto`;
9
+ }, []);
10
+ return cdnImageUrl;
11
+ };
12
+ export { useMediaImage };
@@ -23,7 +23,7 @@ const Routing = ({ onNotAccessible, customerId, locale, I18n, onI18nError }) =>
23
23
  {
24
24
  path: Routes.INTRO,
25
25
  element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
26
- React.createElement(Intro, null))),
26
+ React.createElement(Intro, { customerId: customerId }))),
27
27
  },
28
28
  {
29
29
  path: Routes.ITEM,
@@ -1,3 +1,6 @@
1
1
  import { FC } from "react";
2
- declare const Intro: FC;
2
+ declare type IntroProps = {
3
+ readonly customerId: string;
4
+ };
5
+ declare const Intro: FC<IntroProps>;
3
6
  export { Intro };
@@ -1,18 +1,20 @@
1
1
  import { Button } from "@lookiero/aurora-next/build/components/atoms/Button/Button";
2
+ import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
3
+ import { I18nMessages } from "../../i18n/i18n";
2
4
  import { Icon } from "@lookiero/aurora-next/build/components/primitives/Icon/Icon";
5
+ import { Spinner } from "../../components/atoms/spinner/Spinner";
3
6
  import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
4
7
  import { useI18nMessage } from "@lookiero/i18n-react";
5
- import { CommandStatus } from "@lookiero/messaging-react";
6
- import React, { useCallback } from "react";
7
- import { View } from "react-native";
8
8
  import { useSetCheckoutIntroShown } from "../../../domain/react/useSetCheckoutIntroShown";
9
- import { Body } from "../../components/layouts/body/Body";
10
- import { I18nMessages } from "../../i18n/i18n";
9
+ import { useViewFiveItemsDiscountByCustomerId } from "../../../projection/react/useViewFiveItemsDiscountByCustomerId";
10
+ import { View } from "react-native";
11
+ import React, { useCallback } from "react";
11
12
  import { styles } from "./Intro.style";
13
+ import { Body } from "../../components/layouts/body/Body";
12
14
  const Bullet = ({ text }) => (React.createElement(View, { style: styles.bullet },
13
15
  React.createElement(Icon, { name: "rounded-tick", style: styles.tickIcon }),
14
16
  React.createElement(Text, { detail: true, level: 2 }, text)));
15
- const Intro = () => {
17
+ const Intro = ({ customerId }) => {
16
18
  const titleText = useI18nMessage({ id: I18nMessages.INTRO_TITLE });
17
19
  const subTitleText = useI18nMessage({ id: I18nMessages.INTRO_SUBTITLE });
18
20
  const discountText = useI18nMessage({ id: I18nMessages.INTRO_DISCOUNT });
@@ -20,15 +22,22 @@ const Intro = () => {
20
22
  const bulletTwoText = useI18nMessage({ id: I18nMessages.INTRO_BULLET_TWO });
21
23
  const bulletThreeText = useI18nMessage({ id: I18nMessages.INTRO_BULLET_THREE });
22
24
  const buttonText = useI18nMessage({ id: I18nMessages.INTRO_BUTTON });
23
- const { setCheckoutIntroShown, status: setCheckoutIntroShownStatus } = useSetCheckoutIntroShown();
25
+ const [fiveItemsDiscount, fiveItemsDiscountState] = useViewFiveItemsDiscountByCustomerId({
26
+ customerId,
27
+ });
28
+ const [setCheckoutIntroShown, setCheckoutIntroShownStatus] = useSetCheckoutIntroShown();
24
29
  const handleOnPress = useCallback(() => setCheckoutIntroShown(), [setCheckoutIntroShown]);
30
+ if (fiveItemsDiscountState === QueryStatus.LOADING)
31
+ return React.createElement(Spinner, null);
25
32
  return (React.createElement(Body, null,
26
33
  React.createElement(View, null,
27
34
  React.createElement(Text, { heading: true, level: 3, style: styles.title }, titleText),
28
35
  React.createElement(Text, { body: true, level: 3 }, subTitleText),
29
36
  React.createElement(View, { style: styles.discountContainer },
30
37
  React.createElement(View, { style: styles.discount },
31
- React.createElement(Text, { heading: true, level: 2 }, "- 25"),
38
+ React.createElement(Text, { heading: true, level: 2 },
39
+ "- ",
40
+ fiveItemsDiscount),
32
41
  React.createElement(Text, { heading: true, level: 3, style: styles.percentage }, "%")),
33
42
  React.createElement(Text, { body: true, level: 3 }, discountText)),
34
43
  React.createElement(View, { style: styles.description },
@@ -0,0 +1,7 @@
1
+ import { FC } from "react";
2
+ import { MediaProjection } from "../../../../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
3
+ interface ProductVariantSlider {
4
+ readonly producVariantMedia: MediaProjection[];
5
+ }
6
+ declare const ProductVariantSlider: FC<ProductVariantSlider>;
7
+ export { ProductVariantSlider };
@@ -0,0 +1,22 @@
1
+ import React, { useCallback, useState } from "react";
2
+ import { Image } from "react-native";
3
+ import { Slider } from "../../../../components/layouts/slider/Slider";
4
+ import { useMediaImage } from "../../../../hooks/useMediaImage";
5
+ import { style } from "./ProductVariantSlider.style";
6
+ const ProductVariantSlider = ({ producVariantMedia }) => {
7
+ const cdnImageUrl = useMediaImage();
8
+ const [active, setActive] = useState(0);
9
+ const handleOnActiveChanged = useCallback((activeIndex) => setActive(activeIndex), []);
10
+ return (React.createElement(Slider, { active: active, onChanged: handleOnActiveChanged, paginationStyle: style.paginationStyle, paginationItemStyle: style.paginationItemStyle, paginationActiveItemStyle: style.paginationActiveItemStyle, paginationRenderItem: (index) => (React.createElement(Image, { key: producVariantMedia[index]?.perspective, style: style.paginationImage, resizeMode: "contain", source: {
11
+ uri: cdnImageUrl({
12
+ url: producVariantMedia[index]?.url,
13
+ width: 80,
14
+ }),
15
+ }, testID: "product-variant-pagination-image" })) }, producVariantMedia.map((media) => (React.createElement(Image, { key: media.perspective, style: style.image, source: {
16
+ uri: cdnImageUrl({
17
+ url: media.url,
18
+ width: 200,
19
+ }),
20
+ }, testID: "product-variant-image" })))));
21
+ };
22
+ export { ProductVariantSlider };
@@ -0,0 +1,26 @@
1
+ declare const style: {
2
+ image: {
3
+ aspectRatio: number;
4
+ flex: number;
5
+ };
6
+ paginationImage: {
7
+ flex: number;
8
+ };
9
+ paginationStyle: {
10
+ bottom: number;
11
+ marginTop: number;
12
+ position: "relative";
13
+ };
14
+ paginationItemStyle: {
15
+ backgroundColor: string;
16
+ borderColor: string;
17
+ borderRadius: number;
18
+ borderWidth: number;
19
+ height: number;
20
+ width: number;
21
+ };
22
+ paginationActiveItemStyle: {
23
+ borderColor: string;
24
+ };
25
+ };
26
+ export { style };
@@ -0,0 +1,30 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { theme } from "../../../../theme/theme";
3
+ const { colorBase, colorGrayscaleL, colorContent, spaceM } = theme();
4
+ const PAGINATION_SIZE = 37;
5
+ const style = StyleSheet.create({
6
+ image: {
7
+ aspectRatio: 0.75,
8
+ flex: 1,
9
+ },
10
+ paginationImage: {
11
+ flex: 1,
12
+ },
13
+ paginationStyle: {
14
+ bottom: 0,
15
+ marginTop: spaceM,
16
+ position: "relative",
17
+ },
18
+ paginationItemStyle: {
19
+ backgroundColor: colorBase,
20
+ borderColor: colorGrayscaleL,
21
+ borderRadius: 0,
22
+ borderWidth: 1,
23
+ height: PAGINATION_SIZE,
24
+ width: PAGINATION_SIZE,
25
+ },
26
+ paginationActiveItemStyle: {
27
+ borderColor: colorContent,
28
+ },
29
+ });
30
+ export { style };
@@ -101,4 +101,4 @@ interface ViewFirstAvailableCheckoutByCustomerIdHandlerFunctionArgs extends Quer
101
101
  readonly view: FirstAvailableCheckoutByCustomerIdView;
102
102
  }
103
103
  declare const viewFirstAvailableCheckoutByCustomerIdHandler: QueryHandlerFunction<ViewFirstAvailableCheckoutByCustomerId, ViewFirstAvailableCheckoutByCustomerIdResult, ViewFirstAvailableCheckoutByCustomerIdHandlerFunctionArgs>;
104
- export { CheckoutProjection, CheckoutStatus, CheckoutItemProjection, CheckoutItemStatus, MediaPerspective, Currency, VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID, viewFirstAvailableCheckoutByCustomerId, FirstAvailableCheckoutByCustomerIdView, viewFirstAvailableCheckoutByCustomerIdHandler, };
104
+ export { CheckoutProjection, CheckoutStatus, CheckoutItemProjection, CheckoutItemStatus, MediaPerspective, MediaProjection, Currency, VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID, viewFirstAvailableCheckoutByCustomerId, FirstAvailableCheckoutByCustomerIdView, viewFirstAvailableCheckoutByCustomerIdHandler, };
@@ -0,0 +1,23 @@
1
+ import { Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
2
+ declare type FiveItemsDiscountByCustomerIdProjection = number;
3
+ declare const VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID = "view_five_items_discount_by_customer_id";
4
+ interface ViewFiveItemsDiscountByCustomerIdPayload {
5
+ readonly customerId: string;
6
+ }
7
+ interface ViewFiveItemsDiscountByCustomerId extends Query<typeof VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID>, ViewFiveItemsDiscountByCustomerIdPayload {
8
+ }
9
+ interface ViewFiveItemsDiscountByCustomerIdFunction {
10
+ (payload: ViewFiveItemsDiscountByCustomerIdPayload): ViewFiveItemsDiscountByCustomerId;
11
+ }
12
+ declare const viewFiveItemsDiscountByCustomerId: ViewFiveItemsDiscountByCustomerIdFunction;
13
+ interface FiveItemsDiscountByCustomerIdViewArgs {
14
+ readonly customerId: string;
15
+ }
16
+ interface FiveItemsDiscountByCustomerIdView {
17
+ (args: FiveItemsDiscountByCustomerIdViewArgs): Promise<FiveItemsDiscountByCustomerIdProjection>;
18
+ }
19
+ interface ViewFiveItemsDiscountByCustomerIdHandlerFunctionArgs extends QueryHandlerFunctionArgs {
20
+ readonly view: FiveItemsDiscountByCustomerIdView;
21
+ }
22
+ declare const viewFiveItemsDiscountByCustomerIdHandler: QueryHandlerFunction<ViewFiveItemsDiscountByCustomerId, FiveItemsDiscountByCustomerIdProjection, ViewFiveItemsDiscountByCustomerIdHandlerFunctionArgs>;
23
+ export { FiveItemsDiscountByCustomerIdProjection, VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID, viewFiveItemsDiscountByCustomerId, FiveItemsDiscountByCustomerIdView, viewFiveItemsDiscountByCustomerIdHandler, };
@@ -0,0 +1,8 @@
1
+ import { query } from "@lookiero/messaging";
2
+ const VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID = "view_five_items_discount_by_customer_id";
3
+ const viewFiveItemsDiscountByCustomerId = (payload) => ({
4
+ ...query({ name: VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID }),
5
+ ...payload,
6
+ });
7
+ const viewFiveItemsDiscountByCustomerIdHandler = ({ view }) => async ({ customerId }) => view({ customerId });
8
+ export { VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID, viewFiveItemsDiscountByCustomerId, viewFiveItemsDiscountByCustomerIdHandler, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [