ordering-ui-react-native 0.23.73 → 0.23.74

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.23.73",
3
+ "version": "0.23.74",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -38,7 +38,8 @@ import {
38
38
  ItemContent,
39
39
  TimerInputWrapper,
40
40
  OverLine,
41
- InputContainer
41
+ InputContainer,
42
+ FilterAlert
42
43
  } from './styles';
43
44
  import { PreviousOrders } from '../PreviousOrders';
44
45
  import { OrdersOptionParams } from '../../types';
@@ -76,7 +77,8 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
76
77
  loadLogisticOrders,
77
78
  isLogisticActivated,
78
79
  handleChangeOrderStatus,
79
- handleSendCustomerReview
80
+ handleSendCustomerReview,
81
+ ordersFiltered
80
82
  } = props;
81
83
 
82
84
  const defaultSearchList = {
@@ -108,6 +110,8 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
108
110
  const [slaSettingTime, setSlaSettingTime] = useState(6000)
109
111
  const [currentDeliveryType, setCurrentDeliveryType] = useState('Delivery')
110
112
  const [search, setSearch] = useState(defaultSearchList)
113
+ const hasSearchFilters = JSON.stringify(defaultSearchList) !== JSON.stringify(search)
114
+
111
115
  const deliveryStatus = [
112
116
  {
113
117
  key: t('OK', 'Ok'),
@@ -290,13 +294,27 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
290
294
 
291
295
  const tagsList = ordersGroup[currentTabSelected]?.defaultFilter ?? []
292
296
  const currentOrdersGroup = ordersGroup[currentTabSelected]
297
+ const ordersValidation = hasSearchFilters ? ordersFiltered : currentOrdersGroup
298
+
299
+ const paginationValidation =
300
+ !ordersValidation?.error?.length &&
301
+ !ordersValidation?.loading &&
302
+ ordersValidation?.pagination?.totalPages &&
303
+ ordersValidation?.pagination?.currentPage < ordersValidation?.pagination?.totalPages &&
304
+ ordersValidation?.orders?.length > 0
305
+
306
+ const loadingValidation = (
307
+ ordersValidation?.loading ||
308
+ (ordersValidation?.pagination?.total === null && isNetConnected) ||
309
+ logisticOrders?.loading
310
+ ) && !ordersValidation?.error?.length
293
311
 
294
312
  const isEqual = (array1: any, array2: any) => {
295
313
  return array1?.every((item: any) => array2.includes(item)) && array2?.every((item: any) => array1.includes(item))
296
314
  }
297
315
 
298
316
  const handleLoadMore = () => {
299
- loadMoreOrders && loadMoreOrders();
317
+ loadMoreOrders && loadMoreOrders({ allStatusses: hasSearchFilters });
300
318
  };
301
319
 
302
320
  const getOrderStatus = (key: number) => {
@@ -304,13 +322,6 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
304
322
  };
305
323
 
306
324
  const applyFilters = () => {
307
- setOrdersGroup({
308
- ...ordersGroup,
309
- [currentTabSelected]: {
310
- ...ordersGroup[currentTabSelected],
311
- orders: []
312
- }
313
- })
314
325
  const dateRange = calculateDate(search.date.type, search.date.from, search.date.to)
315
326
  onFiltered && onFiltered({ ...search, date: { ...dateRange } })
316
327
  setOpenSearchModal(false)
@@ -380,6 +391,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
380
391
  }
381
392
 
382
393
  const handleClose = () => {
394
+ setSearch(defaultSearchList)
383
395
  setOpenSearchModal(false)
384
396
  setOpenSLASettingModal(false)
385
397
  }
@@ -470,6 +482,22 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
470
482
 
471
483
  return (
472
484
  <>
485
+ {hasSearchFilters && (
486
+ <FilterAlert>
487
+ <AntDesignIcon
488
+ name='warning'
489
+ color='#FFC700'
490
+ size={12}
491
+ onPress={() => setOpenSearchModal(true)}
492
+ />
493
+ <OText size={10} mLeft={5} mRight={5}>
494
+ {t('WARNING_FILTER_APPLIED', 'Filters applied. You may miss new orders.')}
495
+ </OText>
496
+ <Pressable onPress={() => handleClearFilters()}>
497
+ <OText textDecorationLine='underline' size={10} color='rgb(44, 123, 229)'>{t('CLEAR_FILTERS', 'Clear filters')}</OText>
498
+ </Pressable>
499
+ </FilterAlert>
500
+ )}
473
501
  <View style={styles.header}>
474
502
  <OText style={styles.title}>{t('MY_ORDERS', 'My orders')}</OText>
475
503
  <IconWrapper>
@@ -481,75 +509,95 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
481
509
  name='refresh-cw'
482
510
  color={theme.colors.backgroundDark}
483
511
  size={24}
484
- onPress={() => currentTabSelected === 'logisticOrders' ? loadLogisticOrders && loadLogisticOrders() : loadOrders && loadOrders({ newFetch: true })}
512
+ onPress={() => currentTabSelected === 'logisticOrders' ? loadLogisticOrders && loadLogisticOrders() : loadOrders && loadOrders({ newFetch: true, }, { allStatusses: hasSearchFilters })}
485
513
  style={{
486
514
  marginRight: 20
487
515
  }}
488
516
  />
489
517
  )}
490
- <FontistoIcon
491
- name='search'
492
- color={theme.colors.backgroundDark}
493
- size={24}
494
- onPress={() => setOpenSearchModal(true)}
495
- />
496
- </IconWrapper>
497
- </View>
498
- <FiltersTab>
499
- <ScrollView
500
- ref={scrollRefTab}
501
- showsVerticalScrollIndicator={false}
502
- showsHorizontalScrollIndicator={false}
503
- horizontal
504
- nestedScrollEnabled={true}
505
- >
506
- <TabsContainer>
507
- {(isLogisticActivated && !isBusinessApp && !combineTabs) && (
508
- <Pressable
509
- style={styles.pressable}
510
- onPress={() => setCurrentTabSelected('logisticOrders')}>
511
- <OIcon
512
- src={theme.images?.general?.chronometer}
513
- borderBottomWidth={currentTabSelected === 'logisticOrders' ? 1 : 0}
514
- width={currentTabSelected === 'logisticOrders' ? 26 : 24}
515
- height={currentTabSelected === 'logisticOrders' ? 26 : 24}
516
- color={
517
- currentTabSelected === 'logisticOrders'
518
- ? theme.colors.textGray
519
- : theme.colors.unselectText
520
- }
521
- style={styles.icon}
522
- />
523
- </Pressable>
524
- )}
525
- {tabs.map((tab: any) => (
526
- <TabPressable
527
- key={tab.key}
528
- onPress={() => setCurrentTabSelected(tab?.title)}
529
- isSelected={tab.title === currentTabSelected ? 1 : 0}
530
- >
531
- <OText
518
+ {currentTabSelected !== 'logisticOrders' && (
519
+ <View>
520
+ {hasSearchFilters && (
521
+ <AntDesignIcon
522
+ name='exclamationcircle'
523
+ color={theme.colors.primary}
524
+ size={16}
532
525
  style={{
533
- ...styles.tab,
534
- fontSize: tab.title === currentTabSelected ? 16 : 14,
535
- borderBottomWidth: Platform.OS === 'ios' && tab.title === currentTabSelected ? 1 : 0,
526
+ position: 'absolute',
527
+ zIndex: 1000,
528
+ right: -8,
529
+ top: -5
536
530
  }}
537
- color={
538
- tab.title === currentTabSelected
539
- ? theme.colors.textGray
540
- : theme.colors.unselectText
541
- }
542
- weight={tab.title === currentTabSelected ? '600' : 'normal'}
531
+ onPress={() => setOpenSearchModal(true)}
532
+ />
533
+ )}
534
+ <FontistoIcon
535
+ name='filter'
536
+ color={theme.colors.backgroundDark}
537
+ size={24}
538
+ onPress={() => setOpenSearchModal(true)}
539
+ />
540
+ </View>
541
+ )}
542
+ </IconWrapper>
543
+ </View>
544
+ {!hasSearchFilters && (
545
+ <FiltersTab>
546
+ <ScrollView
547
+ ref={scrollRefTab}
548
+ showsVerticalScrollIndicator={false}
549
+ showsHorizontalScrollIndicator={false}
550
+ horizontal
551
+ nestedScrollEnabled={true}
552
+ >
553
+ <TabsContainer>
554
+ {(isLogisticActivated && !isBusinessApp && !combineTabs) && (
555
+ <Pressable
556
+ style={styles.pressable}
557
+ onPress={() => setCurrentTabSelected('logisticOrders')}>
558
+ <OIcon
559
+ src={theme.images?.general?.chronometer}
560
+ borderBottomWidth={currentTabSelected === 'logisticOrders' ? 1 : 0}
561
+ width={currentTabSelected === 'logisticOrders' ? 26 : 24}
562
+ height={currentTabSelected === 'logisticOrders' ? 26 : 24}
563
+ color={
564
+ currentTabSelected === 'logisticOrders'
565
+ ? theme.colors.textGray
566
+ : theme.colors.unselectText
567
+ }
568
+ style={styles.icon}
569
+ />
570
+ </Pressable>
571
+ )}
572
+ {!hasSearchFilters && tabs.map((tab: any) => (
573
+ <TabPressable
574
+ key={tab.key}
575
+ onPress={() => setCurrentTabSelected(tab?.title)}
576
+ isSelected={tab.title === currentTabSelected ? 1 : 0}
543
577
  >
544
- {tab.text}
545
- </OText>
546
- </TabPressable>
547
- ))}
548
- </TabsContainer>
549
- </ScrollView>
550
- </FiltersTab>
578
+ <OText
579
+ style={{
580
+ ...styles.tab,
581
+ fontSize: tab.title === currentTabSelected ? 16 : 14,
582
+ borderBottomWidth: Platform.OS === 'ios' && tab.title === currentTabSelected ? 1 : 0,
583
+ }}
584
+ color={
585
+ tab.title === currentTabSelected
586
+ ? theme.colors.textGray
587
+ : theme.colors.unselectText
588
+ }
589
+ weight={tab.title === currentTabSelected ? '600' : 'normal'}
590
+ >
591
+ {tab.text}
592
+ </OText>
593
+ </TabPressable>
594
+ ))}
595
+ </TabsContainer>
596
+ </ScrollView>
597
+ </FiltersTab>
598
+ )}
551
599
  <View style={{ flex: 1, minHeight: HEIGHT_SCREEN - 450 }}>
552
- {showTagsList && (
600
+ {showTagsList && !hasSearchFilters && (
553
601
  <View
554
602
  style={{
555
603
  display: 'flex',
@@ -648,17 +696,17 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
648
696
  refreshControl={
649
697
  <RefreshControl
650
698
  refreshing={refreshing}
651
- onRefresh={() => { isNetConnected && (currentTabSelected === 'logisticOrders' ? loadLogisticOrders && loadLogisticOrders() : loadOrders && loadOrders({ newFetch: true })) }}
699
+ onRefresh={() => { isNetConnected && (currentTabSelected === 'logisticOrders' ? loadLogisticOrders && loadLogisticOrders() : loadOrders && loadOrders({ newFetch: true }, { allStatusses: hasSearchFilters })) }}
652
700
  />
653
701
  }
654
702
  >
655
- {!currentOrdersGroup?.error?.length &&
656
- currentOrdersGroup?.orders?.length > 0 &&
703
+ {!ordersValidation?.error?.length &&
704
+ (ordersValidation?.orders?.length > 0 || ordersFiltered?.orders?.length > 0) &&
657
705
  currentTabSelected !== 'logisticOrders' &&
658
- !currentOrdersGroup?.loading &&
706
+ !ordersValidation?.loading &&
659
707
  (
660
708
  <PreviousOrders
661
- orders={ordersFormatted}
709
+ orders={hasSearchFilters ? ordersFiltered?.orders : ordersFormatted}
662
710
  navigation={props.navigation}
663
711
  onNavigationRedirect={onNavigationRedirect}
664
712
  getOrderStatus={getOrderStatus}
@@ -688,14 +736,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
688
736
  )
689
737
  }
690
738
  {(
691
- (
692
- (
693
- currentOrdersGroup?.loading ||
694
- (currentOrdersGroup?.pagination?.total === null && isNetConnected) ||
695
- logisticOrders?.loading
696
- ) &&
697
- !currentOrdersGroup?.error?.length
698
- ) || internetLoading
739
+ loadingValidation || internetLoading
699
740
  ) && (
700
741
  <View style={{ marginTop: 10 }}>
701
742
  {[...Array(5)].map((_, i) => (
@@ -727,11 +768,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
727
768
  )}
728
769
 
729
770
  {isNetConnected &&
730
- !currentOrdersGroup?.error?.length &&
731
- !currentOrdersGroup?.loading &&
732
- currentOrdersGroup?.pagination?.totalPages &&
733
- currentOrdersGroup?.pagination?.currentPage < currentOrdersGroup?.pagination?.totalPages &&
734
- currentOrdersGroup?.orders?.length > 0 &&
771
+ paginationValidation &&
735
772
  (
736
773
  <OButton
737
774
  onClick={handleLoadMore}
@@ -745,9 +782,9 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
745
782
  )}
746
783
 
747
784
  {!internetLoading &&
748
- ((!currentOrdersGroup?.loading &&
749
- (currentOrdersGroup?.error?.length ||
750
- currentOrdersGroup?.orders?.length === 0)) ||
785
+ ((!ordersValidation?.loading &&
786
+ (ordersValidation?.error?.length ||
787
+ ordersValidation?.orders?.length === 0)) ||
751
788
  (currentTabSelected === 'logisticOrders' &&
752
789
  (logisticOrders && !logisticOrders?.loading && (logisticOrders?.error?.length > 0 || logisticOrders?.orders?.length === 0 || !logisticOrders?.orders?.some(order => !order?.expired))))
753
790
  ) &&
@@ -755,11 +792,11 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
755
792
  <NotFoundSource
756
793
  content={
757
794
  !isNetConnected ? t('NETWORK_ERROR', 'Network Error') :
758
- ((currentTabSelected !== 'logisticOrders' && !currentOrdersGroup?.error?.length) ||
795
+ ((currentTabSelected !== 'logisticOrders' && !ordersValidation?.error?.length) ||
759
796
  (currentTabSelected === 'logisticOrders' && (!logisticOrders?.error?.length || (logisticOrders?.orders?.length > 0 && !logisticOrders?.orders?.some(order => !order?.expired)))))
760
797
  ? t('NO_RESULTS_FOUND', 'Sorry, no results found')
761
- : currentOrdersGroup?.error?.[0]?.message ||
762
- currentOrdersGroup?.error?.[0] ||
798
+ : ordersValidation?.error?.[0]?.message ||
799
+ ordersValidation?.error?.[0] ||
763
800
  (currentTabSelected === 'logisticOrders' && logisticOrders?.error) ||
764
801
  t('NETWORK_ERROR', 'Network Error')
765
802
  }
@@ -154,3 +154,17 @@ export const Actions = styled.View`
154
154
  export const InputContainer = styled.View`
155
155
  position: relative;
156
156
  `
157
+
158
+ export const FilterAlert = styled.View`
159
+ position: absolute;
160
+ z-index: 1000;
161
+ flex-direction: row;
162
+ top: 50px;
163
+ background-color: #FFF9E2;
164
+ flex-wrap: wrap;
165
+ align-items: flex-start;
166
+ justify-content: flex-start;
167
+ right: 10px;
168
+ padding: 5px;
169
+ border-radius: 10px
170
+ `
@@ -288,8 +288,8 @@ export interface OrdersOptionParams {
288
288
  rememberOrderStatus?: any;
289
289
  titleContent?: string;
290
290
  customArray?: Array<any>;
291
- loadMoreOrders?: () => {};
292
- loadOrders?: ({ }: any) => {};
291
+ loadMoreOrders?: (options ?: any) => {};
292
+ loadOrders?: ({ }: any, options?: any) => {};
293
293
  messages?: any;
294
294
  setMessages?: () => {};
295
295
  loadMessages?: () => {};
@@ -328,6 +328,7 @@ export interface OrdersOptionParams {
328
328
  isDriverApp?: boolean;
329
329
  combineTabs?: boolean;
330
330
  setCombineTabsState?: any;
331
+ ordersFiltered?: any
331
332
  }
332
333
  export interface ActiveOrdersParams {
333
334
  orders?: any;