ordering-ui-react-native 0.12.14 → 0.12.18
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 +1 -1
- package/src/components/AddressList/index.tsx +3 -1
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +168 -156
- package/themes/business/src/components/NewOrderNotification/index.tsx +14 -1
- package/themes/business/src/components/OrderDetails/Delivery.tsx +3 -1
- package/themes/business/src/components/OrdersOption/index.tsx +19 -15
- package/themes/business/src/components 2/AcceptOrRejectOrder/index.tsx +389 -0
- package/themes/business/src/components 2/AcceptOrRejectOrder/styles.tsx +36 -0
- package/themes/business/src/components 2/BusinessController/index.tsx +155 -0
- package/themes/business/src/components 2/BusinessController/styles.tsx +19 -0
- package/themes/business/src/components 2/Chat/index.tsx +1152 -0
- package/themes/business/src/components 2/Chat/styles.tsx +12 -0
- package/themes/business/src/components 2/Contacts/index.tsx +299 -0
- package/themes/business/src/components 2/Contacts/styles.tsx +42 -0
- package/themes/business/src/components 2/DriverMap/index.tsx +525 -0
- package/themes/business/src/components 2/FloatingButton/index.tsx +141 -0
- package/themes/business/src/components 2/FloatingButton/styles.tsx +35 -0
- package/themes/business/src/components 2/ForgotPasswordForm/index.tsx +204 -0
- package/themes/business/src/components 2/ForgotPasswordForm/styles.tsx +11 -0
- package/themes/business/src/components 2/GoogleMap/index.tsx +347 -0
- package/themes/business/src/components 2/Home/index.tsx +111 -0
- package/themes/business/src/components 2/Home/styles.tsx +27 -0
- package/themes/business/src/components 2/LanguageSelector/index.tsx +124 -0
- package/themes/business/src/components 2/LanguageSelector/lang_country.json +152 -0
- package/themes/business/src/components 2/LanguageSelector/styles.tsx +17 -0
- package/themes/business/src/components 2/LoginForm/index.tsx +663 -0
- package/themes/business/src/components 2/LoginForm/styles.tsx +48 -0
- package/themes/business/src/components 2/LogoutButton/index.tsx +63 -0
- package/themes/business/src/components 2/MapView/index.tsx +317 -0
- package/themes/business/src/components 2/MessagesOption/index.tsx +337 -0
- package/themes/business/src/components 2/MessagesOption/styles.tsx +27 -0
- package/themes/business/src/components 2/NewOrderNotification/index.tsx +167 -0
- package/themes/business/src/components 2/NewOrderNotification/styles.tsx +8 -0
- package/themes/business/src/components 2/NotFoundSource/index.tsx +52 -0
- package/themes/business/src/components 2/NotFoundSource/styles.tsx +17 -0
- package/themes/business/src/components 2/OrderDetails/Business.tsx +683 -0
- package/themes/business/src/components 2/OrderDetails/Delivery.tsx +454 -0
- package/themes/business/src/components 2/OrderDetails/OrderContentComponent.tsx +391 -0
- package/themes/business/src/components 2/OrderDetails/OrderHeaderComponent.tsx +148 -0
- package/themes/business/src/components 2/OrderDetails/styles.tsx +84 -0
- package/themes/business/src/components 2/OrderMessage/index.tsx +344 -0
- package/themes/business/src/components 2/OrderMessage/styles.tsx +5 -0
- package/themes/business/src/components 2/OrderSummary/index.tsx +700 -0
- package/themes/business/src/components 2/OrderSummary/styles.tsx +61 -0
- package/themes/business/src/components 2/OrdersOption/index.tsx +755 -0
- package/themes/business/src/components 2/OrdersOption/styles.tsx +54 -0
- package/themes/business/src/components 2/OrdersOptionBusiness/index.tsx +51 -0
- package/themes/business/src/components 2/OrdersOptionBusiness/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionCity/index.tsx +52 -0
- package/themes/business/src/components 2/OrdersOptionCity/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionDate/index.tsx +52 -0
- package/themes/business/src/components 2/OrdersOptionDate/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionDelivery/index.tsx +35 -0
- package/themes/business/src/components 2/OrdersOptionDelivery/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionDriver/index.tsx +50 -0
- package/themes/business/src/components 2/OrdersOptionDriver/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionPaymethod/index.tsx +49 -0
- package/themes/business/src/components 2/OrdersOptionPaymethod/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionStatus/index.tsx +46 -0
- package/themes/business/src/components 2/OrdersOptionStatus/styles.tsx +8 -0
- package/themes/business/src/components 2/PhoneInputNumber/index.tsx +160 -0
- package/themes/business/src/components 2/PhoneInputNumber/styles.tsx +3 -0
- package/themes/business/src/components 2/PreviousMessages/index.tsx +304 -0
- package/themes/business/src/components 2/PreviousMessages/styles.tsx +32 -0
- package/themes/business/src/components 2/PreviousOrders/index.tsx +180 -0
- package/themes/business/src/components 2/PreviousOrders/styles.tsx +38 -0
- package/themes/business/src/components 2/ProductItemAccordion/index.tsx +301 -0
- package/themes/business/src/components 2/ProductItemAccordion/styles.tsx +61 -0
- package/themes/business/src/components 2/SearchBar/index.tsx +112 -0
- package/themes/business/src/components 2/SignupForm/index.tsx +530 -0
- package/themes/business/src/components 2/SignupForm/styles.tsx +16 -0
- package/themes/business/src/components 2/StoresList/index.tsx +208 -0
- package/themes/business/src/components 2/StoresList/styles.tsx +26 -0
- package/themes/business/src/components 2/UserFormDetails/index.tsx +513 -0
- package/themes/business/src/components 2/UserFormDetails/styles.tsx +40 -0
- package/themes/business/src/components 2/UserProfileForm/index.tsx +496 -0
- package/themes/business/src/components 2/UserProfileForm/styles.tsx +36 -0
- package/themes/business/src/components 2/VerifyPhone/index.tsx +201 -0
- package/themes/business/src/components 2/VerifyPhone/styles.tsx +43 -0
- package/themes/business/src/components 2/shared/OAlert.tsx +52 -0
- package/themes/business/src/components 2/shared/OButton.tsx +149 -0
- package/themes/business/src/components 2/shared/OChatBubble.tsx +100 -0
- package/themes/business/src/components 2/shared/ODropDown.tsx +195 -0
- package/themes/business/src/components 2/shared/ODropDownCalendar.tsx +328 -0
- package/themes/business/src/components 2/shared/OFab.tsx +54 -0
- package/themes/business/src/components 2/shared/OIcon.tsx +67 -0
- package/themes/business/src/components 2/shared/OIconButton.tsx +127 -0
- package/themes/business/src/components 2/shared/OInput.tsx +144 -0
- package/themes/business/src/components 2/shared/OLink.tsx +76 -0
- package/themes/business/src/components 2/shared/OModal.tsx +275 -0
- package/themes/business/src/components 2/shared/OSegment.tsx +86 -0
- package/themes/business/src/components 2/shared/OText.tsx +55 -0
- package/themes/business/src/components 2/shared/OTextarea.tsx +46 -0
- package/themes/business/src/components 2/shared/OToast.tsx +92 -0
- package/themes/business/src/components 2/shared/index.tsx +27 -0
- package/themes/business/src/types/index.tsx +4 -1
- package/themes/kiosk/src/components/CategoriesMenu/index.tsx +128 -83
- package/themes/kiosk/src/components/DrawerView/index.tsx +57 -0
- package/themes/kiosk/src/components/DrawerView/styles.tsx +30 -0
- package/themes/kiosk/src/components/LanguageSelector/index.tsx +78 -58
- package/themes/kiosk/src/components/OrderDetails/index.tsx +3 -1
- package/themes/kiosk/src/components/ProductForm/index.tsx +129 -127
- package/themes/kiosk/src/components/ProductForm/styles.tsx +1 -1
- package/themes/original/src/components/BusinessesListing/index.tsx +9 -6
- package/themes/original/src/components/OrderProgress/index.tsx +32 -18
|
@@ -0,0 +1,755 @@
|
|
|
1
|
+
import React, { useEffect, useState, useRef } from 'react';
|
|
2
|
+
import { View, Pressable, StyleSheet, ScrollView, RefreshControl, Linking, Platform } from 'react-native';
|
|
3
|
+
import { useLanguage, useUtils, OrderListGroups } from 'ordering-components/native';
|
|
4
|
+
import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
|
|
5
|
+
import FeatherIcon from 'react-native-vector-icons/Feather';
|
|
6
|
+
import FontistoIcon from 'react-native-vector-icons/Fontisto'
|
|
7
|
+
import { useTheme } from 'styled-components/native';
|
|
8
|
+
import { DeviceOrientationMethods } from '../../../../../src/hooks/DeviceOrientation'
|
|
9
|
+
|
|
10
|
+
import { OText, OButton, OModal, OIconButton, OInput, OIcon } from '../shared';
|
|
11
|
+
import { NotFoundSource } from '../NotFoundSource';
|
|
12
|
+
import {
|
|
13
|
+
FiltersTab,
|
|
14
|
+
TabsContainer,
|
|
15
|
+
Tag,
|
|
16
|
+
IconWrapper,
|
|
17
|
+
ModalContainer,
|
|
18
|
+
ModalTitle,
|
|
19
|
+
FilterBtnWrapper
|
|
20
|
+
} from './styles';
|
|
21
|
+
import { PreviousOrders } from '../PreviousOrders';
|
|
22
|
+
import { OrdersOptionParams } from '../../types';
|
|
23
|
+
import { NewOrderNotification } from '../NewOrderNotification';
|
|
24
|
+
|
|
25
|
+
import { TouchableOpacity } from 'react-native-gesture-handler';
|
|
26
|
+
import GestureRecognizer from 'react-native-swipe-gestures';
|
|
27
|
+
import ODropDown from '../shared/ODropDown';
|
|
28
|
+
import { OrdersOptionStatus } from '../OrdersOptionStatus'
|
|
29
|
+
import { OrdersOptionCity } from '../OrdersOptionCity';
|
|
30
|
+
import { OrdersOptionBusiness } from '../OrdersOptionBusiness';
|
|
31
|
+
import { OrdersOptionDelivery } from '../OrdersOptionDelivery';
|
|
32
|
+
import { OrdersOptionPaymethod } from '../OrdersOptionPaymethod';
|
|
33
|
+
import { OrdersOptionDriver } from '../OrdersOptionDriver';
|
|
34
|
+
import { OrdersOptionDate } from '../OrdersOptionDate';
|
|
35
|
+
|
|
36
|
+
const tabsList: any = {
|
|
37
|
+
pending: 1,
|
|
38
|
+
inProgress: 2,
|
|
39
|
+
completed: 3,
|
|
40
|
+
cancelled: 4
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const tabsListText: any = {
|
|
44
|
+
1: 'pending',
|
|
45
|
+
2: 'inProgress',
|
|
46
|
+
3: 'completed',
|
|
47
|
+
4: 'cancelled'
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const swipeConfig = {
|
|
51
|
+
velocityThreshold: 0.3,
|
|
52
|
+
directionalOffsetThreshold: 80
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const { useDeviceOrientation, PORTRAIT } = DeviceOrientationMethods
|
|
56
|
+
|
|
57
|
+
const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
58
|
+
const {
|
|
59
|
+
setCurrentFilters,
|
|
60
|
+
tabs,
|
|
61
|
+
currentTabSelected,
|
|
62
|
+
setCurrentTabSelected,
|
|
63
|
+
ordersGroup,
|
|
64
|
+
setOrdersGroup,
|
|
65
|
+
orderStatus,
|
|
66
|
+
loadOrders,
|
|
67
|
+
loadMoreOrders,
|
|
68
|
+
onNavigationRedirect,
|
|
69
|
+
filtered,
|
|
70
|
+
onFiltered,
|
|
71
|
+
handleClickOrder,
|
|
72
|
+
handleClickLogisticOrder,
|
|
73
|
+
isBusinessApp,
|
|
74
|
+
logisticOrders,
|
|
75
|
+
loadLogisticOrders
|
|
76
|
+
} = props;
|
|
77
|
+
|
|
78
|
+
const defaultSearchList = {
|
|
79
|
+
id: '',
|
|
80
|
+
state: '',
|
|
81
|
+
city: '',
|
|
82
|
+
business: '',
|
|
83
|
+
delivery_type: '',
|
|
84
|
+
paymethod: '',
|
|
85
|
+
driver: '',
|
|
86
|
+
date: {
|
|
87
|
+
from: '',
|
|
88
|
+
to: '',
|
|
89
|
+
type: ''
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const theme = useTheme();
|
|
94
|
+
const [, t] = useLanguage();
|
|
95
|
+
const [{ parseDate }] = useUtils()
|
|
96
|
+
const [orientationState] = useDeviceOrientation();
|
|
97
|
+
const [openModal, setOpenModal] = useState(false)
|
|
98
|
+
const [search, setSearch] = useState(defaultSearchList)
|
|
99
|
+
|
|
100
|
+
const WIDTH_SCREEN = orientationState?.dimensions?.width
|
|
101
|
+
const HEIGHT_SCREEN = orientationState?.dimensions?.height
|
|
102
|
+
const IS_PORTRAIT = orientationState.orientation === PORTRAIT
|
|
103
|
+
|
|
104
|
+
const styles = StyleSheet.create({
|
|
105
|
+
header: {
|
|
106
|
+
marginBottom: isBusinessApp ? 10 : 20,
|
|
107
|
+
flexDirection: 'row',
|
|
108
|
+
justifyContent: 'space-between',
|
|
109
|
+
alignItems: 'center'
|
|
110
|
+
},
|
|
111
|
+
title: {
|
|
112
|
+
fontFamily: 'Poppins',
|
|
113
|
+
fontStyle: 'normal',
|
|
114
|
+
fontWeight: '600',
|
|
115
|
+
fontSize: 26,
|
|
116
|
+
color: theme.colors.textGray,
|
|
117
|
+
},
|
|
118
|
+
icons: {
|
|
119
|
+
flexDirection: 'row',
|
|
120
|
+
},
|
|
121
|
+
tab: {
|
|
122
|
+
fontFamily: 'Poppins',
|
|
123
|
+
fontStyle: 'normal',
|
|
124
|
+
fontSize: 14,
|
|
125
|
+
paddingBottom: 10,
|
|
126
|
+
marginBottom: -1,
|
|
127
|
+
zIndex: 100,
|
|
128
|
+
borderColor: theme.colors.textGray,
|
|
129
|
+
},
|
|
130
|
+
icon: {
|
|
131
|
+
paddingBottom: 10,
|
|
132
|
+
zIndex: 100,
|
|
133
|
+
marginBottom: 2,
|
|
134
|
+
},
|
|
135
|
+
tagsContainer: {
|
|
136
|
+
marginBottom: 20,
|
|
137
|
+
},
|
|
138
|
+
tag: {
|
|
139
|
+
fontFamily: 'Poppins',
|
|
140
|
+
fontStyle: 'normal',
|
|
141
|
+
fontWeight: 'normal',
|
|
142
|
+
fontSize: 14,
|
|
143
|
+
},
|
|
144
|
+
pressable: {
|
|
145
|
+
alignItems: 'center',
|
|
146
|
+
},
|
|
147
|
+
loadButton: {
|
|
148
|
+
borderRadius: 7.6,
|
|
149
|
+
height: 44,
|
|
150
|
+
marginRight: 10,
|
|
151
|
+
marginBottom: 10,
|
|
152
|
+
marginTop: 5,
|
|
153
|
+
},
|
|
154
|
+
loadButtonText: {
|
|
155
|
+
color: theme.colors.inputTextColor,
|
|
156
|
+
fontFamily: 'Poppins',
|
|
157
|
+
fontStyle: 'normal',
|
|
158
|
+
fontWeight: 'normal',
|
|
159
|
+
fontSize: 18,
|
|
160
|
+
},
|
|
161
|
+
inputStyle: {
|
|
162
|
+
width: '100%',
|
|
163
|
+
borderWidth: 1,
|
|
164
|
+
borderColor: '#DEE2E6',
|
|
165
|
+
borderRadius: 7.6,
|
|
166
|
+
marginBottom: 24
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
const scrollRef = useRef() as React.MutableRefObject<ScrollView>;
|
|
171
|
+
const scrollListRef = useRef() as React.MutableRefObject<ScrollView>;
|
|
172
|
+
const scrollRefTab = useRef() as React.MutableRefObject<ScrollView>;
|
|
173
|
+
|
|
174
|
+
const [refreshing] = useState(false);
|
|
175
|
+
|
|
176
|
+
const [tagsState, setTags] = useState<any>({ values: [] })
|
|
177
|
+
|
|
178
|
+
const tagsList = ordersGroup[currentTabSelected]?.defaultFilter ?? []
|
|
179
|
+
const currentOrdersGroup = ordersGroup[currentTabSelected]
|
|
180
|
+
|
|
181
|
+
const isEqual = (array1: any, array2: any) => {
|
|
182
|
+
return array1?.every((item: any) => array2.includes(item)) && array2?.every((item: any) => array1.includes(item))
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const handleLoadMore = () => {
|
|
186
|
+
loadMoreOrders && loadMoreOrders();
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const getOrderStatus = (key: number) => {
|
|
190
|
+
return orderStatus.find((status: any) => status.key === key)?.text;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
const applyFilters = () => {
|
|
194
|
+
setOrdersGroup({
|
|
195
|
+
...ordersGroup,
|
|
196
|
+
[currentTabSelected]: {
|
|
197
|
+
...ordersGroup[currentTabSelected],
|
|
198
|
+
orders: []
|
|
199
|
+
}
|
|
200
|
+
})
|
|
201
|
+
const dateRange = calculateDate(search.date.type, search.date.from, search.date.to)
|
|
202
|
+
onFiltered && onFiltered({ ...search, date: { ...dateRange } })
|
|
203
|
+
setOpenModal(false)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const handleTagSelected = (tag: any) => {
|
|
207
|
+
const tags = tagsState?.values.includes(tag)
|
|
208
|
+
? tagsState?.values.filter((t: any) => t !== tag)
|
|
209
|
+
: [...tagsState?.values, tag]
|
|
210
|
+
|
|
211
|
+
setCurrentFilters(!tags.length ? tagsList : tags)
|
|
212
|
+
setTags({ values: isEqual(tags, tagsList) ? [] : tags })
|
|
213
|
+
|
|
214
|
+
setOrdersGroup({
|
|
215
|
+
...ordersGroup,
|
|
216
|
+
[currentTabSelected]: {
|
|
217
|
+
...ordersGroup[currentTabSelected],
|
|
218
|
+
currentFilter: !tags.length ? tagsList : tags
|
|
219
|
+
}
|
|
220
|
+
})
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const handleAllSelect = () => {
|
|
224
|
+
setCurrentFilters(tagsList)
|
|
225
|
+
setTags({ values: [] })
|
|
226
|
+
setOrdersGroup({
|
|
227
|
+
...ordersGroup,
|
|
228
|
+
[currentTabSelected]: {
|
|
229
|
+
...ordersGroup[currentTabSelected],
|
|
230
|
+
currentFilter: tagsList
|
|
231
|
+
}
|
|
232
|
+
})
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const onSwipeLeft = () => {
|
|
236
|
+
let currentTab = tabsList[currentTabSelected]
|
|
237
|
+
currentTab = currentTab >= 4 ? null : currentTab + 1
|
|
238
|
+
|
|
239
|
+
if (!currentTab) return
|
|
240
|
+
|
|
241
|
+
const nextTab = tabsListText[currentTab]
|
|
242
|
+
nextTab && setCurrentTabSelected(nextTab)
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const onSwipeRight = () => {
|
|
246
|
+
let currentTab = tabsList[currentTabSelected]
|
|
247
|
+
currentTab = currentTab <= 1 ? null : currentTab - 1
|
|
248
|
+
|
|
249
|
+
if (!currentTab) return
|
|
250
|
+
|
|
251
|
+
const nextTab = tabsListText[currentTab]
|
|
252
|
+
nextTab && setCurrentTabSelected(nextTab)
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const calculateDate = (type: any, from: any, to: any) => {
|
|
256
|
+
switch (type) {
|
|
257
|
+
case 'today':
|
|
258
|
+
const date = parseDate(new Date(), { outputFormat: 'MM/DD/YYYY' })
|
|
259
|
+
return { from: `${date} 00:00:00`, to: `${date} 23:59:59` }
|
|
260
|
+
case 'yesterday':
|
|
261
|
+
const yesterday = new Date()
|
|
262
|
+
yesterday.setDate(yesterday.getDate() - 1)
|
|
263
|
+
const start1 = parseDate(yesterday, { outputFormat: 'MM/DD/YYYY' })
|
|
264
|
+
const end1 = parseDate(new Date(), { outputFormat: 'MM/DD/YYYY' })
|
|
265
|
+
return { from: `${start1} 00:00:00`, to: `${end1} 23:59:59` }
|
|
266
|
+
case 'last_7days':
|
|
267
|
+
const last_7days = new Date()
|
|
268
|
+
last_7days.setDate(last_7days.getDate() - 6)
|
|
269
|
+
const start7 = parseDate(last_7days, { outputFormat: 'MM/DD/YYYY' })
|
|
270
|
+
const end7 = parseDate(new Date(), { outputFormat: 'MM/DD/YYYY' })
|
|
271
|
+
return { from: `${start7} 00:00:00`, to: `${end7} 23:59:59` }
|
|
272
|
+
case 'last_30days':
|
|
273
|
+
const last_30days = new Date()
|
|
274
|
+
last_30days.setDate(last_30days.getDate() - 29)
|
|
275
|
+
const start30 = parseDate(last_30days, { outputFormat: 'MM/DD/YYYY' })
|
|
276
|
+
const end30 = parseDate(new Date(), { outputFormat: 'MM/DD/YYYY' })
|
|
277
|
+
return { from: `${start30} 00:00:00`, to: `${end30} 23:59:59` }
|
|
278
|
+
default:
|
|
279
|
+
const start = from ? `${parseDate(from, { outputFormat: 'MM/DD/YYYY' })} 00:00:00` : ''
|
|
280
|
+
const end = to ? `${parseDate(to, { outputFormat: 'MM/DD/YYYY' })} 23:59:59` : ''
|
|
281
|
+
return { from: start, to: end }
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
useEffect(() => {
|
|
286
|
+
setCurrentFilters(null)
|
|
287
|
+
onFiltered && onFiltered(null)
|
|
288
|
+
setSearch(defaultSearchList)
|
|
289
|
+
scrollRefTab.current?.scrollTo({ animated: true });
|
|
290
|
+
scrollListRef.current?.scrollTo({ animated: true });
|
|
291
|
+
scrollRef.current?.scrollTo({ y: 0, animated: true });
|
|
292
|
+
}, [currentTabSelected])
|
|
293
|
+
|
|
294
|
+
return (
|
|
295
|
+
// <GestureRecognizer
|
|
296
|
+
// onSwipeLeft={onSwipeLeft}
|
|
297
|
+
// onSwipeRight={onSwipeRight}
|
|
298
|
+
// config={swipeConfig}
|
|
299
|
+
// style={{ flex: 1 }}
|
|
300
|
+
// >
|
|
301
|
+
<>
|
|
302
|
+
<View style={styles.header}>
|
|
303
|
+
<OText style={styles.title}>{t('MY_ORDERS', 'My orders')}</OText>
|
|
304
|
+
<IconWrapper>
|
|
305
|
+
<FeatherIcon
|
|
306
|
+
name='refresh-cw'
|
|
307
|
+
color={theme.colors.backgroundDark}
|
|
308
|
+
size={24}
|
|
309
|
+
onPress={() => loadOrders && loadOrders({ newFetch: true })}
|
|
310
|
+
style={{ marginRight: 20 }}
|
|
311
|
+
/>
|
|
312
|
+
<FontistoIcon
|
|
313
|
+
name='search'
|
|
314
|
+
color={theme.colors.backgroundDark}
|
|
315
|
+
size={24}
|
|
316
|
+
onPress={() => setOpenModal(true)}
|
|
317
|
+
/>
|
|
318
|
+
</IconWrapper>
|
|
319
|
+
</View>
|
|
320
|
+
{isBusinessApp && (
|
|
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')}
|
|
335
|
+
</OText>
|
|
336
|
+
</TouchableOpacity>
|
|
337
|
+
</View>
|
|
338
|
+
)}
|
|
339
|
+
<FiltersTab>
|
|
340
|
+
<ScrollView
|
|
341
|
+
ref={scrollRefTab}
|
|
342
|
+
showsVerticalScrollIndicator={false}
|
|
343
|
+
showsHorizontalScrollIndicator={false}
|
|
344
|
+
horizontal
|
|
345
|
+
nestedScrollEnabled={true}
|
|
346
|
+
>
|
|
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>
|
|
364
|
+
{tabs.map((tab: any) => (
|
|
365
|
+
<Pressable
|
|
366
|
+
key={tab.key}
|
|
367
|
+
style={styles.pressable}
|
|
368
|
+
onPress={() => setCurrentTabSelected(tab?.title)}>
|
|
369
|
+
<OText
|
|
370
|
+
style={{
|
|
371
|
+
...styles.tab,
|
|
372
|
+
fontSize: tab.title === currentTabSelected ? 16 : 14,
|
|
373
|
+
borderBottomWidth: tab.title === currentTabSelected ? 1 : 0,
|
|
374
|
+
}}
|
|
375
|
+
color={
|
|
376
|
+
tab.title === currentTabSelected
|
|
377
|
+
? theme.colors.textGray
|
|
378
|
+
: theme.colors.unselectText
|
|
379
|
+
}
|
|
380
|
+
weight={tab.title === currentTabSelected ? '600' : 'normal'}
|
|
381
|
+
>
|
|
382
|
+
{tab.text}
|
|
383
|
+
</OText>
|
|
384
|
+
</Pressable>
|
|
385
|
+
))}
|
|
386
|
+
</TabsContainer>
|
|
387
|
+
</ScrollView>
|
|
388
|
+
</FiltersTab>
|
|
389
|
+
<View style={{ flex: 1, minHeight: HEIGHT_SCREEN - 250 }}>
|
|
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={
|
|
404
|
+
isEqual(currentOrdersGroup.currentFilter, tagsList)
|
|
405
|
+
? theme.colors.primary
|
|
406
|
+
: theme.colors.tabBar
|
|
407
|
+
}>
|
|
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={
|
|
432
|
+
currentOrdersGroup.currentFilter.includes(key) &&
|
|
433
|
+
!isEqual(currentOrdersGroup.currentFilter, tagsList)
|
|
434
|
+
? theme.colors.primary
|
|
435
|
+
: theme.colors.tabBar
|
|
436
|
+
}>
|
|
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
|
+
)}
|
|
457
|
+
|
|
458
|
+
<ScrollView
|
|
459
|
+
ref={scrollListRef}
|
|
460
|
+
showsVerticalScrollIndicator={false}
|
|
461
|
+
style={{ flex: 1 }}
|
|
462
|
+
nestedScrollEnabled={true}
|
|
463
|
+
refreshControl={
|
|
464
|
+
<RefreshControl
|
|
465
|
+
refreshing={refreshing}
|
|
466
|
+
onRefresh={() => {currentTabSelected === 'logisticOrders' ? loadLogisticOrders() : loadOrders && loadOrders({ newFetch: true })}}
|
|
467
|
+
/>
|
|
468
|
+
}
|
|
469
|
+
>
|
|
470
|
+
{!currentOrdersGroup?.error?.length &&
|
|
471
|
+
currentOrdersGroup?.orders?.length > 0 &&
|
|
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
|
|
502
|
+
style={{
|
|
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
|
+
)}
|
|
527
|
+
|
|
528
|
+
{!currentOrdersGroup?.error?.length &&
|
|
529
|
+
!currentOrdersGroup?.loading &&
|
|
530
|
+
currentOrdersGroup?.pagination?.totalPages &&
|
|
531
|
+
currentOrdersGroup?.pagination?.currentPage < currentOrdersGroup?.pagination?.totalPages &&
|
|
532
|
+
currentOrdersGroup?.orders?.length > 0 &&
|
|
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
|
+
)}
|
|
544
|
+
|
|
545
|
+
{!currentOrdersGroup?.loading &&
|
|
546
|
+
(currentOrdersGroup?.error?.length ||
|
|
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 ||
|
|
554
|
+
currentOrdersGroup?.error[0] ||
|
|
555
|
+
t('NETWORK_ERROR', 'Network Error')
|
|
556
|
+
}
|
|
557
|
+
image={theme.images.general.notFound}
|
|
558
|
+
conditioned={false}
|
|
559
|
+
/>
|
|
560
|
+
)}
|
|
561
|
+
</ScrollView>
|
|
562
|
+
</View>
|
|
563
|
+
{/* </GestureRecognizer> */}
|
|
564
|
+
|
|
565
|
+
<NewOrderNotification />
|
|
566
|
+
<OModal open={openModal} entireModal customClose>
|
|
567
|
+
<ModalContainer
|
|
568
|
+
nestedScrollEnabled={true}
|
|
569
|
+
>
|
|
570
|
+
<OIconButton
|
|
571
|
+
icon={theme.images.general.arrow_left}
|
|
572
|
+
borderColor={theme.colors.clear}
|
|
573
|
+
iconColor={theme.colors.backArrow}
|
|
574
|
+
iconStyle={{ width: 20, height: 13 }}
|
|
575
|
+
style={{
|
|
576
|
+
maxWidth: 40,
|
|
577
|
+
height: 35,
|
|
578
|
+
justifyContent: 'flex-end',
|
|
579
|
+
marginBottom: 30,
|
|
580
|
+
marginTop: 30
|
|
581
|
+
}}
|
|
582
|
+
onClick={() => setOpenModal(false)}
|
|
583
|
+
/>
|
|
584
|
+
<ModalTitle>{t('SEARCH_ORDERS', 'Search orders')}</ModalTitle>
|
|
585
|
+
<OInput
|
|
586
|
+
value={search.id}
|
|
587
|
+
onChange={(value: any) => setSearch({ ...search, id: value })}
|
|
588
|
+
style={styles.inputStyle}
|
|
589
|
+
placeholder={t('ORDER_NUMBER', 'Order number')}
|
|
590
|
+
autoCorrect={false}
|
|
591
|
+
/>
|
|
592
|
+
<OrdersOptionDate
|
|
593
|
+
{...props}
|
|
594
|
+
search={search}
|
|
595
|
+
onSearch={setSearch}
|
|
596
|
+
/>
|
|
597
|
+
<OrdersOptionStatus
|
|
598
|
+
{...props}
|
|
599
|
+
search={search}
|
|
600
|
+
onSearch={setSearch}
|
|
601
|
+
/>
|
|
602
|
+
<OrdersOptionCity
|
|
603
|
+
{...props}
|
|
604
|
+
search={search}
|
|
605
|
+
onSearch={setSearch}
|
|
606
|
+
/>
|
|
607
|
+
<OrdersOptionBusiness
|
|
608
|
+
{...props}
|
|
609
|
+
search={search}
|
|
610
|
+
onSearch={setSearch}
|
|
611
|
+
/>
|
|
612
|
+
<OrdersOptionDelivery
|
|
613
|
+
{...props}
|
|
614
|
+
search={search}
|
|
615
|
+
onSearch={setSearch}
|
|
616
|
+
/>
|
|
617
|
+
<OrdersOptionPaymethod
|
|
618
|
+
{...props}
|
|
619
|
+
search={search}
|
|
620
|
+
onSearch={setSearch}
|
|
621
|
+
/>
|
|
622
|
+
<OrdersOptionDriver
|
|
623
|
+
{...props}
|
|
624
|
+
search={search}
|
|
625
|
+
onSearch={setSearch}
|
|
626
|
+
/>
|
|
627
|
+
<OButton
|
|
628
|
+
text={t('SEARCH', 'Search')}
|
|
629
|
+
textStyle={{ color: theme.colors.white }}
|
|
630
|
+
imgRightSrc={null}
|
|
631
|
+
style={{
|
|
632
|
+
borderRadius: 7.6,
|
|
633
|
+
marginBottom: 70,
|
|
634
|
+
marginTop: 60,
|
|
635
|
+
zIndex: 12
|
|
636
|
+
}}
|
|
637
|
+
onClick={applyFilters}
|
|
638
|
+
/>
|
|
639
|
+
</ModalContainer>
|
|
640
|
+
</OModal>
|
|
641
|
+
</>
|
|
642
|
+
);
|
|
643
|
+
};
|
|
644
|
+
|
|
645
|
+
export const OrdersOption = (props: OrdersOptionParams) => {
|
|
646
|
+
const [, t] = useLanguage();
|
|
647
|
+
const theme = useTheme()
|
|
648
|
+
const ordersProps = {
|
|
649
|
+
...props,
|
|
650
|
+
UIComponent: OrdersOptionUI,
|
|
651
|
+
useDefualtSessionManager: true,
|
|
652
|
+
asDashboard: true,
|
|
653
|
+
isIos: Platform.OS === 'ios',
|
|
654
|
+
orderStatus: [
|
|
655
|
+
{ key: 0, text: t('PENDING', 'Pending') },
|
|
656
|
+
{ key: 1, text: t('COMPLETED', 'Completed') },
|
|
657
|
+
{ key: 2, text: t('REJECTED', 'Rejected') },
|
|
658
|
+
{ key: 3, text: t('DRIVER_IN_BUSINESS', 'Driver in business') },
|
|
659
|
+
{ key: 4, text: t('READY_FOR_PICKUP', 'Ready for pickup') },
|
|
660
|
+
{ key: 5, text: t('REJECTED_BY_BUSINESS', 'Rejected by business') },
|
|
661
|
+
{ key: 6, text: t('REJECTED_BY_DRIVER', 'Rejected by Driver') },
|
|
662
|
+
{ key: 7, text: t('ACCEPTED_BY_BUSINESS', 'Accepted by business') },
|
|
663
|
+
{ key: 8, text: t('ACCEPTED_BY_DRIVER', 'Accepted by driver') },
|
|
664
|
+
{
|
|
665
|
+
key: 9,
|
|
666
|
+
text: t('PICK_UP_COMPLETED_BY_DRIVER', 'Pick up completed by driver'),
|
|
667
|
+
},
|
|
668
|
+
{
|
|
669
|
+
key: 10,
|
|
670
|
+
text: t('PICK_UP_FAILED_BY_DRIVER', 'Pick up Failed by driver'),
|
|
671
|
+
},
|
|
672
|
+
{
|
|
673
|
+
key: 11,
|
|
674
|
+
text: t('DELIVERY_COMPLETED_BY_DRIVER', 'Delivery completed by driver'),
|
|
675
|
+
},
|
|
676
|
+
{
|
|
677
|
+
key: 12,
|
|
678
|
+
text: t('DELIVERY_FAILED_BY_DRIVER', 'Delivery Failed by driver'),
|
|
679
|
+
},
|
|
680
|
+
{ key: 13, text: t('PREORDER', 'Preorder') },
|
|
681
|
+
{ key: 14, text: t('ORDER_NOT_READY', 'Order not ready') },
|
|
682
|
+
{
|
|
683
|
+
key: 15,
|
|
684
|
+
text: t(
|
|
685
|
+
'ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER',
|
|
686
|
+
'Order picked up completed by customer',
|
|
687
|
+
),
|
|
688
|
+
},
|
|
689
|
+
{ key: 16, text: t('CANCELLED_BY_CUSTOMER', 'Cancelled by customer') },
|
|
690
|
+
{
|
|
691
|
+
key: 17,
|
|
692
|
+
text: t(
|
|
693
|
+
'ORDER_NOT_PICKEDUP_BY_CUSTOMER',
|
|
694
|
+
'Order not picked up by customer',
|
|
695
|
+
),
|
|
696
|
+
},
|
|
697
|
+
{
|
|
698
|
+
key: 18,
|
|
699
|
+
text: t(
|
|
700
|
+
'DRIVER_ALMOST_ARRIVED_TO_BUSINESS',
|
|
701
|
+
'Driver almost arrived to business',
|
|
702
|
+
),
|
|
703
|
+
},
|
|
704
|
+
{
|
|
705
|
+
key: 19,
|
|
706
|
+
text: t(
|
|
707
|
+
'DRIVER_ALMOST_ARRIVED_TO_CUSTOMER',
|
|
708
|
+
'Driver almost arrived to customer',
|
|
709
|
+
),
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
key: 20,
|
|
713
|
+
text: t(
|
|
714
|
+
'ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS',
|
|
715
|
+
'Customer almost arrived to business',
|
|
716
|
+
),
|
|
717
|
+
},
|
|
718
|
+
{
|
|
719
|
+
key: 21,
|
|
720
|
+
text: t(
|
|
721
|
+
'ORDER_CUSTOMER_ARRIVED_BUSINESS',
|
|
722
|
+
'Customer arrived to business',
|
|
723
|
+
),
|
|
724
|
+
},
|
|
725
|
+
],
|
|
726
|
+
tabs: [
|
|
727
|
+
{
|
|
728
|
+
key: 0,
|
|
729
|
+
text: t('PENDING', 'Pending'),
|
|
730
|
+
tags: props?.orderGroupStatusCustom?.pending ?? [0, 13],
|
|
731
|
+
title: 'pending'
|
|
732
|
+
},
|
|
733
|
+
{
|
|
734
|
+
key: 1,
|
|
735
|
+
text: t('IN_PROGRESS', 'In Progress'),
|
|
736
|
+
tags: props?.orderGroupStatusCustom?.inProgress ?? [3, 4, 7, 8, 9, 14, 18, 19, 20, 21],
|
|
737
|
+
title: 'inProgress',
|
|
738
|
+
},
|
|
739
|
+
{
|
|
740
|
+
key: 2,
|
|
741
|
+
text: t('COMPLETED', 'Completed'),
|
|
742
|
+
tags: props?.orderGroupStatusCustom?.completed ?? [1, 11, 15],
|
|
743
|
+
title: 'completed',
|
|
744
|
+
},
|
|
745
|
+
{
|
|
746
|
+
key: 3,
|
|
747
|
+
text: t('CANCELLED', 'Cancelled'),
|
|
748
|
+
tags: props?.orderGroupStatusCustom?.cancelled ?? [2, 5, 6, 10, 12, 16, 17],
|
|
749
|
+
title: 'cancelled',
|
|
750
|
+
},
|
|
751
|
+
]
|
|
752
|
+
};
|
|
753
|
+
|
|
754
|
+
return <OrderListGroups {...ordersProps} />;
|
|
755
|
+
};
|