ordering-ui-react-native 0.16.59 → 0.16.62

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.
@@ -2,6 +2,7 @@ import React, { useState } from 'react';
2
2
  import {
3
3
  SingleOrderCard as SingleOrderCardController,
4
4
  useUtils,
5
+ useOrder,
5
6
  useLanguage
6
7
  } from 'ordering-components/native';
7
8
  import { StyleSheet, TouchableOpacity, View } from 'react-native';
@@ -9,6 +10,7 @@ import { useTheme } from 'styled-components/native';
9
10
  import { OIcon, OText, OButton } from '../shared';
10
11
  import IconAntDesign from 'react-native-vector-icons/AntDesign'
11
12
  import { SingleOrderCardParams } from '../../types';
13
+ import { OAlert } from '../../../../../src/components/shared'
12
14
 
13
15
  import {
14
16
  Container,
@@ -32,14 +34,18 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
32
34
  onNavigationRedirect,
33
35
  pastOrders,
34
36
  isMessageView,
35
- handleClickOrder
37
+ handleClickOrder,
38
+ handleRemoveCart,
39
+ cartState
36
40
  } = props;
37
41
 
38
42
  const [{ parsePrice, optimizeImage, parseDate }] = useUtils();
39
43
  const [, t] = useLanguage();
44
+ const [{ carts }] = useOrder()
40
45
  const theme = useTheme();
41
46
 
42
47
  const [reorderSelected, setReorderSelected] = useState<number | null>(null);
48
+ const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
43
49
 
44
50
  const allowedOrderStatus = [1, 2, 5, 6, 10, 11, 12];
45
51
 
@@ -97,9 +103,21 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
97
103
  }
98
104
  });
99
105
 
