ordering-ui-react-native 0.16.47 → 0.16.50

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.
@@ -49,7 +49,7 @@ export const ProductDescription = styled.View`
49
49
  `
50
50
 
51
51
  export const ProductEditions = styled.View`
52
-
52
+ padding: 0 40px;
53
53
  `
54
54
 
55
55
  export const SectionTitle = styled.View`
@@ -99,4 +99,8 @@ export const WeightUnitItem = styled.View`
99
99
  `}
100
100
  `
101
101
  export const ProductSummary = styled.View`
102
+ padding: 26px 40px;
103
+ position: relative;
104
+ background-color: white;
105
+ z-index: 100;
102
106
  `
@@ -1,5 +1,4 @@
1
1
  import React, { useState } from 'react';
2
- import moment from 'moment';
3
2
  import {
4
3
  SingleOrderCard as SingleOrderCardController,
5
4
  useUtils,
@@ -36,20 +35,20 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
36
35
  handleClickOrder
37
36
  } = props;
38
37
 
39
- const [{ parsePrice, optimizeImage }] = useUtils();
38
+ const [{ parsePrice, optimizeImage, parseDate }] = useUtils();
40
39
  const [, t] = useLanguage();
41
- const theme = useTheme();
40
+ const theme = useTheme();
42
41
 
43
- const [reorderSelected, setReorderSelected] = useState<number | null>(null);
42
+ const [reorderSelected, setReorderSelected] = useState<number | null>(null);
44
43
 
45
- const allowedOrderStatus = [1, 2, 5, 6, 10, 11, 12];
44
+ const allowedOrderStatus = [1, 2, 5, 6, 10, 11, 12];
46
45
 
47
46
  const styles = StyleSheet.create({
48
- logo: {
49
- borderRadius: 8,
50
- width: 64,
51
- height: 64
52
- },
47
+ logo: {
48
+ borderRadius: 8,
49
+ width: 64,
50
+ height: 64
51
+ },
53
52
  logoWrapper: {
54
53
  overflow: 'hidden',
55
54
  backgroundColor: 'white',
@@ -62,79 +61,75 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
62
61
  },
63
62
  buttonText: {
64
63
  color: theme.colors.primary,
65
- fontSize: 10,
66
- marginLeft: 2,
67
- marginRight: 2,
64
+ fontSize: 10,
65
+ marginLeft: 2,
66
+ marginRight: 2,
68
67
  },
69
68
  reorderLoading: {
70
69
  width: 80,
71
- height: 40,
72
- borderRadius: 10,
70
+ height: 40,
71
+ borderRadius: 10,
73
72
  },
74
73
  reorderbutton: {
75
- height: 23,
76
- paddingLeft: 10,
77
- paddingRight: 10,
78
- borderRadius: 23,
79
- shadowOpacity: 0,
80
- backgroundColor: theme.colors.primaryContrast,
81
- borderWidth: 0,
82
- },
74
+ height: 23,
75
+ paddingLeft: 10,
76
+ paddingRight: 10,
77
+ borderRadius: 23,
78
+ shadowOpacity: 0,
79
+ backgroundColor: theme.colors.primaryContrast,
80
+ borderWidth: 0,
81
+ },
83
82
  reviewButton: {
84
- height: 23,
85
- maxHeight: 23,
86
- backgroundColor: theme.colors.white,
87
- alignItems: 'center',
88
- justifyContent: 'center',
89
- paddingHorizontal: 10,
90
- borderRadius: 23,
91
- borderWidth: 1,
92
- borderColor: theme.colors.primaryContrast,
83
+ height: 23,
84
+ maxHeight: 23,
85
+ backgroundColor: theme.colors.white,
86
+ alignItems: 'center',
87
+ justifyContent: 'center',
88
+ paddingHorizontal: 10,
89
+ borderRadius: 23,
90
+ borderWidth: 1,
91
+ borderColor: theme.colors.primaryContrast,
93
92
  marginRight: 2
94
- },
93
+ },
95
94
  infoText: {
96
95
  flexDirection: 'row',
97
96
  alignItems: 'center'
98
97
  }
99
- });
98
+ });
100
99
 
