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,1262 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
StyleSheet,
|
|
4
|
-
View,
|
|
5
|
-
TouchableOpacity,
|
|
6
|
-
ActivityIndicator,
|
|
7
|
-
Platform,
|
|
8
|
-
} from 'react-native';
|
|
9
|
-
import Clipboard from '@react-native-clipboard/clipboard';
|
|
10
|
-
import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
|
|
11
|
-
import { useTheme } from 'styled-components/native';
|
|
12
|
-
import {
|
|
13
|
-
ToastType,
|
|
14
|
-
useToast,
|
|
15
|
-
useLanguage,
|
|
16
|
-
OrderDetails as OrderDetailsController,
|
|
17
|
-
useUtils,
|
|
18
|
-
useConfig,
|
|
19
|
-
useSession,
|
|
20
|
-
} from 'ordering-components/native';
|
|
21
|
-
import {
|
|
22
|
-
Actions,
|
|
23
|
-
OrderDetailsContainer,
|
|
24
|
-
Header,
|
|
25
|
-
OrderContent,
|
|
26
|
-
OrderBusiness,
|
|
27
|
-
OrderCustomer,
|
|
28
|
-
OrderHeader,
|
|
29
|
-
OrderProducts,
|
|
30
|
-
Table,
|
|
31
|
-
OrderBill,
|
|
32
|
-
Total,
|
|
33
|
-
Pickup,
|
|
34
|
-
AssignDriver,
|
|
35
|
-
DriverItem,
|
|
36
|
-
} from './styles';
|
|
37
|
-
import { AcceptOrRejectOrder } from '../AcceptOrRejectOrder';
|
|
38
|
-
import { Chat } from '../Chat';
|
|
39
|
-
import { FloatingButton } from '../FloatingButton';
|
|
40
|
-
import { ProductItemAccordion } from '../ProductItemAccordion';
|
|
41
|
-
import { GoogleMap } from '../GoogleMap';
|
|
42
|
-
import { OButton, OModal, OText, OIconButton, OIcon, OLink } from '../shared';
|
|
43
|
-
import { OrderDetailsParams } from '../../types';
|
|
44
|
-
import { verifyDecimals, getProductPrice } from '../../utils';
|
|
45
|
-
import { USER_TYPE } from '../../config/constants';
|
|
46
|
-
import CountryPicker from 'react-native-country-picker-modal';
|
|
47
|
-
import { NotFoundSource } from '../NotFoundSource';
|
|
48
|
-
|
|
49
|
-
export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
50
|
-
const {
|
|
51
|
-
navigation,
|
|
52
|
-
messages,
|
|
53
|
-
setMessages,
|
|
54
|
-
readMessages,
|
|
55
|
-
messagesReadList,
|
|
56
|
-
handleAssignDriver,
|
|
57
|
-
handleChangeOrderStatus,
|
|
58
|
-
isFromCheckout,
|
|
59
|
-
driverLocation,
|
|
60
|
-
actions,
|
|
61
|
-
titleAccept,
|
|
62
|
-
titleReject,
|
|
63
|
-
appTitle,
|
|
64
|
-
} = props;
|
|
65
|
-
|
|
66
|
-
const theme = useTheme();
|
|
67
|
-
const [, t] = useLanguage();
|
|
68
|
-
const [{ parsePrice, parseNumber, parseDate }] = useUtils();
|
|
69
|
-
const [{ user, token }] = useSession();
|
|
70
|
-
const [{ configs }] = useConfig();
|
|
71
|
-
const [, { showToast }] = useToast();
|
|
72
|
-
const [unreadAlert, setUnreadAlert] = useState({
|
|
73
|
-
business: false,
|
|
74
|
-
driver: false,
|
|
75
|
-
});
|
|
76
|
-
const { order, businessData, loading, error } = props.order;
|
|
77
|
-
const { drivers, loadingDriver } = props.drivers;
|
|
78
|
-
const itemsDrivers: any = [];
|
|
79
|
-
const [actionOrder, setActionOrder] = useState('');
|
|
80
|
-
const [openModalForBusiness, setOpenModalForBusiness] = useState(false);
|
|
81
|
-
const [openModalForAccept, setOpenModalForAccept] = useState(false);
|
|
82
|
-
const [openModalForMapView, setOpenModalForMapView] = useState(false);
|
|
83
|
-
const [isDriverModalVisible, setIsDriverModalVisible] = useState(false);
|
|
84
|
-
|
|
85
|
-
if (order?.status === 7 || order?.status === 4) {
|
|
86
|
-
if (drivers?.length > 0 && drivers) {
|
|
87
|
-
drivers.forEach((driver: any) => {
|
|
88
|
-
itemsDrivers.push({
|
|
89
|
-
available: driver?.available,
|
|
90
|
-
key: driver?.id,
|
|
91
|
-
value: driver?.id,
|
|
92
|
-
label: driver?.name,
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
if (
|
|
97
|
-
!drivers?.some((driver: any) => driver?.id === order?.driver?.id) &&
|
|
98
|
-
order?.driver?.id
|
|
99
|
-
) {
|
|
100
|
-
itemsDrivers.push({
|
|
101
|
-
available: order?.driver?.available,
|
|
102
|
-
key: order?.driver?.id,
|
|
103
|
-
value: order?.driver?.id,
|
|
104
|
-
label: order?.driver?.name,
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (order?.driver && (!drivers?.length || drivers?.length === 0)) {
|
|
110
|
-
itemsDrivers.push({
|
|
111
|
-
available: order?.driver?.available,
|
|
112
|
-
key: order?.driver?.id,
|
|
113
|
-
value: order?.driver?.id,
|
|
114
|
-
label: order?.driver?.name,
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (order?.driver) {
|
|
119
|
-
itemsDrivers.push({
|
|
120
|
-
available: true,
|
|
121
|
-
key: null,
|
|
122
|
-
value: null,
|
|
123
|
-
label: t('UNASSIGN_DRIVER', 'Unassign Driver'),
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (itemsDrivers.length > 0) {
|
|
128
|
-
itemsDrivers.sort((a: any, b: any) => {
|
|
129
|
-
if (a.available > b.available) return -1;
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const colors: any = {
|
|
135
|
-
//BLUE
|
|
136
|
-
0: theme.colors.statusOrderBlue,
|
|
137
|
-
3: theme.colors.statusOrderBlue,
|
|
138
|
-
4: theme.colors.statusOrderBlue,
|
|
139
|
-
7: theme.colors.statusOrderBlue,
|
|
140
|
-
8: theme.colors.statusOrderBlue,
|
|
141
|
-
9: theme.colors.statusOrderBlue,
|
|
142
|
-
13: theme.colors.statusOrderBlue,
|
|
143
|
-
14: theme.colors.statusOrderBlue,
|
|
144
|
-
18: theme.colors.statusOrderBlue,
|
|
145
|
-
19: theme.colors.statusOrderBlue,
|
|
146
|
-
20: theme.colors.statusOrderBlue,
|
|
147
|
-
21: theme.colors.statusOrderBlue,
|
|
148
|
-
//GREEN
|
|
149
|
-
1: theme.colors.statusOrderGreen,
|
|
150
|
-
11: theme.colors.statusOrderGreen,
|
|
151
|
-
15: theme.colors.statusOrderGreen,
|
|
152
|
-
//RED
|
|
153
|
-
2: theme.colors.statusOrderRed,
|
|
154
|
-
5: theme.colors.statusOrderRed,
|
|
155
|
-
6: theme.colors.statusOrderRed,
|
|
156
|
-
10: theme.colors.statusOrderRed,
|
|
157
|
-
12: theme.colors.statusOrderRed,
|
|
158
|
-
16: theme.colors.statusOrderRed,
|
|
159
|
-
17: theme.colors.statusOrderRed,
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
const handleCopyClipboard = () => {
|
|
163
|
-
const businessName = !!order?.business?.name
|
|
164
|
-
? `${order?.business?.name} \n`
|
|
165
|
-
: '';
|
|
166
|
-
|
|
167
|
-
const businessEmail = !!order?.business?.email
|
|
168
|
-
? `${order?.business?.email} \n`
|
|
169
|
-
: '';
|
|
170
|
-
|
|
171
|
-
const businessCellphone = !!order?.business?.cellphone
|
|
172
|
-
? `${order?.business?.cellphone} \n`
|
|
173
|
-
: '';
|
|
174
|
-
|
|
175
|
-
const businessPhone = !!order?.business?.phone
|
|
176
|
-
? `${order?.business?.phone} \n`
|
|
177
|
-
: '';
|
|
178
|
-
|
|
179
|
-
const businessAddress = !!order?.business?.address
|
|
180
|
-
? `${order?.business?.address} \n`
|
|
181
|
-
: '';
|
|
182
|
-
|
|
183
|
-
const businessSpecialAddress = !!order?.business?.address_notes
|
|
184
|
-
? `${order?.business?.address_notes} \n \n`
|
|
185
|
-
: '';
|
|
186
|
-
|
|
187
|
-
const customerName = !!order?.customer?.name
|
|
188
|
-
? `${order?.customer?.name} ${order?.customer?.middle_name || ''} ${
|
|
189
|
-
order?.customer?.lastname || ''
|
|
190
|
-
} ${order?.customer?.second_lastname || ''} \n`
|
|
191
|
-
: '';
|
|
192
|
-
|
|
193
|
-
const customerEmail = !!order?.customer.email
|
|
194
|
-
? `${order?.customer.email} \n`
|
|
195
|
-
: '';
|
|
196
|
-
|
|
197
|
-
const customerCellPhone = !!order?.customer?.cellphone
|
|
198
|
-
? `${order?.customer?.cellphone} \n`
|
|
199
|
-
: '';
|
|
200
|
-
|
|
201
|
-
const customerPhone = !!order?.customer?.phone
|
|
202
|
-
? `${order?.customer?.phone} \n`
|
|
203
|
-
: '';
|
|
204
|
-
|
|
205
|
-
const customerAddress = !!order?.customer?.address
|
|
206
|
-
? `${order?.customer?.address} \n`
|
|
207
|
-
: '';
|
|
208
|
-
|
|
209
|
-
const customerSpecialAddress = !!order?.customer?.address_notes
|
|
210
|
-
? `${order?.customer?.address_notes} \n`
|
|
211
|
-
: '';
|
|
212
|
-
|
|
213
|
-
const payment = order?.paymethod?.name
|
|
214
|
-
? `${order?.paymethod?.name} - ${
|
|
215
|
-
order.delivery_type === 1
|
|
216
|
-
? t('DELIVERY', 'Delivery')
|
|
217
|
-
: order.delivery_type === 2
|
|
218
|
-
? t('PICKUP', 'Pickup')
|
|
219
|
-
: order.delivery_type === 3
|
|
220
|
-
? t('EAT_IN', 'Eat in')
|
|
221
|
-
: order.delivery_type === 4
|
|
222
|
-
? t('CURBSIDE', 'Curbside')
|
|
223
|
-
: t('DRIVER_THRU', 'Driver thru')
|
|
224
|
-
}\n`
|
|
225
|
-
: '';
|
|
226
|
-
const productsInArray =
|
|
227
|
-
order?.products.length &&
|
|
228
|
-
order?.products.map((product: any, i: number) => {
|
|
229
|
-
return ` ${product?.quantity} X ${product?.name} ${parsePrice(
|
|
230
|
-
product.total ?? getProductPrice(product),
|
|
231
|
-
)}\n`;
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
const productsInString = productsInArray.join(' ');
|
|
235
|
-
const orderDetails = `${t(
|
|
236
|
-
'ORDER_DETAILS',
|
|
237
|
-
'Order Details',
|
|
238
|
-
)}:\n${productsInString}\n`;
|
|
239
|
-
|
|
240
|
-
const subtotal = `${t('SUBTOTAL', 'Subtotal')}: ${parsePrice(
|
|
241
|
-
order?.subtotal,
|
|
242
|
-
)}\n`;
|
|
243
|
-
|
|
244
|
-
const drivertip = `${t('DRIVER_TIP', 'Driver tip')} ${parsePrice(
|
|
245
|
-
order?.summary?.driver_tip || order?.totalDriverTip,
|
|
246
|
-
)}\n`;
|
|
247
|
-
|
|
248
|
-
const deliveryFee = `${t('DELIVERY_FEE', 'Delivery fee')} ${verifyDecimals(
|
|
249
|
-
order?.service_fee,
|
|
250
|
-
parseNumber,
|
|
251
|
-
)}% ${parsePrice(order?.summary?.service_fee || order?.serviceFee || 0)}\n`;
|
|
252
|
-
|
|
253
|
-
const total = `${t('TOTAL', 'Total')} ${parsePrice(
|
|
254
|
-
order?.summary?.total || order?.total,
|
|
255
|
-
)}\n`;
|
|
256
|
-
|
|
257
|
-
const orderStatus = `${t('INVOICE_ORDER_NO', 'Order No.')} ${order.id} ${t(
|
|
258
|
-
'IS',
|
|
259
|
-
'is',
|
|
260
|
-
)} ${getOrderStatus(order?.status)?.value}\n`;
|
|
261
|
-
|
|
262
|
-
Clipboard.setString(
|
|
263
|
-
`${orderStatus} ${payment} ${t(
|
|
264
|
-
'BUSINESS_DETAILS',
|
|
265
|
-
'Business Details',
|
|
266
|
-
)}\n ${businessName} ${businessEmail} ${businessCellphone} ${businessPhone} ${businessAddress} ${businessSpecialAddress}${t(
|
|
267
|
-
'CUSTOMER_DETAILS',
|
|
268
|
-
'Customer Details',
|
|
269
|
-
)}\n ${customerName} ${customerEmail} ${customerCellPhone} ${customerPhone} ${customerAddress} ${customerSpecialAddress}\n${orderDetails} ${subtotal} ${drivertip} ${deliveryFee} ${total}`,
|
|
270
|
-
);
|
|
271
|
-
|
|
272
|
-
showToast(
|
|
273
|
-
ToastType.Info,
|
|
274
|
-
t('COPY_TO_CLIPBOARD', 'Copy to clipboard.'),
|
|
275
|
-
1000,
|
|
276
|
-
);
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
const getOrderStatus = (s: string) => {
|
|
280
|
-
const status = parseInt(s);
|
|
281
|
-
const orderStatus = [
|
|
282
|
-
{
|
|
283
|
-
key: 0,
|
|
284
|
-
value: t('PENDING', 'Pending'),
|
|
285
|
-
slug: 'PENDING',
|
|
286
|
-
percentage: 0.25,
|
|
287
|
-
},
|
|
288
|
-
{
|
|
289
|
-
key: 1,
|
|
290
|
-
value: t('COMPLETED', 'Completed'),
|
|
291
|
-
slug: 'COMPLETED',
|
|
292
|
-
percentage: 1,
|
|
293
|
-
},
|
|
294
|
-
{
|
|
295
|
-
key: 2,
|
|
296
|
-
value: t('REJECTED', 'Rejected'),
|
|
297
|
-
slug: 'REJECTED',
|
|
298
|
-
percentage: 0,
|
|
299
|
-
},
|
|
300
|
-
{
|
|
301
|
-
key: 3,
|
|
302
|
-
value: t('DRIVER_IN_BUSINESS', 'Driver in business'),
|
|
303
|
-
slug: 'DRIVER_IN_BUSINESS',
|
|
304
|
-
percentage: 0.6,
|
|
305
|
-
},
|
|
306
|
-
{
|
|
307
|
-
key: 4,
|
|
308
|
-
value: t('READY_FOR_PICKUP', 'Ready for pickup'),
|
|
309
|
-
slug: 'READY_FOR_PICKUP',
|
|
310
|
-
percentage: 0.7,
|
|
311
|
-
},
|
|
312
|
-
{
|
|
313
|
-
key: 5,
|
|
314
|
-
value: t('REJECTED', 'Rejected'),
|
|
315
|
-
slug: 'REJECTED_BY_BUSINESS',
|
|
316
|
-
percentage: 0,
|
|
317
|
-
},
|
|
318
|
-
{
|
|
319
|
-
key: 6,
|
|
320
|
-
value: t('REJECTED_BY_DRIVER', 'Rejected by Driver'),
|
|
321
|
-
slug: 'REJECTED_BY_DRIVER',
|
|
322
|
-
percentage: 0,
|
|
323
|
-
},
|
|
324
|
-
{
|
|
325
|
-
key: 7,
|
|
326
|
-
value: t('ACCEPTED_BY_BUSINESS', 'Accepted by business'),
|
|
327
|
-
slug: 'ACCEPTED_BY_BUSINESS',
|
|
328
|
-
percentage: 0.35,
|
|
329
|
-
},
|
|
330
|
-
{
|
|
331
|
-
key: 8,
|
|
332
|
-
value: t('ACCEPTED_BY_DRIVER', 'Accepted by driver'),
|
|
333
|
-
slug: 'ACCEPTED_BY_DRIVER',
|
|
334
|
-
percentage: 0.45,
|
|
335
|
-
},
|
|
336
|
-
{
|
|
337
|
-
key: 9,
|
|
338
|
-
value: t('PICK_UP_COMPLETED_BY_DRIVER', 'Pick up completed by driver'),
|
|
339
|
-
slug: 'PICK_UP_COMPLETED_BY_DRIVER',
|
|
340
|
-
percentage: 0.8,
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
key: 10,
|
|
344
|
-
value: t('PICK_UP_FAILED_BY_DRIVER', 'Pick up Failed by driver'),
|
|
345
|
-
slug: 'PICK_UP_FAILED_BY_DRIVER',
|
|
346
|
-
percentage: 0,
|
|
347
|
-
},
|
|
348
|
-
{
|
|
349
|
-
key: 11,
|
|
350
|
-
value: t(
|
|
351
|
-
'DELIVERY_COMPLETED_BY_DRIVER',
|
|
352
|
-
'Delivery completed by driver',
|
|
353
|
-
),
|
|
354
|
-
slug: 'DELIVERY_COMPLETED_BY_DRIVER',
|
|
355
|
-
percentage: 1,
|
|
356
|
-
},
|
|
357
|
-
{
|
|
358
|
-
key: 12,
|
|
359
|
-
value: t('DELIVERY_FAILED_BY_DRIVER', 'Delivery Failed by driver'),
|
|
360
|
-
slug: 'DELIVERY_FAILED_BY_DRIVER',
|
|
361
|
-
percentage: 0,
|
|
362
|
-
},
|
|
363
|
-
{
|
|
364
|
-
key: 13,
|
|
365
|
-
value: t('PREORDER', 'PreOrder'),
|
|
366
|
-
slug: 'PREORDER',
|
|
367
|
-
percentage: 0,
|
|
368
|
-
},
|
|
369
|
-
{
|
|
370
|
-
key: 14,
|
|
371
|
-
value: t('ORDER_NOT_READY', 'Order not ready'),
|
|
372
|
-
slug: 'ORDER_NOT_READY',
|
|
373
|
-
percentage: 0,
|
|
374
|
-
},
|
|
375
|
-
{
|
|
376
|
-
key: 15,
|
|
377
|
-
value: t(
|
|
378
|
-
'ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER',
|
|
379
|
-
'Order picked up completed by customer',
|
|
380
|
-
),
|
|
381
|
-
slug: 'ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER',
|
|
382
|
-
percentage: 100,
|
|
383
|
-
},
|
|
384
|
-
{
|
|
385
|
-
key: 16,
|
|
386
|
-
value: t('CANCELLED_BY_CUSTOMER', 'Cancelled by customer'),
|
|
387
|
-
slug: 'CANCELLED_BY_CUSTOMER',
|
|
388
|
-
percentage: 0,
|
|
389
|
-
},
|
|
390
|
-
{
|
|
391
|
-
key: 17,
|
|
392
|
-
value: t(
|
|
393
|
-
'ORDER_NOT_PICKEDUP_BY_CUSTOMER',
|
|
394
|
-
'Order not picked up by customer',
|
|
395
|
-
),
|
|
396
|
-
slug: 'ORDER_NOT_PICKEDUP_BY_CUSTOMER',
|
|
397
|
-
percentage: 0,
|
|
398
|
-
},
|
|
399
|
-
{
|
|
400
|
-
key: 18,
|
|
401
|
-
value: t(
|
|
402
|
-
'DRIVER_ALMOST_ARRIVED_TO_BUSINESS',
|
|
403
|
-
'Driver almost arrived to business',
|
|
404
|
-
),
|
|
405
|
-
slug: 'DRIVER_ALMOST_ARRIVED_TO_BUSINESS',
|
|
406
|
-
percentage: 0.15,
|
|
407
|
-
},
|
|
408
|
-
{
|
|
409
|
-
key: 19,
|
|
410
|
-
value: t(
|
|
411
|
-
'DRIVER_ALMOST_ARRIVED_TO_CUSTOMER',
|
|
412
|
-
'Driver almost arrived to customer',
|
|
413
|
-
),
|
|
414
|
-
slug: 'DRIVER_ALMOST_ARRIVED_TO_CUSTOMER',
|
|
415
|
-
percentage: 0.9,
|
|
416
|
-
},
|
|
417
|
-
{
|
|
418
|
-
key: 20,
|
|
419
|
-
value: t(
|
|
420
|
-
'ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS',
|
|
421
|
-
'Customer almost arrived to business',
|
|
422
|
-
),
|
|
423
|
-
slug: 'ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS',
|
|
424
|
-
percentage: 90,
|
|
425
|
-
},
|
|
426
|
-
{
|
|
427
|
-
key: 21,
|
|
428
|
-
value: t(
|
|
429
|
-
'ORDER_CUSTOMER_ARRIVED_BUSINESS',
|
|
430
|
-
'Customer arrived to business',
|
|
431
|
-
),
|
|
432
|
-
slug: 'ORDER_CUSTOMER_ARRIVED_BUSINESS',
|
|
433
|
-
percentage: 95,
|
|
434
|
-
},
|
|
435
|
-
];
|
|
436
|
-
|
|
437
|
-
const objectStatus = orderStatus.find(o => o.key === status);
|
|
438
|
-
|
|
439
|
-
return objectStatus && objectStatus;
|
|
440
|
-
};
|
|
441
|
-
|
|
442
|
-
const handleOpenMessagesForBusiness = () => {
|
|
443
|
-
setOpenModalForBusiness(true);
|
|
444
|
-
readMessages && readMessages();
|
|
445
|
-
setUnreadAlert({ ...unreadAlert, business: false });
|
|
446
|
-
};
|
|
447
|
-
|
|
448
|
-
const handleViewActionOrder = (action: string) => {
|
|
449
|
-
if (openModalForMapView) {
|
|
450
|
-
setOpenModalForMapView(false);
|
|
451
|
-
}
|
|
452
|
-
setActionOrder(action);
|
|
453
|
-
setOpenModalForAccept(true);
|
|
454
|
-
};
|
|
455
|
-
|
|
456
|
-
const handleViewSummaryOrder = () => {
|
|
457
|
-
navigation?.navigate &&
|
|
458
|
-
navigation.navigate('OrderSummary', {
|
|
459
|
-
order,
|
|
460
|
-
orderStatus: getOrderStatus(order?.status)?.value,
|
|
461
|
-
});
|
|
462
|
-
};
|
|
463
|
-
|
|
464
|
-
const handleCloseModal = () => {
|
|
465
|
-
setOpenModalForBusiness(false);
|
|
466
|
-
};
|
|
467
|
-
|
|
468
|
-
const handleOpenMapView = () => {
|
|
469
|
-
setOpenModalForMapView(!openModalForMapView);
|
|
470
|
-
};
|
|
471
|
-
|
|
472
|
-
const handleArrowBack: any = () => {
|
|
473
|
-
navigation?.canGoBack() && navigation.goBack();
|
|
474
|
-
};
|
|
475
|
-
|
|
476
|
-
useEffect(() => {
|
|
477
|
-
if (messagesReadList?.length) {
|
|
478
|
-
openModalForBusiness
|
|
479
|
-
? setUnreadAlert({ ...unreadAlert, business: false })
|
|
480
|
-
: setUnreadAlert({ ...unreadAlert, driver: false });
|
|
481
|
-
}
|
|
482
|
-
}, [messagesReadList]);
|
|
483
|
-
|
|
484
|
-
const locations = [
|
|
485
|
-
{
|
|
486
|
-
...order?.driver?.location,
|
|
487
|
-
title: t('DRIVER', 'Driver'),
|
|
488
|
-
icon:
|
|
489
|
-
order?.driver?.photo ||
|
|
490
|
-
'https://res.cloudinary.com/demo/image/fetch/c_thumb,g_face,r_max/https://www.freeiconspng.com/thumbs/driver-icon/driver-icon-14.png',
|
|
491
|
-
level: 4,
|
|
492
|
-
},
|
|
493
|
-
{
|
|
494
|
-
...order?.business?.location,
|
|
495
|
-
title: order?.business?.name,
|
|
496
|
-
icon: order?.business?.logo || theme.images.dummies.businessLogo,
|
|
497
|
-
level: 2,
|
|
498
|
-
},
|
|
499
|
-
{
|
|
500
|
-
...order?.customer?.location,
|
|
501
|
-
title: t('CUSTOMER', 'Customer'),
|
|
502
|
-
icon:
|
|
503
|
-
order?.customer?.photo ||
|
|
504
|
-
'https://res.cloudinary.com/demo/image/upload/c_thumb,g_face,r_max/d_avatar.png/non_existing_id.png',
|
|
505
|
-
level: 3,
|
|
506
|
-
},
|
|
507
|
-
];
|
|
508
|
-
|
|
509
|
-
useEffect(() => {
|
|
510
|
-
if (openModalForAccept) {
|
|
511
|
-
setOpenModalForAccept(false);
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
if (openModalForMapView) {
|
|
515
|
-
setOpenModalForMapView(false);
|
|
516
|
-
}
|
|
517
|
-
}, [loading]);
|
|
518
|
-
|
|
519
|
-
const showFloatButtonsAcceptOrReject: any = {
|
|
520
|
-
0: true,
|
|
521
|
-
};
|
|
522
|
-
|
|
523
|
-
useEffect(() => {
|
|
524
|
-
if (driverLocation) {
|
|
525
|
-
locations[0] = { ...locations[0], driverLocation };
|
|
526
|
-
}
|
|
527
|
-
}, [driverLocation]);
|
|
528
|
-
|
|
529
|
-
const styles = StyleSheet.create({
|
|
530
|
-
driverOff: {
|
|
531
|
-
backgroundColor: theme.colors.notAvailable,
|
|
532
|
-
},
|
|
533
|
-
rowDirection: {
|
|
534
|
-
flexDirection: 'row',
|
|
535
|
-
},
|
|
536
|
-
statusBar: {
|
|
537
|
-
height: 10,
|
|
538
|
-
},
|
|
539
|
-
logo: {
|
|
540
|
-
width: 75,
|
|
541
|
-
height: 75,
|
|
542
|
-
borderRadius: 10,
|
|
543
|
-
},
|
|
544
|
-
textBold: {
|
|
545
|
-
fontWeight: '600',
|
|
546
|
-
},
|
|
547
|
-
btnPickUp: {
|
|
548
|
-
borderWidth: 0,
|
|
549
|
-
backgroundColor: theme.colors.btnBGWhite,
|
|
550
|
-
borderRadius: 8,
|
|
551
|
-
},
|
|
552
|
-
btnBackArrow: {
|
|
553
|
-
borderWidth: 0,
|
|
554
|
-
backgroundColor: theme.colors.backgroundLight,
|
|
555
|
-
borderColor: theme.colors.primary,
|
|
556
|
-
shadowColor: theme.colors.primary,
|
|
557
|
-
alignItems: 'flex-start',
|
|
558
|
-
justifyContent: 'flex-start',
|
|
559
|
-
paddingLeft: 0,
|
|
560
|
-
height: 14,
|
|
561
|
-
},
|
|
562
|
-
icons: {
|
|
563
|
-
maxWidth: 40,
|
|
564
|
-
height: 25,
|
|
565
|
-
},
|
|
566
|
-
linkWithIcons: {
|
|
567
|
-
flexDirection: 'row',
|
|
568
|
-
alignItems: 'center',
|
|
569
|
-
justifyContent: 'space-between',
|
|
570
|
-
marginBottom: 5,
|
|
571
|
-
flex: 1,
|
|
572
|
-
},
|
|
573
|
-
});
|
|
574
|
-
|
|
575
|
-
const locationsToSend = locations.filter(
|
|
576
|
-
(location: any) => location?.lat && location?.lng,
|
|
577
|
-
);
|
|
578
|
-
|
|
579
|
-
return (
|
|
580
|
-
<>
|
|
581
|
-
{(!order || Object.keys(order).length === 0) &&
|
|
582
|
-
(error?.length < 1 || !error) && (
|
|
583
|
-
<View
|
|
584
|
-
style={{
|
|
585
|
-
padding: 20,
|
|
586
|
-
backgroundColor: theme.colors.backgroundLight,
|
|
587
|
-
}}>
|
|
588
|
-
{[...Array(6)].map((item, i) => (
|
|
589
|
-
<Placeholder key={i} Animation={Fade}>
|
|
590
|
-
<View style={{ flexDirection: 'row', marginBottom: 30 }}>
|
|
591
|
-
<Placeholder>
|
|
592
|
-
<PlaceholderLine width={90} />
|
|
593
|
-
<PlaceholderLine width={50} />
|
|
594
|
-
<PlaceholderLine width={20} />
|
|
595
|
-
<PlaceholderLine width={10} />
|
|
596
|
-
</Placeholder>
|
|
597
|
-
</View>
|
|
598
|
-
</Placeholder>
|
|
599
|
-
))}
|
|
600
|
-
</View>
|
|
601
|
-
)}
|
|
602
|
-
|
|
603
|
-
{(!!error || error) && (
|
|
604
|
-
<NotFoundSource
|
|
605
|
-
btnTitle={t('GO_TO_MY_ORDERS', 'Go to my orders')}
|
|
606
|
-
content={
|
|
607
|
-
props.order.error[0] ||
|
|
608
|
-
props.order.error ||
|
|
609
|
-
t('NETWORK_ERROR', 'Network Error')
|
|
610
|
-
}
|
|
611
|
-
onClickButton={() => navigation.navigate('Orders')}
|
|
612
|
-
/>
|
|
613
|
-
)}
|
|
614
|
-
|
|
615
|
-
{order && Object.keys(order).length > 0 && (error?.length < 1 || !error) && (
|
|
616
|
-
<>
|
|
617
|
-
<Header>
|
|
618
|
-
<OIconButton
|
|
619
|
-
icon={theme.images.general.arrow_left}
|
|
620
|
-
iconStyle={{ width: 20, height: 20 }}
|
|
621
|
-
borderColor={theme.colors.clear}
|
|
622
|
-
style={{ ...styles.icons, justifyContent: 'flex-end' }}
|
|
623
|
-
onClick={() => handleArrowBack()}
|
|
624
|
-
/>
|
|
625
|
-
|
|
626
|
-
<Actions>
|
|
627
|
-
<OIconButton
|
|
628
|
-
icon={theme.images.general.map}
|
|
629
|
-
iconStyle={{
|
|
630
|
-
width: 20,
|
|
631
|
-
height: 20,
|
|
632
|
-
tintColor: theme.colors.backArrow,
|
|
633
|
-
}}
|
|
634
|
-
borderColor={theme.colors.clear}
|
|
635
|
-
style={styles.icons}
|
|
636
|
-
onClick={() => handleOpenMapView()}
|
|
637
|
-
/>
|
|
638
|
-
|
|
639
|
-
<OIconButton
|
|
640
|
-
icon={theme.images.general.messages}
|
|
641
|
-
iconStyle={{
|
|
642
|
-
width: 20,
|
|
643
|
-
height: 20,
|
|
644
|
-
tintColor: theme.colors.backArrow,
|
|
645
|
-
}}
|
|
646
|
-
borderColor={theme.colors.clear}
|
|
647
|
-
style={styles.icons}
|
|
648
|
-
onClick={() => handleOpenMessagesForBusiness()}
|
|
649
|
-
/>
|
|
650
|
-
</Actions>
|
|
651
|
-
</Header>
|
|
652
|
-
<OrderHeader>
|
|
653
|
-
<OText size={13} style={{ marginBottom: 5 }}>
|
|
654
|
-
{order?.delivery_datetime_utc
|
|
655
|
-
? parseDate(order?.delivery_datetime_utc)
|
|
656
|
-
: parseDate(order?.delivery_datetime, { utc: false })}
|
|
657
|
-
</OText>
|
|
658
|
-
|
|
659
|
-
<OText numberOfLines={2} size={20} weight="600">
|
|
660
|
-
<>
|
|
661
|
-
{`${t('INVOICE_ORDER_NO', 'Order No.')} ${order.id} ${t(
|
|
662
|
-
'IS',
|
|
663
|
-
'is',
|
|
664
|
-
)} `}
|
|
665
|
-
<OText
|
|
666
|
-
size={20}
|
|
667
|
-
weight="600"
|
|
668
|
-
color={colors[order?.status] || theme.colors.primary}>
|
|
669
|
-
{getOrderStatus(order?.status)?.value}
|
|
670
|
-
</OText>
|
|
671
|
-
</>
|
|
672
|
-
</OText>
|
|
673
|
-
<OText size={13}>
|
|
674
|
-
{`${order?.paymethod?.name} - ${
|
|
675
|
-
order.delivery_type === 1
|
|
676
|
-
? t('DELIVERY', 'Delivery')
|
|
677
|
-
: order.delivery_type === 2
|
|
678
|
-
? t('PICKUP', 'Pickup')
|
|
679
|
-
: order.delivery_type === 3
|
|
680
|
-
? t('EAT_IN', 'Eat in')
|
|
681
|
-
: order.delivery_type === 4
|
|
682
|
-
? t('CURBSIDE', 'Curbside')
|
|
683
|
-
: t('DRIVER_THRU', 'Driver thru')
|
|
684
|
-
}`}
|
|
685
|
-
</OText>
|
|
686
|
-
</OrderHeader>
|
|
687
|
-
<OrderDetailsContainer keyboardShouldPersistTaps="handled">
|
|
688
|
-
<>
|
|
689
|
-
<OrderContent>
|
|
690
|
-
<OrderBusiness>
|
|
691
|
-
<OText style={{ marginBottom: 5 }} size={16} weight="600">
|
|
692
|
-
{t('BUSINESS_DETAILS', 'Business details')}
|
|
693
|
-
</OText>
|
|
694
|
-
|
|
695
|
-
<OText numberOfLines={1} mBottom={4} ellipsizeMode="tail">
|
|
696
|
-
{order?.business?.name}
|
|
697
|
-
</OText>
|
|
698
|
-
|
|
699
|
-
{!!order?.business?.email && (
|
|
700
|
-
<View style={styles.linkWithIcons}>
|
|
701
|
-
<OLink
|
|
702
|
-
PressStyle={styles.linkWithIcons}
|
|
703
|
-
url={`mailto:${order?.business?.email}`}
|
|
704
|
-
shorcut={order?.business?.email}
|
|
705
|
-
/>
|
|
706
|
-
</View>
|
|
707
|
-
)}
|
|
708
|
-
|
|
709
|
-
{!!order?.business?.cellphone && (
|
|
710
|
-
<View style={styles.linkWithIcons}>
|
|
711
|
-
<OLink
|
|
712
|
-
PressStyle={styles.linkWithIcons}
|
|
713
|
-
url={`tel:${order?.business?.cellphone}`}
|
|
714
|
-
shorcut={`${order?.business?.cellphone}`}
|
|
715
|
-
/>
|
|
716
|
-
</View>
|
|
717
|
-
)}
|
|
718
|
-
|
|
719
|
-
{!!order?.business?.phone && (
|
|
720
|
-
<View style={styles.linkWithIcons}>
|
|
721
|
-
<OLink
|
|
722
|
-
PressStyle={styles.linkWithIcons}
|
|
723
|
-
url={`tel:${order?.business?.phone}`}
|
|
724
|
-
shorcut={order?.business?.phone}
|
|
725
|
-
/>
|
|
726
|
-
</View>
|
|
727
|
-
)}
|
|
728
|
-
|
|
729
|
-
{!!order?.business?.address && (
|
|
730
|
-
<View style={styles.linkWithIcons}>
|
|
731
|
-
<OLink
|
|
732
|
-
PressStyle={styles.linkWithIcons}
|
|
733
|
-
url={Platform.select({
|
|
734
|
-
ios: `maps:0,0?q=${order?.business?.address}`,
|
|
735
|
-
android: `geo:0,0?q=${order?.business?.address}`,
|
|
736
|
-
})}
|
|
737
|
-
shorcut={order?.business?.address}
|
|
738
|
-
/>
|
|
739
|
-
</View>
|
|
740
|
-
)}
|
|
741
|
-
|
|
742
|
-
{!!order?.business?.address_notes && (
|
|
743
|
-
<View style={styles.linkWithIcons}>
|
|
744
|
-
<OLink
|
|
745
|
-
PressStyle={styles.linkWithIcons}
|
|
746
|
-
url={Platform.select({
|
|
747
|
-
ios: `maps:0,0?q=${order?.business?.address_notes}`,
|
|
748
|
-
android: `geo:0,0?q=${order?.business?.address_notes}`,
|
|
749
|
-
})}
|
|
750
|
-
shorcut={order?.business?.address_notes}
|
|
751
|
-
/>
|
|
752
|
-
</View>
|
|
753
|
-
)}
|
|
754
|
-
</OrderBusiness>
|
|
755
|
-
|
|
756
|
-
<OrderCustomer>
|
|
757
|
-
<OText style={{ marginBottom: 5 }} size={16} weight="600">
|
|
758
|
-
{t('CUSTOMER_DETAILS', 'Customer details')}
|
|
759
|
-
</OText>
|
|
760
|
-
|
|
761
|
-
<View style={{ flexDirection: 'row' }}>
|
|
762
|
-
<OText numberOfLines={2} mBottom={4}>
|
|
763
|
-
<OText
|
|
764
|
-
numberOfLines={1}
|
|
765
|
-
mBottom={4}
|
|
766
|
-
ellipsizeMode="tail"
|
|
767
|
-
space>
|
|
768
|
-
{order?.customer?.name}
|
|
769
|
-
</OText>
|
|
770
|
-
|
|
771
|
-
<OText
|
|
772
|
-
numberOfLines={1}
|
|
773
|
-
mBottom={4}
|
|
774
|
-
ellipsizeMode="tail"
|
|
775
|
-
space>
|
|
776
|
-
{order?.customer?.middle_name}
|
|
777
|
-
</OText>
|
|
778
|
-
|
|
779
|
-
<OText
|
|
780
|
-
numberOfLines={1}
|
|
781
|
-
mBottom={4}
|
|
782
|
-
ellipsizeMode="tail"
|
|
783
|
-
space>
|
|
784
|
-
{order?.customer?.lastname}
|
|
785
|
-
</OText>
|
|
786
|
-
|
|
787
|
-
<OText
|
|
788
|
-
numberOfLines={1}
|
|
789
|
-
mBottom={4}
|
|
790
|
-
ellipsizeMode="tail"
|
|
791
|
-
space>
|
|
792
|
-
{order?.customer?.second_lastname}
|
|
793
|
-
</OText>
|
|
794
|
-
</OText>
|
|
795
|
-
</View>
|
|
796
|
-
|
|
797
|
-
{!!order?.customer?.email && (
|
|
798
|
-
<View style={styles.linkWithIcons}>
|
|
799
|
-
<OLink
|
|
800
|
-
PressStyle={styles.linkWithIcons}
|
|
801
|
-
url={`mailto:${order?.customer?.email}`}
|
|
802
|
-
shorcut={order?.customer?.email}
|
|
803
|
-
/>
|
|
804
|
-
</View>
|
|
805
|
-
)}
|
|
806
|
-
|
|
807
|
-
{!!order?.customer?.cellphone && (
|
|
808
|
-
<View style={styles.linkWithIcons}>
|
|
809
|
-
<OLink
|
|
810
|
-
PressStyle={styles.linkWithIcons}
|
|
811
|
-
url={`tel:${order?.customer?.cellphone}`}
|
|
812
|
-
shorcut={order?.customer?.cellphone}
|
|
813
|
-
/>
|
|
814
|
-
</View>
|
|
815
|
-
)}
|
|
816
|
-
|
|
817
|
-
{!!order?.customer?.phone && (
|
|
818
|
-
<View style={styles.linkWithIcons}>
|
|
819
|
-
<OLink
|
|
820
|
-
PressStyle={styles.linkWithIcons}
|
|
821
|
-
url={`tel:${order?.customer?.phone}`}
|
|
822
|
-
shorcut={order?.customer?.phone}
|
|
823
|
-
/>
|
|
824
|
-
</View>
|
|
825
|
-
)}
|
|
826
|
-
|
|
827
|
-
{!!order?.customer?.address && (
|
|
828
|
-
<View style={styles.linkWithIcons}>
|
|
829
|
-
<OLink
|
|
830
|
-
PressStyle={styles.linkWithIcons}
|
|
831
|
-
url={Platform.select({
|
|
832
|
-
ios: `maps:0,0?q=${order?.customer?.address}`,
|
|
833
|
-
android: `geo:0,0?q=${order?.customer?.address}`,
|
|
834
|
-
})}
|
|
835
|
-
shorcut={order?.customer?.address}
|
|
836
|
-
/>
|
|
837
|
-
</View>
|
|
838
|
-
)}
|
|
839
|
-
|
|
840
|
-
{!!order?.customer?.internal_number && (
|
|
841
|
-
<OText numberOfLines={1} mBottom={4} ellipsizeMode="tail">
|
|
842
|
-
{order?.customer?.internal_number}
|
|
843
|
-
</OText>
|
|
844
|
-
)}
|
|
845
|
-
|
|
846
|
-
{!!order?.customer?.address_notes && (
|
|
847
|
-
<OText numberOfLines={1} mBottom={4} ellipsizeMode="tail">
|
|
848
|
-
{order?.customer?.address_notes}
|
|
849
|
-
</OText>
|
|
850
|
-
)}
|
|
851
|
-
|
|
852
|
-
{!!order?.customer.zipcode && (
|
|
853
|
-
<OText numberOfLines={1} mBottom={4} ellipsizeMode="tail">
|
|
854
|
-
{order?.customer?.zipcode}
|
|
855
|
-
</OText>
|
|
856
|
-
)}
|
|
857
|
-
</OrderCustomer>
|
|
858
|
-
|
|
859
|
-
<OrderProducts>
|
|
860
|
-
<OText style={{ marginBottom: 5 }} size={16} weight="600">
|
|
861
|
-
{t('ORDER_DETAILS', 'Order Details')}
|
|
862
|
-
</OText>
|
|
863
|
-
|
|
864
|
-
{order?.products?.length &&
|
|
865
|
-
order?.products.map((product: any, i: number) => (
|
|
866
|
-
<ProductItemAccordion
|
|
867
|
-
key={product?.id || i}
|
|
868
|
-
product={product}
|
|
869
|
-
/>
|
|
870
|
-
))}
|
|
871
|
-
</OrderProducts>
|
|
872
|
-
|
|
873
|
-
<OrderBill>
|
|
874
|
-
<Table>
|
|
875
|
-
<OText mBottom={4}>{t('SUBTOTAL', 'Subtotal')}</OText>
|
|
876
|
-
<OText mBottom={4}>
|
|
877
|
-
{parsePrice(
|
|
878
|
-
order.tax_type === 1
|
|
879
|
-
? order?.summary?.subtotal + order?.summary?.tax ?? 0
|
|
880
|
-
: order?.summary?.subtotal ?? 0,
|
|
881
|
-
)}
|
|
882
|
-
</OText>
|
|
883
|
-
</Table>
|
|
884
|
-
|
|
885
|
-
{order?.tax_type !== 1 && (
|
|
886
|
-
<Table>
|
|
887
|
-
<OText mBottom={4}>
|
|
888
|
-
{t('TAX', 'Tax')}
|
|
889
|
-
{`(${verifyDecimals(
|
|
890
|
-
order?.summary?.tax_rate,
|
|
891
|
-
parseNumber,
|
|
892
|
-
)}%)`}
|
|
893
|
-
</OText>
|
|
894
|
-
|
|
895
|
-
<OText mBottom={4}>
|
|
896
|
-
{parsePrice(order?.summary?.tax ?? 0)}
|
|
897
|
-
</OText>
|
|
898
|
-
</Table>
|
|
899
|
-
)}
|
|
900
|
-
|
|
901
|
-
{order?.summary?.discount > 0 && (
|
|
902
|
-
<Table>
|
|
903
|
-
{order?.offer_type === 1 ? (
|
|
904
|
-
<OText mBottom={4}>
|
|
905
|
-
<OText>{t('DISCOUNT', 'Discount')}</OText>
|
|
906
|
-
|
|
907
|
-
<OText>
|
|
908
|
-
{`(${verifyDecimals(
|
|
909
|
-
order?.offer_rate,
|
|
910
|
-
parsePrice,
|
|
911
|
-
)}%)`}
|
|
912
|
-
</OText>
|
|
913
|
-
</OText>
|
|
914
|
-
) : (
|
|
915
|
-
<OText mBottom={4}>{t('DISCOUNT', 'Discount')}</OText>
|
|
916
|
-
)}
|
|
917
|
-
|
|
918
|
-
<OText mBottom={4}>
|
|
919
|
-
- {parsePrice(order?.summary?.discount)}
|
|
920
|
-
</OText>
|
|
921
|
-
</Table>
|
|
922
|
-
)}
|
|
923
|
-
|
|
924
|
-
{order?.summary?.subtotal_with_discount > 0 &&
|
|
925
|
-
order?.summary?.discount > 0 &&
|
|
926
|
-
order?.summary?.total >= 0 && (
|
|
927
|
-
<Table>
|
|
928
|
-
<OText mBottom={4}>
|
|
929
|
-
{t(
|
|
930
|
-
'SUBTOTAL_WITH_DISCOUNT',
|
|
931
|
-
'Subtotal with discount',
|
|
932
|
-
)}
|
|
933
|
-
</OText>
|
|
934
|
-
{order?.tax_type === 1 ? (
|
|
935
|
-
<OText mBottom={4}>
|
|
936
|
-
{parsePrice(
|
|
937
|
-
order?.summary?.subtotal_with_discount +
|
|
938
|
-
order?.summary?.tax ?? 0,
|
|
939
|
-
)}
|
|
940
|
-
</OText>
|
|
941
|
-
) : (
|
|
942
|
-
<OText mBottom={4}>
|
|
943
|
-
{parsePrice(
|
|
944
|
-
order?.summary?.subtotal_with_discount ?? 0,
|
|
945
|
-
)}
|
|
946
|
-
</OText>
|
|
947
|
-
)}
|
|
948
|
-
</Table>
|
|
949
|
-
)}
|
|
950
|
-
|
|
951
|
-
{order?.summary?.delivery_price > 0 && (
|
|
952
|
-
<Table>
|
|
953
|
-
<OText mBottom={4}>
|
|
954
|
-
{t('DELIVERY_FEE', 'Delivery Fee')}
|
|
955
|
-
</OText>
|
|
956
|
-
|
|
957
|
-
<OText mBottom={4}>
|
|
958
|
-
{parsePrice(order?.summary?.delivery_price)}
|
|
959
|
-
</OText>
|
|
960
|
-
</Table>
|
|
961
|
-
)}
|
|
962
|
-
|
|
963
|
-
<Table>
|
|
964
|
-
<OText mBottom={4}>
|
|
965
|
-
{t('DRIVER_TIP', 'Driver tip')}{' '}
|
|
966
|
-
{order?.summary?.driver_tip > 0 &&
|
|
967
|
-
parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
|
|
968
|
-
!parseInt(configs?.driver_tip_use_custom?.value, 10) &&
|
|
969
|
-
`(${verifyDecimals(
|
|
970
|
-
order?.summary?.driver_tip,
|
|
971
|
-
parseNumber,
|
|
972
|
-
)}%)`}
|
|
973
|
-
</OText>
|
|
974
|
-
|
|
975
|
-
<OText mBottom={4}>
|
|
976
|
-
{parsePrice(order?.summary?.driver_tip ?? 0)}
|
|
977
|
-
</OText>
|
|
978
|
-
</Table>
|
|
979
|
-
|
|
980
|
-
{order?.summary?.service_fee > 0 && (
|
|
981
|
-
<Table>
|
|
982
|
-
<OText mBottom={4}>
|
|
983
|
-
{t('SERVICE_FEE', 'Service Fee')}{' '}
|
|
984
|
-
{`(${verifyDecimals(
|
|
985
|
-
order?.summary?.service_fee,
|
|
986
|
-
parseNumber,
|
|
987
|
-
)}%)`}
|
|
988
|
-
</OText>
|
|
989
|
-
|
|
990
|
-
<OText mBottom={4}>
|
|
991
|
-
{parsePrice(order?.summary?.service_fee)}
|
|
992
|
-
</OText>
|
|
993
|
-
</Table>
|
|
994
|
-
)}
|
|
995
|
-
|
|
996
|
-
<Total>
|
|
997
|
-
<Table>
|
|
998
|
-
<OText mBottom={4} style={styles.textBold}>
|
|
999
|
-
{t('TOTAL', 'Total')}
|
|
1000
|
-
</OText>
|
|
1001
|
-
|
|
1002
|
-
<OText
|
|
1003
|
-
mBottom={4}
|
|
1004
|
-
style={styles.textBold}
|
|
1005
|
-
color={theme.colors.primary}>
|
|
1006
|
-
{parsePrice(order?.summary?.total ?? 0)}
|
|
1007
|
-
</OText>
|
|
1008
|
-
</Table>
|
|
1009
|
-
</Total>
|
|
1010
|
-
</OrderBill>
|
|
1011
|
-
</OrderContent>
|
|
1012
|
-
|
|
1013
|
-
{(order?.status === 7 || order?.status === 4) &&
|
|
1014
|
-
order?.delivery_type === 1 && (
|
|
1015
|
-
<AssignDriver>
|
|
1016
|
-
<OText style={{ marginBottom: 5 }} size={16} weight="600">
|
|
1017
|
-
{t('ASSIGN_DRIVER', 'Assign driver')}
|
|
1018
|
-
</OText>
|
|
1019
|
-
|
|
1020
|
-
<View
|
|
1021
|
-
style={{
|
|
1022
|
-
backgroundColor: theme.colors.inputChat,
|
|
1023
|
-
borderRadius: 7.5,
|
|
1024
|
-
}}>
|
|
1025
|
-
<CountryPicker
|
|
1026
|
-
// @ts-ignore
|
|
1027
|
-
countryCode={undefined}
|
|
1028
|
-
visible={isDriverModalVisible}
|
|
1029
|
-
onClose={() => setIsDriverModalVisible(false)}
|
|
1030
|
-
withCountryNameButton
|
|
1031
|
-
renderFlagButton={() => (
|
|
1032
|
-
<>
|
|
1033
|
-
<TouchableOpacity
|
|
1034
|
-
onPress={() => setIsDriverModalVisible(true)}
|
|
1035
|
-
disabled={
|
|
1036
|
-
itemsDrivers.length === 0 || loadingDriver
|
|
1037
|
-
}>
|
|
1038
|
-
{loadingDriver ? (
|
|
1039
|
-
<DriverItem justifyContent="center">
|
|
1040
|
-
<ActivityIndicator
|
|
1041
|
-
size="small"
|
|
1042
|
-
color={theme.colors.primary}
|
|
1043
|
-
/>
|
|
1044
|
-
</DriverItem>
|
|
1045
|
-
) : (
|
|
1046
|
-
<DriverItem justifyContent="space-between">
|
|
1047
|
-
<OText>
|
|
1048
|
-
{itemsDrivers.length > 0
|
|
1049
|
-
? order?.driver?.name ||
|
|
1050
|
-
t('SELECT_DRIVER', 'Select Driver')
|
|
1051
|
-
: t('WITHOUT_DRIVERS', 'Without drivers')}
|
|
1052
|
-
</OText>
|
|
1053
|
-
<OIcon
|
|
1054
|
-
src={theme?.images?.general?.chevronDown}
|
|
1055
|
-
color={theme.colors.backArrow}
|
|
1056
|
-
width={20}
|
|
1057
|
-
height={20}
|
|
1058
|
-
/>
|
|
1059
|
-
</DriverItem>
|
|
1060
|
-
)}
|
|
1061
|
-
</TouchableOpacity>
|
|
1062
|
-
</>
|
|
1063
|
-
)}
|
|
1064
|
-
flatListProps={{
|
|
1065
|
-
keyExtractor: (item: any) => item.value,
|
|
1066
|
-
data: itemsDrivers || [],
|
|
1067
|
-
renderItem: ({ item }: any) => (
|
|
1068
|
-
<TouchableOpacity
|
|
1069
|
-
style={!item.available && styles.driverOff}
|
|
1070
|
-
disabled={
|
|
1071
|
-
!item.available ||
|
|
1072
|
-
order?.driver?.id === item.value
|
|
1073
|
-
}
|
|
1074
|
-
onPress={() => {
|
|
1075
|
-
handleAssignDriver &&
|
|
1076
|
-
handleAssignDriver(item.value);
|
|
1077
|
-
setIsDriverModalVisible(false);
|
|
1078
|
-
}}>
|
|
1079
|
-
<DriverItem>
|
|
1080
|
-
<OText
|
|
1081
|
-
color={!item.available && theme.colors.grey}>
|
|
1082
|
-
{item.label}
|
|
1083
|
-
{!item.available &&
|
|
1084
|
-
` (${t('NOT_AVAILABLE', 'Not available')})`}
|
|
1085
|
-
{item.value === order?.driver?.id &&
|
|
1086
|
-
` (${t('SELECTED', 'Selected')})`}
|
|
1087
|
-
</OText>
|
|
1088
|
-
</DriverItem>
|
|
1089
|
-
</TouchableOpacity>
|
|
1090
|
-
),
|
|
1091
|
-
}}
|
|
1092
|
-
/>
|
|
1093
|
-
</View>
|
|
1094
|
-
</AssignDriver>
|
|
1095
|
-
)}
|
|
1096
|
-
|
|
1097
|
-
{order?.status === 7 && (
|
|
1098
|
-
<Pickup>
|
|
1099
|
-
<OButton
|
|
1100
|
-
style={styles.btnPickUp}
|
|
1101
|
-
textStyle={{ color: theme.colors.primary }}
|
|
1102
|
-
text={t('READY_FOR_PICKUP', 'Ready for pickup')}
|
|
1103
|
-
onClick={() =>
|
|
1104
|
-
handleChangeOrderStatus && handleChangeOrderStatus(4)
|
|
1105
|
-
}
|
|
1106
|
-
imgLeftStyle={{ tintColor: theme.colors.backArrow }}
|
|
1107
|
-
imgRightSrc={false}
|
|
1108
|
-
isLoading={loading}
|
|
1109
|
-
/>
|
|
1110
|
-
</Pickup>
|
|
1111
|
-
)}
|
|
1112
|
-
|
|
1113
|
-
{order?.status === 4 && ![1].includes(order?.delivery_type) && (
|
|
1114
|
-
<Pickup>
|
|
1115
|
-
<OButton
|
|
1116
|
-
style={{
|
|
1117
|
-
...styles.btnPickUp,
|
|
1118
|
-
backgroundColor: theme.colors.green,
|
|
1119
|
-
}}
|
|
1120
|
-
textStyle={{ color: theme.colors.white }}
|
|
1121
|
-
text={t(
|
|
1122
|
-
'PICKUP_COMPLETED_BY_CUSTOMER',
|
|
1123
|
-
'Pickup completed by customer',
|
|
1124
|
-
)}
|
|
1125
|
-
onClick={() =>
|
|
1126
|
-
handleChangeOrderStatus && handleChangeOrderStatus(15)
|
|
1127
|
-
}
|
|
1128
|
-
imgLeftStyle={{ tintColor: theme.colors.backArrow }}
|
|
1129
|
-
imgRightSrc={false}
|
|
1130
|
-
isLoading={loading}
|
|
1131
|
-
/>
|
|
1132
|
-
</Pickup>
|
|
1133
|
-
)}
|
|
1134
|
-
|
|
1135
|
-
{order?.status === 4 && ![1].includes(order?.delivery_type) && (
|
|
1136
|
-
<Pickup>
|
|
1137
|
-
<OButton
|
|
1138
|
-
style={{
|
|
1139
|
-
...styles.btnPickUp,
|
|
1140
|
-
backgroundColor: theme.colors.red,
|
|
1141
|
-
}}
|
|
1142
|
-
textStyle={{ color: theme.colors.white }}
|
|
1143
|
-
text={t(
|
|
1144
|
-
'ORDER_NOT_PICKEDUP_BY_CUSTOMER',
|
|
1145
|
-
'Order not picked up by customer',
|
|
1146
|
-
)}
|
|
1147
|
-
onClick={() =>
|
|
1148
|
-
handleChangeOrderStatus && handleChangeOrderStatus(17)
|
|
1149
|
-
}
|
|
1150
|
-
imgLeftStyle={{ tintColor: theme.colors.backArrow }}
|
|
1151
|
-
imgRightSrc={false}
|
|
1152
|
-
isLoading={loading}
|
|
1153
|
-
/>
|
|
1154
|
-
</Pickup>
|
|
1155
|
-
)}
|
|
1156
|
-
|
|
1157
|
-
<OModal
|
|
1158
|
-
open={openModalForBusiness}
|
|
1159
|
-
order={order}
|
|
1160
|
-
title={`${t('INVOICE_ORDER_NO', 'Order No.')} ${order?.id}`}
|
|
1161
|
-
entireModal
|
|
1162
|
-
onClose={() => handleCloseModal()}>
|
|
1163
|
-
<Chat
|
|
1164
|
-
type={
|
|
1165
|
-
openModalForBusiness ? USER_TYPE.BUSINESS : USER_TYPE.DRIVER
|
|
1166
|
-
}
|
|
1167
|
-
orderId={order?.id}
|
|
1168
|
-
messages={messages}
|
|
1169
|
-
order={order}
|
|
1170
|
-
setMessages={setMessages}
|
|
1171
|
-
/>
|
|
1172
|
-
</OModal>
|
|
1173
|
-
|
|
1174
|
-
<OModal
|
|
1175
|
-
open={openModalForAccept}
|
|
1176
|
-
onClose={() => setOpenModalForAccept(false)}
|
|
1177
|
-
entireModal
|
|
1178
|
-
customClose>
|
|
1179
|
-
<AcceptOrRejectOrder
|
|
1180
|
-
handleUpdateOrder={handleChangeOrderStatus}
|
|
1181
|
-
closeModal={setOpenModalForAccept}
|
|
1182
|
-
customerCellphone={order?.customer?.cellphone}
|
|
1183
|
-
loading={loading}
|
|
1184
|
-
action={actionOrder}
|
|
1185
|
-
orderId={order?.id}
|
|
1186
|
-
notShowCustomerPhone={false}
|
|
1187
|
-
actions={actions}
|
|
1188
|
-
titleAccept={titleAccept}
|
|
1189
|
-
titleReject={titleReject}
|
|
1190
|
-
appTitle={appTitle}
|
|
1191
|
-
/>
|
|
1192
|
-
</OModal>
|
|
1193
|
-
|
|
1194
|
-
<OModal
|
|
1195
|
-
open={openModalForMapView}
|
|
1196
|
-
onClose={() => handleOpenMapView()}
|
|
1197
|
-
entireModal
|
|
1198
|
-
customClose>
|
|
1199
|
-
<GoogleMap
|
|
1200
|
-
location={order?.customer?.location}
|
|
1201
|
-
locations={locationsToSend}
|
|
1202
|
-
driverLocation={driverLocation}
|
|
1203
|
-
navigation={navigation}
|
|
1204
|
-
handleViewActionOrder={handleViewActionOrder}
|
|
1205
|
-
handleOpenMapView={handleOpenMapView}
|
|
1206
|
-
readOnly
|
|
1207
|
-
showAcceptOrReject={
|
|
1208
|
-
showFloatButtonsAcceptOrReject[order?.status]
|
|
1209
|
-
}
|
|
1210
|
-
/>
|
|
1211
|
-
</OModal>
|
|
1212
|
-
</>
|
|
1213
|
-
<View style={{ height: 30 }} />
|
|
1214
|
-
</OrderDetailsContainer>
|
|
1215
|
-
|
|
1216
|
-
{order &&
|
|
1217
|
-
Object.keys(order).length > 0 &&
|
|
1218
|
-
getOrderStatus(order?.status)?.value ===
|
|
1219
|
-
t('PENDING', 'Pending') && (
|
|
1220
|
-
<>
|
|
1221
|
-
<FloatingButton
|
|
1222
|
-
btnText={t('REJECT', 'Reject')}
|
|
1223
|
-
isSecondaryBtn={false}
|
|
1224
|
-
secondButtonClick={() => handleViewActionOrder('accept')}
|
|
1225
|
-
firstButtonClick={() => handleViewActionOrder('reject')}
|
|
1226
|
-
secondBtnText={t('ACCEPT', 'Accept')}
|
|
1227
|
-
secondButton={true}
|
|
1228
|
-
firstColorCustom={theme.colors.red}
|
|
1229
|
-
secondColorCustom={theme.colors.green}
|
|
1230
|
-
/>
|
|
1231
|
-
</>
|
|
1232
|
-
)}
|
|
1233
|
-
|
|
1234
|
-
{order &&
|
|
1235
|
-
Object.keys(order).length > 0 &&
|
|
1236
|
-
getOrderStatus(order?.status)?.value !==
|
|
1237
|
-
t('PENDING', 'Pending') && (
|
|
1238
|
-
<FloatingButton
|
|
1239
|
-
btnText={t('COPY', 'Copy')}
|
|
1240
|
-
isSecondaryBtn={false}
|
|
1241
|
-
colorTxt1={theme.colors.primary}
|
|
1242
|
-
secondButtonClick={handleViewSummaryOrder}
|
|
1243
|
-
firstButtonClick={handleCopyClipboard}
|
|
1244
|
-
secondBtnText={t('PRINT', 'Print')}
|
|
1245
|
-
secondButton={true}
|
|
1246
|
-
firstColorCustom="transparent"
|
|
1247
|
-
secondColorCustom={theme.colors.primary}
|
|
1248
|
-
/>
|
|
1249
|
-
)}
|
|
1250
|
-
</>
|
|
1251
|
-
)}
|
|
1252
|
-
</>
|
|
1253
|
-
);
|
|
1254
|
-
};
|
|
1255
|
-
|
|
1256
|
-
export const OrderDetails = (props: OrderDetailsParams) => {
|
|
1257
|
-
const orderDetailsProps = {
|
|
1258
|
-
...props,
|
|
1259
|
-
UIComponent: OrderDetailsUI,
|
|
1260
|
-
};
|
|
1261
|
-
return <OrderDetailsController {...orderDetailsProps} />;
|
|
1262
|
-
};
|