ordering-ui-react-native 0.16.80-release → 0.16.81-release

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.16.80-release",
3
+ "version": "0.16.81-release",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -131,26 +131,6 @@ export const OrderCreating = (props: any) => {
131
131
  <OText size={14}>{address}</OText>
132
132
  </LocationWrapper>
133
133
  )}
134
- {cart && !orderState?.options?.moment && (
135
- <DeliveryWrapper>
136
- <DeliveryContentWrapper>
137
- <SimpleIcon
138
- name='clock'
139
- size={20}
140
- color={theme.colors.primary}
141
- style={{ marginRight: 10 }}
142
- />
143
- <OText size={14}>
144
- {orderState?.options?.type === 1
145
- ? t('DELIVERY_TIME', 'Delivery Time')
146
- : t('PICK_UP', 'Pick Time')}
147
- </OText>
148
- </DeliveryContentWrapper>
149
- <View>
150
- <OText size={14} weight='700'>{parseDeliveryTime()}</OText>
151
- </View>
152
- </DeliveryWrapper>
153
- )}
154
134
  {cardData?.card?.brand && (
155
135
  <View style={{ flexDirection: 'row', marginBottom: 27 }}>
156
136
  {getIconCard(cardData?.card?.brand, 20)}
@@ -1,6 +1,6 @@
1
1
  import React, { useState, useCallback } from 'react'
2
2
 
3
- import { Platform, StyleSheet, View, TouchableOpacity } from 'react-native';
3
+ import { Platform, StyleSheet, View, TouchableOpacity, ScrollView } from 'react-native';
4
4
 
5
5
  import { OButton, OText, OLink, OModal } from '../shared'
6
6
  import {
@@ -348,9 +348,15 @@ export const OrderContentComponent = (props: OrderContent) => {
348
348
  )}
349
349
 
350
350
  {!!order?.customer?.address_notes && (
351
- <OText numberOfLines={1} mBottom={4} ellipsizeMode="tail">
352
- {order?.customer?.address_notes}
353
- </OText>
351
+ <ScrollView
352
+ showsVerticalScrollIndicator={false}
353
+ showsHorizontalScrollIndicator={false}
354
+ horizontal
355
+ >
356
+ <OText numberOfLines={1} mBottom={4} ellipsizeMode="tail">
357
+ {order?.customer?.address_notes}
358
+ </OText>
359
+ </ScrollView>
354
360
  )}
355
361
 
356
362
  {!!order?.customer?.zipcode && (
@@ -54,12 +54,12 @@ export const OrderDetailsLogisticUI = (props: OrderDetailsLogisticParams) => {
54
54
  };
55
55
 
56
56
  const handleRejectLogisticOrder = (order: any) => {
57
- handleClickLogisticOrder?.(2, orderAssingId || order?.logistic_order_id)
57
+ handleClickLogisticOrder?.(2, orderAssingId || order?.logistic_order_id, order)
58
58
  handleArrowBack()
59
59
  }
60
60
 
61
61
  const handleAcceptLogisticOrder = (order: any) => {
62
- handleClickLogisticOrder?.(1, orderAssingId || order?.logistic_order_id)
62
+ handleClickLogisticOrder?.(1, orderAssingId || order?.logistic_order_id, order)
63
63
  handleArrowBack()
64
64
  }
65
65
 
@@ -346,7 +346,7 @@ export const getOrderStatus = (s: string, t: any) => {
346
346
  return objectStatus && objectStatus;
347
347
  };
348
348
 
349
- export const transformDistance = (value : number, distanceUnit?: string) => {
349
+ export const transformDistance = (value: number, distanceUnit?: string) => {
350
350
  return distanceUnit === 'mi'
351
351
  ? (value / 1.609).toFixed(2)
352
352
  : distanceUnit === 'ft'
@@ -354,7 +354,7 @@ export const transformDistance = (value : number, distanceUnit?: string) => {
354
354
  : (value).toFixed(2)
355
355
  }
356
356
 
357
- export const formatSeconds = (seconds : number) => {
357
+ export const formatSeconds = (seconds: number) => {
358
358
  // Hours, minutes and seconds
359
359
  const hrs = Math.floor(seconds / 3600)
360
360
  const mins = Math.floor((seconds % 3600) / 60)
@@ -377,8 +377,8 @@ export const calculateDistance = (
377
377
  const lat1 = pointA.lat;
378
378
  const lon1 = pointA.lng;
379
379
 
380
- const lat2 = pointB.latitude;
381
- const lon2 = pointB.longitude;
380
+ const lat2 = pointB?.latitude;
381
+ const lon2 = pointB?.longitude;
382
382
 
383
383
  const R = 6371e3;
384
384
  const φ1 = lat1 * (Math.PI / 180);
@@ -13,8 +13,8 @@ import IconAntDesign from 'react-native-vector-icons/AntDesign'
13
13
  import {
14
14
  StyleSheet,
15
15
  View,
16
- TouchableOpacity,
17
- Platform
16
+ Platform,
17
+ Pressable
18
18
  } from 'react-native';
19
19
  import Spinner from 'react-native-loading-spinner-overlay';
20
20
  import { MomentOptionParams } from '../../types';
@@ -38,7 +38,14 @@ const MomentOptionUI = (props: MomentOptionParams) => {
38
38
  hoursList,
39
39
  dateSelected,
40
40
  timeSelected,
41
- isCart,
41
+ cateringPreorder,
42
+ isCart,
43
+ preorderLeadTime,
44
+ business,
45
+ getActualSchedule,
46
+ preorderMaximumDays,
47
+ preorderMinimumDays,
48
+ isPage,
42
49
  handleAsap,
43
50
  handleChangeDate,
44
51
  handleChangeTime,
@@ -152,8 +159,8 @@ const MomentOptionUI = (props: MomentOptionParams) => {
152
159
 
153
160
  const [selectedTime, setSelectedTime] = useState(null);
154
161
  const [datesWhitelist, setDateWhitelist] = useState<any>([{ start: null, end: null }])
155
- const [selectDate, setSelectedDate] = useState<any>(null)
156
-
162
+ const [selectDate, setSelectedDate] = useState<any>(dateSelected)
163
+ const [timeList, setTimeList] = useState<any>(hoursList)
157
164
  const goToBack = () => navigation?.canGoBack() && navigation.goBack();
158
165
 
159
166
  const _handleAsap = () => {
@@ -165,9 +172,9 @@ const MomentOptionUI = (props: MomentOptionParams) => {
165
172
  }
166
173
  };
167
174
 
168
- const handleChangeMoment = () => {
175
+ const handleChangeMoment = (time?: any) => {
169
176
  setMomentState({ isLoading: 1, isEditing: true });
170
- handleChangeTime(selectedTime);
177
+ handleChangeTime(time ?? selectedTime);
171
178
  };
172
179
 
173
180
  const momento = moment(
@@ -206,6 +213,14 @@ const MomentOptionUI = (props: MomentOptionParams) => {
206
213
  if (handleChangeDate) handleChangeDate(moment(val).format('YYYY-MM-DD'))
207
214
  }
208
215
 
216
+ const handleChangeTimeSelected = (time: any) => {
217
+ if (cateringPreorder) {
218
+ handleChangeMoment(time)
219
+ } else {
220
+ setSelectedTime(time)
221
+ }
222
+ }
223
+
209
224
  const LeftSelector = () => {
210
225
  return (
211
226
  <View style={{ height: '100%', justifyContent: 'flex-end' }}>
@@ -232,20 +247,25 @@ const MomentOptionUI = (props: MomentOptionParams) => {
232
247
 
233
248
  useEffect(() => {
234
249
  if (datesList?.length > 0) {
235
- const _datesList = datesList.slice(0, Number(configs?.max_days_preorder?.value || 6))
236
- const minDateParts = _datesList[0].split('-')
237
- const maxDateParts = _datesList[_datesList.length - 1].split('-')
238
- const _minDate = new Date(minDateParts[0], minDateParts[1] - 1, minDateParts[2])
239
- const _maxDate = new Date(maxDateParts[0], maxDateParts[1] - 1, maxDateParts[2])
240
- setDateWhitelist([{ start: _minDate, end: _maxDate }])
250
+ const _datesList = datesList.slice((cateringPreorder && preorderMinimumDays) || 0, Number(cateringPreorder ? preorderMaximumDays || configs?.max_days_preorder?.value : configs?.max_days_preorder?.value ?? 6))
251
+ if (_datesList?.length > 0) {
252
+ const minDateParts = _datesList?.[0]?.split('-')
253
+ const maxDateParts = _datesList[_datesList.length - 1].split('-')
254
+ const _minDate = new Date(minDateParts[0], minDateParts[1] - 1, minDateParts[2])
255
+ const _maxDate = new Date(maxDateParts[0], maxDateParts[1] - 1, maxDateParts[2])
256
+ setDateWhitelist([{ start: _minDate, end: _maxDate }])
257
+ }
241
258
  }
242
- }, [datesList])
259
+ }, [JSON.stringify(datesList), preorderMinimumDays, preorderMaximumDays, cateringPreorder])
243
260
 
244
261
  useEffect(() => {
245
262
  if (dateSelected) {
246
263
  const dateParts = dateSelected.split('-')
247
264
  const _dateSelected = new Date(dateParts[0], dateParts[1] - 1, dateParts[2])
248
265
  setSelectedDate(_dateSelected)
266
+ if (cateringPreorder) {
267
+ onSelectDate(_dateSelected)
268
+ }
249
269
  }
250
270
  }, [dateSelected])
251
271
 
@@ -253,42 +273,98 @@ const MomentOptionUI = (props: MomentOptionParams) => {
253
273
  setSelectedTime(timeSelected)
254
274
  }, [timeSelected])
255
275
 
276
+ useEffect(() => {
277
+ if (cateringPreorder) {
278
+ let _timeLists = []
279
+ const schedule = business && getActualSchedule()
280
+ if (!schedule && business) {
281
+ return
282
+ }
283
+ _timeLists = hoursList
284
+ .filter(hour => (!business || schedule?.lapses?.some((lapse: any) =>
285
+ moment(dateSelected + ` ${hour.startTime}`) >= moment(dateSelected + ` ${lapse.open.hour}:${lapse.open.minute}`).add(preorderLeadTime, 'minutes') && moment(dateSelected + ` ${hour.endTime}`) <= moment(dateSelected + ` ${lapse.close.hour}:${lapse.close.minute}`))) &&
286
+ moment(dateSelected + ` ${hour.startTime}`) < moment(dateSelected + ` ${hour.endTime}`) &&
287
+ (moment().add(preorderLeadTime, 'minutes') < moment(dateSelected + ` ${hour.startTime}`) || !cateringPreorder))
288
+ .map(hour => {
289
+ return {
290
+ value: hour.startTime,
291
+ text: is12hours ? (
292
+ hour.startTime.includes('12')
293
+ ? `${hour.startTime}PM`
294
+ : parseTime(moment(hour.startTime, 'HH:mm'), { outputFormat: 'hh:mma' })
295
+ ) : (
296
+ parseTime(moment(hour.startTime, 'HH:mm'), { outputFormat: 'HH:mm' })
297
+ ),
298
+ endText: is12hours ? (
299
+ hour.endTime.includes('12')
300
+ ? `${hour.endTime}PM`
301
+ : parseTime(moment(hour.endTime, 'HH:mm'), { outputFormat: 'hh:mma' })
302
+ ) : (
303
+ parseTime(moment(hour.endTime, 'HH:mm'), { outputFormat: 'HH:mm' })
304
+ )
305
+ }
306
+ })
307
+ if (_timeLists?.length > 0) {
308
+ setTimeList(_timeLists)
309
+ }
310
+ } else {
311
+ setTimeList(hoursList.map(hour => {
312
+ return {
313
+ value: hour.startTime,
314
+ text: is12hours ? (
315
+ hour.startTime.includes('12')
316
+ ? `${hour.startTime}PM`
317
+ : parseTime(moment(hour.startTime, 'HH:mm'), { outputFormat: 'hh:mma' })
318
+ ) : (
319
+ parseTime(moment(hour.startTime, 'HH:mm'), { outputFormat: 'HH:mm' })
320
+ )
321
+ }
322
+ }))
323
+ }
324
+ }, [dateSelected, JSON.stringify(hoursList), JSON.stringify(datesWhitelist), cateringPreorder, JSON.stringify(business)])
325
+
256
326
  return (
257
327
  <>
258
328
  <Container
259
329
  style={{
260
- paddingLeft: 40,
261
- paddingRight: 40
262
- }}>
263
- <View style={{ paddingBottom: 90, paddingRight: 20 }}>
264
- <NavBar
265
- onActionLeft={() => goToBack()}
266
- btnStyle={{ paddingLeft: 0 }}
267
- style={{ paddingBottom: 0 }}
268
- paddingTop={Platform.OS === 'ios' ? 10 : 0}
269
- title={t('QUESTION_WHEN_ORDER', 'When do you want your order?')}
270
- titleAlign={'center'}
271
- titleStyle={{ fontSize: 14, marginRight: 0, marginLeft: 0 }}
272
- titleWrapStyle={{ paddingHorizontal: 0 }}
273
- />
274
- <WrapSelectOption
275
- onPress={() => _handleAsap()}
276
- disabled={orderState.loading} style={{ alignItems: 'flex-start' }}>
277
- {optionSelected.isAsap ? (
278
- <OIcon
279
- src={theme.images.general.option_checked}
280
- width={16}
281
- style={{ marginEnd: 24 }}
282
- />
283
- ) : (
284
- <OIcon
285
- src={theme.images.general.option_normal}
286
- width={16}
287
- style={{ marginEnd: 24 }}
288
- />
289
- )}
290
- <OText color={optionSelected.isAsap ? theme.colors.textNormal : theme.colors.disabled}>{t('ASAP_ABBREVIATION', 'ASAP') + ` (${t(moment().format('dddd')?.toLocaleUpperCase(), moment().format('dddd'))}, ${t(monthsEnum[moment().format('MMM')], moment().format('MMM'))}${moment().format(' D, yyyy h:mm A')} + ${t('DELIVERY_TIME', 'delivery time')})`}</OText>
291
- </WrapSelectOption>
330
+ paddingLeft: !cateringPreorder || isPage ? 40 : 0,
331
+ paddingRight: !cateringPreorder || isPage ? 40 : 0
332
+ }}
333
+ nestedScrollEnabled
334
+ >
335
+ <View style={{ paddingBottom: cateringPreorder ? 0 : 90, paddingRight: 20 }}>
336
+ {!isCart && (
337
+ <NavBar
338
+ onActionLeft={() => goToBack()}
339
+ btnStyle={{ paddingLeft: 0 }}
340
+ style={{ paddingBottom: 0 }}
341
+ paddingTop={Platform.OS === 'ios' ? 10 : 0}
342
+ title={t('QUESTION_WHEN_ORDER', 'When do you want your order?')}
343
+ titleAlign={'center'}
344
+ titleStyle={{ fontSize: 20, marginRight: 0, marginLeft: 0 }}
345
+ titleWrapStyle={{ paddingHorizontal: 0 }}
346
+ />
347
+ )}
348
+ {(preorderMinimumDays === 0 && preorderLeadTime === 0) || !cateringPreorder && (
349
+ <WrapSelectOption
350
+ onPress={() => _handleAsap()}
351
+ disabled={orderState.loading} style={{ alignItems: 'flex-start' }}>
352
+ {optionSelected.isAsap ? (
353
+ <OIcon
354
+ src={theme.images.general.option_checked}
355
+ width={16}
356
+ style={{ marginEnd: 24 }}
357
+ />
358
+ ) : (
359
+ <OIcon
360
+ src={theme.images.general.option_normal}
361
+ width={16}
362
+ style={{ marginEnd: 24 }}
363
+ />
364
+ )}
365
+ <OText color={optionSelected.isAsap ? theme.colors.textNormal : theme.colors.disabled}>{t('ASAP_ABBREVIATION', 'ASAP') + ` (${t(moment().format('dddd')?.toLocaleUpperCase(), moment().format('dddd'))}, ${t(monthsEnum[moment().format('MMM')], moment().format('MMM'))}${moment().format(' D, yyyy h:mm A')} + ${t('DELIVERY_TIME', 'delivery time')})`}</OText>
366
+ </WrapSelectOption>
367
+ )}
292
368
  <WrapSelectOption
293
369
  onPress={() => setOptionSelected({ isAsap: false, isSchedule: true })}
294
370
  disabled={orderState.loading}>
@@ -307,57 +383,80 @@ const MomentOptionUI = (props: MomentOptionParams) => {
307
383
  )}
308
384
  <OText color={optionSelected.isSchedule ? theme.colors.textNormal : theme.colors.disabled}>{t('SCHEDULE_FOR_LATER', 'Schedule for later')}</OText>
309
385
  </WrapSelectOption>
310
-
311
386
  {optionSelected.isSchedule && (
312
387
  <OrderTimeWrapper>
313
- <View style={{ flex: 1 }}>
314
- {selectDate && datesWhitelist[0]?.start !== null && (
315
- <CalendarStrip
316
- scrollable
317
- style={styles.calendar}
318
- calendarHeaderContainerStyle={styles.calendarHeaderContainer}
319
- calendarHeaderStyle={styles.calendarHeader}
320
- dateNumberStyle={styles.dateNumber}
321
- dateNameStyle={styles.dateName}
322
- iconContainer={{ flex: 0.1 }}
323
- highlightDateNameStyle={styles.highlightDateName}
324
- highlightDateNumberStyle={styles.highlightDateNumber}
325
- dayContainerStyle={{ height: '100%' }}
326
- highlightDateContainerStyle={{ height: '100%' }}
327
- calendarHeaderFormat='MMMM, YYYY'
328
- iconStyle={{ borderWidth: 1 }}
329
- selectedDate={selectDate}
330
- datesWhitelist={datesWhitelist}
331
- disabledDateNameStyle={styles.disabledDateName}
332
- disabledDateNumberStyle={styles.disabledDateNumber}
333
- disabledDateOpacity={0.6}
334
- onDateSelected={(date) => onSelectDate(date)}
335
- leftSelector={<LeftSelector />}
336
- rightSelector={<RightSelector />}
337
- />
338
- )}
339
- </View>
340
- <TimeListWrapper nestedScrollEnabled={true}>
388
+ {datesWhitelist[0]?.start === datesWhitelist[0]?.end && (
389
+ <OText>
390
+ {moment(selectDate).format('Do MMMM, YYYY')}
391
+ </OText>
392
+ )}
393
+ {datesWhitelist[0]?.start !== datesWhitelist[0]?.end && (
394
+ <View style={{ flex: 1 }}>
395
+ {selectDate && datesWhitelist[0]?.start !== null && (
396
+ <CalendarStrip
397
+ scrollable
398
+ style={styles.calendar}
399
+ calendarHeaderContainerStyle={styles.calendarHeaderContainer}
400
+ calendarHeaderStyle={styles.calendarHeader}
401
+ dateNumberStyle={styles.dateNumber}
402
+ dateNameStyle={styles.dateName}
403
+ iconContainer={{ flex: 0.1 }}
404
+ highlightDateNameStyle={styles.highlightDateName}
405
+ highlightDateNumberStyle={styles.highlightDateNumber}
406
+ dayContainerStyle={{ height: '100%' }}
407
+ highlightDateContainerStyle={{ height: '100%' }}
408
+ calendarHeaderFormat='MMMM, YYYY'
409
+ iconStyle={{ borderWidth: 1 }}
410
+ selectedDate={dateSelected}
411
+ datesWhitelist={datesWhitelist}
412
+ minDate={moment()}
413
+ maxDate={cateringPreorder ? moment().add(preorderMaximumDays, 'days') : undefined}
414
+ disabledDateNameStyle={styles.disabledDateName}
415
+ disabledDateNumberStyle={styles.disabledDateNumber}
416
+ disabledDateOpacity={0.6}
417
+ onDateSelected={(date) => onSelectDate(date)}
418
+ leftSelector={<LeftSelector />}
419
+ rightSelector={<RightSelector />}
420
+ />
421
+ )}
422
+ </View>
423
+ )}
424
+ <TimeListWrapper nestedScrollEnabled={true} cateringPreorder={cateringPreorder}>
341
425
  <TimeContentWrapper>
342
- {hoursList.map((time: any, i: number) => (
343
- <TouchableOpacity key={i} onPress={() => setSelectedTime(time.startTime)}>
344
- <TimeItem active={selectedTime === time.startTime}>
426
+ {timeList.map((time: any, i: number) => (
427
+ <Pressable key={i} onPress={() => handleChangeTimeSelected(time.value)}>
428
+ <TimeItem
429
+ active={selectedTime === time.value}
430
+ cateringPreorder={cateringPreorder}
431
+ >
432
+ {cateringPreorder && (
433
+ <>
434
+ {selectedTime === time.value ? (
435
+ <OIcon
436
+ src={theme.images.general.option_checked}
437
+ width={18}
438
+ style={{ marginEnd: 24, bottom: 2 }}
439
+ />
440
+ ) : (
441
+ <OIcon
442
+ src={theme.images.general.option_normal}
443
+ width={18}
444
+ style={{ marginEnd: 24, bottom: 2 }}
445
+ />
446
+ )}
447
+ </>
448
+ )}
345
449
  <OText
346
- size={14}
347
- color={selectedTime === time.startTime ? theme.colors.primary : theme.colors.textNormal}
450
+ size={cateringPreorder ? 18 : 16}
451
+ color={selectedTime === time.value ? theme.colors.primary : theme.colors.textNormal}
348
452
  style={{
349
453
  lineHeight: 24
350
454
  }}
351
- >{is12hours ? (
352
- time.startTime.includes('12')
353
- ? `${time.startTime}PM`
354
- : parseTime(moment(time.startTime, 'HH:mm'), { outputFormat: 'hh:mma' })
355
- ) : time.startTime
356
- }</OText>
455
+ >{time.text} {cateringPreorder && `- ${time.endText}`}</OText>
357
456
  </TimeItem>
358
- </TouchableOpacity>
457
+ </Pressable>
359
458
  ))}
360
- {hoursList.length % 3 === 2 && (
459
+ {timeList.length % 3 === 2 && (
361
460
  <TimeItem style={{ backgroundColor: 'transparent' }} />
362
461
  )}
363
462
  </TimeContentWrapper>
@@ -367,7 +466,7 @@ const MomentOptionUI = (props: MomentOptionParams) => {
367
466
  </View>
368
467
  <Spinner visible={momentState.isLoading === 1} />
369
468
  </Container>
370
- {!isCart && (
469
+ {!isCart && !cateringPreorder && (
371
470
  <View style={{ position: 'absolute', bottom: bottom, paddingBottom: 20, paddingHorizontal: 40, backgroundColor: 'white', width: '100%' }}>
372
471
  <OButton onClick={() => handleChangeMoment()} isDisabled={!selectedTime} text={t('CONTINUE', 'Continue')} style={{ borderRadius: 7.6, height: 44, shadowOpacity: 0 }} textStyle={{ color: 'white', fontSize: 14 }} showNextIcon />
373
472
  </View>
@@ -279,6 +279,7 @@ const MultiCheckoutUI = (props: any) => {
279
279
  hideDeliveryFee={configs?.multi_business_checkout_show_combined_delivery_fee?.value === '1'}
280
280
  hideDriverTip={configs?.multi_business_checkout_show_combined_driver_tip?.value === '1'}
281
281
  onNavigationRedirect={(route: string, params: any) => props.navigation.navigate(route, params)}
282
+ businessConfigs={cart?.business?.configs}
282
283
  />
283
284
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 13, marginHorizontal: -40 }} />
284
285
  </React.Fragment>