ordering-ui-react-native 0.12.12 → 0.12.16

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.
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useState, useRef } from 'react';
2
- import { View, Pressable, StyleSheet, ScrollView, RefreshControl, Linking } from 'react-native';
2
+ import { View, Pressable, StyleSheet, ScrollView, RefreshControl, Linking, Platform } from 'react-native';
3
3
  import { useLanguage, useUtils, OrderListGroups } from 'ordering-components/native';
4
4
  import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
5
5
  import FeatherIcon from 'react-native-vector-icons/Feather';
@@ -41,11 +41,10 @@ const tabsList: any = {
41
41
  };
42
42
 
43
43
  const tabsListText: any = {
44
- 1: 'logistic_pending',
45
- 2: 'pending',
46
- 3: 'inProgress',
47
- 4: 'completed',
48
- 5: 'cancelled'
44
+ 1: 'pending',
45
+ 2: 'inProgress',
46
+ 3: 'completed',
47
+ 4: 'cancelled'
49
48
  };
50
49
 
51
50
  const swipeConfig = {
@@ -70,7 +69,10 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
70
69
  filtered,
71
70
  onFiltered,
72
71
  handleClickOrder,
73
- isBusinessApp
72
+ handleClickLogisticOrder,
73
+ isBusinessApp,
74
+ logisticOrders,
75
+ loadLogisticOrders
74
76
  } = props;
75
77
 
76
78
  const defaultSearchList = {
@@ -87,7 +89,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
87
89
  type: ''
88
90
  }
89
91
  }
90
- console.log('ORDERS', ordersGroup)
92
+
91
93
  const theme = useTheme();
92
94
  const [, t] = useLanguage();
93
95
  const [{ parseDate }] = useUtils()
@@ -125,6 +127,11 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
125
127
  zIndex: 100,
126
128
  borderColor: theme.colors.textGray,
127
129
  },
130
+ icon: {
131
+ paddingBottom: 10,
132
+ zIndex: 100,
133
+ marginBottom: 2,
134
+ },
128
135
  tagsContainer: {
129
136
  marginBottom: 20,
130
137
  },
@@ -172,7 +179,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
172
179
  const currentOrdersGroup = ordersGroup[currentTabSelected]
173
180
 
174
181
  const isEqual = (array1: any, array2: any) => {
175
- return array1.every((item: any) => array2.includes(item)) && array2.every((item: any) => array1.includes(item))
182
+ return array1?.every((item: any) => array2.includes(item)) && array2?.every((item: any) => array1.includes(item))
176
183
  }
177
184
 
178
185
  const handleLoadMore = () => {
@@ -192,7 +199,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
192
199
  }
193
200
  })
194
201
  const dateRange = calculateDate(search.date.type, search.date.from, search.date.to)
195
- onFiltered && onFiltered({...search, date: {...dateRange}})
202
+ onFiltered && onFiltered({ ...search, date: { ...dateRange } })
196
203
  setOpenModal(false)
197
204
  }
198
205
 
@@ -249,29 +256,29 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
249
256
  switch (type) {
250
257
  case 'today':
251
258
  const date = parseDate(new Date(), { outputFormat: 'MM/DD/YYYY' })
252
- return {from: `${date} 00:00:00`, to: `${date} 23:59:59`}
259
+ return { from: `${date} 00:00:00`, to: `${date} 23:59:59` }
253
260
  case 'yesterday':
254
261
  const yesterday = new Date()
255
262
  yesterday.setDate(yesterday.getDate() - 1)
256
263
  const start1 = parseDate(yesterday, { outputFormat: 'MM/DD/YYYY' })
257
264
  const end1 = parseDate(new Date(), { outputFormat: 'MM/DD/YYYY' })
258
- return {from: `${start1} 00:00:00`, to: `${end1} 23:59:59`}
265
+ return { from: `${start1} 00:00:00`, to: `${end1} 23:59:59` }
259
266
  case 'last_7days':
260
267
  const last_7days = new Date()
261
268
  last_7days.setDate(last_7days.getDate() - 6)
262
269
  const start7 = parseDate(last_7days, { outputFormat: 'MM/DD/YYYY' })
263
270
  const end7 = parseDate(new Date(), { outputFormat: 'MM/DD/YYYY' })
264
- return {from: `${start7} 00:00:00`, to: `${end7} 23:59:59`}
271
+ return { from: `${start7} 00:00:00`, to: `${end7} 23:59:59` }
265
272
  case 'last_30days':
266
273
  const last_30days = new Date()
267
274
  last_30days.setDate(last_30days.getDate() - 29)
268
275
  const start30 = parseDate(last_30days, { outputFormat: 'MM/DD/YYYY' })
269
276
  const end30 = parseDate(new Date(), { outputFormat: 'MM/DD/YYYY' })
270
- return {from: `${start30} 00:00:00`, to: `${end30} 23:59:59`}
277
+ return { from: `${start30} 00:00:00`, to: `${end30} 23:59:59` }
271
278
  default:
272
279
  const start = from ? `${parseDate(from, { outputFormat: 'MM/DD/YYYY' })} 00:00:00` : ''
273
280
  const end = to ? `${parseDate(to, { outputFormat: 'MM/DD/YYYY' })} 23:59:59` : ''
274
- return {from: start, to: end}
281
+ return { from: start, to: end }
275
282
  }