101
100
  const handleReorderClick = (id: number) => {
102
- setReorderSelected(id);
103
- handleReorder && handleReorder(id);
104
- };
101
+ setReorderSelected(id);
102
+ handleReorder && handleReorder(id);
103
+ };
105
104
 
106
105
  const handleClickOrderReview = (order: any) => {
107
106
  if (pastOrders) {
108
107
  onNavigationRedirect &&
109
- onNavigationRedirect('ReviewOrder', {
110
- order: {
111
- id: order?.id,
112
- business_id: order?.business_id,
113
- logo: order?.business?.logo,
114
- driver: order?.driver,
115
- products: order?.products,
116
- review: order?.review,
117
- user_review: order?.user_review
118
- },
119
- });
108
+ onNavigationRedirect('ReviewOrder', {
109
+ order: {
110
+ id: order?.id,
111
+ business_id: order?.business_id,
112
+ logo: order?.business?.logo,
113
+ driver: order?.driver,
114
+ products: order?.products,
115
+ review: order?.review,
116
+ user_review: order?.user_review
117
+ },
118
+ });
120
119
  return
121
120
  }
122
121
  if (isMessageView) {
123
- handleClickOrder(order?.uuid)
124
- return
125
- }
126
- onNavigationRedirect &&
127
- onNavigationRedirect('OrderDetails', { orderId: order?.uuid });
128
- };
122
+ handleClickOrder(order?.uuid)
123
+ return
124
+ }
125
+ onNavigationRedirect &&
126
+ onNavigationRedirect('OrderDetails', { orderId: order?.uuid });
127
+ };
129
128
 
130
129
  const handleClickViewOrder = (uuid: string) => {
131
- onNavigationRedirect &&
132
- onNavigationRedirect('OrderDetails', { orderId: uuid });
133
- };
134
-
135
- const formatDate = (date: string, option?: any) => {
136
- return option?.utc ? moment.utc(date).format('DD/MM/YY \u2022 h:m a') : moment(date).format('DD/MM/YY \u2022 h:m a');
137
- };
130
+ onNavigationRedirect &&
131
+ onNavigationRedirect('OrderDetails', { orderId: uuid });
132
+ };
138
133
 