100
- const handleReorderClick = (id: number) => {
101
- setReorderSelected(id);
102
- handleReorder && handleReorder(id);
106
+ const handleReorderClick = (order: any) => {
107
+ if (carts[`businessId:${order?.business_id}`] && carts[`businessId:${order?.business_id}`]?.products?.length > 0) {
108
+ setConfirm({
109
+ open: true,
110
+ content: [t('QUESTION_DELETE_PRODUCTS_FROM_CART', 'Are you sure that you want to delete all products from cart?')],
111
+ title: t('ORDER', 'Order'),
112
+ handleOnAccept: async () => {
113
+ handleRemoveCart()
114
+ setConfirm({ ...confirm, open: false })
115
+ }
116
+ })
117
+ } else {
118
+ setReorderSelected(order?.id);
119
+ handleReorder && handleReorder(order?.id);
120
+ }
103
121
  };
104
122
 
105
123
  const handleClickOrderReview = (order: any) => {
@@ -135,134 +153,151 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
135
153
  handleFavoriteOrder && handleFavoriteOrder(!order?.favorite)
136
154
  };
137
155
 
156
+ const handleOriginalReorder = () => {
157
+ setConfirm({ ...confirm, open: false, title: null })
158
+ setReorderSelected(order?.id);
159
+ handleReorder && handleReorder(order?.id);
160
+ }
161
+
138
162
  return (
139
- <Container
140
- onPress={() => handleClickViewOrder(order?.uuid)}
141
- activeOpacity={0.7}
142
- >
143
- <InnerContainer>
144
- {!!order.business?.logo && (
145
- <Logo style={styles.logoWrapper}>
146
- <OIcon
147
- url={optimizeImage(order.business?.logo, 'h_300,c_limit')}
148
- style={styles.logo}
149
- />
150
- </Logo>
151
- )}
152
- <CardInfoWrapper>
153
- <ContentHeader>
154
- <View style={{ flex: 1 }}>
155
- <OText size={12} lineHeight={18} weight={'600'} numberOfLines={1} ellipsizeMode={'tail'}>
156
- {order.business?.name}
157
- </OText>
158
- </View>
159
- {!!!pastOrders && (
160
- <>
161
- {isMessageView ? (
162
- <>
163
- {order?.unread_count > 0 && (
164
- <UnreadMessageCounter>
165
- <OText size={12} color={theme.colors.primary} lineHeight={18} >
166
- {order?.unread_count}
163
+ <>
164
+ <Container
165
+ onPress={() => handleClickViewOrder(order?.uuid)}
166
+ activeOpacity={0.7}
167
+ >
168
+ <InnerContainer>
169
+ {!!order.business?.logo && (
170
+ <Logo style={styles.logoWrapper}>
171
+ <OIcon
172
+ url={optimizeImage(order.business?.logo, 'h_300,c_limit')}
173
+ style={styles.logo}
174
+ />
175
+ </Logo>
176
+ )}
177
+ <CardInfoWrapper>
178
+ <ContentHeader>
179
+ <View style={{ flex: 1 }}>
180
+ <OText size={12} lineHeight={18} weight={'600'} numberOfLines={1} ellipsizeMode={'tail'}>
181
+ {order.business?.name}
182
+ </OText>
183
+ </View>
184
+ {!!!pastOrders && (
185
+ <>
186
+ {isMessageView ? (
187
+ <>
188
+ {order?.unread_count > 0 && (
189
+ <UnreadMessageCounter>
190
+ <OText size={12} color={theme.colors.primary} lineHeight={18} >
191
+ {order?.unread_count}
192
+ </OText>
193
+ </UnreadMessageCounter>
194
+ )}
195
+ </>
196
+ ) : (
197
+ <Price>
198
+ <OText size={12} lineHeight={18}>
199
+ {parsePrice(order?.summary?.total || order?.total)}
200
+ </OText>
201
+ </Price>
202
+ )}
203
+ </>
204
+ )}
205
+ {!!pastOrders && (
206
+ <ButtonWrapper>
207
+ {allowedOrderStatus.includes(parseInt(order?.status)) &&
208
+ !order.review && (
209
+ <TouchableOpacity
210
+ onPress={() => handleClickOrderReview(order)}
211
+ style={styles.reviewButton}>
212
+ <OText size={10} color={theme.colors.primary} numberOfLines={1}>
213
+ {t('REVIEW', 'Review')}
167
214
  </OText>
168
- </UnreadMessageCounter>
215
+ </TouchableOpacity>
169
216
  )}
170
- </>
171
- ) : (
172
- <Price>
173
- <OText size={12} lineHeight={18}>
174
- {parsePrice(order?.summary?.total || order?.total)}
175
- </OText>
176
- </Price>
177
- )}
178
- </>
179
- )}
180
- {!!pastOrders && (
181
- <ButtonWrapper>
182
- {allowedOrderStatus.includes(parseInt(order?.status)) &&
183
- !order.review && (
184
- <TouchableOpacity
185
- onPress={() => handleClickOrderReview(order)}
186
- style={styles.reviewButton}>
187
- <OText size={10} color={theme.colors.primary} numberOfLines={1}>
188
- {t('REVIEW', 'Review')}
217
+ {order.cart && (
218
+ <OButton
219
+ text={t('REORDER', 'Reorder')}
220
+ imgRightSrc={''}
221
+ textStyle={styles.buttonText}
222
+ style={
223
+ ((reorderLoading && order.id === reorderSelected) || cartState?.loading)
224
+ ? styles.reorderLoading
225
+ : styles.reorderbutton
226
+ }
227
+ onClick={() => handleReorderClick(order)}
228
+ isLoading={(reorderLoading && order.id === reorderSelected) || cartState?.loading}
229
+ />
230
+ )}
231
+ </ButtonWrapper>
232
+ )}
233
+ </ContentHeader>
234
+ <ContentFooter>
235
+ <View style={{ flex: 1 }}>
236
+ <View style={styles.infoText}>
237
+ {!!!pastOrders && (
238
+ <>
239
+ <OText
240
+ size={10}
241
+ space
242
+ color={theme.colors.textSecondary}
243
+ style={{ marginVertical: 3 }}
244
+ lineHeight={15}
245
+ numberOfLines={1}
246
+ >
247
+ {t('ORDER_NO', 'Order No') + '.'}
189
248
  </OText>
190
- </TouchableOpacity>
249
+ <OText
250
+ size={10}
251
+ color={theme.colors.textSecondary}
252
+ style={{ marginVertical: 3 }}
253
+ lineHeight={15}
254
+ numberOfLines={1}
255
+ >
256
+ {order.id + ` \u2022 `}
257
+ </OText>
258
+ </>
191
259
  )}
192
- {order.cart && (
193
- <OButton
194
- text={t('REORDER', 'Reorder')}
195
- imgRightSrc={''}
196
- textStyle={styles.buttonText}
197
- style={
198
- reorderLoading && order.id === reorderSelected
199
- ? styles.reorderLoading
200
- : styles.reorderbutton
201
- }
202
- onClick={() => handleReorderClick(order.id)}
203
- isLoading={reorderLoading && order.id === reorderSelected}
204
- />
205
- )}
206
- </ButtonWrapper>
207
- )}
208
- </ContentHeader>
209
- <ContentFooter>
210
- <View style={{ flex: 1 }}>
211
- <View style={styles.infoText}>
212
- {!!!pastOrders && (
213
- <>
214
- <OText
215
- size={10}
216
- space
217
- color={theme.colors.textSecondary}
218
- style={{ marginVertical: 3 }}
219
- lineHeight={15}
220
- numberOfLines={1}
221
- >
222
- {t('ORDER_NO', 'Order No') + '.'}
223
- </OText>
224
- <OText
225
- size={10}
226
- color={theme.colors.textSecondary}
227
- style={{ marginVertical: 3 }}
228
- lineHeight={15}
229
- numberOfLines={1}
230
- >
231
- {order.id + ` \u2022 `}
232
- </OText>
233
- </>
234
- )}
260
+ <OText
261
+ size={10}
262
+ lineHeight={15}
263
+ color={theme.colors.textSecondary}
264
+ style={{ marginVertical: 3 }}
265
+ numberOfLines={1}>
266
+ {order?.delivery_datetime_utc ? parseDate(order?.delivery_datetime_utc) : parseDate(order?.delivery_datetime, { utc: false })}
267
+ </OText>
268
+ </View>
235
269
  <OText
270
+ color={theme.colors.primary}
236
271
  size={10}
237
272
  lineHeight={15}
238
- color={theme.colors.textSecondary}
239
- style={{ marginVertical: 3 }}
240
273
  numberOfLines={1}>
241
- {order?.delivery_datetime_utc ? parseDate(order?.delivery_datetime_utc) : parseDate(order?.delivery_datetime, { utc: false })}
274
+ {getOrderStatus(order.status)?.value}
242
275
  </OText>
243
276
  </View>
244
- <OText
245
- color={theme.colors.primary}
246
- size={10}
247
- lineHeight={15}
248
- numberOfLines={1}>
249
- {getOrderStatus(order.status)?.value}
250
- </OText>
251
- </View>
252
- <TouchableOpacity
253
- onPress={handleChangeFavorite}
254
- style={{ marginTop: 5 }}
255
- >
256
- <IconAntDesign
257
- name={order?.favorite ? 'heart' : 'hearto'}
258
- color={theme.colors.danger5}
259
- size={16}
260
- />
261
- </TouchableOpacity>
262
- </ContentFooter>
263
- </CardInfoWrapper>
264
- </InnerContainer>
265
- </Container>
277
+ <TouchableOpacity
278
+ onPress={handleChangeFavorite}
279
+ style={{ marginTop: 5 }}
280
+ >
281
+ <IconAntDesign
282
+ name={order?.favorite ? 'heart' : 'hearto'}
283
+ color={theme.colors.danger5}
284
+ size={16}
285
+ />
286
+ </TouchableOpacity>
287
+ </ContentFooter>
288
+ </CardInfoWrapper>
289
+ </InnerContainer>
290
+ </Container>
291
+ <OAlert
292
+ open={confirm.open}
293
+ title={confirm.title}
294
+ content={confirm.content}
295
+ onAccept={confirm.handleOnAccept}
296
+ onCancel={() => handleOriginalReorder()}
297
+ onClose={() => handleOriginalReorder()}
298
+ />
299
+ </>
300
+
266
301
  )
267
302
  }
268
303
 
@@ -4,6 +4,7 @@ import {
4
4
  useConfig,
5
5
  useOrder,
6
6
  useUtils,
7
+ useSession,
7
8
  SingleProductCard as SingleProductCardController
8
9
  } from 'ordering-components/native';
9
10
  import { useTheme } from 'styled-components/native';
@@ -32,7 +33,9 @@ const SinguleProductCardUI = React.memo((props: SingleProductCardParams) => {
32
33
  productAddedToCartLength,
33
34
  style,
34
35
  handleFavoriteProduct,
35
- enableIntersection
36
+ enableIntersection,
37
+ navigation,
38
+ businessId
36
39
  } = props;
37
40
 
38
41
  const theme = useTheme();
@@ -86,9 +89,9 @@ const SinguleProductCardUI = React.memo((props: SingleProductCardParams) => {
86
89
  }
87
90
  });
88
91
 
89
-
90
92
  const [, t] = useLanguage();
91
93
  const [stateConfig] = useConfig();
94
+ const [{ auth }] = useSession()
92
95
  const [{ parsePrice, optimizeImage }] = useUtils();
93
96
  const [orderState] = useOrder()
94
97
  const [isIntersectionObserver, setIsIntersectionObserver] = useState(!enableIntersection)
@@ -118,7 +121,11 @@ const SinguleProductCardUI = React.memo((props: SingleProductCardParams) => {
118
121
  );
119
122
 
120
123
  const handleChangeFavorite = () => {
121
- handleFavoriteProduct && handleFavoriteProduct(!product?.favorite)
124
+ if (auth) {
125
+ handleFavoriteProduct && handleFavoriteProduct(!product?.favorite)
126
+ } else {
127
+ navigation && navigation.navigate('Login');
128
+ }
122
129
  }
123
130
 
124
131
  return (
@@ -148,7 +155,7 @@ const SinguleProductCardUI = React.memo((props: SingleProductCardParams) => {
148
155
  weight={'500'}
149
156
  numberOfLines={1}
150
157
  ellipsizeMode="tail"
151
- style={styles.line18}>
158
+ style={{ ...styles.line18, flex: 1 }}>
152
159
  {product?.name}
153
160
  </OText>
154
161
  <TouchableOpacity
@@ -49,10 +49,11 @@ const OBottomPopup = (props: Props) => {
49
49
  <View style={{ paddingTop: top, paddingBottom: bottom }}>
50
50
  <View style={styles.modalTitleStyle}>
51
51
  {closeIcon && (
52
- <TouchableOpacity onPress={onClose} style={styles.closeIconStyle}>
52
+ <TouchableOpacity onPress={() => onClose()} style={styles.closeIconStyle}>
53
53
  <OIcon
54
54
  src={closeIcon}
55
- width={30}
55
+ width={20}
56
+ height={20}
56
57
  />
57
58
  </TouchableOpacity>
58
59
  )}
@@ -93,7 +94,8 @@ const styles = StyleSheet.create({
93
94
  closeIconStyle: {
94
95
  position: 'absolute',
95
96
  left: 25,
96
- top: 22.5
97
+ top: 25,
98
+ zIndex: 100
97
99
  },
98
100
  modalTitleStyle: {
99
101
  position: 'relative',
@@ -169,6 +169,7 @@ export interface BusinessesListingParams {
169
169
  priceLevelSelected?: any;
170
170
  handleChangePriceLevel?: any;
171
171
  businessTypeSelected?: any;
172
+ logosLayout?: boolean;
172
173
  }
173
174
  export interface HighestRatedBusinessesParams {
174
175
  businessesList: { businesses: Array<any>, loading: boolean, error: null | string };
@@ -287,7 +288,8 @@ export interface BusinessProductsListParams {
287
288
  onClickCategory?: any,
288
289
  lazyLoadProductsRecommended?: boolean,
289
290
  isFiltMode?: boolean,
290
- handleUpdateProducts?: any
291
+ handleUpdateProducts?: any,
292
+ navigation?: any;
291
293
  }
292
294
  export interface SingleProductCardParams {
293
295
  businessId: any;
@@ -300,6 +302,7 @@ export interface SingleProductCardParams {
300
302
  handleFavoriteProduct?: any;
301
303
  handleUpdateProducts?: any;
302
304
  enableIntersection?: boolean;
305
+ navigation?: any;
303
306
  }
304
307
  export interface BusinessInformationParams {
305
308
  navigation?: any,
@@ -549,7 +552,9 @@ export interface OrderTypeSelectParams {
549
552
  defaultValue?: number;
550
553
  configTypes?: Array<any>;
551
554
  orderTypes: Array<any>;
552
- setOrderTypeValue?: (value: number) => any
555
+ setOrderTypeValue?: (value: number) => any,
556
+ isChewLayout?: boolean;
557
+ chewOrderTypes?: any;
553
558
  }
554
559
  export interface UpsellingProductsParams {
555
560
  isCustomMode?: boolean;
@@ -692,7 +697,9 @@ export interface SingleOrderCardParams {
692
697
  onNavigationRedirect?: (route: string, params?: any) => {},
693
698
  pastOrders: any,
694
699
  isMessageView?: any,
695
- handleClickOrder: (value: any) => {}
700
+ handleClickOrder: (value: any) => {},
701
+ handleRemoveCart: () => {},
702
+ cartState: any
696
703
  }
697
704
 
698
705
  export interface PreviousBusinessOrderedParams {