276
283
  }
277
284
 
@@ -311,22 +318,22 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
311
318
  </IconWrapper>
312
319
  </View>
313
320
  {isBusinessApp && (
314
- <View style={{ flex: 1, flexDirection: 'row', justifyContent: 'flex-start', maxHeight:40}}>
315
- <OIcon
316
- src={theme.images.general.information}
317
- width={12}
318
- height={12}
319
- color={theme.colors.skyBlue}
320
- style={{marginRight: 5}}
321
- />
322
- <OText size={12}>
323
- {t('MORE_SETTINGS_GO_TO', 'For more settings go to ')}
321
+ <View style={{ flex: 1, flexDirection: 'row', justifyContent: 'flex-start', maxHeight: 40 }}>
322
+ <OIcon
323
+ src={theme.images.general.information}
324
+ width={12}
325
+ height={12}
326
+ color={theme.colors.skyBlue}
327
+ style={{ marginRight: 5 }}
328
+ />
329
+ <OText size={12}>
330
+ {t('MORE_SETTINGS_GO_TO', 'For more settings go to ')}
331
+ </OText>
332
+ <TouchableOpacity onPress={() => { Linking.openURL('https://new-admin.tryordering.com/') }}>
333
+ <OText size={12} color={theme.colors.skyBlue}>
334
+ {t('LINK_MORE_SETTINGS_GO_TO', 'new-admin.ordering.co')}
324
335
  </OText>
325
- <TouchableOpacity onPress={() => {Linking.openURL('https://new-admin.tryordering.com/')}}>
326
- <OText size={12} color={theme.colors.skyBlue}>
327
- {t('LINK_MORE_SETTINGS_GO_TO', 'new-admin.ordering.co')}
328
- </OText>
329
- </TouchableOpacity>
336
+ </TouchableOpacity>
330
337
  </View>
331
338
  )}
332
339
  <FiltersTab>
@@ -338,6 +345,22 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
338
345
  nestedScrollEnabled={true}
339
346
  >
340
347
  <TabsContainer width={WIDTH_SCREEN}>