139
134
  const handleChangeFavorite = () => {
140
135
  handleFavoriteOrder && handleFavoriteOrder(!order?.favorite)
@@ -143,7 +138,7 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
143
138
  return (
144
139
  <Container
145
140
  onPress={() => handleClickViewOrder(order?.uuid)}
146
- activeOpacity={0.7}
141
+ activeOpacity={0.7}
147
142
  >
148
143
  <InnerContainer>
149
144
  {!!order.business?.logo && (
@@ -164,22 +159,22 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
164
159
  {!!!pastOrders && (
165
160
  <>
166
161
  {isMessageView ? (
167
- <>
168
- {order?.unread_count > 0 && (
169
- <UnreadMessageCounter>
170
- <OText size={12} color={theme.colors.primary} lineHeight={18} >
171
- {order?.unread_count}
172
- </OText>
173
- </UnreadMessageCounter>
174
- )}
175
- </>
176
- ) : (
177
- <Price>
178
- <OText size={12} lineHeight={18}>
179
- {parsePrice(order?.summary?.total || order?.total)}
180
- </OText>
181
- </Price>
182
- )}
162
+ <>
163
+ {order?.unread_count > 0 && (
164
+ <UnreadMessageCounter>
165
+ <OText size={12} color={theme.colors.primary} lineHeight={18} >
166
+ {order?.unread_count}
167
+ </OText>
168
+ </UnreadMessageCounter>
169
+ )}
170
+ </>
171
+ ) : (
172
+ <Price>
173
+ <OText size={12} lineHeight={18}>
174
+ {parsePrice(order?.summary?.total || order?.total)}
175
+ </OText>
176
+ </Price>
177
+ )}
183
178
  </>
184
179
  )}
185
180
  {!!pastOrders && (
@@ -243,29 +238,27 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
243
238
  color={theme.colors.textSecondary}
244
239
  style={{ marginVertical: 3 }}
245
240
  numberOfLines={1}>
246
- {order?.delivery_datetime_utc
247
- ? formatDate(order?.delivery_datetime_utc)
248
- : formatDate(order?.delivery_datetime, { utc: false })}
241
+ {order?.delivery_datetime_utc ? parseDate(order?.delivery_datetime_utc) : parseDate(order?.delivery_datetime, { utc: false })}
249
242
  </OText>
250
243
  </View>
251
- <OText
252
- color={theme.colors.primary}
253
- size={10}
254
- lineHeight={15}
255
- numberOfLines={1}>
256
- {getOrderStatus(order.status)?.value}
257
- </OText>
244
+ <OText
245
+ color={theme.colors.primary}
246
+ size={10}
247
+ lineHeight={15}
248
+ numberOfLines={1}>
249
+ {getOrderStatus(order.status)?.value}
250
+ </OText>
258
251
  </View>
259
252
  <TouchableOpacity
260
- onPress={handleChangeFavorite}
253
+ onPress={handleChangeFavorite}
261
254
  style={{ marginTop: 5 }}
262
- >
263
- <IconAntDesign
264
- name={order?.favorite ? 'heart' : 'hearto'}
265
- color={theme.colors.danger5}
266
- size={16}
267
- />
268
- </TouchableOpacity>
255
+ >
256
+ <IconAntDesign
257
+ name={order?.favorite ? 'heart' : 'hearto'}
258
+ color={theme.colors.danger5}
259
+ size={16}
260
+ />
261
+ </TouchableOpacity>
269
262
  </ContentFooter>
270
263
  </CardInfoWrapper>
271
264
  </InnerContainer>
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useState } from 'react';
2
2
  import {
3
3
  useLanguage,
4
4
  useConfig,
@@ -10,6 +10,8 @@ import { useTheme } from 'styled-components/native';
10
10
  import { SingleProductCardParams } from '../../types';
11
11
  import { CardContainer, CardInfo, SoldOut, QuantityContainer, PricesContainer, RibbonBox, LogoWrapper } from './styles';
12
12
  import { StyleSheet, View, TouchableOpacity, Image } from 'react-native';
13
+ import { InView } from 'react-native-intersection-observer'
14
+ import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
13
15
  import { OText } from '../shared';
14
16
  import FastImage from 'react-native-fast-image'
15
17
  import IconAntDesign from 'react-native-vector-icons/AntDesign'
@@ -29,7 +31,8 @@ const SinguleProductCardUI = React.memo((props: SingleProductCardParams) => {
29
31
  onProductClick,
30
32
  productAddedToCartLength,
31
33
  style,
32
- handleFavoriteProduct
34
+ handleFavoriteProduct,
35
+ enableIntersection
33
36
  } = props;
34
37
 
35
38
  const theme = useTheme();
@@ -87,7 +90,7 @@ const SinguleProductCardUI = React.memo((props: SingleProductCardParams) => {
87
90
  const [stateConfig] = useConfig();
88
91
  const [{ parsePrice, optimizeImage }] = useUtils();
89
92
  const [orderState] = useOrder();
90
-
93
+ const [isIntersectionObserver, setIsIntersectionObserver] = useState(!enableIntersection)
91
94
  const editMode = typeof product?.code !== 'undefined';
92
95
 
93
96
  const removeToBalance = editMode ? product?.quantity : 0;
@@ -117,103 +120,110 @@ const SinguleProductCardUI = React.memo((props: SingleProductCardParams) => {
117
120
  }
118
121
 
119
122
  return (
120
- <CardContainer
121
- style={[
122
- styles.container,
123
- (isSoldOut || maxProductQuantity <= 0) && styles.soldOutBackgroundStyle,
124
- (style && { ...style }),
125
- ]}
126
- onPress={() => onProductClick?.(product)}>
127
- {productAddedToCartLength > 0 && (
128
- <QuantityContainer style={[styles.quantityContainer, {
129
- transform: [{ translateX: 10 }, { translateY: -10 }],
130
- }]}>
131
- <OText size={12} color={theme.colors.white}>{productAddedToCartLength.toString()}</OText>
132
- </QuantityContainer>
133
- )}
134
- <CardInfo>
135
- <View style={styles.titleWrapper}>
136
- <OText
137
- size={12}
138
- weight={'500'}
139
- numberOfLines={1}
140
- ellipsizeMode="tail"
141
- style={styles.line18}>
142
- {product?.name}
143
- </OText>
144
- <TouchableOpacity
145
- onPress={handleChangeFavorite}
146
- >
147
- <IconAntDesign
148
- name={product?.favorite ? 'heart' : 'hearto'}
149
- color={theme.colors.danger5}
150
- size={18}
151
- />
152
- </TouchableOpacity>
153
- </View>
154
- <PricesContainer>
155
- <OText color={theme.colors.primary}>{product?.price ? parsePrice(product?.price) : ''}</OText>
156
- {product?.offer_price !== null && product?.in_offer && (
157
- <OText style={styles.regularPriceStyle}>{product?.offer_price ? parsePrice(product?.offer_price) : ''}</OText>
123
+ <InView style={{ minHeight: 140 }} triggerOnce={true} onChange={(inView: boolean) => setIsIntersectionObserver(true)}>
124
+ {isIntersectionObserver && (
125
+ <CardContainer
126
+ style={[
127
+ styles.container,
128
+ (isSoldOut || maxProductQuantity <= 0) && styles.soldOutBackgroundStyle,
129
+ (style && { ...style }),
130
+ ]}
131
+ onPress={() => onProductClick?.(product)}>
132
+ {productAddedToCartLength > 0 && (
133
+ <QuantityContainer style={[styles.quantityContainer, {
134
+ transform: [{ translateX: 10 }, { translateY: -10 }],
135
+ }]}>
136
+ <OText size={12} color={theme.colors.white}>{productAddedToCartLength.toString()}</OText>
137
+ </QuantityContainer>
158
138
  )}
159
- </PricesContainer>
160
- <OText
161
- size={10}
162
- numberOfLines={2}
163
- ellipsizeMode="tail"
164
- color={theme.colors.textSecondary}
165
- style={styles.line15}>
166
- {product?.description}
167
- </OText>
168
- </CardInfo>
169
- <LogoWrapper>
170
- {product?.ribbon?.enabled && (
171
- <RibbonBox
172
- bgColor={product?.ribbon?.color}
173
- isRoundRect={product?.ribbon?.shape === shape?.rectangleRound}
174
- isCapsule={product?.ribbon?.shape === shape?.capsuleShape}
175
- >
139
+ <CardInfo>
140
+ <View style={styles.titleWrapper}>
141
+ <OText
142
+ size={12}
143
+ weight={'500'}
144
+ numberOfLines={1}
145
+ ellipsizeMode="tail"
146
+ style={styles.line18}>
147
+ {product?.name}
148
+ </OText>
149
+ <TouchableOpacity
150
+ onPress={handleChangeFavorite}
151
+ >
152
+ <IconAntDesign
153
+ name={product?.favorite ? 'heart' : 'hearto'}
154
+ color={theme.colors.danger5}
155
+ size={18}
156
+ />
157
+ </TouchableOpacity>
158
+ </View>
159
+ <PricesContainer>
160
+ <OText color={theme.colors.primary}>{product?.price ? parsePrice(product?.price) : ''}</OText>
161
+ {product?.offer_price !== null && product?.in_offer && (
162
+ <OText style={styles.regularPriceStyle}>{product?.offer_price ? parsePrice(product?.offer_price) : ''}</OText>
163
+ )}
164
+ </PricesContainer>
176
165
  <OText
177
166
  size={10}
178
- weight={'400'}
179
- color={theme.colors.white}
180
167
  numberOfLines={2}
181
- ellipsizeMode='tail'
182
- lineHeight={13}
183
- >
184
- {product?.ribbon?.text}
168
+ ellipsizeMode="tail"
169
+ color={theme.colors.textSecondary}
170
+ style={styles.line15}>
171
+ {product?.description}
185
172
  </OText>
186
- </RibbonBox>
187
- )}
188
- {product?.images ? (
189
- <FastImage
190
- style={styles.productStyle}
191
- source={{
192
- uri: optimizeImage(product?.images, 'h_250,c_limit'),
193
- priority: FastImage.priority.normal,
194
- }}
195
- resizeMode={FastImage.resizeMode.cover}
196
- />
197
- ) : (
198
- <FastImage
199
- style={styles.productStyle}
200
- source={{
201
- uri: Image.resolveAssetSource(theme.images.dummies.product).uri,
202
- priority: FastImage.priority.normal,
203
- }}
204
- resizeMode={FastImage.resizeMode.cover}
205
- />
206
- )}
207
- </LogoWrapper>
208
-
209
- {(isSoldOut || maxProductQuantity <= 0) && (
210
- <SoldOut>
211
- <OText size={12} weight="bold" color={theme.colors.textSecondary} style={styles.soldOutTextStyle}>
212
- {t('SOLD_OUT', 'SOLD OUT')}
213
- </OText>
214
- </SoldOut>
173
+ </CardInfo>
174
+ <LogoWrapper>
175
+ {product?.ribbon?.enabled && (
176
+ <RibbonBox
177
+ bgColor={product?.ribbon?.color}
178
+ isRoundRect={product?.ribbon?.shape === shape?.rectangleRound}
179
+ isCapsule={product?.ribbon?.shape === shape?.capsuleShape}
180
+ >
181
+ <OText
182
+ size={10}
183
+ weight={'400'}
184
+ color={theme.colors.white}
185
+ numberOfLines={2}
186
+ ellipsizeMode='tail'
187
+ lineHeight={13}
188
+ >
189
+ {product?.ribbon?.text}
190
+ </OText>
191
+ </RibbonBox>
192
+ )}
193
+ {product?.images ? (
194
+ <>
195
+ {isIntersectionObserver && (
196
+ <FastImage
197
+ style={styles.productStyle}
198
+ source={{
199
+ uri: optimizeImage(product?.images, 'h_250,c_limit'),
200
+ priority: FastImage.priority.normal,
201
+ }}
202
+ resizeMode={FastImage.resizeMode.cover}
203
+ />
204
+ )}
205
+ </>
206
+ ) : (
207
+ <FastImage
208
+ style={styles.productStyle}
209
+ source={{
210
+ uri: Image.resolveAssetSource(theme.images.dummies.product).uri,
211
+ priority: FastImage.priority.normal,
212
+ }}
213
+ resizeMode={FastImage.resizeMode.cover}
214
+ />
215
+ )}
216
+ </LogoWrapper>
217
+ {(isSoldOut || maxProductQuantity <= 0) && (
218
+ <SoldOut>
219
+ <OText size={12} weight="bold" color={theme.colors.textSecondary} style={styles.soldOutTextStyle}>
220
+ {t('SOLD_OUT', 'SOLD OUT')}
221
+ </OText>
222
+ </SoldOut>
223
+ )}
224
+ </CardContainer>
215
225
  )}
216
- </CardContainer>
226
+ </InView >
217
227
  );
218
228
  }, SingleProductCardPropsAreEqual);
219
229
 
@@ -213,6 +213,7 @@ export interface BusinessControllerParams {
213
213
  handleFavoriteBusiness?: any,
214
214
  setFavoriteIds?: any;
215
215
  handleUpdateBusinessList?: any;
216
+ enableIntersection?: boolean;
216
217
  }
217
218
  export interface BusinessProductsListingParams {
218
219
  navigation?: any;
@@ -289,15 +290,16 @@ export interface BusinessProductsListParams {
289
290
  handleUpdateProducts?: any
290
291
  }
291
292
  export interface SingleProductCardParams {
292
- businessId: any,
293
+ businessId: any;
293
294
  product: any;
294
295
  isSoldOut: boolean;
295
296
  onProductClick: any;
296
297
  productAddedToCartLength: number;
297
- style?: ViewStyle,
298
- categoryState?: any,
299
- handleFavoriteProduct?: any,
300
- handleUpdateProducts?: any
298
+ style?: ViewStyle;
299
+ categoryState?: any;
300
+ handleFavoriteProduct?: any;
301
+ handleUpdateProducts?: any;
302
+ enableIntersection?: boolean;
301
303
  }
302
304
  export interface BusinessInformationParams {
303
305
  navigation?: any,