ordering-ui-react-native 0.22.34-release → 0.22.35-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.22.34-release",
3
+ "version": "0.22.35-release",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -37,7 +37,8 @@ import {
37
37
  ItemContent,
38
38
  TimerInputWrapper,
39
39
  OverLine,
40
- InputContainer
40
+ InputContainer,
41
+ FilterAlert
41
42
  } from './styles';
42
43
  import { PreviousOrders } from '../PreviousOrders';
43
44
  import { OrdersOptionParams } from '../../types';
@@ -75,7 +76,8 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
75
76
  loadLogisticOrders,
76
77
  isLogisticActivated,
77
78
  handleChangeOrderStatus,
78
- handleSendCustomerReview
79
+ handleSendCustomerReview,
80
+ ordersFiltered
79
81
  } = props;
80
82
 
81
83
  const defaultSearchList = {
@@ -106,6 +108,8 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
106
108
  const [slaSettingTime, setSlaSettingTime] = useState(6000)
107
109
  const [currentDeliveryType, setCurrentDeliveryType] = useState('Delivery')
108
110
  const [search, setSearch] = useState(defaultSearchList)
111
+ const hasSearchFilters = JSON.stringify(defaultSearchList) !== JSON.stringify(search)
112
+
109
113
  const deliveryStatus = [
110
114
  {
111
115
  key: t('OK', 'Ok'),
@@ -288,13 +292,27 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
288
292
 
289
293
  const tagsList = ordersGroup[currentTabSelected]?.defaultFilter ?? []
290
294
  const currentOrdersGroup = ordersGroup[currentTabSelected]
295
+ const ordersValidation = hasSearchFilters ? ordersFiltered : currentOrdersGroup
296
+
297
+ const paginationValidation =
298
+ !ordersValidation?.error?.length &&
299
+ !ordersValidation?.loading &&
300
+ ordersValidation?.pagination?.totalPages &&
301
+ ordersValidation?.pagination?.currentPage < ordersValidation?.pagination?.totalPages &&
302
+ ordersValidation?.orders?.length > 0
303
+
304
+ const loadingValidation = (
305
+ ordersValidation?.loading ||
306
+ (ordersValidation?.pagination?.total === null && isNetConnected) ||
307
+ logisticOrders?.loading
308
+ ) && !ordersValidation?.error?.length
291
309
 
292
310
  const isEqual = (array1: any, array2: any) => {
293
311
  return array1?.every((item: any) => array2.includes(item)) && array2?.every((item: any) => array1.includes(item))
294
312
  }
295
313
 
296
314
  const handleLoadMore = () => {
297
- loadMoreOrders && loadMoreOrders();
315
+ loadMoreOrders && loadMoreOrders({ allStatusses: hasSearchFilters });
298
316
  };
299
317
 
300
318
  const getOrderStatus = (key: number) => {
@@ -302,13 +320,6 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
302
320
  };
303
321
 
304
322
  const applyFilters = () => {
305
- setOrdersGroup({
306
- ...ordersGroup,
307
- [currentTabSelected]: {
308
- ...ordersGroup[currentTabSelected],
309
- orders: []
310
- }
311
- })
312
323
  const dateRange = calculateDate(search.date.type, search.date.from, search.date.to)
313
324
  onFiltered && onFiltered({ ...search, date: { ...dateRange } })
314
325
  setOpenSearchModal(false)
@@ -378,6 +389,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
378
389
  }
379
390
 
380
391
  const handleClose = () => {
392
+ setSearch(defaultSearchList)
381
393
  setOpenSearchModal(false)
382
394
  setOpenSLASettingModal(false)
383
395
  }
@@ -459,6 +471,22 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
459
471
 
460
472
  return (
461
473
  <>
474
+ {hasSearchFilters && (
475
+ <FilterAlert>
476
+ <AntDesignIcon
477
+ name='warning'
478
+ color='#FFC700'
479
+ size={12}
480
+ onPress={() => setOpenSearchModal(true)}
481
+ />
482
+ <OText size={10} mLeft={5} mRight={5}>
483
+ {t('WARNING_FILTER_APPLIED', 'Filters applied. You may miss new orders.')}
484
+ </OText>
485
+ <Pressable onPress={() => handleClearFilters()}>
486
+ <OText textDecorationLine='underline' size={10} color='rgb(44, 123, 229)'>{t('CLEAR_FILTERS', 'Clear filters')}</OText>
487
+ </Pressable>
488
+ </FilterAlert>
489
+ )}
462
490
  <View style={styles.header}>
463
491
  <OText style={styles.title}>{t('MY_ORDERS', 'My orders')}</OText>
464
492
  <IconWrapper>
@@ -470,75 +498,95 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
470
498
  name='refresh-cw'
471
499
  color={theme.colors.backgroundDark}
472
500
  size={24}
473
- onPress={() => currentTabSelected === 'logisticOrders' ? loadLogisticOrders && loadLogisticOrders() : loadOrders && loadOrders({ newFetch: true })}
501
+ onPress={() => currentTabSelected === 'logisticOrders' ? loadLogisticOrders && loadLogisticOrders() : loadOrders && loadOrders({ newFetch: true, }, { allStatusses: hasSearchFilters })}
474
502
  style={{
475
503
  marginRight: 20
476
504
  }}
477
505
  />
478
506
  )}
479
- <FontistoIcon
480
- name='search'
481
- color={theme.colors.backgroundDark}
482
- size={24}
483
- onPress={() => setOpenSearchModal(true)}
484
- />
485
- </IconWrapper>
486
- </View>
487
- <FiltersTab>
488
- <ScrollView
489
- ref={scrollRefTab}
490
- showsVerticalScrollIndicator={false}
491
- showsHorizontalScrollIndicator={false}
492
- horizontal
493
- nestedScrollEnabled={true}
494
- >
495
- <TabsContainer>
496
- {(isLogisticActivated && !isBusinessApp && !combineTabs) && (
497
- <Pressable
498
- style={styles.pressable}
499
- onPress={() => setCurrentTabSelected('logisticOrders')}>
500
- <OIcon
501
- src={theme.images?.general?.chronometer}
502
- borderBottomWidth={currentTabSelected === 'logisticOrders' ? 1 : 0}
503
- width={currentTabSelected === 'logisticOrders' ? 26 : 24}
504
- height={currentTabSelected === 'logisticOrders' ? 26 : 24}
505
- color={
506
- currentTabSelected === 'logisticOrders'
507
- ? theme.colors.textGray
508
- : theme.colors.unselectText
509
- }
510
- style={styles.icon}
511
- />
512
- </Pressable>
513
- )}
514
- {tabs.map((tab: any) => (
515
- <TabPressable
516
- key={tab.key}
517
- onPress={() => setCurrentTabSelected(tab?.title)}
518
- isSelected={tab.title === currentTabSelected ? 1 : 0}
519
- >
520
- <OText
507
+ {currentTabSelected !== 'logisticOrders' && (
508
+ <View>
509
+ {hasSearchFilters && (
510
+ <AntDesignIcon
511
+ name='exclamationcircle'
512
+ color={theme.colors.primary}
513
+ size={16}
521
514
  style={{
522
- ...styles.tab,
523
- fontSize: tab.title === currentTabSelected ? 16 : 14,
524
- borderBottomWidth: Platform.OS === 'ios' && tab.title === currentTabSelected ? 1 : 0,
515
+ position: 'absolute',
516
+ zIndex: 1000,
517
+ right: -8,
518
+ top: -5
525
519
  }}
526
- color={
527
- tab.title === currentTabSelected
528
- ? theme.colors.textGray
529
- : theme.colors.unselectText
530
- }
531
- weight={tab.title === currentTabSelected ? '600' : 'normal'}
520
+ onPress={() => setOpenSearchModal(true)}
521
+ />
522
+ )}
523
+ <FontistoIcon
524
+ name='filter'
525
+ color={theme.colors.backgroundDark}
526
+ size={24}
527
+ onPress={() => setOpenSearchModal(true)}
528
+ />
529
+ </View>
530
+ )}
531
+ </IconWrapper>
532
+ </View>
533
+ {!hasSearchFilters && (
534
+ <FiltersTab>
535
+ <ScrollView
536
+ ref={scrollRefTab}
537
+ showsVerticalScrollIndicator={false}
538
+ showsHorizontalScrollIndicator={false}
539
+ horizontal
540
+ nestedScrollEnabled={true}
541
+ >
542
+ <TabsContainer>
543
+ {(isLogisticActivated && !isBusinessApp && !combineTabs) && (
544
+ <Pressable
545
+ style={styles.pressable}
546
+ onPress={() => setCurrentTabSelected('logisticOrders')}>
547
+ <OIcon
548
+ src={theme.images?.general?.chronometer}
549
+ borderBottomWidth={currentTabSelected === 'logisticOrders' ? 1 : 0}
550
+ width={currentTabSelected === 'logisticOrders' ? 26 : 24}
551
+ height={currentTabSelected === 'logisticOrders' ? 26 : 24}
552
+ color={
553
+ currentTabSelected === 'logisticOrders'
554
+ ? theme.colors.textGray
555
+ : theme.colors.unselectText
556
+ }
557
+ style={styles.icon}
558
+ />
559
+ </Pressable>
560
+ )}
561
+ {!hasSearchFilters && tabs.map((tab: any) => (
562
+ <TabPressable
563
+ key={tab.key}
564
+ onPress={() => setCurrentTabSelected(tab?.title)}
565
+ isSelected={tab.title === currentTabSelected ? 1 : 0}
532
566
  >
533
- {tab.text}
534
- </OText>
535
- </TabPressable>
536
- ))}
537
- </TabsContainer>
538
- </ScrollView>
539
- </FiltersTab>
567
+ <OText
568
+ style={{
569
+ ...styles.tab,
570
+ fontSize: tab.title === currentTabSelected ? 16 : 14,
571
+ borderBottomWidth: Platform.OS === 'ios' && tab.title === currentTabSelected ? 1 : 0,
572
+ }}
573
+ color={
574
+ tab.title === currentTabSelected
575
+ ? theme.colors.textGray
576
+ : theme.colors.unselectText
577
+ }
578
+ weight={tab.title === currentTabSelected ? '600' : 'normal'}
579
+ >
580
+ {tab.text}
581
+ </OText>
582
+ </TabPressable>
583
+ ))}
584
+ </TabsContainer>
585
+ </ScrollView>
586
+ </FiltersTab>
587
+ )}
540
588
  <View style={{ flex: 1, minHeight: HEIGHT_SCREEN - 450 }}>
541
- {showTagsList && (
589
+ {showTagsList && !hasSearchFilters && (
542
590
  <View
543
591
  style={{
544
592
  display: 'flex',
@@ -629,17 +677,17 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
629
677
  refreshControl={
630
678
  <RefreshControl
631
679
  refreshing={refreshing}
632
- onRefresh={() => { isNetConnected && (currentTabSelected === 'logisticOrders' ? loadLogisticOrders && loadLogisticOrders() : loadOrders && loadOrders({ newFetch: true })) }}
680
+ onRefresh={() => { isNetConnected && (currentTabSelected === 'logisticOrders' ? loadLogisticOrders && loadLogisticOrders() : loadOrders && loadOrders({ newFetch: true }, { allStatusses: hasSearchFilters })) }}
633
681
  />
634
682
  }
635
683
  >
636
- {!currentOrdersGroup?.error?.length &&
637
- currentOrdersGroup?.orders?.length > 0 &&
684
+ {!ordersValidation?.error?.length &&
685
+ (ordersValidation?.orders?.length > 0 || ordersFiltered?.orders?.length > 0) &&
638
686
  currentTabSelected !== 'logisticOrders' &&
639
- !currentOrdersGroup?.loading &&
687
+ !ordersValidation?.loading &&
640
688
  (
641
689
  <PreviousOrders
642
- orders={ordersFormatted}
690
+ orders={hasSearchFilters ? ordersFiltered?.orders : ordersFormatted}
643
691
  navigation={props.navigation}
644
692
  onNavigationRedirect={onNavigationRedirect}
645
693
  getOrderStatus={getOrderStatus}
@@ -669,14 +717,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
669
717
  )
670
718
  }
671
719
  {(
672
- (
673
- (
674
- currentOrdersGroup?.loading ||
675
- (currentOrdersGroup?.pagination?.total === null && isNetConnected) ||
676
- logisticOrders?.loading
677
- ) &&
678
- !currentOrdersGroup?.error?.length
679
- ) || internetLoading
720
+ loadingValidation || internetLoading
680
721
  ) && (
681
722
  <View style={{ marginTop: 10 }}>
682
723
  {[...Array(5)].map((_, i) => (
@@ -708,11 +749,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
708
749
  )}
709
750
 
710
751
  {isNetConnected &&
711
- !currentOrdersGroup?.error?.length &&
712
- !currentOrdersGroup?.loading &&
713
- currentOrdersGroup?.pagination?.totalPages &&
714
- currentOrdersGroup?.pagination?.currentPage < currentOrdersGroup?.pagination?.totalPages &&
715
- currentOrdersGroup?.orders?.length > 0 &&
752
+ paginationValidation &&
716
753
  (
717
754
  <OButton
718
755
  onClick={handleLoadMore}
@@ -726,9 +763,9 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
726
763
  )}
727
764
 
728
765
  {!internetLoading &&
729
- ((!currentOrdersGroup?.loading &&
730
- (currentOrdersGroup?.error?.length ||
731
- currentOrdersGroup?.orders?.length === 0)) ||
766
+ ((!ordersValidation?.loading &&
767
+ (ordersValidation?.error?.length ||
768
+ ordersValidation?.orders?.length === 0)) ||
732
769
  (currentTabSelected === 'logisticOrders' &&
733
770
  (logisticOrders && !logisticOrders?.loading && (logisticOrders?.error?.length > 0 || logisticOrders?.orders?.length === 0 || !logisticOrders?.orders?.some(order => !order?.expired))))
734
771
  ) &&
@@ -736,11 +773,11 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
736
773
  <NotFoundSource
737
774
  content={
738
775
  !isNetConnected ? t('NETWORK_ERROR', 'Network Error') :
739
- ((currentTabSelected !== 'logisticOrders' && !currentOrdersGroup?.error?.length) ||
776
+ ((currentTabSelected !== 'logisticOrders' && !ordersValidation?.error?.length) ||
740
777
  (currentTabSelected === 'logisticOrders' && (!logisticOrders?.error?.length || (logisticOrders?.orders?.length > 0 && !logisticOrders?.orders?.some(order => !order?.expired)))))
741
778
  ? t('NO_RESULTS_FOUND', 'Sorry, no results found')
742
- : currentOrdersGroup?.error?.[0]?.message ||
743
- currentOrdersGroup?.error?.[0] ||
779
+ : ordersValidation?.error?.[0]?.message ||
780
+ ordersValidation?.error?.[0] ||
744
781
  (currentTabSelected === 'logisticOrders' && logisticOrders?.error) ||
745
782
  t('NETWORK_ERROR', 'Network Error')
746
783
  }
@@ -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;