348
+ <Pressable
349
+ style={styles.pressable}
350
+ onPress={() => setCurrentTabSelected('logisticOrders')}>
351
+ <OIcon
352
+ src={theme.images?.general?.chronometer}
353
+ borderBottomWidth={currentTabSelected === 'logisticOrders' ? 1 : 0}
354
+ width={currentTabSelected === 'logisticOrders' ? 26 : 24}
355
+ height={currentTabSelected === 'logisticOrders' ? 26 : 24}
356
+ color={
357
+ currentTabSelected === 'logisticOrders'
358
+ ? theme.colors.textGray
359
+ : theme.colors.unselectText
360
+ }
361
+ style={styles.icon}
362
+ />
363
+ </Pressable>
341
364
  {tabs.map((tab: any) => (
342
365
  <Pressable
343
366
  key={tab.key}
@@ -364,71 +387,73 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
364
387
  </ScrollView>
365
388
  </FiltersTab>
366
389
  <View style={{ flex: 1, minHeight: HEIGHT_SCREEN - 250 }}>
367
- <View
368
- style={{
369
- display: 'flex',
370
- flexDirection: 'row',
371
- alignContent: 'center',
372
- alignItems: 'center',
373
- }}
374
- >
375
- {tagsList && tagsList?.length > 1 && (
376
- <View style={{ marginBottom: 20 }}>
377
- <Tag
378
- onPress={() => handleAllSelect()}
379
- isSelected={
380
- isEqual(currentOrdersGroup.currentFilter, tagsList)
381
- ? theme.colors.primary
382
- : theme.colors.tabBar
383
- }>
384
- <OText
385
- style={styles.tag}
386
- color={
390
+ {currentTabSelected !== 'logisticOrders' && (
391
+ <View
392
+ style={{
393
+ display: 'flex',
394
+ flexDirection: 'row',
395
+ alignContent: 'center',
396
+ alignItems: 'center',
397
+ }}
398
+ >
399
+ {tagsList && tagsList?.length > 1 && (
400
+ <View style={{ marginBottom: 20 }}>
401
+ <Tag
402
+ onPress={() => handleAllSelect()}
403
+ isSelected={
387
404
  isEqual(currentOrdersGroup.currentFilter, tagsList)
388
- ? theme.colors.white
389
- : theme.colors.black
405
+ ? theme.colors.primary
406
+ : theme.colors.tabBar
390
407
  }>
391
- {t('All', 'All')}
392
- </OText>
393
- </Tag>
394
- </View>
395
- )}
396
- <ScrollView
397
- ref={scrollRef}
398
- showsVerticalScrollIndicator={false}
399
- showsHorizontalScrollIndicator={false}
400
- contentContainerStyle={styles.tagsContainer}
401
- horizontal
402
- >
403
- {tagsList && tagsList.map((key: number) => (
404
- <Tag
405
- key={key}
406
- onPress={() => !currentOrdersGroup.loading && handleTagSelected(key)}
407
- isSelected={
408
- currentOrdersGroup.currentFilter.includes(key) &&
409
- !isEqual(currentOrdersGroup.currentFilter, tagsList)
410
- ? theme.colors.primary
411
- : theme.colors.tabBar
412
- }>
413
- <OText
414
- style={styles.tag}
415
- color={
408
+ <OText
409
+ style={styles.tag}
410
+ color={
411
+ isEqual(currentOrdersGroup.currentFilter, tagsList)
412
+ ? theme.colors.white
413
+ : theme.colors.black
414
+ }>
415
+ {t('All', 'All')}
416
+ </OText>
417
+ </Tag>
418
+ </View>
419
+ )}
420
+ <ScrollView
421
+ ref={scrollRef}
422
+ showsVerticalScrollIndicator={false}
423
+ showsHorizontalScrollIndicator={false}
424
+ contentContainerStyle={styles.tagsContainer}
425
+ horizontal
426
+ >
427
+ {tagsList && tagsList.map((key: number) => (
428
+ <Tag
429
+ key={key}
430
+ onPress={() => !currentOrdersGroup.loading && handleTagSelected(key)}
431
+ isSelected={
416
432
  currentOrdersGroup.currentFilter.includes(key) &&
417
- !isEqual(currentOrdersGroup.currentFilter, tagsList)
418
- ? theme.colors.white
419
- : theme.colors.black
433
+ !isEqual(currentOrdersGroup.currentFilter, tagsList)
434
+ ? theme.colors.primary
435
+ : theme.colors.tabBar
420
436
  }>
421
- {getOrderStatus(key)}
422
- {
423
- currentOrdersGroup.currentFilter.includes(key) &&
424
- !isEqual(currentOrdersGroup.currentFilter, tagsList) &&
425
- ' X'
426
- }
427
- </OText>
428
- </Tag>
429
- ))}
430
- </ScrollView>
431
- </View>
437
+ <OText
438
+ style={styles.tag}
439
+ color={
440
+ currentOrdersGroup.currentFilter.includes(key) &&
441
+ !isEqual(currentOrdersGroup.currentFilter, tagsList)
442
+ ? theme.colors.white
443
+ : theme.colors.black
444
+ }>
445
+ {getOrderStatus(key)}
446
+ {
447
+ currentOrdersGroup.currentFilter.includes(key) &&
448
+ !isEqual(currentOrdersGroup.currentFilter, tagsList) &&
449
+ ' X'
450
+ }
451
+ </OText>
452
+ </Tag>
453
+ ))}
454
+ </ScrollView>
455
+ </View>
456
+ )}
432
457
 
433
458
  <ScrollView
434
459
  ref={scrollListRef}
@@ -438,92 +463,105 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
438
463
  refreshControl={
439
464
  <RefreshControl
440
465
  refreshing={refreshing}
441
- onRefresh={() => loadOrders && loadOrders({ newFetch: true })}
466
+ onRefresh={() => {currentTabSelected === 'logisticOrders' ? loadLogisticOrders() : loadOrders && loadOrders({ newFetch: true })}}
442
467
  />
443
468
  }
444
469
  >
445
470
  {!currentOrdersGroup?.error?.length &&
446
471
  currentOrdersGroup?.orders?.length > 0 &&
447
- (
448
- <PreviousOrders
449
- orders={currentOrdersGroup.orders}
450
- onNavigationRedirect={onNavigationRedirect}
451
- getOrderStatus={getOrderStatus}
452
- handleClickOrder={handleClickOrder}
453
- />
454
- )}
455
-
456
- {(currentOrdersGroup?.loading ||
457
- currentOrdersGroup?.pagination?.total === null) &&
458
- (
459
- <>
460
- <View>
461
- {[...Array(5)].map((_, i) => (
462
- <Placeholder key={i} Animation={Fade}>
463
- <View
464
- style={{
465
- width: '100%',
466
- flexDirection: 'row',
467
- marginBottom: 10,
468
- }}>
469
- <PlaceholderLine
470
- width={IS_PORTRAIT ? 22 : 11}
471
- height={74}
472
+ currentTabSelected !== 'logisticOrders' &&
473
+ (
474
+ <PreviousOrders
475
+ orders={currentOrdersGroup.orders}
476
+ onNavigationRedirect={onNavigationRedirect}
477
+ getOrderStatus={getOrderStatus}
478
+ handleClickOrder={handleClickOrder}
479
+ />
480
+ )}
481
+ {!logisticOrders?.error?.length &&
482
+ logisticOrders?.orders?.length > 0 &&
483
+ currentTabSelected === 'logisticOrders' && (
484
+ <PreviousOrders
485
+ orders={logisticOrders.orders}
486
+ onNavigationRedirect={onNavigationRedirect}
487
+ getOrderStatus={getOrderStatus}
488
+ handleClickOrder={handleClickLogisticOrder}
489
+ isLogisticOrder
490
+ />
491
+ )
492
+ }
493
+ {((currentOrdersGroup?.loading ||
494
+ currentOrdersGroup?.pagination?.total === null) ||
495
+ (logisticOrders?.loading)) &&
496
+ (
497
+ <>
498
+ <View>
499
+ {[...Array(5)].map((_, i) => (
500
+ <Placeholder key={i} Animation={Fade}>
501
+ <View
472
502
  style={{
473
- marginRight: 20,
474
- marginBottom: 20,
475
- borderRadius: 7.6,
476
- }}
477
- />
478
- <Placeholder>
479
- <PlaceholderLine width={30} style={{ marginTop: 5 }} />
480
- <PlaceholderLine width={50} />
481
- <PlaceholderLine width={20} />
482
- </Placeholder>
483
- </View>
484
- </Placeholder>
485
- ))}
486
- </View>
487
- </>
488
- )}
503
+ width: '100%',
504
+ flexDirection: 'row',
505
+ marginBottom: 10,
506
+ }}>
507
+ <PlaceholderLine
508
+ width={IS_PORTRAIT ? 22 : 11}
509
+ height={74}
510
+ style={{
511
+ marginRight: 20,
512
+ marginBottom: 20,
513
+ borderRadius: 7.6,
514
+ }}
515
+ />
516
+ <Placeholder>
517
+ <PlaceholderLine width={30} style={{ marginTop: 5 }} />
518
+ <PlaceholderLine width={50} />
519
+ <PlaceholderLine width={20} />
520
+ </Placeholder>
521
+ </View>
522
+ </Placeholder>
523
+ ))}
524
+ </View>
525
+ </>
526
+ )}
489
527
 
490
528
  {!currentOrdersGroup?.error?.length &&
491
529
  !currentOrdersGroup?.loading &&
492
530
  currentOrdersGroup?.pagination?.totalPages &&
493
531
  currentOrdersGroup?.pagination?.currentPage < currentOrdersGroup?.pagination?.totalPages &&
494
532
  currentOrdersGroup?.orders?.length > 0 &&
495
- (
496
- <OButton
497
- onClick={handleLoadMore}
498
- text={t('LOAD_MORE_ORDERS', 'Load more orders')}
499
- imgRightSrc={null}
500
- textStyle={styles.loadButtonText}
501
- style={styles.loadButton}
502
- bgColor={theme.colors.primary}
503
- borderColor={theme.colors.primary}
504
- />
505
- )}
533
+ (
534
+ <OButton
535
+ onClick={handleLoadMore}
536
+ text={t('LOAD_MORE_ORDERS', 'Load more orders')}
537
+ imgRightSrc={null}
538
+ textStyle={styles.loadButtonText}
539
+ style={styles.loadButton}
540
+ bgColor={theme.colors.primary}
541
+ borderColor={theme.colors.primary}
542
+ />
543
+ )}
506
544
 
507
545
  {!currentOrdersGroup?.loading &&
508
546
  (currentOrdersGroup?.error?.length ||
509
- currentOrdersGroup?.orders?.length === 0) &&
510
- (
511
- <NotFoundSource
512
- content={
513
- !currentOrdersGroup?.error?.length
514
- ? t('NO_RESULTS_FOUND', 'Sorry, no results found')
515
- : currentOrdersGroup?.error[0]?.message ||
547
+ currentOrdersGroup?.orders?.length === 0) &&
548
+ (
549
+ <NotFoundSource
550
+ content={
551
+ !currentOrdersGroup?.error?.length
552
+ ? t('NO_RESULTS_FOUND', 'Sorry, no results found')
553
+ : currentOrdersGroup?.error[0]?.message ||
516
554
  currentOrdersGroup?.error[0] ||
517
555
  t('NETWORK_ERROR', 'Network Error')
518
- }
519
- image={theme.images.general.notFound}
520
- conditioned={false}
521
- />
522
- )}
556
+ }
557
+ image={theme.images.general.notFound}
558
+ conditioned={false}
559
+ />
560
+ )}
523
561
  </ScrollView>
