@whatmore-repo/whatmore-reactnative-sdk 1.0.30 → 1.0.32
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/index.js +2 -1
- package/package.json +1 -1
- package/src/api/navigation-commands/NavigationCommands.js +2 -0
- package/src/components/WhatmoreRootComponent.js +1 -1
- package/src/components/carousel-view/EventTileWithProduct.js +81 -34
- package/src/components/cta-buttons/ShopNowButton.jsx +2 -2
- package/src/globals/useAppState_APP.js +2 -1
- package/src/utils/PriceUtils.js +1 -1
package/index.js
CHANGED
|
@@ -12,6 +12,7 @@ export function WhatmoreBase(props){
|
|
|
12
12
|
setGlobalState('template', props.template);
|
|
13
13
|
setGlobalState('modalUsed', props.modalUsed);
|
|
14
14
|
setGlobalState('activateMock', props.activateMock);
|
|
15
|
+
setGlobalState('customStyles', props.customStyles);
|
|
15
16
|
}, []);
|
|
16
17
|
|
|
17
18
|
// return (
|
|
@@ -24,7 +25,7 @@ export function WhatmoreBase(props){
|
|
|
24
25
|
// );
|
|
25
26
|
|
|
26
27
|
return (
|
|
27
|
-
<WhatmoreRootComponent shopId={props.shopId} onAction={props.onAction}
|
|
28
|
+
<WhatmoreRootComponent shopId={props.shopId} onAction={props.onAction} />
|
|
28
29
|
);
|
|
29
30
|
}
|
|
30
31
|
|
package/package.json
CHANGED
|
@@ -29,6 +29,8 @@ export async function navigateToProductPage(product, brandDomainContext, whatmor
|
|
|
29
29
|
else {
|
|
30
30
|
const parts = product?.product_link?.split('/');
|
|
31
31
|
const sku = parts?.[parts?.length - 1];
|
|
32
|
+
if(!sku)
|
|
33
|
+
return;
|
|
32
34
|
navigation.navigate(
|
|
33
35
|
'ProductDetail',
|
|
34
36
|
{url: sku}
|
|
@@ -2,7 +2,7 @@ import React, { useState, useEffect, lazy } from 'react';
|
|
|
2
2
|
import { WHATMORE_BACKEND_BASE_URL } from '../constants/AppGlobalVars';
|
|
3
3
|
import { extractEvents, removeInvalidEvents } from '../utils/EventSanityUtils';
|
|
4
4
|
import { View } from 'react-native';
|
|
5
|
-
|
|
5
|
+
// import EventTileWithProduct from './carousel-view/EventTileWithProduct.js';
|
|
6
6
|
const EventTileWithProduct = lazy(() => import('./carousel-view/EventTileWithProduct.js'));
|
|
7
7
|
const EventClickComponent = lazy(() => import('./EventClickComponent'));
|
|
8
8
|
|
|
@@ -5,20 +5,24 @@ import { useState, useRef } from 'react';
|
|
|
5
5
|
import ChevronRightIcon from '../../icons/icon-components/ChevronRight';
|
|
6
6
|
import ChevronLeftIcon from '../../icons/icon-components/ChevronLeft';
|
|
7
7
|
import { getGlobalState } from '../../globals/useAppState_APP';
|
|
8
|
+
import { getPriceStringWithCurrency } from '../../utils/PriceUtils';
|
|
8
9
|
|
|
9
10
|
export default function EventTileWithProduct(props) {
|
|
10
11
|
const [activeIndex, setActiveIndex] = useState(1);
|
|
11
12
|
const [renderedEvents, setRenderedEvents] = useState(5)
|
|
12
13
|
const { width } = Dimensions.get('window');
|
|
13
|
-
const customStyles
|
|
14
|
+
const customStyles= getGlobalState('customStyles');
|
|
14
15
|
const ITEM_WIDTH = width * 0.33;
|
|
15
|
-
const CARD_HEIGHT = 40*(customStyles?.videoTileSize ?? 5);
|
|
16
|
+
const CARD_HEIGHT = 40 * (customStyles?.videoTileSize ?? 5.5);
|
|
17
|
+
const safeAreaViewHeight = customStyles?.showProductDetails ? 100 : 50;
|
|
18
|
+
const brandThemeColor = customStyles?.brandThemeColor;
|
|
19
|
+
// const brandThemeFont = customStyles?.brandThemeFont;
|
|
16
20
|
|
|
17
21
|
const styles = StyleSheet.create({
|
|
18
22
|
container: {
|
|
19
23
|
position: 'relative',
|
|
20
24
|
width: '100%',
|
|
21
|
-
height: CARD_HEIGHT +
|
|
25
|
+
height: CARD_HEIGHT + safeAreaViewHeight,
|
|
22
26
|
},
|
|
23
27
|
arrowContainerRight: {
|
|
24
28
|
position: 'absolute',
|
|
@@ -34,7 +38,7 @@ export default function EventTileWithProduct(props) {
|
|
|
34
38
|
top: '50%',
|
|
35
39
|
transform: [{ translateY: -30 }],
|
|
36
40
|
width: 28,
|
|
37
|
-
height: 28,
|
|
41
|
+
height: 28,
|
|
38
42
|
marginHorizontal: 5,
|
|
39
43
|
}
|
|
40
44
|
});
|
|
@@ -43,7 +47,7 @@ export default function EventTileWithProduct(props) {
|
|
|
43
47
|
setInitialEventIndex(index);
|
|
44
48
|
setIsModalOpen(true);
|
|
45
49
|
};
|
|
46
|
-
|
|
50
|
+
|
|
47
51
|
const { events, isModalOpen, setInitialEventIndex, setIsModalOpen } = props;
|
|
48
52
|
// const [pausedVideos, setPausedVideos] = useState({});
|
|
49
53
|
// const handleVideoLoad = (index) => {
|
|
@@ -64,7 +68,7 @@ export default function EventTileWithProduct(props) {
|
|
|
64
68
|
|
|
65
69
|
const scrollRight = () => {
|
|
66
70
|
setRenderedEvents(prev => prev + 2);
|
|
67
|
-
if (activeIndex < events.length -
|
|
71
|
+
if (activeIndex < events.length - 2) {
|
|
68
72
|
const newIndex = activeIndex + 2;
|
|
69
73
|
flatListRef.current.scrollToIndex({ index: newIndex, animated: true });
|
|
70
74
|
setActiveIndex(newIndex);
|
|
@@ -81,29 +85,72 @@ export default function EventTileWithProduct(props) {
|
|
|
81
85
|
// }
|
|
82
86
|
// },[])
|
|
83
87
|
const renderItem = ({ item, index }) => {
|
|
88
|
+
const price = Math.round(+item.products?.[0]?.price);
|
|
89
|
+
const compare_price = Math.round(+item.products?.[0]?.compare_price);
|
|
90
|
+
const calculatedDiscount = (compare_price && compare_price != 0 && compare_price > price) ? Math.round(((compare_price - price) / compare_price) * 100) : NaN;
|
|
84
91
|
return (
|
|
85
|
-
<TouchableOpacity onPress={() => handleClick(index)} key={index}>
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
<TouchableOpacity style={{ height: CARD_HEIGHT, top: 20, width: ITEM_WIDTH, marginHorizontal: 3 * (customStyles?.videoTileSpacing ?? 3), }} onPress={() => handleClick(index)} key={index}>
|
|
93
|
+
<Video
|
|
94
|
+
ref={videoRef}
|
|
95
|
+
source={{ uri: item?.thumbnail_image }}
|
|
96
|
+
controls={false}
|
|
97
|
+
repeat
|
|
98
|
+
muted
|
|
99
|
+
resizeMode={"cover"}
|
|
100
|
+
// paused={index !== activeIndex}
|
|
101
|
+
// onLoad={() => handleVideoLoad(index)}
|
|
102
|
+
|
|
103
|
+
style={{
|
|
104
|
+
aspectRatio: 0.5625,
|
|
105
|
+
borderRadius: 10,
|
|
106
|
+
width: ITEM_WIDTH,
|
|
107
|
+
height: CARD_HEIGHT
|
|
108
|
+
}}
|
|
109
|
+
/>
|
|
110
|
+
{(customStyles?.showProductDetails) &&
|
|
111
|
+
<View style={{ display: 'flex', paddingTop: 10, gap: 4 }}>
|
|
112
|
+
<Text
|
|
113
|
+
style={{ fontSize: 9, paddingRight: 4 }}
|
|
114
|
+
numberOfLines={1}
|
|
115
|
+
ellipsizeMode="tail">
|
|
116
|
+
{item?.products?.[0]?.title}
|
|
117
|
+
</Text>
|
|
118
|
+
<View style={{ display: 'flex', flexDirection: 'row', gap: 6 }}>
|
|
119
|
+
<Text
|
|
120
|
+
style={{ fontSize: 9, fontWeight: 'bold' }}
|
|
121
|
+
numberOfLines={1}
|
|
122
|
+
ellipsizeMode="tail">
|
|
123
|
+
{getPriceStringWithCurrency(price, " ", item.products?.[0]?.currency)}
|
|
124
|
+
</Text>
|
|
125
|
+
{!isNaN(compare_price) && compare_price > price &&
|
|
126
|
+
<Text
|
|
127
|
+
style={{ fontSize: 9, textDecorationLine: 'line-through', color: '#808191' }}
|
|
128
|
+
numberOfLines={1}
|
|
129
|
+
ellipsizeMode="tail">
|
|
130
|
+
{getPriceStringWithCurrency(compare_price, " ", item.products?.[0]?.currency)}
|
|
131
|
+
</Text>
|
|
132
|
+
}
|
|
133
|
+
</View>
|
|
95
134
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
135
|
+
{!isNaN(calculatedDiscount) && calculatedDiscount != 0 &&
|
|
136
|
+
<View style={{
|
|
137
|
+
alignSelf: 'flex-start',
|
|
138
|
+
backgroundColor: brandThemeColor ?? 'green',
|
|
139
|
+
alignItems: "center",
|
|
140
|
+
borderRadius: 3,
|
|
141
|
+
paddingVertical: 2.5,
|
|
142
|
+
paddingHorizontal: 4
|
|
143
|
+
}}>
|
|
144
|
+
<Text style={{
|
|
145
|
+
fontSize: 9,
|
|
146
|
+
color: 'white',
|
|
147
|
+
width: "fit-content",
|
|
148
|
+
|
|
149
|
+
}}>
|
|
150
|
+
{`${calculatedDiscount}% Off`}
|
|
151
|
+
</Text>
|
|
152
|
+
</View>}
|
|
153
|
+
</View>}
|
|
107
154
|
</TouchableOpacity>
|
|
108
155
|
);
|
|
109
156
|
};
|
|
@@ -133,13 +180,13 @@ export default function EventTileWithProduct(props) {
|
|
|
133
180
|
);
|
|
134
181
|
}
|
|
135
182
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
183
|
+
// const handleScroll = (event) => {
|
|
184
|
+
// const offsetX = event.nativeEvent.contentOffset.x;
|
|
185
|
+
// const index = Math.round((offsetX + ITEM_WIDTH)/ ITEM_WIDTH);
|
|
186
|
+
// setRenderedEvents(prev => prev + 1)
|
|
187
|
+
// setActiveIndex(index);
|
|
188
|
+
// };
|
|
142
189
|
|
|
143
190
|
|
|
144
191
|
|
|
145
|
-
|
|
192
|
+
// "react-native-video": "github:freeboub/react-native-video#chore/fixAppBoot"
|
|
@@ -4,7 +4,7 @@ import { Text, TouchableOpacity, View } from "react-native";
|
|
|
4
4
|
function ShopNow(props){
|
|
5
5
|
const whatmorePrimaryColor = getGlobalState('whatmorePrimaryColor');
|
|
6
6
|
const whatmorePrimaryFont = getGlobalState('whatmorePrimaryFont');
|
|
7
|
-
|
|
7
|
+
const customStyles= getGlobalState('customStyles');
|
|
8
8
|
// const onClick = props.onClick;
|
|
9
9
|
const height = props.height;
|
|
10
10
|
|
|
@@ -16,7 +16,7 @@ function ShopNow(props){
|
|
|
16
16
|
width: '100%',
|
|
17
17
|
height: height,
|
|
18
18
|
padding: BOX_PADDING,
|
|
19
|
-
backgroundColor: whatmorePrimaryColor
|
|
19
|
+
backgroundColor: customStyles?.brandThemeColor ?? whatmorePrimaryColor
|
|
20
20
|
}}
|
|
21
21
|
// onPress={(e) => {
|
|
22
22
|
// e.stopPropagation();
|
package/src/utils/PriceUtils.js
CHANGED
|
@@ -24,5 +24,5 @@ export function getPriceStringWithCurrency(price, spaceString = "", currencyCode
|
|
|
24
24
|
return "";
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
return getSymbolFromCurrency(currencyCode) + spaceString + priceWithCommas(roundedPrice(price));
|
|
27
|
+
return getSymbolFromCurrency(currencyCode ?? "INR") + spaceString + priceWithCommas(roundedPrice(price));
|
|
28
28
|
}
|