ordering-ui-react-native 0.23.72 → 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,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useState, useRef } from 'react';
|
|
2
|
-
import { View, Pressable, StyleSheet, ScrollView, RefreshControl, Platform, TouchableOpacity
|
|
2
|
+
import { View, Pressable, StyleSheet, ScrollView, RefreshControl, Platform, TouchableOpacity } from 'react-native';
|
|
3
3
|
import { useLanguage, useUtils, OrderListGroups, useConfig } from 'ordering-components/native';
|
|
4
4
|
import SelectDropdown from 'react-native-select-dropdown'
|
|
5
5
|
import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
|
|
@@ -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'),
|
|
@@ -139,8 +143,6 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
139
143
|
const HEIGHT_SCREEN = orientationState?.dimensions?.height
|
|
140
144
|
const IS_PORTRAIT = orientationState.orientation === PORTRAIT
|
|
141
145
|
const showTagsList = !props.isAlsea && !props.isDriverApp && currentTabSelected !== 'logisticOrders'
|
|
142
|
-
const AnimatedFeatherIcon = Animated.createAnimatedComponent(FeatherIcon);
|
|
143
|
-
const spinValue = new Animated.Value(0);
|
|
144
146
|
|
|
145
147
|
const preorderTypeList = [
|
|
146
148
|
{ key: null, name: t('SLA', 'SLA\'s') },
|
|
@@ -292,13 +294,27 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
292
294
|
|
|
293
295
|
const tagsList = ordersGroup[currentTabSelected]?.defaultFilter ?? []
|
|
294
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
|
|
295
311
|
|
|
296
312
|
const isEqual = (array1: any, array2: any) => {
|
|
297
313
|
return array1?.every((item: any) => array2.includes(item)) && array2?.every((item: any) => array1.includes(item))
|
|
298
314
|
}
|
|
299
315
|
|
|
300
316
|
const handleLoadMore = () => {
|
|
301
|
-
loadMoreOrders && loadMoreOrders();
|
|
317
|
+
loadMoreOrders && loadMoreOrders({ allStatusses: hasSearchFilters });
|
|
302
318
|
};
|
|
303
319
|
|
|
304
320
|
const getOrderStatus = (key: number) => {
|
|
@@ -306,13 +322,6 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
306
322
|
};
|
|
307
323
|
|
|
308
324
|
const applyFilters = () => {
|
|
309
|
-
setOrdersGroup({
|
|
310
|
-
...ordersGroup,
|
|
311
|
-
[currentTabSelected]: {
|
|
312
|
-
...ordersGroup[currentTabSelected],
|
|
313
|
-
orders: []
|
|
314
|
-
}
|
|
315
|
-
})
|
|
316
325
|
const dateRange = calculateDate(search.date.type, search.date.from, search.date.to)
|
|
317
326
|
onFiltered && onFiltered({ ...search, date: { ...dateRange } })
|
|
318
327
|
setOpenSearchModal(false)
|
|
@@ -382,6 +391,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
382
391
|
}
|
|
383
392
|
|
|
384
393
|
const handleClose = () => {
|
|
394
|
+
setSearch(defaultSearchList)
|
|
385
395
|
setOpenSearchModal(false)
|
|
386
396
|
setOpenSLASettingModal(false)
|
|
387
397
|
}
|
|
@@ -470,26 +480,24 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
470
480
|
}
|
|
471
481
|
}, [isNetConnected, JSON.stringify(offlineActionsState.orders)]);
|
|
472
482
|
|
|
473
|
-
const handleInitAnimation = () => {
|
|
474
|
-
Animated.timing(
|
|
475
|
-
spinValue,
|
|
476
|
-
{
|
|
477
|
-
toValue: 1,
|
|
478
|
-
duration: 2000,
|
|
479
|
-
easing: Easing.linear,
|
|
480
|
-
useNativeDriver: true
|
|
481
|
-
}
|
|
482
|
-
).start()
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
useEffect(() => {
|
|
486
|
-
if (currentOrdersGroup?.loading || logisticOrders?.loading){
|
|
487
|
-
handleInitAnimation()
|
|
488
|
-
}
|
|
489
|
-
}, [currentOrdersGroup?.loading, logisticOrders?.loading])
|
|
490
|
-
|
|
491
483
|
return (
|
|
492
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
|
+
)}
|
|
493
501
|
<View style={styles.header}>
|
|
494
502
|
<OText style={styles.title}>{t('MY_ORDERS', 'My orders')}</OText>
|
|
495
503
|
<IconWrapper>
|
|
@@ -497,85 +505,99 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
497
505
|
<WebsocketStatus />
|
|
498
506
|
</View>
|
|
499
507
|
{isNetConnected && (
|
|
500
|
-
<
|
|
508
|
+
<FeatherIcon
|
|
501
509
|
name='refresh-cw'
|
|
502
510
|
color={theme.colors.backgroundDark}
|
|
503
511
|
size={24}
|
|
504
|
-
onPress={() => currentTabSelected === 'logisticOrders' ? loadLogisticOrders && loadLogisticOrders() : loadOrders && loadOrders({ newFetch: true })}
|
|
512
|
+
onPress={() => currentTabSelected === 'logisticOrders' ? loadLogisticOrders && loadLogisticOrders() : loadOrders && loadOrders({ newFetch: true, }, { allStatusses: hasSearchFilters })}
|
|
505
513
|
style={{
|
|
506
|
-
marginRight: 20
|
|
507
|
-
transform: [{
|
|
508
|
-
rotate: spinValue.interpolate({
|
|
509
|
-
inputRange: [0, 0.3],
|
|
510
|
-
outputRange: ['0deg', '360deg'],
|
|
511
|
-
})
|
|
512
|
-
}]
|
|
514
|
+
marginRight: 20
|
|
513
515
|
}}
|
|
514
516
|
/>
|
|
515
517
|
)}
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
</View>
|
|
524
|
-
<FiltersTab>
|
|
525
|
-
<ScrollView
|
|
526
|
-
ref={scrollRefTab}
|
|
527
|
-
showsVerticalScrollIndicator={false}
|
|
528
|
-
showsHorizontalScrollIndicator={false}
|
|
529
|
-
horizontal
|
|
530
|
-
nestedScrollEnabled={true}
|
|
531
|
-
>
|
|
532
|
-
<TabsContainer>
|
|
533
|
-
{(isLogisticActivated && !isBusinessApp && !combineTabs) && (
|
|
534
|
-
<Pressable
|
|
535
|
-
style={styles.pressable}
|
|
536
|
-
onPress={() => setCurrentTabSelected('logisticOrders')}>
|
|
537
|
-
<OIcon
|
|
538
|
-
src={theme.images?.general?.chronometer}
|
|
539
|
-
borderBottomWidth={currentTabSelected === 'logisticOrders' ? 1 : 0}
|
|
540
|
-
width={currentTabSelected === 'logisticOrders' ? 26 : 24}
|
|
541
|
-
height={currentTabSelected === 'logisticOrders' ? 26 : 24}
|
|
542
|
-
color={
|
|
543
|
-
currentTabSelected === 'logisticOrders'
|
|
544
|
-
? theme.colors.textGray
|
|
545
|
-
: theme.colors.unselectText
|
|
546
|
-
}
|
|
547
|
-
style={styles.icon}
|
|
548
|
-
/>
|
|
549
|
-
</Pressable>
|
|
550
|
-
)}
|
|
551
|
-
{tabs.map((tab: any) => (
|
|
552
|
-
<TabPressable
|
|
553
|
-
key={tab.key}
|
|
554
|
-
onPress={() => setCurrentTabSelected(tab?.title)}
|
|
555
|
-
isSelected={tab.title === currentTabSelected ? 1 : 0}
|
|
556
|
-
>
|
|
557
|
-
<OText
|
|
518
|
+
{currentTabSelected !== 'logisticOrders' && (
|
|
519
|
+
<View>
|
|
520
|
+
{hasSearchFilters && (
|
|
521
|
+
<AntDesignIcon
|
|
522
|
+
name='exclamationcircle'
|
|
523
|
+
color={theme.colors.primary}
|
|
524
|
+
size={16}
|
|
558
525
|
style={{
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
526
|
+
position: 'absolute',
|
|
527
|
+
zIndex: 1000,
|
|
528
|
+
right: -8,
|
|
529
|
+
top: -5
|
|
562
530
|
}}
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
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}
|
|
569
577
|
>
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
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
|
+
)}
|
|
577
599
|
<View style={{ flex: 1, minHeight: HEIGHT_SCREEN - 450 }}>
|
|
578
|
-
{showTagsList && (
|
|
600
|
+
{showTagsList && !hasSearchFilters && (
|
|
579
601
|
<View
|
|
580
602
|
style={{
|
|
581
603
|
display: 'flex',
|
|
@@ -674,17 +696,17 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
674
696
|
refreshControl={
|
|
675
697
|
<RefreshControl
|
|
676
698
|
refreshing={refreshing}
|
|
677
|
-
onRefresh={() => { isNetConnected && (currentTabSelected === 'logisticOrders' ? loadLogisticOrders && loadLogisticOrders() : loadOrders && loadOrders({ newFetch: true })) }}
|
|
699
|
+
onRefresh={() => { isNetConnected && (currentTabSelected === 'logisticOrders' ? loadLogisticOrders && loadLogisticOrders() : loadOrders && loadOrders({ newFetch: true }, { allStatusses: hasSearchFilters })) }}
|
|
678
700
|
/>
|
|
679
701
|
}
|
|
680
702
|
>
|
|
681
|
-
{!
|
|
682
|
-
|
|
703
|
+
{!ordersValidation?.error?.length &&
|
|
704
|
+
(ordersValidation?.orders?.length > 0 || ordersFiltered?.orders?.length > 0) &&
|
|
683
705
|
currentTabSelected !== 'logisticOrders' &&
|
|
684
|
-
!
|
|
706
|
+
!ordersValidation?.loading &&
|
|
685
707
|
(
|
|
686
708
|
<PreviousOrders
|
|
687
|
-
orders={ordersFormatted}
|
|
709
|
+
orders={hasSearchFilters ? ordersFiltered?.orders : ordersFormatted}
|
|
688
710
|
navigation={props.navigation}
|
|
689
711
|
onNavigationRedirect={onNavigationRedirect}
|
|
690
712
|
getOrderStatus={getOrderStatus}
|
|
@@ -714,14 +736,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
714
736
|
)
|
|
715
737
|
}
|
|
716
738
|
{(
|
|
717
|
-
|
|
718
|
-
(
|
|
719
|
-
currentOrdersGroup?.loading ||
|
|
720
|
-
(currentOrdersGroup?.pagination?.total === null && isNetConnected) ||
|
|
721
|
-
logisticOrders?.loading
|
|
722
|
-
) &&
|
|
723
|
-
!currentOrdersGroup?.error?.length
|
|
724
|
-
) || internetLoading
|
|
739
|
+
loadingValidation || internetLoading
|
|
725
740
|
) && (
|
|
726
741
|
<View style={{ marginTop: 10 }}>
|
|
727
742
|
{[...Array(5)].map((_, i) => (
|
|
@@ -753,11 +768,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
753
768
|
)}
|
|
754
769
|
|
|
755
770
|
{isNetConnected &&
|
|
756
|
-
|
|
757
|
-
!currentOrdersGroup?.loading &&
|
|
758
|
-
currentOrdersGroup?.pagination?.totalPages &&
|
|
759
|
-
currentOrdersGroup?.pagination?.currentPage < currentOrdersGroup?.pagination?.totalPages &&
|
|
760
|
-
currentOrdersGroup?.orders?.length > 0 &&
|
|
771
|
+
paginationValidation &&
|
|
761
772
|
(
|
|
762
773
|
<OButton
|
|
763
774
|
onClick={handleLoadMore}
|
|
@@ -771,9 +782,9 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
771
782
|
)}
|
|
772
783
|
|
|
773
784
|
{!internetLoading &&
|
|
774
|
-
((!
|
|
775
|
-
(
|
|
776
|
-
|
|
785
|
+
((!ordersValidation?.loading &&
|
|
786
|
+
(ordersValidation?.error?.length ||
|
|
787
|
+
ordersValidation?.orders?.length === 0)) ||
|
|
777
788
|
(currentTabSelected === 'logisticOrders' &&
|
|
778
789
|
(logisticOrders && !logisticOrders?.loading && (logisticOrders?.error?.length > 0 || logisticOrders?.orders?.length === 0 || !logisticOrders?.orders?.some(order => !order?.expired))))
|
|
779
790
|
) &&
|
|
@@ -781,11 +792,11 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
781
792
|
<NotFoundSource
|
|
782
793
|
content={
|
|
783
794
|
!isNetConnected ? t('NETWORK_ERROR', 'Network Error') :
|
|
784
|
-
((currentTabSelected !== 'logisticOrders' && !
|
|
795
|
+
((currentTabSelected !== 'logisticOrders' && !ordersValidation?.error?.length) ||
|
|
785
796
|
(currentTabSelected === 'logisticOrders' && (!logisticOrders?.error?.length || (logisticOrders?.orders?.length > 0 && !logisticOrders?.orders?.some(order => !order?.expired)))))
|
|
786
797
|
? t('NO_RESULTS_FOUND', 'Sorry, no results found')
|
|
787
|
-
:
|
|
788
|
-
|
|
798
|
+
: ordersValidation?.error?.[0]?.message ||
|
|
799
|
+
ordersValidation?.error?.[0] ||
|
|
789
800
|
(currentTabSelected === 'logisticOrders' && logisticOrders?.error) ||
|
|
790
801
|
t('NETWORK_ERROR', 'Network Error')
|
|
791
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;
|