524
562
  </View>
525
- {/* </GestureRecognizer> */}
526
-
563
+ {/* </GestureRecognizer> */}
564
+
527
565
  <NewOrderNotification />
528
566
  <OModal open={openModal} entireModal customClose>
529
567
  <ModalContainer
@@ -546,7 +584,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
546
584
  <ModalTitle>{t('SEARCH_ORDERS', 'Search orders')}</ModalTitle>
547
585
  <OInput
548
586
  value={search.id}
549
- onChange={(value: any) => setSearch({...search, id: value})}
587
+ onChange={(value: any) => setSearch({ ...search, id: value })}
550
588
  style={styles.inputStyle}
551
589
  placeholder={t('ORDER_NUMBER', 'Order number')}
552
590
  autoCorrect={false}
@@ -606,12 +644,13 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
606
644
 
607
645
  export const OrdersOption = (props: OrdersOptionParams) => {
608
646
  const [, t] = useLanguage();
609
-
647
+ const theme = useTheme()
610
648
  const ordersProps = {
611
649
  ...props,
612
650
  UIComponent: OrdersOptionUI,
613
651
  useDefualtSessionManager: true,
614
652
  asDashboard: true,
653
+ isIos: Platform.OS === 'ios',
615
654
  orderStatus: [
616
655
  { key: 0, text: t('PENDING', 'Pending') },
617
656
  { key: 1, text: t('COMPLETED', 'Completed') },
@@ -687,30 +726,24 @@ export const OrdersOption = (props: OrdersOptionParams) => {
687
726
  tabs: [
688
727
  {
689
728
  key: 0,
690
- text: t('Logistics', 'Logistics'),
691
- tags: [0],
692
- title: 'Logistics'
693
- },
694
- {
695
- key: 1,
696
729
  text: t('PENDING', 'Pending'),
697
730
  tags: props?.orderGroupStatusCustom?.pending ?? [0, 13],
698
731
  title: 'pending'
699
732
  },
700
733
  {
701
- key: 2,
734
+ key: 1,
702
735
  text: t('IN_PROGRESS', 'In Progress'),
703
736
  tags: props?.orderGroupStatusCustom?.inProgress ?? [3, 4, 7, 8, 9, 14, 18, 19, 20, 21],
704
737
  title: 'inProgress',
705
738
  },
706
739
  {
707
- key: 3,
740
+ key: 2,
708
741
  text: t('COMPLETED', 'Completed'),
709
742
  tags: props?.orderGroupStatusCustom?.completed ?? [1, 11, 15],
710
743
  title: 'completed',
711
744
  },
712
745
  {
713
- key: 4,
746
+ key: 3,
714
747
  text: t('CANCELLED', 'Cancelled'),
715
748
  tags: props?.orderGroupStatusCustom?.cancelled ?? [2, 5, 6, 10, 12, 16, 17],
716
749
  title: 'cancelled',