ordering-ui-react-native 0.18.40 → 0.18.41

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.18.40",
3
+ "version": "0.18.41",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -23,7 +23,7 @@ import { useTheme } from 'styled-components/native';
23
23
 
24
24
  import { ProductItemAccordion } from '../ProductItemAccordion';
25
25
 
26
- export const OrderSummary = ({ order, navigation, orderStatus }: any) => {
26
+ export const OrderSummary = ({ order, navigation, orderStatus, askBluetoothPermission, getPermissions, isGrantedPermissions, checkBluetoothPermission }: any) => {
27
27
  const handleArrowBack: any = () => {
28
28
  navigation?.canGoBack() && navigation.goBack();
29
29
  };
@@ -48,10 +48,10 @@ export const OrderSummary = ({ order, navigation, orderStatus }: any) => {
48
48
  const getSuboptions = (suboptions: any) => {
49
49
  const array: any = []
50
50
  suboptions?.length > 0 &&
51
- suboptions?.map((suboption: any) => {
52
- const string = `&nbsp;&nbsp;&nbsp;${getFormattedSubOptionName(suboption)}<br/>`
53
- array.push(string)
54
- })
51
+ suboptions?.map((suboption: any) => {
52
+ const string = `&nbsp;&nbsp;&nbsp;${getFormattedSubOptionName(suboption)}<br/>`
53
+ array.push(string)
54
+ })
55
55
 
56
56
  return array.join('')
57
57
  }
@@ -60,12 +60,12 @@ export const OrderSummary = ({ order, navigation, orderStatus }: any) => {
60
60
  const array: any = [];
61
61
 
62
62
  options?.length &&
63
- options?.map((option: any) => {
64
- const string =
65
- ` ${option.name}<br/>${getSuboptions(option.suboptions)}`;
63
+ options?.map((option: any) => {
64
+ const string =
65
+ ` ${option.name}<br/>${getSuboptions(option.suboptions)}`;
66
66
 
67
- array.push(string)
68
- })
67
+ array.push(string)
68
+ })
69
69
 
70
70
  if (productComment) {
71
71
  array.push(`${t('COMMENT', 'Comment')}<br/>&nbsp;&nbsp;&nbsp;&nbsp;${productComment}`)
@@ -88,46 +88,38 @@ export const OrderSummary = ({ order, navigation, orderStatus }: any) => {
88
88
 
89
89
  ${orderStatus} </br>
90
90
 
91
- ${t('DELIVERY_TYPE', 'Delivery Type')}: ${
92
- deliveryStatus[order?.delivery_type]
93
- }
91
+ ${t('DELIVERY_TYPE', 'Delivery Type')}: ${deliveryStatus[order?.delivery_type]
92
+ }
94
93
  </br>
95
- ${t('DELIVERY_DATE', 'Delivery Date')}: ${
96
- order?.delivery_datetime_utc
94
+ ${t('DELIVERY_DATE', 'Delivery Date')}: ${order?.delivery_datetime_utc
97
95
  ? parseDate(order?.delivery_datetime_utc)
98
96
  : parseDate(order?.delivery_datetime, { utc: false })
99
- }
97
+ }
100
98
  </br>
101
99
  ${t('PAYMENT_METHOD')}: ${order?.paymethod?.name}
102
100
  </p>
103
101
 
104
102
  <h1>${t('CUSTOMER_DETAILS', 'Customer details')}</h1>
105
- <p style="font-size: 27px"> ${t('FULL_NAME', 'Full Name')}: ${
106
- order?.customer?.name
107
- } ${order?.customer?.middle_name} ${order?.customer?.lastname} ${
108
- order?.customer?.second_lastname
109
- }
103
+ <p style="font-size: 27px"> ${t('FULL_NAME', 'Full Name')}: ${order?.customer?.name
104
+ } ${order?.customer?.middle_name} ${order?.customer?.lastname} ${order?.customer?.second_lastname
105
+ }
110
106
  </br>
111
107
  ${t('EMAIL', 'Email')}: ${order?.customer?.email}
112
108
  </br>
113
109
  ${t('MOBILE_PHONE', 'Mobile Phone')}: ${order?.customer?.cellphone}
114
110
  </br>
115
- ${
116
- !!order?.customer?.phone
117
- ? `${t('MOBILE_PHONE', 'Mobile Phone')}: ${
118
- order?.customer?.phone
119
- } </br>`
120
- : ''
121
- }
111
+ ${!!order?.customer?.phone
112
+ ? `${t('MOBILE_PHONE', 'Mobile Phone')}: ${order?.customer?.phone
113
+ } </br>`
114
+ : ''
115
+ }
122
116
  ${t('FULL_ADDRESS', 'Full Addres')}: ${order?.customer?.address}
123
117
  </br>
124
- ${
125
- !!order?.customer?.internal_number
126
- ? `${t('INTERNAL_NUMBER', 'Internal Number')}: ${
127
- order?.customer?.internal_number
128
- } </br>`
129
- : ''
130
- }
118
+ ${!!order?.customer?.internal_number
119
+ ? `${t('INTERNAL_NUMBER', 'Internal Number')}: ${order?.customer?.internal_number
120
+ } </br>`
121
+ : ''
122
+ }
131
123
  ${t('ZIPCODE', 'Zipcode')}: ${order?.customer.zipcode}
132
124
  </p>
133
125
 
@@ -139,30 +131,26 @@ export const OrderSummary = ({ order, navigation, orderStatus }: any) => {
139
131
  </br>
140
132
  ${t('BUSINESS_PHONE', 'Business Phone')}: ${order?.business?.cellphone}
141
133
  </br>
142
- ${
143
- !!order?.business?.phone
144
- ? `${t('BUSINESS_PHONE', 'Business Phone')}: ${
145
- order?.business?.phone
146
- } </br>`
147
- : ''
148
- }
134
+ ${!!order?.business?.phone
135
+ ? `${t('BUSINESS_PHONE', 'Business Phone')}: ${order?.business?.phone
136
+ } </br>`
137
+ : ''
138
+ }
149
139
 
150
140
  ${t('ADDRESS', 'Address')}: ${order?.business?.address}
151
141
  </br>
152
- ${
153
- !!order?.business?.address_notes
154
- ? `${t('SPECIAL_ADDRESS', 'Special Address')}: ${
155
- order?.business?.address_notes
156
- } `
157
- : ''
158
- }
142
+ ${!!order?.business?.address_notes
143
+ ? `${t('SPECIAL_ADDRESS', 'Special Address')}: ${order?.business?.address_notes
144
+ } `
145
+ : ''
146
+ }
159
147
  </p>
160
148
  <h1> ${t('ORDER_DETAILS', 'Order Details')}</h1>
161
149
 
162
150
  ${order?.products.length &&
163
- order?.products.map(
164
- (product: any, i: number) =>
165
- `<div style="display: flex;flexDirection:row;flex-wrap:wrap">
151
+ order?.products.map(
152
+ (product: any, i: number) =>
153
+ `<div style="display: flex;flexDirection:row;flex-wrap:wrap">
166
154
  <div style="display:flex;width:100%">
167
155
  <div style="display:flex; justify-content: flex-start; font-size: 26px; width: 70%">
168
156
  ${product?.quantity} ${product?.name}
@@ -179,8 +167,8 @@ export const OrderSummary = ({ order, navigation, orderStatus }: any) => {
179
167
  </div>
180
168
  </div>
181
169
  </div>`
182
- )
183
- }
170
+ )
171
+ }
184
172
  <div style="display: flex;">
185
173
 
186
174
  <div style="display:flex; justify-content: flex-start; font-size: 26px; width: 70%">
@@ -189,62 +177,58 @@ export const OrderSummary = ({ order, navigation, orderStatus }: any) => {
189
177
 
190
178
  <div style="display:flex; justify-content: flex-end; font-size: 26px; width: 30%">
191
179
  ${parsePrice(
192
- order.tax_type === 1
193
- ? order?.summary?.subtotal + order?.summary?.tax ?? 0
194
- : order?.summary?.subtotal ?? 0,
195
- )}
180
+ order.tax_type === 1
181
+ ? order?.summary?.subtotal + order?.summary?.tax ?? 0
182
+ : order?.summary?.subtotal ?? 0,
183
+ )}
196
184
  </div>
197
185
 
198
186
  </div>
199
187
 
200
188
  <div style="display: flex">
201
- ${
202
- order?.summary?.discount > 0
203
- ? order?.offer_type === 1
204
- ? `<div style="display:flex; justify-content: flex-start; font-size: 26px; width: 70%">
189
+ ${order?.summary?.discount > 0
190
+ ? order?.offer_type === 1
191
+ ? `<div style="display:flex; justify-content: flex-start; font-size: 26px; width: 70%">
205
192
  ${t('DISCOUNT', 'Discount')} (${verifyDecimals(
206
- order?.offer_rate,
207
- parsePrice,
208
- )}%)
193
+ order?.offer_rate,
194
+ parsePrice,
195
+ )}%)
209
196
  </div>`
210
- : `<div style="display:flex; justify-content: flex-start; font-size: 26px; width: 70%"> ${t(
211
- 'DISCOUNT',
212
- 'Discount',
213
- )}
197
+ : `<div style="display:flex; justify-content: flex-start; font-size: 26px; width: 70%"> ${t(
198
+ 'DISCOUNT',
199
+ 'Discount',
200
+ )}
214
201
  </div>`
215
- : ''
216
- }
217
- ${
218
- order?.summary?.discount > 0
219
- ? `<div style="display:flex; justify-content: flex-end; font-size: 26px; width: 30%">- ${parsePrice(
220
- order?.summary?.discount,
221
- )}
202
+ : ''
203
+ }
204
+ ${order?.summary?.discount > 0
205
+ ? `<div style="display:flex; justify-content: flex-end; font-size: 26px; width: 30%">- ${parsePrice(
206
+ order?.summary?.discount,
207
+ )}
222
208
  </div>`
223
- : ''
224
- }
209
+ : ''
210
+ }
225
211
  </div>
226
212
 
227
- ${
228
- order?.tax_type !== 1
229
- ? `<div style="font-size: 25px">
213
+ ${order?.tax_type !== 1
214
+ ? `<div style="font-size: 25px">
230
215
  ${t('TAX', 'Tax')}
231
216
  ${verifyDecimals(order?.summary?.tax_rate, parseNumber)}%
232
217
  ${parsePrice(order?.summary?.tax ?? 0)}
233
218
  ${t('TAX', 'Tax')}
234
219
  ${verifyDecimals(order?.summary?.tax_rate, parseNumber)}%
235
220
  </div>`
236
- : ''
237
- }
238
-
239
- ${
240
- order?.summary?.delivery_price > 0
241
- ? `<div style="font-size: 25px;"> ${t(
242
- 'DELIVERY_FEE',
243
- 'Delivery Fee',
244
- )}
221
+ : ''
222
+ }
223
+
224
+ ${order?.summary?.delivery_price > 0
225
+ ? `<div style="font-size: 25px;"> ${t(
226
+ 'DELIVERY_FEE',
227
+ 'Delivery Fee',
228
+ )}
245
229
  </div>`
246
- : ''
247
- }
230
+ : ''
231
+ }
248
232
 
249
233
  <div style="display: flex">
250
234
 
@@ -336,6 +320,25 @@ export const OrderSummary = ({ order, navigation, orderStatus }: any) => {
336
320
  },
337
321
  });
338
322
 
323
+ const handlePrint = async () => {
324
+ if (Platform.OS === 'ios') {
325
+ silentPrint()
326
+ return
327
+ }
328
+ const _permissions = await getPermissions()
329
+
330
+ if (!isGrantedPermissions) {
331
+ checkBluetoothPermission()
332
+ }
333
+ if (isGrantedPermissions) {
334
+ const response = await askBluetoothPermission();
335
+ const isGranted = _permissions.reduce((allPermissions: boolean, _permission: string) => allPermissions && response?.[_permission] === 'granted', true)
336
+ if (isGranted) {
337
+ printPDF()
338
+ }
339
+ }
340
+ };
341
+
339
342
  return (
340
343
  <>
341
344
  <Content>
@@ -364,17 +367,15 @@ export const OrderSummary = ({ order, navigation, orderStatus }: any) => {
364
367
  </OText>
365
368
 
366
369
  <OText style={{ marginBottom: 5 }}>
367
- {`${t('DELIVERY_TYPE', 'Delivery Type')}: ${
368
- deliveryStatus[order?.delivery_type]
369
- }`}
370
+ {`${t('DELIVERY_TYPE', 'Delivery Type')}: ${deliveryStatus[order?.delivery_type]
371
+ }`}
370
372
  </OText>
371
373
 
372
374
  <OText style={{ marginBottom: 5 }}>
373
- {`${t('DELIVERY_DATE', 'Delivery Date')}: ${
374
- order?.delivery_datetime_utc
375
+ {`${t('DELIVERY_DATE', 'Delivery Date')}: ${order?.delivery_datetime_utc
375
376
  ? parseDate(order?.delivery_datetime_utc)
376
377
  : parseDate(order?.delivery_datetime, { utc: false })
377
- }`}
378
+ }`}
378
379
  </OText>
379
380
 
380
381
  <OText style={{ marginBottom: 5 }}>{`${t('PAYMENT_METHOD')}: ${t(
@@ -399,11 +400,9 @@ export const OrderSummary = ({ order, navigation, orderStatus }: any) => {
399
400
  adjustsFontSizeToFit
400
401
  ellipsizeMode="tail"
401
402
  color={theme.colors.textGray}>
402
- {`${t('FULL_NAME', 'Full Name')}: ${order?.customer?.name} ${
403
- order?.customer?.middle_name
404
- } ${order?.customer?.lastname} ${
405
- order?.customer?.second_lastname
406
- }`}
403
+ {`${t('FULL_NAME', 'Full Name')}: ${order?.customer?.name} ${order?.customer?.middle_name
404
+ } ${order?.customer?.lastname} ${order?.customer?.second_lastname
405
+ }`}
407
406
  </OText>
408
407
 
409
408
  <OText
@@ -423,9 +422,8 @@ export const OrderSummary = ({ order, navigation, orderStatus }: any) => {
423
422
  adjustsFontSizeToFit
424
423
  ellipsizeMode="tail"
425
424
  color={theme.colors.textGray}>
426
- {`${t('MOBILE_PHONE', 'Mobile Phone')}: ${
427
- order?.customer?.cellphone
428
- }`}
425
+ {`${t('MOBILE_PHONE', 'Mobile Phone')}: ${order?.customer?.cellphone
426
+ }`}
429
427
  </OText>
430
428
 
431
429
  {!!order?.customer?.phone && (
@@ -436,9 +434,8 @@ export const OrderSummary = ({ order, navigation, orderStatus }: any) => {
436
434
  adjustsFontSizeToFit
437
435
  ellipsizeMode="tail"
438
436
  color={theme.colors.textGray}>
439
- {`${t('MOBILE_PHONE', 'Mobile Phone')}: ${
440
- order?.customer?.phone
441
- }`}
437
+ {`${t('MOBILE_PHONE', 'Mobile Phone')}: ${order?.customer?.phone
438
+ }`}
442
439
  </OText>
443
440
  )}
444
441
 
@@ -508,9 +505,8 @@ export const OrderSummary = ({ order, navigation, orderStatus }: any) => {
508
505
  numberOfLines={2}
509
506
  ellipsizeMode="tail"
510
507
  color={theme.colors.textGray}>
511
- {`${t('BUSINESS_PHONE', 'Business Phone')}: ${
512
- order?.business?.cellphone
513
- }`}
508
+ {`${t('BUSINESS_PHONE', 'Business Phone')}: ${order?.business?.cellphone
509
+ }`}
514
510
  </OText>
515
511
  )}
516
512
 
@@ -521,9 +517,8 @@ export const OrderSummary = ({ order, navigation, orderStatus }: any) => {
521
517
  numberOfLines={2}
522
518
  ellipsizeMode="tail"
523
519
  color={theme.colors.textGray}>
524
- {`${t('BUSINESS_PHONE', 'Business Phone')}: ${
525
- order?.business?.phone
526
- }`}
520
+ {`${t('BUSINESS_PHONE', 'Business Phone')}: ${order?.business?.phone
521
+ }`}
527
522
  </OText>
528
523
  )}
529
524
 
@@ -545,9 +540,8 @@ export const OrderSummary = ({ order, navigation, orderStatus }: any) => {
545
540
  adjustsFontSizeToFit
546
541
  ellipsizeMode="tail"
547
542
  color={theme.colors.textGray}>
548
- {`${t('SPECIAL_ADDRESS', 'Special Address')}: ${
549
- order?.business?.address_notes
550
- }`}
543
+ {`${t('SPECIAL_ADDRESS', 'Special Address')}: ${order?.business?.address_notes
544
+ }`}
551
545
  </OText>
552
546
  )}
553
547
  </OrderBusiness>
@@ -686,9 +680,7 @@ export const OrderSummary = ({ order, navigation, orderStatus }: any) => {
686
680
 
687
681
  <View style={{ marginBottom: 0 }}>
688
682
  <FloatingButton
689
- firstButtonClick={() =>
690
- Platform.OS === 'ios' ? silentPrint() : printPDF()
691
- }
683
+ firstButtonClick={() => handlePrint()}
692
684
  btnText={t('PRINT', 'Print')}
693
685
  color={theme.colors.green}
694
686
  widthButton={'100%'}
@@ -187,7 +187,7 @@ export const AnalyticsSegment = (props: any) => {
187
187
  segmentClient.track('Coupon Denied', {
188
188
  business_id: coupon.business_id,
189
189
  coupon: coupon.coupon,
190
- user_id: coupon.user.id,
190
+ user_id: coupon?.user_id,
191
191
  reason: typeof coupon.reason === 'string' ? t(coupon.reason) : t(coupon.reason[0])
192
192
  })
193
193
  }
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useState } from 'react'
2
- import { useLanguage, BusinessSearchList, useOrder, useUtils, showToast, ToastType } from 'ordering-components/native'
2
+ import { useLanguage, BusinessSearchList, useOrder, useUtils, useEvent, showToast, ToastType } from 'ordering-components/native'
3
3
  import { ScrollView, StyleSheet, TouchableOpacity, View, Dimensions } from 'react-native'
4
4
  import { useSafeAreaInsets } from 'react-native-safe-area-context'
5
5
  import { useTheme } from 'styled-components/native'
@@ -54,6 +54,7 @@ export const BusinessListingSearchUI = (props: BusinessSearchParams) => {
54
54
  const screenWidth = Dimensions.get('window').width;
55
55
  const theme = useTheme()
56
56
  const [orderState] = useOrder()
57
+ const [events] = useEvent()
57
58
  const { top } = useSafeAreaInsets();
58
59
  const [, t] = useLanguage()
59
60
  const [{ parsePrice, parseDistance, optimizeImage }] = useUtils();
@@ -225,6 +226,13 @@ export const BusinessListingSearchUI = (props: BusinessSearchParams) => {
225
226
  }
226
227
  };
227
228
 
229
+ const onChangeTermValue = (query: any) => {
230
+ handleChangeTermValue(query)
231
+ if (query) {
232
+ events.emit('products_searched', query)
233
+ }
234
+ }
235
+
228
236
  useEffect(() => {
229
237
  if (filters.business_types?.length === 0 && filters.orderBy === 'default' && Object.keys(filters)?.length === 2 && !openFilters) {
230
238
  handleSearchbusinessAndProducts(true)
@@ -287,7 +295,7 @@ export const BusinessListingSearchUI = (props: BusinessSearchParams) => {
287
295
  {...(isChewLayout && { height: 55 })}
288
296
  inputStyle={{ ...styles.searchInput }}
289
297
  placeholder={t('SEARCH_BUSINESSES', 'Search Businesses')}
290
- onSearch={(val: string) => handleChangeTermValue(val)}
298
+ onSearch={(val: string) => onChangeTermValue(val)}
291
299
  value={termValue}
292
300
  />
293
301
  </SearchWrapper>
@@ -261,7 +261,7 @@ const CheckoutUI = (props: any) => {
261
261
  const checkValidationFields = () => {
262
262
  setUserErrors([])
263
263
  const errors = []
264
- const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes']
264
+ const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes', 'comments']
265
265
  const _requiredFields: any = []
266
266
 
267
267
  Object.values(validationFields?.fields?.checkout).map((field: any) => {
@@ -454,7 +454,7 @@ export const MultiCheckout = (props: any) => {
454
454
  handleOnRedirectCheckout: (cartUuid: string) => {
455
455
  props.navigation.navigate('CheckoutNavigator', {
456
456
  screen: 'CheckoutPage',
457
- cartUuid: cartUuid
457
+ cartUuid
458
458
  })
459
459
  }
460
460
  }
@@ -18,7 +18,7 @@ import {
18
18
  } from "rn-placeholder";
19
19
 
20
20
  import { View, ScrollView } from 'react-native'
21
- import { getOrderStatus } from '../../utils'
21
+ import { getOrderStatus, flatArray } from '../../utils'
22
22
 
23
23
  const OrdersOptionUI = (props: OrdersOptionParams) => {
24
24
  const {
@@ -121,6 +121,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
121
121
  }
122
122
 
123
123
  useEffect(() => {
124
+ if (reorderState?.loading) return
124
125
  const _businessId = 'businessId:' + reorderState?.result?.business_id
125
126
  if (reorderState?.error) {
126
127
  if (reorderState?.result?.business_id) {
@@ -128,21 +129,39 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
128
129
  navigation.navigate('Business', { store: reorderState?.result?.business?.slug })
129
130
  }
130
131
  }
131
- if (!reorderState?.error && reorderState.loading === false && reorderState?.result?.business_id) {
132
+ if (!reorderState?.error && !reorderState.loading && reorderState?.result?.business_id) {
132
133
  const cartProducts = carts?.[_businessId]?.products
133
- const available = cartProducts.every((product: any) => product.valid === true)
134
- const orderProducts = orders.find((order: any) => order?.id === reorderState?.result?.orderId)?.products
135
134
 
136
- if (available && reorderState?.result?.uuid && (cartProducts?.length === orderProducts?.length)) {
137
- onNavigationRedirect && onNavigationRedirect('CheckoutNavigator', { cartUuid: reorderState?.result.uuid })
135
+ const available = cartProducts.every((product: any) => product.valid)
136
+ const orderProducts = orders.find(
137
+ (order: any) => Array.isArray(order?.id)
138
+ ? order?.id?.includes(reorderState?.result?.orderId)
139
+ : order?.id === reorderState?.result?.orderId
140
+ )?.products
141
+
142
+ const productsFlatten = orderProducts?.length && flatArray(orderProducts)?.filter(product => product?.order_id === reorderState?.result?.orderId)
143
+
144
+ if (available && reorderState?.result?.uuid && (cartProducts?.length === productsFlatten?.length)) {
145
+ const multiOrders = flatArray(orderProducts)?.map(product => product.order_id)
146
+ const params = multiOrders?.length > 1
147
+ ? { screen: 'MultiCheckout', checkCarts: true }
148
+ : { cartUuid: reorderState?.result.uuid }
149
+
150
+ onNavigationRedirect && onNavigationRedirect('CheckoutNavigator', params)
138
151
  } else {
139
152
  _setStoreData('adjust-cart-products', JSON.stringify(_businessId))
140
- cartProducts?.length !== orderProducts?.length && _setStoreData('already-removed', JSON.stringify('removed'))
153
+ cartProducts?.length !== productsFlatten?.length && _setStoreData('already-removed', JSON.stringify('removed'))
141
154
  navigation.navigate('Business', { store: reorderState?.result?.business?.slug })
142
155
  }
143
156
  }
144
157
  }, [reorderState])
145
158
 
159
+ useEffect(() => {
160
+ if (reorderState?.error) {
161
+ showToast(ToastType.Error, reorderState?.result)
162
+ }
163
+ }, [reorderState])
164
+
146
165
  useFocusEffect(
147
166
  React.useCallback(() => {
148
167
  if (!businessesSearchList) {
@@ -47,7 +47,7 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
47
47
  const theme = useTheme();
48
48
  const isFocused = useIsFocused();
49
49
 
50
- const [reorderSelected, setReorderSelected] = useState<number | null>(null);
50
+ let [reorderSelected, setReorderSelected] = useState<number | null>(null);
51
51
  const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
52
52
  const [isPressed, setIsPressed] = useState(false)
53
53
 
@@ -130,19 +130,29 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
130
130
  });
131
131
 
132
132
  const handleReorderClick = (order: any) => {
133
- if (carts[`businessId:${order?.business_id}`] && carts[`businessId:${order?.business_id}`]?.products?.length > 0) {
133
+ setReorderSelected(null)
134
+ reorderSelected = null
135
+ const isMultiOrders = Array.isArray(order?.id)
136
+
137
+ const isRemoveCart = isMultiOrders
138
+ ? order?.business_id?.some((businessId: any) => !!carts[`businessId:${businessId}`]?.uuid)
139
+ : carts[`businessId:${order?.business_id}`] && !!carts[`businessId:${order?.business_id}`]?.uuid
140
+
141
+ if (isRemoveCart) {
134
142
  setConfirm({
135
143
  open: true,
136
144
  content: [t('QUESTION_DELETE_PRODUCTS_FROM_CART', 'Are you sure that you want to delete all products from cart?')],
137
145
  title: t('ORDER', 'Order'),
138
146
  handleOnAccept: async () => {
139
- handleRemoveCart()
147
+ handleRemoveCart(order)
140
148
  setConfirm({ ...confirm, open: false })
141
149
  }
142
150
  })
143
151
  } else {
144
- setReorderSelected(order?.id);
145
- handleReorder && handleReorder(order?.id);
152
+ const orderId = Array.isArray(order?.id) ? order?.id[0] : order?.id
153
+ setReorderSelected(orderId)
154
+ reorderSelected = orderId
155
+ handleReorder && handleReorder(order?.id)
146
156
  }
147
157
  };
148
158
 
@@ -286,7 +296,7 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
286
296
  </OText>
287
297
  </TouchableOpacity>
288
298
  )}
289
- {order.cart && !hideReorderButton && (
299
+ {!hideReorderButton && order?.id === 'number' && (
290
300
  <OButton
291
301
  text={t('REORDER', 'Reorder')}
292
302
  imgRightSrc={''}
@@ -751,7 +751,7 @@ export interface SingleOrderCardParams {
751
751
  pastOrders: any,
752
752
  isMessageView?: any,
753
753
  handleClickOrder: (value: any) => {},
754
- handleRemoveCart: () => {},
754
+ handleRemoveCart: (value: any) => {},
755
755
  cartState: any
756
756
  }
757
757