ordering-ui-react-native 0.10.3 → 0.11.3
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 +2 -1
- package/themes/business/index.tsx +12 -12
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +49 -43
- package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +4 -10
- package/themes/business/src/components/Chat/index.tsx +97 -60
- package/themes/business/src/components/DriverMap/index.tsx +196 -183
- package/themes/business/src/components/FloatingButton/index.tsx +61 -43
- package/themes/business/src/components/FloatingButton/styles.tsx +2 -5
- package/themes/business/src/components/GoogleMap/index.tsx +10 -8
- package/themes/business/src/components/Home/index.tsx +2 -5
- package/themes/business/src/components/Home/styles.tsx +1 -2
- package/themes/business/src/components/LanguageSelector/index.tsx +1 -3
- package/themes/business/src/components/MessagesOption/index.tsx +13 -18
- package/themes/business/src/components/MessagesOption/styles.tsx +3 -0
- package/themes/business/src/components/OrderDetails/Business.tsx +642 -0
- package/themes/business/src/components/OrderDetails/Delivery.tsx +436 -0
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +378 -0
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +148 -0
- package/themes/business/src/components/OrderDetails/styles.tsx +16 -74
- package/themes/business/src/components/OrderMessage/index.tsx +5 -2
- package/themes/business/src/components/OrdersOption/index.tsx +344 -302
- package/themes/business/src/components/OrdersOption/styles.tsx +4 -2
- package/themes/business/src/components/PreviousMessages/index.tsx +15 -8
- package/themes/business/src/components/PreviousOrders/index.tsx +86 -141
- package/themes/business/src/components/PreviousOrders/styles.tsx +4 -3
- package/themes/business/src/components/UserProfileForm/index.tsx +73 -6
- package/themes/business/src/components/UserProfileForm/styles.tsx +0 -2
- package/themes/business/src/components/shared/OModal.tsx +9 -7
- package/themes/business/src/components/shared/OTextarea.tsx +2 -1
- package/themes/business/src/layouts/SafeAreaContainer.tsx +2 -2
- package/themes/business/src/types/index.tsx +24 -13
- package/themes/business/src/utils/index.tsx +160 -0
- package/themes/business/src/components/OrderDetails/index.tsx +0 -1262
- package/themes/business/src/components/OrderDetailsDelivery/index.tsx +0 -1056
- package/themes/business/src/components/OrderDetailsDelivery/styles.tsx +0 -142
|
@@ -1,242 +1,61 @@
|
|
|
1
|
-
// React & React Native
|
|
2
1
|
import React, { useEffect, useState, useRef } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
Pressable,
|
|
6
|
-
StyleSheet,
|
|
7
|
-
ScrollView,
|
|
8
|
-
Dimensions,
|
|
9
|
-
RefreshControl,
|
|
10
|
-
} from 'react-native';
|
|
11
|
-
|
|
12
|
-
// Ordering
|
|
13
|
-
import { useLanguage, CumulativeOrders } from 'ordering-components/native';
|
|
14
|
-
import { useTheme } from 'styled-components/native';
|
|
15
|
-
|
|
16
|
-
// Third-party
|
|
2
|
+
import { View, Pressable, StyleSheet, ScrollView, RefreshControl } from 'react-native';
|
|
3
|
+
import { useLanguage, OrderListGroups } from 'ordering-components/native';
|
|
17
4
|
import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
|
|
5
|
+
import { DeviceOrientationMethods } from '../../../../../src/hooks/DeviceOrientation'
|
|
18
6
|
|
|
19
|
-
|
|
7
|
+
import { useTheme } from 'styled-components/native';
|
|
8
|
+
import { OText, OButton } from '../shared';
|
|
9
|
+
import { NotFoundSource } from '../NotFoundSource';
|
|
20
10
|
import { FiltersTab, TabsContainer, Tag } from './styles';
|
|
21
11
|
import { PreviousOrders } from '../PreviousOrders';
|
|
22
|
-
import { OText, OIconButton } from '../shared';
|
|
23
12
|
import { OrdersOptionParams } from '../../types';
|
|
24
13
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
14
|
+
import GestureRecognizer from 'react-native-swipe-gestures';
|
|
15
|
+
|
|
16
|
+
const tabsList: any = {
|
|
17
|
+
pending: 1,
|
|
18
|
+
inProgress: 2,
|
|
19
|
+
completed: 3,
|
|
20
|
+
cancelled: 4
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const tabsListText: any = {
|
|
24
|
+
1: 'pending',
|
|
25
|
+
2: 'inProgress',
|
|
26
|
+
3: 'completed',
|
|
27
|
+
4: 'cancelled'
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const swipeConfig = {
|
|
31
|
+
velocityThreshold: 0.3,
|
|
32
|
+
directionalOffsetThreshold: 80
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const { useDeviceOrientation, PORTRAIT } = DeviceOrientationMethods
|
|
32
36
|
|
|
33
37
|
const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
34
38
|
const {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
setCurrentFilters,
|
|
40
|
+
tabs,
|
|
41
|
+
currentTabSelected,
|
|
42
|
+
setCurrentTabSelected,
|
|
43
|
+
ordersGroup,
|
|
44
|
+
setOrdersGroup,
|
|
45
|
+
orderStatus,
|
|
41
46
|
loadOrders,
|
|
47
|
+
loadMoreOrders,
|
|
42
48
|
onNavigationRedirect,
|
|
43
49
|
} = props;
|
|
44
50
|
|
|
45
|
-
// Hooks
|
|
46
51
|
const theme = useTheme();
|
|
47
52
|
const [, t] = useLanguage();
|
|
53
|
+
const [orientationState] = useDeviceOrientation();
|
|
48
54
|
|
|
49
|
-
const
|
|
50
|
-
{ key: 0, text: t('PENDING', 'Pending') },
|
|
51
|
-
{ key: 1, text: t('COMPLETED', 'Completed') },
|
|
52
|
-
{ key: 2, text: t('REJECTED', 'Rejected') },
|
|
53
|
-
{ key: 3, text: t('DRIVER_IN_BUSINESS', 'Driver in business') },
|
|
54
|
-
{ key: 4, text: t('READY_FOR_PICKUP', 'Ready for pickup') },
|
|
55
|
-
{ key: 5, text: t('REJECTED_BY_BUSINESS', 'Rejected by business') },
|
|
56
|
-
{ key: 6, text: t('REJECTED_BY_DRIVER', 'Rejected by Driver') },
|
|
57
|
-
{ key: 7, text: t('ACCEPTED_BY_BUSINESS', 'Accepted by business') },
|
|
58
|
-
{ key: 8, text: t('ACCEPTED_BY_DRIVER', 'Accepted by driver') },
|
|
59
|
-
{
|
|
60
|
-
key: 9,
|
|
61
|
-
text: t('PICK_UP_COMPLETED_BY_DRIVER', 'Pick up completed by driver'),
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
key: 10,
|
|
65
|
-
text: t('PICK_UP_FAILED_BY_DRIVER', 'Pick up Failed by driver'),
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
key: 11,
|
|
69
|
-
text: t('DELIVERY_COMPLETED_BY_DRIVER', 'Delivery completed by driver'),
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
key: 12,
|
|
73
|
-
text: t('DELIVERY_FAILED_BY_DRIVER', 'Delivery Failed by driver'),
|
|
74
|
-
},
|
|
75
|
-
{ key: 13, text: t('PREORDER', 'Preorder') },
|
|
76
|
-
{ key: 14, text: t('ORDER_NOT_READY', 'Order not ready') },
|
|
77
|
-
{
|
|
78
|
-
key: 15,
|
|
79
|
-
text: t(
|
|
80
|
-
'ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER',
|
|
81
|
-
'Order picked up completed by customer',
|
|
82
|
-
),
|
|
83
|
-
},
|
|
84
|
-
{ key: 16, text: t('CANCELLED_BY_CUSTOMER', 'Cancelled by customer') },
|
|
85
|
-
{
|
|
86
|
-
key: 17,
|
|
87
|
-
text: t(
|
|
88
|
-
'ORDER_NOT_PICKEDUP_BY_CUSTOMER',
|
|
89
|
-
'Order not picked up by customer',
|
|
90
|
-
),
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
key: 18,
|
|
94
|
-
text: t(
|
|
95
|
-
'DRIVER_ALMOST_ARRIVED_TO_BUSINESS',
|
|
96
|
-
'Driver almost arrived to business',
|
|
97
|
-
),
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
key: 19,
|
|
101
|
-
text: t(
|
|
102
|
-
'DRIVER_ALMOST_ARRIVED_TO_CUSTOMER',
|
|
103
|
-
'Driver almost arrived to customer',
|
|
104
|
-
),
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
key: 20,
|
|
108
|
-
text: t(
|
|
109
|
-
'ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS',
|
|
110
|
-
'Customer almost arrived to business',
|
|
111
|
-
),
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
key: 21,
|
|
115
|
-
text: t(
|
|
116
|
-
'ORDER_CUSTOMER_ARRIVED_BUSINESS',
|
|
117
|
-
'Customer arrived to business',
|
|
118
|
-
),
|
|
119
|
-
},
|
|
120
|
-
];
|
|
121
|
-
|
|
122
|
-
const tabs = [
|
|
123
|
-
{ key: 0, text: t('PENDING', 'Pending'), tags: [0, 13], title: 'pending' },
|
|
124
|
-
{
|
|
125
|
-
key: 1,
|
|
126
|
-
text: t('IN_PROGRESS', 'In Progress'),
|
|
127
|
-
tags: [3, 4, 7, 8, 9, 14, 18, 19, 20, 21],
|
|
128
|
-
title: 'inProgress',
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
key: 2,
|
|
132
|
-
text: t('COMPLETED', 'Completed'),
|
|
133
|
-
tags: [1, 11, 15],
|
|
134
|
-
title: 'completed',
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
key: 3,
|
|
138
|
-
text: t('CANCELLED', 'Cancelled'),
|
|
139
|
-
tags: [2, 5, 6, 10, 12, 16, 17],
|
|
140
|
-
title: 'cancelled',
|
|
141
|
-
},
|
|
142
|
-
];
|
|
143
|
-
|
|
144
|
-
// Refs
|
|
145
|
-
const scrollRefTag = useRef() as React.MutableRefObject<ScrollView>;
|
|
146
|
-
const scrollRefTab = useRef() as React.MutableRefObject<ScrollView>;
|
|
147
|
-
|
|
148
|
-
// States
|
|
149
|
-
const [activeTab, setActiveTab] = useState<Tab>(tabs[0]);
|
|
150
|
-
const [tagsStatus, setTagsStatus] = useState<number[]>(tabs[0].tags);
|
|
151
|
-
const [isRefreshing, setIsRefreshing] = useState<boolean>(false);
|
|
152
|
-
const [reload, setReload] = useState<boolean>(false);
|
|
153
|
-
const [orientation, setOrientation] = useState<string>(
|
|
154
|
-
Dimensions.get('window').width < Dimensions.get('window').height
|
|
155
|
-
? 'Portrait'
|
|
156
|
-
: 'Landscape',
|
|
157
|
-
);
|
|
158
|
-
const [windowsWidth, setWindowsWidth] = useState<number>(
|
|
159
|
-
parseInt(parseFloat(String(Dimensions.get('window').width)).toFixed(0)),
|
|
160
|
-
);
|
|
161
|
-
|
|
162
|
-
// Handles
|
|
163
|
-
const handleChangeTab = async (tab: Tab) => {
|
|
164
|
-
if (tab.key === activeTab.key) {
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
55
|
+
const WIDTH_SCREEN = orientationState?.dimensions?.width
|
|
167
56
|
|
|
168
|
-
|
|
169
|
-
scrollRefTab.current?.scrollToEnd({ animated: true });
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
if (tab.key === tabs[0].key) {
|
|
173
|
-
scrollRefTab.current?.scrollTo({ animated: true });
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
scrollRefTag.current?.scrollTo({
|
|
177
|
-
y: 0,
|
|
178
|
-
animated: true,
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
setActiveTab(tab);
|
|
182
|
-
setTagsStatus(tab.tags);
|
|
183
|
-
loadOrders?.(tab.title, false);
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
const handleChangeTag = (key: number) => {
|
|
187
|
-
if (activeStatus?.includes(key)) {
|
|
188
|
-
setActiveStatus?.(activeStatus?.filter((tag: number) => tag !== key));
|
|
189
|
-
} else {
|
|
190
|
-
activeStatus && setActiveStatus?.(activeStatus.concat(key));
|
|
191
|
-
}
|
|
192
|
-
};
|
|
57
|
+
const IS_PORTRAIT = orientationState.orientation === PORTRAIT
|
|
193
58
|
|
|
194
|
-
const handleRefreshAndReload = (loadType: string) => {
|
|
195
|
-
if (loadType === 'refresh') {
|
|
196
|
-
setIsRefreshing(true);
|
|
197
|
-
} else {
|
|
198
|
-
setReload(true);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
loadOrders?.(activeTab.title, false, true);
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
const getOrderStatus = (key: number) => {
|
|
205
|
-
return orderStatus.find(status => status.key === key)?.text;
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
// Events
|
|
209
|
-
Dimensions.addEventListener('change', ({ window: { width, height } }) => {
|
|
210
|
-
setWindowsWidth(
|
|
211
|
-
parseInt(parseFloat(String(Dimensions.get('window').width)).toFixed(0)),
|
|
212
|
-
);
|
|
213
|
-
|
|
214
|
-
if (width < height) {
|
|
215
|
-
setOrientation('Portrait');
|
|
216
|
-
} else {
|
|
217
|
-
setOrientation('Landscape');
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
// Effects
|
|
222
|
-
useEffect(() => {
|
|
223
|
-
if (
|
|
224
|
-
!pending?.loading ||
|
|
225
|
-
!inProgress?.loading ||
|
|
226
|
-
!completed?.loading ||
|
|
227
|
-
!cancelled?.loading
|
|
228
|
-
) {
|
|
229
|
-
setIsRefreshing(false);
|
|
230
|
-
setReload(false);
|
|
231
|
-
}
|
|
232
|
-
}, [
|
|
233
|
-
pending?.loading,
|
|
234
|
-
inProgress?.loading,
|
|
235
|
-
completed?.loading,
|
|
236
|
-
cancelled?.loading,
|
|
237
|
-
]);
|
|
238
|
-
|
|
239
|
-
// Styles
|
|
240
59
|
const styles = StyleSheet.create({
|
|
241
60
|
header: {
|
|
242
61
|
marginBottom: 25,
|
|
@@ -257,12 +76,13 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
257
76
|
fontFamily: 'Poppins',
|
|
258
77
|
fontStyle: 'normal',
|
|
259
78
|
fontSize: 14,
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
79
|
+
paddingBottom: 10,
|
|
80
|
+
marginBottom: -1,
|
|
81
|
+
zIndex: 100,
|
|
82
|
+
borderColor: theme.colors.textGray,
|
|
263
83
|
},
|
|
264
84
|
tagsContainer: {
|
|
265
|
-
marginBottom:
|
|
85
|
+
marginBottom: 20,
|
|
266
86
|
},
|
|
267
87
|
tag: {
|
|
268
88
|
fontFamily: 'Poppins',
|
|
@@ -271,8 +91,6 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
271
91
|
fontSize: 14,
|
|
272
92
|
},
|
|
273
93
|
pressable: {
|
|
274
|
-
flex: 1,
|
|
275
|
-
minWidth: 88,
|
|
276
94
|
alignItems: 'center',
|
|
277
95
|
},
|
|
278
96
|
loadButton: {
|
|
@@ -291,35 +109,95 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
291
109
|
},
|
|
292
110
|
});
|
|
293
111
|
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
112
|
+
const scrollRef = useRef() as React.MutableRefObject<ScrollView>;
|
|
113
|
+
const scrollListRef = useRef() as React.MutableRefObject<ScrollView>;
|
|
114
|
+
const scrollRefTab = useRef() as React.MutableRefObject<ScrollView>;
|
|
115
|
+
|
|
116
|
+
const [refreshing] = useState(false);
|
|
117
|
+
|
|
118
|
+
const [tagsState, setTags] = useState<any>({ values: [] })
|
|
119
|
+
|
|
120
|
+
const tagsList = ordersGroup[currentTabSelected].defaultFilter ?? []
|
|
121
|
+
const currentOrdersGroup = ordersGroup[currentTabSelected]
|
|
122
|
+
|
|
123
|
+
const isEqual = (array1: any, array2: any) => {
|
|
124
|
+
return array1.every((item: any) => array2.includes(item)) && array2.every((item: any) => array1.includes(item))
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const handleLoadMore = () => {
|
|
128
|
+
loadMoreOrders && loadMoreOrders();
|
|
299
129
|
};
|
|
300
130
|
|
|
131
|
+
const getOrderStatus = (key: number) => {
|
|
132
|
+
return orderStatus.find((status: any) => status.key === key)?.text;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const handleTagSelected = (tag: any) => {
|
|
136
|
+
const tags = tagsState?.values.includes(tag)
|
|
137
|
+
? tagsState?.values.filter((t: any) => t !== tag)
|
|
138
|
+
: [...tagsState?.values, tag]
|
|
139
|
+
|
|
140
|
+
setCurrentFilters(!tags.length ? tagsList : tags)
|
|
141
|
+
setTags({ values: isEqual(tags, tagsList) ? [] : tags })
|
|
142
|
+
|
|
143
|
+
setOrdersGroup({
|
|
144
|
+
...ordersGroup,
|
|
145
|
+
[currentTabSelected]: {
|
|
146
|
+
...ordersGroup[currentTabSelected],
|
|
147
|
+
currentFilter: !tags.length ? tagsList : tags
|
|
148
|
+
}
|
|
149
|
+
})
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const handleAllSelect = () => {
|
|
153
|
+
setCurrentFilters(tagsList)
|
|
154
|
+
setTags({ values: [] })
|
|
155
|
+
setOrdersGroup({
|
|
156
|
+
...ordersGroup,
|
|
157
|
+
[currentTabSelected]: {
|
|
158
|
+
...ordersGroup[currentTabSelected],
|
|
159
|
+
currentFilter: tagsList
|
|
160
|
+
}
|
|
161
|
+
})
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const onSwipeLeft = () => {
|
|
165
|
+
let currentTab = tabsList[currentTabSelected]
|
|
166
|
+
currentTab = currentTab >= 4 ? null : currentTab + 1
|
|
167
|
+
|
|
168
|
+
if (!currentTab) return
|
|
169
|
+
|
|
170
|
+
const nextTab = tabsListText[currentTab]
|
|
171
|
+
nextTab && setCurrentTabSelected(nextTab)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const onSwipeRight = () => {
|
|
175
|
+
let currentTab = tabsList[currentTabSelected]
|
|
176
|
+
currentTab = currentTab <= 1 ? null : currentTab - 1
|
|
177
|
+
|
|
178
|
+
if (!currentTab) return
|
|
179
|
+
|
|
180
|
+
const nextTab = tabsListText[currentTab]
|
|
181
|
+
nextTab && setCurrentTabSelected(nextTab)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
useEffect(() => {
|
|
185
|
+
setCurrentFilters(null)
|
|
186
|
+
scrollRefTab.current?.scrollTo({ animated: true });
|
|
187
|
+
scrollListRef.current?.scrollTo({ animated: true });
|
|
188
|
+
scrollRef.current?.scrollTo({ y: 0, animated: true });
|
|
189
|
+
}, [currentTabSelected])
|
|
190
|
+
|
|
301
191
|
return (
|
|
192
|
+
// <GestureRecognizer
|
|
193
|
+
// onSwipeLeft={onSwipeLeft}
|
|
194
|
+
// onSwipeRight={onSwipeRight}
|
|
195
|
+
// config={swipeConfig}
|
|
196
|
+
// style={{ flex: 1 }}
|
|
197
|
+
// >
|
|
302
198
|
<>
|
|
303
199
|
<View style={styles.header}>
|
|
304
200
|
<OText style={styles.title}>{t('MY_ORDERS', 'My orders')}</OText>
|
|
305
|
-
|
|
306
|
-
<View style={styles.icons}>
|
|
307
|
-
<OIconButton
|
|
308
|
-
icon={theme.images.general.reload}
|
|
309
|
-
borderColor={theme.colors.clear}
|
|
310
|
-
iconStyle={{ width: 25, height: 25 }}
|
|
311
|
-
style={{ maxWidth: 40, height: 35 }}
|
|
312
|
-
onClick={() => handleRefreshAndReload('reload')}
|
|
313
|
-
/>
|
|
314
|
-
|
|
315
|
-
{/* <OIconButton
|
|
316
|
-
icon={theme.images.general.search}
|
|
317
|
-
borderColor={theme.colors.clear}
|
|
318
|
-
iconStyle={{ width: 25, height: 25 }}
|
|
319
|
-
style={{ maxWidth: 40, height: 35 }}
|
|
320
|
-
onClick={() => {}}
|
|
321
|
-
/> */}
|
|
322
|
-
</View>
|
|
323
201
|
</View>
|
|
324
202
|
|
|
325
203
|
<FiltersTab>
|
|
@@ -327,64 +205,96 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
327
205
|
ref={scrollRefTab}
|
|
328
206
|
showsVerticalScrollIndicator={false}
|
|
329
207
|
showsHorizontalScrollIndicator={false}
|
|
330
|
-
horizontal
|
|
331
|
-
|
|
332
|
-
|
|
208
|
+
horizontal
|
|
209
|
+
nestedScrollEnabled={true}
|
|
210
|
+
>
|
|
211
|
+
<TabsContainer width={WIDTH_SCREEN}>
|
|
212
|
+
{tabs.map((tab: any) => (
|
|
333
213
|
<Pressable
|
|
334
214
|
key={tab.key}
|
|
335
215
|
style={styles.pressable}
|
|
336
|
-
onPress={() =>
|
|
216
|
+
onPress={() => setCurrentTabSelected(tab?.title)}>
|
|
337
217
|
<OText
|
|
338
|
-
style={
|
|
218
|
+
style={{
|
|
219
|
+
...styles.tab,
|
|
220
|
+
fontSize: tab.title === currentTabSelected ? 16 : 14,
|
|
221
|
+
borderBottomWidth: tab.title === currentTabSelected ? 1 : 0,
|
|
222
|
+
}}
|
|
339
223
|
color={
|
|
340
|
-
tab.
|
|
224
|
+
tab.title === currentTabSelected
|
|
341
225
|
? theme.colors.textGray
|
|
342
226
|
: theme.colors.unselectText
|
|
343
227
|
}
|
|
344
|
-
weight={tab.
|
|
228
|
+
weight={tab.title === currentTabSelected ? '600' : 'normal'}
|
|
229
|
+
>
|
|
345
230
|
{tab.text}
|
|
346
231
|
</OText>
|
|
347
|
-
|
|
348
|
-
<View
|
|
349
|
-
style={{
|
|
350
|
-
width: '100%',
|
|
351
|
-
borderBottomColor:
|
|
352
|
-
tab.key === activeTab.key
|
|
353
|
-
? theme.colors.textGray
|
|
354
|
-
: theme.colors.tabBar,
|
|
355
|
-
borderBottomWidth: 2,
|
|
356
|
-
}}
|
|
357
|
-
/>
|
|
358
232
|
</Pressable>
|
|
359
233
|
))}
|
|
360
234
|
</TabsContainer>
|
|
361
235
|
</ScrollView>
|
|
362
236
|
</FiltersTab>
|
|
363
237
|
|
|
364
|
-
<View
|
|
238
|
+
<View
|
|
239
|
+
style={{
|
|
240
|
+
display: 'flex',
|
|
241
|
+
flexDirection: 'row',
|
|
242
|
+
alignContent: 'center',
|
|
243
|
+
alignItems: 'center',
|
|
244
|
+
}}
|
|
245
|
+
>
|
|
246
|
+
{tagsList && tagsList?.length > 1 && (
|
|
247
|
+
<View style={{ marginBottom: 20 }}>
|
|
248
|
+
<Tag
|
|
249
|
+
onPress={() => handleAllSelect()}
|
|
250
|
+
isSelected={
|
|
251
|
+
isEqual(currentOrdersGroup.currentFilter, tagsList)
|
|
252
|
+
? theme.colors.primary
|
|
253
|
+
: theme.colors.tabBar
|
|
254
|
+
}>
|
|
255
|
+
<OText
|
|
256
|
+
style={styles.tag}
|
|
257
|
+
color={
|
|
258
|
+
isEqual(currentOrdersGroup.currentFilter, tagsList)
|
|
259
|
+
? theme.colors.white
|
|
260
|
+
: theme.colors.black
|
|
261
|
+
}>
|
|
262
|
+
{t('All', 'All')}
|
|
263
|
+
</OText>
|
|
264
|
+
</Tag>
|
|
265
|
+
</View>
|
|
266
|
+
)}
|
|
365
267
|
<ScrollView
|
|
366
|
-
ref={
|
|
268
|
+
ref={scrollRef}
|
|
367
269
|
showsVerticalScrollIndicator={false}
|
|
368
270
|
showsHorizontalScrollIndicator={false}
|
|
369
271
|
contentContainerStyle={styles.tagsContainer}
|
|
370
|
-
horizontal
|
|
371
|
-
|
|
272
|
+
horizontal
|
|
273
|
+
>
|
|
274
|
+
{tagsList && tagsList.map((key: number) => (
|
|
372
275
|
<Tag
|
|
373
276
|
key={key}
|
|
374
|
-
onPress={() =>
|
|
277
|
+
onPress={() => !currentOrdersGroup.loading && handleTagSelected(key)}
|
|
375
278
|
isSelected={
|
|
376
|
-
|
|
279
|
+
currentOrdersGroup.currentFilter.includes(key) &&
|
|
280
|
+
!isEqual(currentOrdersGroup.currentFilter, tagsList)
|
|
377
281
|
? theme.colors.primary
|
|
378
282
|
: theme.colors.tabBar
|
|
379
283
|
}>
|
|
380
284
|
<OText
|
|
381
285
|
style={styles.tag}
|
|
382
286
|
color={
|
|
383
|
-
|
|
287
|
+
currentOrdersGroup.currentFilter.includes(key) &&
|
|
288
|
+
!isEqual(currentOrdersGroup.currentFilter, tagsList)
|
|
384
289
|
? theme.colors.white
|
|
385
290
|
: theme.colors.black
|
|
386
291
|
}>
|
|
387
292
|
{getOrderStatus(key)}
|
|
293
|
+
{
|
|
294
|
+
currentOrdersGroup.currentFilter.includes(key) &&
|
|
295
|
+
!isEqual(currentOrdersGroup.currentFilter, tagsList) &&
|
|
296
|
+
' X'
|
|
297
|
+
}
|
|
388
298
|
</OText>
|
|
389
299
|
</Tag>
|
|
390
300
|
))}
|
|
@@ -392,38 +302,33 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
392
302
|
</View>
|
|
393
303
|
|
|
394
304
|
<ScrollView
|
|
305
|
+
ref={scrollListRef}
|
|
395
306
|
showsVerticalScrollIndicator={false}
|
|
396
307
|
style={{ flex: 1 }}
|
|
308
|
+
nestedScrollEnabled={true}
|
|
397
309
|
refreshControl={
|
|
398
310
|
<RefreshControl
|
|
399
|
-
refreshing={
|
|
400
|
-
onRefresh={() =>
|
|
311
|
+
refreshing={refreshing}
|
|
312
|
+
onRefresh={() => loadOrders && loadOrders({ newFetch: true })}
|
|
401
313
|
/>
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
)}
|
|
418
|
-
|
|
419
|
-
{(pending?.loading ||
|
|
420
|
-
inProgress?.loading ||
|
|
421
|
-
completed?.loading ||
|
|
422
|
-
cancelled?.loading ||
|
|
423
|
-
reload) && (
|
|
314
|
+
}
|
|
315
|
+
>
|
|
316
|
+
{!currentOrdersGroup.error?.length &&
|
|
317
|
+
!!currentOrdersGroup.orders?.length &&
|
|
318
|
+
(
|
|
319
|
+
<PreviousOrders
|
|
320
|
+
orders={currentOrdersGroup.orders}
|
|
321
|
+
onNavigationRedirect={onNavigationRedirect}
|
|
322
|
+
getOrderStatus={getOrderStatus}
|
|
323
|
+
/>
|
|
324
|
+
)}
|
|
325
|
+
|
|
326
|
+
{(currentOrdersGroup.loading ||
|
|
327
|
+
currentOrdersGroup.pagination.total === null) &&
|
|
328
|
+
(
|
|
424
329
|
<>
|
|
425
330
|
<View>
|
|
426
|
-
{[...Array(5)].map((
|
|
331
|
+
{[...Array(5)].map((_, i) => (
|
|
427
332
|
<Placeholder key={i} Animation={Fade}>
|
|
428
333
|
<View
|
|
429
334
|
style={{
|
|
@@ -432,7 +337,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
432
337
|
marginBottom: 10,
|
|
433
338
|
}}>
|
|
434
339
|
<PlaceholderLine
|
|
435
|
-
width={
|
|
340
|
+
width={IS_PORTRAIT ? 22 : 11}
|
|
436
341
|
height={74}
|
|
437
342
|
style={{
|
|
438
343
|
marginRight: 20,
|
|
@@ -451,16 +356,153 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
451
356
|
</View>
|
|
452
357
|
</>
|
|
453
358
|
)}
|
|
359
|
+
|
|
360
|
+
{!currentOrdersGroup.error?.length &&
|
|
361
|
+
!currentOrdersGroup.loading &&
|
|
362
|
+
currentOrdersGroup.pagination.totalPages &&
|
|
363
|
+
currentOrdersGroup.pagination.currentPage < currentOrdersGroup.pagination.totalPages &&
|
|
364
|
+
currentOrdersGroup.orders.length &&
|
|
365
|
+
(
|
|
366
|
+
<OButton
|
|
367
|
+
onClick={handleLoadMore}
|
|
368
|
+
text={t('LOAD_MORE_ORDERS', 'Load more orders')}
|
|
369
|
+
imgRightSrc={null}
|
|
370
|
+
textStyle={styles.loadButtonText}
|
|
371
|
+
style={styles.loadButton}
|
|
372
|
+
bgColor={theme.colors.primary}
|
|
373
|
+
borderColor={theme.colors.primary}
|
|
374
|
+
/>
|
|
375
|
+
)}
|
|
376
|
+
|
|
377
|
+
{!currentOrdersGroup.loading &&
|
|
378
|
+
(currentOrdersGroup.error?.length ||
|
|
379
|
+
!currentOrdersGroup.orders?.length) &&
|
|
380
|
+
(
|
|
381
|
+
<NotFoundSource
|
|
382
|
+
content={
|
|
383
|
+
!currentOrdersGroup.error?.length
|
|
384
|
+
? t('NO_RESULTS_FOUND', 'Sorry, no results found')
|
|
385
|
+
: currentOrdersGroup?.error[0]?.message ||
|
|
386
|
+
currentOrdersGroup?.error[0] ||
|
|
387
|
+
t('NETWORK_ERROR', 'Network Error')
|
|
388
|
+
}
|
|
389
|
+
image={theme.images.general.notFound}
|
|
390
|
+
conditioned={false}
|
|
391
|
+
/>
|
|
392
|
+
)}
|
|
454
393
|
</ScrollView>
|
|
394
|
+
{/* </GestureRecognizer> */}
|
|
455
395
|
</>
|
|
456
396
|
);
|
|
457
397
|
};
|
|
458
398
|
|
|
459
399
|
export const OrdersOption = (props: OrdersOptionParams) => {
|
|
460
|
-
const
|
|
400
|
+
const [, t] = useLanguage();
|
|
401
|
+
|
|
402
|
+
const ordersProps = {
|
|
461
403
|
...props,
|
|
462
404
|
UIComponent: OrdersOptionUI,
|
|
405
|
+
useDefualtSessionManager: true,
|
|
406
|
+
asDashboard: true,
|
|
407
|
+
orderStatus: [
|
|
408
|
+
{ key: 0, text: t('PENDING', 'Pending') },
|
|
409
|
+
{ key: 1, text: t('COMPLETED', 'Completed') },
|
|
410
|
+
{ key: 2, text: t('REJECTED', 'Rejected') },
|
|
411
|
+
{ key: 3, text: t('DRIVER_IN_BUSINESS', 'Driver in business') },
|
|
412
|
+
{ key: 4, text: t('READY_FOR_PICKUP', 'Ready for pickup') },
|
|
413
|
+
{ key: 5, text: t('REJECTED_BY_BUSINESS', 'Rejected by business') },
|
|
414
|
+
{ key: 6, text: t('REJECTED_BY_DRIVER', 'Rejected by Driver') },
|
|
415
|
+
{ key: 7, text: t('ACCEPTED_BY_BUSINESS', 'Accepted by business') },
|
|
416
|
+
{ key: 8, text: t('ACCEPTED_BY_DRIVER', 'Accepted by driver') },
|
|
417
|
+
{
|
|
418
|
+
key: 9,
|
|
419
|
+
text: t('PICK_UP_COMPLETED_BY_DRIVER', 'Pick up completed by driver'),
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
key: 10,
|
|
423
|
+
text: t('PICK_UP_FAILED_BY_DRIVER', 'Pick up Failed by driver'),
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
key: 11,
|
|
427
|
+
text: t('DELIVERY_COMPLETED_BY_DRIVER', 'Delivery completed by driver'),
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
key: 12,
|
|
431
|
+
text: t('DELIVERY_FAILED_BY_DRIVER', 'Delivery Failed by driver'),
|
|
432
|
+
},
|
|
433
|
+
{ key: 13, text: t('PREORDER', 'Preorder') },
|
|
434
|
+
{ key: 14, text: t('ORDER_NOT_READY', 'Order not ready') },
|
|
435
|
+
{
|
|
436
|
+
key: 15,
|
|
437
|
+
text: t(
|
|
438
|
+
'ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER',
|
|
439
|
+
'Order picked up completed by customer',
|
|
440
|
+
),
|
|
441
|
+
},
|
|
442
|
+
{ key: 16, text: t('CANCELLED_BY_CUSTOMER', 'Cancelled by customer') },
|
|
443
|
+
{
|
|
444
|
+
key: 17,
|
|
445
|
+
text: t(
|
|
446
|
+
'ORDER_NOT_PICKEDUP_BY_CUSTOMER',
|
|
447
|
+
'Order not picked up by customer',
|
|
448
|
+
),
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
key: 18,
|
|
452
|
+
text: t(
|
|
453
|
+
'DRIVER_ALMOST_ARRIVED_TO_BUSINESS',
|
|
454
|
+
'Driver almost arrived to business',
|
|
455
|
+
),
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
key: 19,
|
|
459
|
+
text: t(
|
|
460
|
+
'DRIVER_ALMOST_ARRIVED_TO_CUSTOMER',
|
|
461
|
+
'Driver almost arrived to customer',
|
|
462
|
+
),
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
key: 20,
|
|
466
|
+
text: t(
|
|
467
|
+
'ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS',
|
|
468
|
+
'Customer almost arrived to business',
|
|
469
|
+
),
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
key: 21,
|
|
473
|
+
text: t(
|
|
474
|
+
'ORDER_CUSTOMER_ARRIVED_BUSINESS',
|
|
475
|
+
'Customer arrived to business',
|
|
476
|
+
),
|
|
477
|
+
},
|
|
478
|
+
],
|
|
479
|
+
tabs: [
|
|
480
|
+
{
|
|
481
|
+
key: 0,
|
|
482
|
+
text: t('PENDING', 'Pending'),
|
|
483
|
+
tags: [0, 13],
|
|
484
|
+
title: 'pending'
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
key: 1,
|
|
488
|
+
text: t('IN_PROGRESS', 'In Progress'),
|
|
489
|
+
tags: [3, 4, 7, 8, 9, 14, 18, 19, 20, 21],
|
|
490
|
+
title: 'inProgress',
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
key: 2,
|
|
494
|
+
text: t('COMPLETED', 'Completed'),
|
|
495
|
+
tags: [1, 11, 15],
|
|
496
|
+
title: 'completed',
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
key: 3,
|
|
500
|
+
text: t('CANCELLED', 'Cancelled'),
|
|
501
|
+
tags: [2, 5, 6, 10, 12, 16, 17],
|
|
502
|
+
title: 'cancelled',
|
|
503
|
+
},
|
|
504
|
+
]
|
|
463
505
|
};
|
|
464
506
|
|
|
465
|
-
return <
|
|
507
|
+
return <OrderListGroups {...ordersProps} />;
|
|
466
508
|
};
|