@lookiero/checkout 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/infrastructure/delivery/http/fetchHttpClient.js +0 -1
- package/dist/infrastructure/ui/components/atoms/price/Price.d.ts +7 -0
- package/dist/infrastructure/ui/components/atoms/price/Price.js +22 -0
- package/dist/infrastructure/ui/components/atoms/price/Price.style.d.ts +13 -0
- package/dist/infrastructure/ui/components/atoms/price/Price.style.js +16 -0
- package/dist/infrastructure/ui/components/atoms/spinner/Spinner.js +4 -5
- package/dist/infrastructure/ui/components/layouts/body/Body.js +4 -5
- package/dist/infrastructure/ui/components/layouts/body/Body.style.d.ts +3 -2
- package/dist/infrastructure/ui/components/layouts/body/Body.style.js +3 -2
- package/dist/infrastructure/ui/components/layouts/slider/Pagination.d.ts +14 -0
- package/dist/infrastructure/ui/components/layouts/slider/Pagination.js +11 -0
- package/dist/infrastructure/ui/components/layouts/slider/Pagination.style.d.ts +23 -0
- package/dist/infrastructure/ui/components/layouts/slider/Pagination.style.js +27 -0
- package/dist/infrastructure/ui/components/layouts/slider/Slider.d.ts +20 -0
- package/dist/infrastructure/ui/components/layouts/slider/Slider.js +132 -0
- package/dist/infrastructure/ui/components/layouts/slider/Slider.style.d.ts +11 -0
- package/dist/infrastructure/ui/components/layouts/slider/Slider.style.js +12 -0
- package/dist/infrastructure/ui/hooks/useMediaImage.d.ts +7 -0
- package/dist/infrastructure/ui/hooks/useMediaImage.js +12 -0
- package/dist/infrastructure/ui/i18n/i18n.d.ts +4 -1
- package/dist/infrastructure/ui/i18n/i18n.js +3 -0
- package/dist/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.d.ts +1 -0
- package/dist/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.js +1 -0
- package/dist/infrastructure/ui/routing/Routing.js +2 -0
- package/dist/infrastructure/ui/views/intro/Intro.js +19 -18
- package/dist/infrastructure/ui/views/intro/Intro.style.d.ts +12 -2
- package/dist/infrastructure/ui/views/intro/Intro.style.js +12 -2
- package/dist/infrastructure/ui/views/item/components/productVariantDescription/ProductVariantDescription.d.ts +11 -0
- package/dist/infrastructure/ui/views/item/components/productVariantDescription/ProductVariantDescription.js +25 -0
- package/dist/infrastructure/ui/views/item/components/productVariantDescription/ProductVariantDescription.style.d.ts +19 -0
- package/dist/infrastructure/ui/views/item/components/productVariantDescription/ProductVariantDescription.style.js +22 -0
- package/dist/infrastructure/ui/views/item/components/productVariantSlider/ProductVariantSlider.d.ts +7 -0
- package/dist/infrastructure/ui/views/item/components/productVariantSlider/ProductVariantSlider.js +22 -0
- package/dist/infrastructure/ui/views/item/components/productVariantSlider/ProductVariantSlider.style.d.ts +25 -0
- package/dist/infrastructure/ui/views/item/components/productVariantSlider/ProductVariantSlider.style.js +29 -0
- package/dist/projection/checkout/viewFirstAvailableCheckoutByCustomerId.d.ts +2 -1
- package/package.json +2 -1
|
@@ -9,7 +9,6 @@ const fetchHttpPost = ({ apiUrl, getAuthToken }) => async ({ endpoint, body }) =
|
|
|
9
9
|
const fetchHttpGet = ({ apiUrl, getAuthToken }) => async ({ endpoint }) => fetch(`${apiUrl}${endpoint}`, {
|
|
10
10
|
method: "GET",
|
|
11
11
|
credentials: "include",
|
|
12
|
-
mode: "no-cors",
|
|
13
12
|
headers: {
|
|
14
13
|
authorization: `Bearer ${getAuthToken()}`,
|
|
15
14
|
},
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import { useI18nNumber } from "@lookiero/i18n-react";
|
|
4
|
+
import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
|
|
5
|
+
import { style } from "./Price.style";
|
|
6
|
+
const Price = ({ price }) => {
|
|
7
|
+
const isDiscounted = price.discountedPrice && price.discountedPrice.percentage !== 0;
|
|
8
|
+
const productPrice = useI18nNumber({
|
|
9
|
+
value: price.amount / 100,
|
|
10
|
+
style: "currency",
|
|
11
|
+
currency: price.currency,
|
|
12
|
+
});
|
|
13
|
+
const productDiscountedPrice = useI18nNumber({
|
|
14
|
+
value: (price.discountedPrice?.amount || 0) / 100,
|
|
15
|
+
style: "currency",
|
|
16
|
+
currency: price.currency,
|
|
17
|
+
});
|
|
18
|
+
return (React.createElement(View, { style: style.price, testID: "price" },
|
|
19
|
+
React.createElement(Text, { body: true, level: 3, style: isDiscounted && style.priceTextDiscounted, testID: "price-text" }, productPrice),
|
|
20
|
+
isDiscounted && (React.createElement(Text, { body: true, level: 3, style: style.discountedPriceText, testID: "discounted-price-text" }, productDiscountedPrice))));
|
|
21
|
+
};
|
|
22
|
+
export { Price };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { theme } from "../../../theme/theme";
|
|
3
|
+
const { colorPrimary, spaceS } = theme();
|
|
4
|
+
const style = StyleSheet.create({
|
|
5
|
+
price: {
|
|
6
|
+
flexDirection: "row",
|
|
7
|
+
},
|
|
8
|
+
priceTextDiscounted: {
|
|
9
|
+
textDecorationLine: "line-through",
|
|
10
|
+
},
|
|
11
|
+
discountedPriceText: {
|
|
12
|
+
marginLeft: spaceS,
|
|
13
|
+
color: colorPrimary,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
export { style };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { View } from "react-native";
|
|
2
|
+
import { ActivityIndicator, View } from "react-native";
|
|
3
|
+
import { theme } from "../../../theme/theme";
|
|
3
4
|
import { style } from "./Spinner.style";
|
|
5
|
+
const { colorPrimary } = theme();
|
|
4
6
|
const Spinner = () => (React.createElement(View, { style: style.container },
|
|
5
|
-
React.createElement(
|
|
6
|
-
React.createElement("circle", { cx: "50", cy: "50", r: "32", stroke: "#000000", strokeWidth: "6", strokeLinecap: "round", fill: "none" },
|
|
7
|
-
React.createElement("animateTransform", { attributeName: "transform", type: "rotate", repeatCount: "indefinite", dur: "1.5384615384615383s", values: "0 50 50;180 50 50;720 50 50", keyTimes: "0;0.5;1" }),
|
|
8
|
-
React.createElement("animate", { attributeName: "stroke-dasharray", repeatCount: "indefinite", dur: "1.5384615384615383s", values: "42.22300526424682 158.83892456549995;176.93449825017714 24.127431579569617;42.22300526424682 158.83892456549995", keyTimes: "0;0.5;1" })))));
|
|
7
|
+
React.createElement(ActivityIndicator, { size: "large", color: colorPrimary })));
|
|
9
8
|
export { Spinner };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Box } from "@lookiero/aurora-next/build/components/atoms/Box/Box";
|
|
2
2
|
import { Layout } from "@lookiero/aurora-next/build/components/atoms/Layout/Layout";
|
|
3
3
|
import React from "react";
|
|
4
|
+
import { SafeAreaView } from "react-native";
|
|
4
5
|
import { style } from "./Body.style";
|
|
5
|
-
const Body = ({ children }) => (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
React.createElement(Layout, { style: style.layout },
|
|
9
|
-
React.createElement(Box, { size: { M: "2/3", L: "1/3" }, style: style.box }, children)));
|
|
6
|
+
const Body = ({ children }) => (React.createElement(SafeAreaView, { style: style.container },
|
|
7
|
+
React.createElement(Layout, { style: style.layout },
|
|
8
|
+
React.createElement(Box, { size: { M: "2/3", L: "1/3" }, style: style.box }, children))));
|
|
10
9
|
export { Body };
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
declare const style: {
|
|
2
|
+
container: {
|
|
3
|
+
flex: number;
|
|
4
|
+
};
|
|
2
5
|
layout: {
|
|
3
6
|
flex: number;
|
|
4
7
|
justifyContent: "center";
|
|
5
8
|
padding: number;
|
|
6
|
-
textAlign: "center";
|
|
7
9
|
};
|
|
8
10
|
box: {
|
|
9
11
|
height: string;
|
|
10
|
-
justifyContent: "space-between";
|
|
11
12
|
};
|
|
12
13
|
};
|
|
13
14
|
export { style };
|
|
@@ -2,15 +2,16 @@ import { StyleSheet } from "react-native";
|
|
|
2
2
|
import { theme } from "../../../theme/theme";
|
|
3
3
|
const { spaceXL } = theme();
|
|
4
4
|
const style = StyleSheet.create({
|
|
5
|
+
container: {
|
|
6
|
+
flex: 1,
|
|
7
|
+
},
|
|
5
8
|
layout: {
|
|
6
9
|
flex: 1,
|
|
7
10
|
justifyContent: "center",
|
|
8
11
|
padding: spaceXL,
|
|
9
|
-
textAlign: "center",
|
|
10
12
|
},
|
|
11
13
|
box: {
|
|
12
14
|
height: "100%",
|
|
13
|
-
justifyContent: "space-between",
|
|
14
15
|
},
|
|
15
16
|
});
|
|
16
17
|
export { style };
|
|
@@ -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,132 @@
|
|
|
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, { style: style.container, onLayout: onLayoutWrapper, testID: "slider" },
|
|
124
|
+
React.createElement(Animated.View, { style: StyleSheet.flatten([
|
|
125
|
+
{
|
|
126
|
+
transform: [{ translateX: pan.x }, { translateY: pan.y }],
|
|
127
|
+
},
|
|
128
|
+
style.sliderAreaStyle,
|
|
129
|
+
]), ...panResponder.panHandlers }, flatennedChildren.map((child, index) => (React.createElement(View, { key: index, style: { width }, testID: "slider-child" }, child)))),
|
|
130
|
+
paginationEnabled && (React.createElement(Pagination, { count: count, activeIndex: getActiveIndex(), onChange: (index) => goTo(index), paginationStyle: paginationStyle, paginationItemStyle: paginationItemStyle, paginationActiveItemStyle: paginationActiveItemStyle, renderItem: paginationRenderItem }))));
|
|
131
|
+
};
|
|
132
|
+
export { Slider };
|
|
@@ -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 };
|
|
@@ -5,6 +5,9 @@ declare enum I18nMessages {
|
|
|
5
5
|
INTRO_BULLET_ONE = "intro.bullet_one",
|
|
6
6
|
INTRO_BULLET_TWO = "intro.bullet_two",
|
|
7
7
|
INTRO_BULLET_THREE = "intro.bullet_three",
|
|
8
|
-
INTRO_BUTTON = "intro.button"
|
|
8
|
+
INTRO_BUTTON = "intro.button",
|
|
9
|
+
ITEM_SIZE = "item.size",
|
|
10
|
+
ITEM_COLOR = "item.color",
|
|
11
|
+
ITEM_UNIQUE = "item.unique"
|
|
9
12
|
}
|
|
10
13
|
export { I18nMessages };
|
|
@@ -7,5 +7,8 @@ var I18nMessages;
|
|
|
7
7
|
I18nMessages["INTRO_BULLET_TWO"] = "intro.bullet_two";
|
|
8
8
|
I18nMessages["INTRO_BULLET_THREE"] = "intro.bullet_three";
|
|
9
9
|
I18nMessages["INTRO_BUTTON"] = "intro.button";
|
|
10
|
+
I18nMessages["ITEM_SIZE"] = "item.size";
|
|
11
|
+
I18nMessages["ITEM_COLOR"] = "item.color";
|
|
12
|
+
I18nMessages["ITEM_UNIQUE"] = "item.unique";
|
|
10
13
|
})(I18nMessages || (I18nMessages = {}));
|
|
11
14
|
export { I18nMessages };
|
|
@@ -14,10 +14,12 @@ const Routing = ({ onNotAccessible, customerId, locale, I18n, onI18nError }) =>
|
|
|
14
14
|
element: React.createElement(CheckoutAccessibilityMiddleware, { customerId: customerId, onNotAccessible: onNotAccessible }),
|
|
15
15
|
children: [
|
|
16
16
|
{
|
|
17
|
+
path: "",
|
|
17
18
|
element: (React.createElement(I18n, { locale: locale, loader: React.createElement(Spinner, null), onError: onI18nError },
|
|
18
19
|
React.createElement(Outlet, null))),
|
|
19
20
|
children: [
|
|
20
21
|
{
|
|
22
|
+
path: "",
|
|
21
23
|
element: React.createElement(CheckoutMiddleware, { customerId: customerId }),
|
|
22
24
|
children: [
|
|
23
25
|
{
|
|
@@ -9,10 +9,10 @@ import { useSetCheckoutIntroShown } from "../../../domain/react/useSetCheckoutIn
|
|
|
9
9
|
import { useViewFiveItemsDiscountByCustomerId } from "../../../projection/react/useViewFiveItemsDiscountByCustomerId";
|
|
10
10
|
import { View } from "react-native";
|
|
11
11
|
import React, { useCallback } from "react";
|
|
12
|
-
import { styles } from "./Intro.style";
|
|
13
12
|
import { Body } from "../../components/layouts/body/Body";
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
import { style } from "./Intro.style";
|
|
14
|
+
const Bullet = ({ text }) => (React.createElement(View, { style: style.bullet },
|
|
15
|
+
React.createElement(Icon, { name: "rounded-tick", style: style.tickIcon }),
|
|
16
16
|
React.createElement(Text, { detail: true, level: 2 }, text)));
|
|
17
17
|
const Intro = ({ customerId }) => {
|
|
18
18
|
const titleText = useI18nMessage({ id: I18nMessages.INTRO_TITLE });
|
|
@@ -30,20 +30,21 @@ const Intro = ({ customerId }) => {
|
|
|
30
30
|
if (fiveItemsDiscountState === QueryStatus.LOADING)
|
|
31
31
|
return React.createElement(Spinner, null);
|
|
32
32
|
return (React.createElement(Body, null,
|
|
33
|
-
React.createElement(View,
|
|
34
|
-
React.createElement(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
React.createElement(View, { style:
|
|
38
|
-
React.createElement(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
React.createElement(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
33
|
+
React.createElement(View, { style: style.container },
|
|
34
|
+
React.createElement(View, { style: style.content },
|
|
35
|
+
React.createElement(Text, { heading: true, level: 3, style: style.title }, titleText),
|
|
36
|
+
React.createElement(Text, { body: true, level: 3 }, subTitleText),
|
|
37
|
+
React.createElement(View, { style: style.discountContainer },
|
|
38
|
+
React.createElement(View, { style: style.discount },
|
|
39
|
+
React.createElement(Text, { heading: true, level: 2 },
|
|
40
|
+
"- ",
|
|
41
|
+
fiveItemsDiscount),
|
|
42
|
+
React.createElement(Text, { heading: true, level: 3, style: style.percentage }, "%")),
|
|
43
|
+
React.createElement(Text, { body: true, level: 3 }, discountText)),
|
|
44
|
+
React.createElement(View, { style: style.description },
|
|
45
|
+
React.createElement(Bullet, { text: bulletOneText }),
|
|
46
|
+
React.createElement(Bullet, { text: bulletTwoText }),
|
|
47
|
+
React.createElement(Bullet, { text: bulletThreeText }))),
|
|
48
|
+
React.createElement(Button, { disabled: setCheckoutIntroShownStatus === CommandStatus.LOADING, onPress: handleOnPress }, buttonText))));
|
|
48
49
|
};
|
|
49
50
|
export { Intro };
|
|
@@ -1,11 +1,21 @@
|
|
|
1
|
-
declare const
|
|
1
|
+
declare const style: {
|
|
2
|
+
container: {
|
|
3
|
+
flex: number;
|
|
4
|
+
justifyContent: "space-between";
|
|
5
|
+
};
|
|
6
|
+
content: {
|
|
7
|
+
alignItems: "center";
|
|
8
|
+
textAlign: "center";
|
|
9
|
+
};
|
|
2
10
|
title: {
|
|
3
11
|
marginBottom: number;
|
|
4
12
|
};
|
|
5
13
|
discountContainer: {
|
|
14
|
+
alignItems: "center";
|
|
6
15
|
backgroundColor: string;
|
|
7
16
|
marginVertical: number;
|
|
8
17
|
padding: number;
|
|
18
|
+
textAlign: "center";
|
|
9
19
|
width: string;
|
|
10
20
|
};
|
|
11
21
|
discount: {
|
|
@@ -31,4 +41,4 @@ declare const styles: {
|
|
|
31
41
|
marginRight: number;
|
|
32
42
|
};
|
|
33
43
|
};
|
|
34
|
-
export {
|
|
44
|
+
export { style };
|
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
import { StyleSheet } from "react-native";
|
|
2
2
|
import { theme } from "../../theme/theme";
|
|
3
3
|
const { borderSize, colorAccent, spaceXS, spaceS, spaceM, spaceL, spaceXL } = theme();
|
|
4
|
-
const
|
|
4
|
+
const style = StyleSheet.create({
|
|
5
|
+
container: {
|
|
6
|
+
flex: 1,
|
|
7
|
+
justifyContent: "space-between",
|
|
8
|
+
},
|
|
9
|
+
content: {
|
|
10
|
+
alignItems: "center",
|
|
11
|
+
textAlign: "center",
|
|
12
|
+
},
|
|
5
13
|
title: {
|
|
6
14
|
marginBottom: spaceM,
|
|
7
15
|
},
|
|
8
16
|
discountContainer: {
|
|
17
|
+
alignItems: "center",
|
|
9
18
|
backgroundColor: colorAccent,
|
|
10
19
|
marginVertical: spaceL,
|
|
11
20
|
padding: spaceM,
|
|
21
|
+
textAlign: "center",
|
|
12
22
|
width: "100%",
|
|
13
23
|
},
|
|
14
24
|
discount: {
|
|
@@ -34,4 +44,4 @@ const styles = StyleSheet.create({
|
|
|
34
44
|
marginRight: spaceS,
|
|
35
45
|
},
|
|
36
46
|
});
|
|
37
|
-
export {
|
|
47
|
+
export { style };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { ColorProjection, PriceProjection, SizeProjection } from "../../../../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
|
|
3
|
+
interface ProductVariantDescriptionProps {
|
|
4
|
+
readonly brand: string;
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly price: PriceProjection;
|
|
7
|
+
readonly size: SizeProjection;
|
|
8
|
+
readonly color: ColorProjection;
|
|
9
|
+
}
|
|
10
|
+
declare const ProductVariantDescription: FC<ProductVariantDescriptionProps>;
|
|
11
|
+
export { ProductVariantDescription };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
|
|
4
|
+
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
5
|
+
import { I18nMessages } from "../../../../i18n/i18n";
|
|
6
|
+
import { Price } from "../../../../components/atoms/price/Price";
|
|
7
|
+
import { style } from "./ProductVariantDescription.style";
|
|
8
|
+
const ProductVariantDescription = ({ brand, name, price, size, color }) => {
|
|
9
|
+
const sizeText = useI18nMessage({ id: I18nMessages.ITEM_SIZE });
|
|
10
|
+
const colorText = useI18nMessage({ id: I18nMessages.ITEM_COLOR });
|
|
11
|
+
const uniqueText = useI18nMessage({ id: I18nMessages.ITEM_UNIQUE });
|
|
12
|
+
return (React.createElement(View, { style: style.container },
|
|
13
|
+
React.createElement(Text, { detail: true, level: 3, style: style.brand }, brand),
|
|
14
|
+
React.createElement(Text, { body: true, level: 2, style: style.name }, name),
|
|
15
|
+
React.createElement(Price, { price: price }),
|
|
16
|
+
React.createElement(Text, { detail: true, level: 2, style: style.size },
|
|
17
|
+
sizeText,
|
|
18
|
+
": ",
|
|
19
|
+
React.createElement(Text, { style: style.text }, size.unique ? uniqueText : size.lookiero)),
|
|
20
|
+
React.createElement(Text, { detail: true, level: 2 },
|
|
21
|
+
colorText,
|
|
22
|
+
": ",
|
|
23
|
+
React.createElement(Text, { style: style.text }, color.label))));
|
|
24
|
+
};
|
|
25
|
+
export { ProductVariantDescription };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare const style: {
|
|
2
|
+
container: {
|
|
3
|
+
width: string;
|
|
4
|
+
};
|
|
5
|
+
brand: {
|
|
6
|
+
color: string;
|
|
7
|
+
textTransform: "uppercase";
|
|
8
|
+
};
|
|
9
|
+
name: {
|
|
10
|
+
marginVertical: number;
|
|
11
|
+
};
|
|
12
|
+
size: {
|
|
13
|
+
marginVertical: number;
|
|
14
|
+
};
|
|
15
|
+
text: {
|
|
16
|
+
color: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export { style };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { theme } from "../../../../theme/theme";
|
|
3
|
+
const { colorGrayscaleL, spaceS, spaceL } = theme();
|
|
4
|
+
const style = StyleSheet.create({
|
|
5
|
+
container: {
|
|
6
|
+
width: "100%",
|
|
7
|
+
},
|
|
8
|
+
brand: {
|
|
9
|
+
color: colorGrayscaleL,
|
|
10
|
+
textTransform: "uppercase",
|
|
11
|
+
},
|
|
12
|
+
name: {
|
|
13
|
+
marginVertical: spaceS,
|
|
14
|
+
},
|
|
15
|
+
size: {
|
|
16
|
+
marginVertical: spaceL,
|
|
17
|
+
},
|
|
18
|
+
text: {
|
|
19
|
+
color: colorGrayscaleL,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
export { style };
|
package/dist/infrastructure/ui/views/item/components/productVariantSlider/ProductVariantSlider.d.ts
ADDED
|
@@ -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 };
|
package/dist/infrastructure/ui/views/item/components/productVariantSlider/ProductVariantSlider.js
ADDED
|
@@ -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,25 @@
|
|
|
1
|
+
declare const style: {
|
|
2
|
+
image: {
|
|
3
|
+
flex: number;
|
|
4
|
+
};
|
|
5
|
+
paginationImage: {
|
|
6
|
+
flex: number;
|
|
7
|
+
};
|
|
8
|
+
paginationStyle: {
|
|
9
|
+
bottom: number;
|
|
10
|
+
marginTop: number;
|
|
11
|
+
position: "relative";
|
|
12
|
+
};
|
|
13
|
+
paginationItemStyle: {
|
|
14
|
+
backgroundColor: string;
|
|
15
|
+
borderColor: string;
|
|
16
|
+
borderRadius: number;
|
|
17
|
+
borderWidth: number;
|
|
18
|
+
height: number;
|
|
19
|
+
width: number;
|
|
20
|
+
};
|
|
21
|
+
paginationActiveItemStyle: {
|
|
22
|
+
borderColor: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export { style };
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
flex: 1,
|
|
8
|
+
},
|
|
9
|
+
paginationImage: {
|
|
10
|
+
flex: 1,
|
|
11
|
+
},
|
|
12
|
+
paginationStyle: {
|
|
13
|
+
bottom: 0,
|
|
14
|
+
marginTop: spaceM,
|
|
15
|
+
position: "relative",
|
|
16
|
+
},
|
|
17
|
+
paginationItemStyle: {
|
|
18
|
+
backgroundColor: colorBase,
|
|
19
|
+
borderColor: colorGrayscaleL,
|
|
20
|
+
borderRadius: 0,
|
|
21
|
+
borderWidth: 1,
|
|
22
|
+
height: PAGINATION_SIZE,
|
|
23
|
+
width: PAGINATION_SIZE,
|
|
24
|
+
},
|
|
25
|
+
paginationActiveItemStyle: {
|
|
26
|
+
borderColor: colorContent,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
export { style };
|
|
@@ -101,4 +101,5 @@ interface ViewFirstAvailableCheckoutByCustomerIdHandlerFunctionArgs extends Quer
|
|
|
101
101
|
readonly view: FirstAvailableCheckoutByCustomerIdView;
|
|
102
102
|
}
|
|
103
103
|
declare const viewFirstAvailableCheckoutByCustomerIdHandler: QueryHandlerFunction<ViewFirstAvailableCheckoutByCustomerId, ViewFirstAvailableCheckoutByCustomerIdResult, ViewFirstAvailableCheckoutByCustomerIdHandlerFunctionArgs>;
|
|
104
|
-
export {
|
|
104
|
+
export type { CheckoutItemProjection, CheckoutProjection, ColorProjection, FirstAvailableCheckoutByCustomerIdView, MediaProjection, PriceProjection, SizeProjection, };
|
|
105
|
+
export { CheckoutStatus, CheckoutItemStatus, MediaPerspective, Currency, VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID, viewFirstAvailableCheckoutByCustomerId, viewFirstAvailableCheckoutByCustomerIdHandler, };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lookiero/checkout",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"@lookiero/i18n-react": "^0.7.2",
|
|
26
26
|
"@lookiero/messaging": "^6.2.1",
|
|
27
27
|
"@lookiero/messaging-react": "^6.2.1",
|
|
28
|
+
"react-native-get-random-values": "^1.8.0",
|
|
28
29
|
"react-router-dom": "^6.3.0",
|
|
29
30
|
"react-router-native": "^6.3.0",
|
|
30
31
|
"uuid": "^9.0.0"
|