ordering-ui-react-native 0.8.3 → 0.8.7

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.
Files changed (47) hide show
  1. package/package.json +2 -1
  2. package/src/components/OrdersOption/index.tsx +1 -12
  3. package/src/navigators/HomeNavigator.tsx +27 -2
  4. package/src/pages/Checkout.tsx +3 -3
  5. package/src/types/react-native-background-timer/index.d.ts +1 -0
  6. package/themes/business/index.tsx +6 -0
  7. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +167 -240
  8. package/themes/business/src/components/Chat/index.tsx +68 -54
  9. package/themes/business/src/components/DriverMap/index.tsx +86 -116
  10. package/themes/business/src/components/GoogleMap/index.tsx +43 -39
  11. package/themes/business/src/components/MessagesOption/index.tsx +73 -59
  12. package/themes/business/src/components/MessagesOption/styles.tsx +1 -1
  13. package/themes/business/src/components/OrderDetails/index.tsx +104 -92
  14. package/themes/business/src/components/OrderDetails/styles.tsx +6 -2
  15. package/themes/business/src/components/OrderDetailsDelivery/index.tsx +816 -0
  16. package/themes/business/src/components/OrderDetailsDelivery/styles.tsx +144 -0
  17. package/themes/business/src/components/OrderMessage/index.tsx +122 -23
  18. package/themes/business/src/components/OrdersOption/index.tsx +52 -66
  19. package/themes/business/src/components/PreviousMessages/index.tsx +2 -2
  20. package/themes/business/src/components/PreviousOrders/index.tsx +5 -5
  21. package/themes/business/src/components/ProductItemAccordion/index.tsx +5 -1
  22. package/themes/business/src/components/StoresList/index.tsx +51 -49
  23. package/themes/business/src/components/UserFormDetails/index.tsx +2 -1
  24. package/themes/business/src/components/UserProfileForm/index.tsx +18 -30
  25. package/themes/business/src/components/UserProfileForm/styles.tsx +0 -2
  26. package/themes/business/src/components/shared/OInput.tsx +3 -2
  27. package/themes/business/src/hooks/useLocation.tsx +7 -3
  28. package/themes/business/src/layouts/SafeAreaContainer.tsx +43 -0
  29. package/themes/business/src/types/index.tsx +8 -0
  30. package/themes/doordash/index.tsx +4 -4
  31. package/themes/doordash/src/components/LoginForm/index.tsx +2 -5
  32. package/themes/doordash/src/components/SingleProductCard/index.tsx +1 -1
  33. package/themes/doordash/src/components/SocialShare/index.tsx +34 -5
  34. package/themes/doordash/src/components/shared/OModal.tsx +1 -6
  35. package/themes/instacart/src/components/AddressForm/index.tsx +2 -60
  36. package/themes/instacart/src/components/AddressList/index.tsx +6 -3
  37. package/themes/instacart/src/components/Home/index.tsx +39 -14
  38. package/themes/instacart/src/components/Home/styles.tsx +7 -0
  39. package/themes/instacart/src/components/LoginForm/index.tsx +3 -3
  40. package/themes/instacart/src/components/LoginForm/styles.tsx +1 -3
  41. package/themes/instacart/src/components/LogoutButton/index.tsx +7 -6
  42. package/themes/instacart/src/components/SocialShare/index.tsx +56 -19
  43. package/themes/instacart/src/components/SocialShare/styles.ts +0 -8
  44. package/themes/instacart/src/components/UserProfileForm/index.tsx +1 -1
  45. package/themes/instacart/src/components/shared/OIcon.tsx +2 -1
  46. package/themes/instacart/src/layouts/Container.tsx +1 -1
  47. package/themes/instacart/src/types/index.tsx +12 -12
@@ -0,0 +1,816 @@
1
+ //React & React Native
2
+ import React, { useState, useEffect } from 'react';
3
+ import { StyleSheet, View } from 'react-native';
4
+
5
+ // Thirds
6
+ import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
7
+
8
+ //OrderingComponent
9
+ import {
10
+ useLanguage,
11
+ OrderDetails as OrderDetailsConTableoller,
12
+ useUtils,
13
+ useConfig,
14
+ useToast,
15
+ ToastType,
16
+ } from 'ordering-components/native';
17
+
18
+ //Components
19
+ import { AcceptOrRejectOrder } from '../AcceptOrRejectOrder';
20
+ import { Chat } from '../Chat';
21
+ import { FloatingButton } from '../FloatingButton';
22
+ import { DriverMap } from '../DriverMap';
23
+ import { OButton, OText, OIconButton } from '../shared';
24
+ import { OModal } from '../shared';
25
+ import { OrderDetailsParams } from '../../types';
26
+ import { ProductItemAccordion } from '../ProductItemAccordion';
27
+ import { USER_TYPE } from '../../config/constants';
28
+ import { useTheme } from 'styled-components/native';
29
+ import { verifyDecimals } from '../../utils';
30
+
31
+ //Styles
32
+ import {
33
+ Actions,
34
+ OrderDetailsContainer,
35
+ Header,
36
+ OrderContent,
37
+ OrderBusiness,
38
+ OrderCustomer,
39
+ OrderHeader,
40
+ OrderProducts,
41
+ Table,
42
+ OrderBill,
43
+ Total,
44
+ Pickup,
45
+ } from './styles';
46
+
47
+ export const OrderDetailsUI = (props: OrderDetailsParams) => {
48
+ const {
49
+ navigation,
50
+ messages,
51
+ setMessages,
52
+ readMessages,
53
+ messagesReadList,
54
+ handleChangeOrderStatus,
55
+ permissions,
56
+ askLocationPermission,
57
+ driverLocation,
58
+ actions,
59
+ titleAccept,
60
+ titleReject,
61
+ appTitle,
62
+ } = props;
63
+
64
+ const [, { showToast }] = useToast();
65
+ const { order, loading } = props.order;
66
+ const theme = useTheme();
67
+ const [, t] = useLanguage();
68
+ const [{ parsePrice, parseNumber, parseDate }] = useUtils();
69
+ const [{ configs }] = useConfig();
70
+ const [actionOrder, setActionOrder] = useState('');
71
+ const [unreadAlert, setUnreadAlert] = useState({
72
+ business: false,
73
+ driver: false,
74
+ });
75
+ const [openModalForMapView, setOpenModalForMapView] = useState(false);
76
+ const [openModalForBusiness, setOpenModalForBusiness] = useState(false);
77
+ const [openModalForAccept, setOpenModalForAccept] = useState(false);
78
+
79
+ const getOrderStatus = (s: string) => {
80
+ const status = parseInt(s);
81
+ const orderStatus = [
82
+ {
83
+ key: 0,
84
+ value: t('PENDING', 'Pending'),
85
+ slug: 'PENDING',
86
+ percentage: 0.25,
87
+ },
88
+ {
89
+ key: 1,
90
+ value: t('COMPLETED', 'Completed'),
91
+ slug: 'COMPLETED',
92
+ percentage: 1,
93
+ },
94
+ {
95
+ key: 2,
96
+ value: t('REJECTED', 'Rejected'),
97
+ slug: 'REJECTED',
98
+ percentage: 0,
99
+ },
100
+ {
101
+ key: 3,
102
+ value: t('DRIVER_IN_BUSINESS', 'Driver in business'),
103
+ slug: 'DRIVER_IN_BUSINESS',
104
+ percentage: 0.6,
105
+ },
106
+ {
107
+ key: 4,
108
+ value: t('PREPARATION_COMPLETED', 'Preparation Completed'),
109
+ slug: 'PREPARATION_COMPLETED',
110
+ percentage: 0.7,
111
+ },
112
+ {
113
+ key: 5,
114
+ value: t('REJECTED', 'Rejected'),
115
+ slug: 'REJECTED_BY_BUSINESS',
116
+ percentage: 0,
117
+ },
118
+ {
119
+ key: 6,
120
+ value: t('REJECTED_BY_DRIVER', 'Rejected by Driver'),
121
+ slug: 'REJECTED_BY_DRIVER',
122
+ percentage: 0,
123
+ },
124
+ {
125
+ key: 7,
126
+ value: t('ACCEPTED_BY_BUSINESS', 'Accepted by business'),
127
+ slug: 'ACCEPTED_BY_BUSINESS',
128
+ percentage: 0.35,
129
+ },
130
+ {
131
+ key: 8,
132
+ value: t('ACCEPTED_BY_DRIVER', 'Accepted by driver'),
133
+ slug: 'ACCEPTED_BY_DRIVER',
134
+ percentage: 0.45,
135
+ },
136
+ {
137
+ key: 9,
138
+ value: t('PICK_UP_COMPLETED_BY_DRIVER', 'Pick up completed by driver'),
139
+ slug: 'PICK_UP_COMPLETED_BY_DRIVER',
140
+ percentage: 0.8,
141
+ },
142
+ {
143
+ key: 10,
144
+ value: t('PICK_UP_FAILED_BY_DRIVER', 'Pick up Failed by driver'),
145
+ slug: 'PICK_UP_FAILED_BY_DRIVER',
146
+ percentage: 0,
147
+ },
148
+ {
149
+ key: 11,
150
+ value: t(
151
+ 'DELIVERY_COMPLETED_BY_DRIVER',
152
+ 'Delivery completed by driver',
153
+ ),
154
+ slug: 'DELIVERY_COMPLETED_BY_DRIVER',
155
+ percentage: 1,
156
+ },
157
+ {
158
+ key: 12,
159
+ value: t('DELIVERY_FAILED_BY_DRIVER', 'Delivery Failed by driver'),
160
+ slug: 'DELIVERY_FAILED_BY_DRIVER',
161
+ percentage: 0,
162
+ },
163
+ {
164
+ key: 13,
165
+ value: t('PREORDER', 'PreOrder'),
166
+ slug: 'PREORDER',
167
+ percentage: 0,
168
+ },
169
+ {
170
+ key: 14,
171
+ value: t('ORDER_NOT_READY', 'Order not ready'),
172
+ slug: 'ORDER_NOT_READY',
173
+ percentage: 0,
174
+ },
175
+ {
176
+ key: 15,
177
+ value: t(
178
+ 'ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER',
179
+ 'Order picked up completed by customer',
180
+ ),
181
+ slug: 'ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER',
182
+ percentage: 100,
183
+ },
184
+ {
185
+ key: 16,
186
+ value: t('CANCELLED_BY_CUSTOMER', 'Cancelled by customer'),
187
+ slug: 'CANCELLED_BY_CUSTOMER',
188
+ percentage: 0,
189
+ },
190
+ {
191
+ key: 17,
192
+ value: t(
193
+ 'ORDER_NOT_PICKEDUP_BY_CUSTOMER',
194
+ 'Order not picked up by customer',
195
+ ),
196
+ slug: 'ORDER_NOT_PICKEDUP_BY_CUSTOMER',
197
+ percentage: 0,
198
+ },
199
+ {
200
+ key: 18,
201
+ value: t(
202
+ 'DRIVER_ALMOST_ARRIVED_TO_BUSINESS',
203
+ 'Driver almost arrived to business',
204
+ ),
205
+ slug: 'DRIVER_ALMOST_ARRIVED_TO_BUSINESS',
206
+ percentage: 0.15,
207
+ },
208
+ {
209
+ key: 19,
210
+ value: t(
211
+ 'DRIVER_ALMOST_ARRIVED_TO_CUSTOMER',
212
+ 'Driver almost arrived to customer',
213
+ ),
214
+ slug: 'DRIVER_ALMOST_ARRIVED_TO_CUSTOMER',
215
+ percentage: 0.9,
216
+ },
217
+ {
218
+ key: 20,
219
+ value: t(
220
+ 'ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS',
221
+ 'Customer almost arrived to business',
222
+ ),
223
+ slug: 'ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS',
224
+ percentage: 90,
225
+ },
226
+ {
227
+ key: 21,
228
+ value: t(
229
+ 'ORDER_CUSTOMER_ARRIVED_BUSINESS',
230
+ 'Customer arrived to business',
231
+ ),
232
+ slug: 'ORDER_CUSTOMER_ARRIVED_BUSINESS',
233
+ percentage: 95,
234
+ },
235
+ ];
236
+
237
+ const objectStatus = orderStatus.find(o => o.key === status);
238
+
239
+ return objectStatus && objectStatus;
240
+ };
241
+
242
+ const showFloatButtonsPickUp: any = {
243
+ 8: true,
244
+ 3: true,
245
+ };
246
+
247
+ const showFloatButtonsAcceptOrReject: any = {
248
+ 0: true,
249
+ 7: true,
250
+ };
251
+
252
+ const marginContainer: any = {
253
+ 0: true,
254
+ 3: true,
255
+ 7: true,
256
+ 8: true,
257
+ 9: true,
258
+ };
259
+
260
+ const handleOpenMessagesForBusiness = () => {
261
+ setOpenModalForBusiness(true);
262
+ readMessages && readMessages();
263
+ setUnreadAlert({ ...unreadAlert, business: false });
264
+ };
265
+
266
+ const handleOpenMapView = async () => {
267
+ if (permissions.locationStatus === 'granted') {
268
+ setOpenModalForMapView(!openModalForMapView);
269
+ } else if (permissions.locationStatus === 'blocked') {
270
+ // redirectToSettings();
271
+ showToast(
272
+ ToastType.Error,
273
+ t('GEOLOCATION_SERVICE_PERMISSION_BLOCKED',
274
+ 'Geolocation service permissions blocked.'),
275
+ );
276
+ } else {
277
+ const response = await askLocationPermission();
278
+ if (response === 'granted') {
279
+ setOpenModalForMapView(!openModalForMapView);
280
+ }
281
+ }
282
+ };
283
+
284
+ const handleViewActionOrder = (action: string) => {
285
+ if (openModalForMapView) {
286
+ setOpenModalForMapView(false);
287
+ }
288
+ setActionOrder(action);
289
+ setOpenModalForAccept(true);
290
+ };
291
+
292
+ useEffect(() => {
293
+ if (permissions.locationStatus !== 'granted' && openModalForMapView) {
294
+ setOpenModalForMapView(false);
295
+ }
296
+ }, [permissions.locationStatus]);
297
+
298
+ useEffect(() => {
299
+ if (openModalForAccept) {
300
+ setOpenModalForAccept(false);
301
+ }
302
+
303
+ if (openModalForBusiness) {
304
+ setOpenModalForBusiness(false);
305
+ }
306
+
307
+ if (openModalForMapView) {
308
+ setOpenModalForMapView(false);
309
+ }
310
+ }, [loading]);
311
+
312
+ const handleCloseModal = () => {
313
+ setOpenModalForBusiness(false);
314
+ };
315
+
316
+ const colors: any = {
317
+ 0: theme.colors.statusOrderBlue,
318
+ 3: theme.colors.statusOrderBlue,
319
+ 5: theme.colors.statusOrderRed,
320
+ 7: theme.colors.StatusOrderBlue,
321
+ 8: theme.colors.statusOrderBlue,
322
+ 9: theme.colors.statusOrderBlue,
323
+ 11: theme.colors.statusOrderGreen,
324
+ 12: theme.colors.statusOrderRed,
325
+ };
326
+
327
+ const handleArrowBack: any = () => {
328
+ navigation?.canGoBack() && navigation.goBack();
329
+ };
330
+
331
+ useEffect(() => {
332
+ if (messagesReadList?.length) {
333
+ openModalForBusiness
334
+ ? setUnreadAlert({ ...unreadAlert, business: false })
335
+ : setUnreadAlert({ ...unreadAlert, driver: false });
336
+ }
337
+ }, [messagesReadList]);
338
+
339
+ const locations = [
340
+ {
341
+ ...order?.business?.location,
342
+ title: order?.business?.name,
343
+ icon: order?.business?.logo || theme.images.dummies.businessLogo,
344
+ type: 'Business',
345
+ },
346
+ {
347
+ ...order?.customer?.location,
348
+ title: order?.customer?.name,
349
+ icon:
350
+ order?.customer?.photo ||
351
+ 'https://res.cloudinary.com/demo/image/upload/c_thumb,g_face,r_max/d_avatar.png/non_existing_id.png',
352
+ type: 'Customer',
353
+ },
354
+ ];
355
+
356
+ useEffect(() => {
357
+ if (driverLocation) {
358
+ locations[0] = driverLocation;
359
+ }
360
+ }, [driverLocation]);
361
+
362
+ const styles = StyleSheet.create({
363
+ rowDirection: {
364
+ flexDirection: 'row',
365
+ },
366
+ statusBar: {
367
+ height: 10,
368
+ },
369
+ logo: {
370
+ width: 75,
371
+ height: 75,
372
+ borderRadius: 10,
373
+ },
374
+ textBold: {
375
+ fontWeight: '600',
376
+ },
377
+ btnPickUp: {
378
+ borderWidth: 0,
379
+ backgroundColor: theme.colors.btnBGWhite,
380
+ borderRadius: 8,
381
+ },
382
+ btnBackArrow: {
383
+ borderWidth: 0,
384
+ backgroundColor: theme.colors.backgroundLight,
385
+ borderColor: theme.colors.primary,
386
+ shadowColor: theme.colors.primary,
387
+ alignItems: 'flex-start',
388
+ justifyContent: 'flex-start',
389
+ paddingLeft: 0,
390
+ height: 14,
391
+ },
392
+ icons: {
393
+ maxWidth: 40,
394
+ height: 25,
395
+ },
396
+ });
397
+
398
+ let locationMarker;
399
+ let isToFollow = false;
400
+ let isBusinessMarker = false;
401
+
402
+ if (order?.status === 7 || order?.status === 8) {
403
+ const markerBusiness = 'Business';
404
+ isBusinessMarker = true;
405
+ locationMarker = locations.find(
406
+ (location: any) => location.type === markerBusiness,
407
+ );
408
+
409
+ if (order?.status === 8) {
410
+ isToFollow = true;
411
+ }
412
+ } else if (order?.status === 3 || order?.status === 9) {
413
+ const markerCustomer = 'Customer';
414
+ isToFollow = true;
415
+ isBusinessMarker = false;
416
+ locationMarker = locations.find(
417
+ (location: any) => location.type === markerCustomer,
418
+ );
419
+ } else {
420
+ const markerBusiness = 'Business';
421
+ locationMarker = locations.find(
422
+ (location: any) => location.type === markerBusiness,
423
+ );
424
+ }
425
+
426
+ return (
427
+ <>
428
+ {(!order || Object.keys(order).length === 0) && (
429
+ <View
430
+ style={{
431
+ padding: 20,
432
+ backgroundColor: theme.colors.backgroundLight,
433
+ }}>
434
+ {[...Array(6)].map((item, i) => (
435
+ <Placeholder key={i} Animation={Fade}>
436
+ <View style={{ flexDirection: 'row', marginBottom: 30 }}>
437
+ <Placeholder>
438
+ <PlaceholderLine width={90} />
439
+ <PlaceholderLine width={50} />
440
+ <PlaceholderLine width={20} />
441
+ <PlaceholderLine width={10} />
442
+ </Placeholder>
443
+ </View>
444
+ </Placeholder>
445
+ ))}
446
+ </View>
447
+ )}
448
+ {order && Object.keys(order).length > 0 && (
449
+ <>
450
+ <Header>
451
+ <OIconButton
452
+ icon={theme.images.general.arrow_left}
453
+ iconStyle={{ width: 20, height: 20 }}
454
+ borderColor={theme.colors.clear}
455
+ style={{ ...styles.icons, justifyContent: 'flex-end' }}
456
+ onClick={() => handleArrowBack()}
457
+ />
458
+
459
+ <Actions>
460
+ <OIconButton
461
+ icon={theme.images.general.map}
462
+ iconStyle={{
463
+ width: 20,
464
+ height: 20,
465
+ tintColor: theme.colors.backArrow,
466
+ }}
467
+ borderColor={theme.colors.clear}
468
+ style={styles.icons}
469
+ onClick={() => handleOpenMapView()}
470
+ />
471
+
472
+ <OIconButton
473
+ icon={theme.images.general.messages}
474
+ iconStyle={{
475
+ width: 20,
476
+ height: 20,
477
+ tintColor: theme.colors.backArrow,
478
+ }}
479
+ borderColor={theme.colors.clear}
480
+ style={styles.icons}
481
+ onClick={() => handleOpenMessagesForBusiness()}
482
+ />
483
+ </Actions>
484
+ </Header>
485
+ <OrderHeader>
486
+ <OText size={13} style={{ marginBottom: 5 }}>
487
+ {order?.delivery_datetime_utc
488
+ ? parseDate(order?.delivery_datetime_utc)
489
+ : parseDate(order?.delivery_datetime, { utc: false })}
490
+ </OText>
491
+
492
+ <OText numberOfLines={2} size={20} weight="600">
493
+ <>
494
+ {`${t('INVOICE_ORDER_NO', 'Order No.')} ${order.id} ${t(
495
+ 'IS',
496
+ 'is',
497
+ )} `}
498
+ <OText
499
+ size={20}
500
+ weight="600"
501
+ color={colors[order?.status] || theme.colors.primary}>
502
+ {getOrderStatus(order?.status)?.value}
503
+ </OText>
504
+ </>
505
+ </OText>
506
+ </OrderHeader>
507
+ <OrderDetailsContainer
508
+ style={{
509
+ marginBottom: marginContainer[order?.status] ? 60 : 0,
510
+ }}
511
+ keyboardShouldPersistTaps="handled">
512
+ <>
513
+ <OrderContent>
514
+ <OrderBusiness>
515
+ <OText style={{ marginBottom: 5 }} size={16} weight="600">
516
+ {t('BUSINESS_DETAILS', 'Business details')}
517
+ </OText>
518
+
519
+ <OText numberOfLines={1} mBottom={4} ellipsizeMode="tail">
520
+ {order?.business?.name}
521
+ </OText>
522
+
523
+ <OText numberOfLines={1} mBottom={4} ellipsizeMode="tail">
524
+ {order?.business?.email}
525
+ </OText>
526
+
527
+ <OText numberOfLines={1} mBottom={4} ellipsizeMode="tail">
528
+ {order?.business?.cellphone}
529
+ </OText>
530
+
531
+ <OText numberOfLines={1} mBottom={4} ellipsizeMode="tail">
532
+ {order?.business?.address}
533
+ </OText>
534
+ </OrderBusiness>
535
+
536
+ <OrderCustomer>
537
+ <OText style={{ marginBottom: 5 }} size={16} weight="600">
538
+ {t('CUSTOMER_DETAILS', 'Customer details')}
539
+ </OText>
540
+
541
+ <OText numberOfLines={1} mBottom={4} ellipsizeMode="tail">
542
+ {order?.customer?.name}
543
+ </OText>
544
+
545
+ <OText numberOfLines={1} mBottom={4} ellipsizeMode="tail">
546
+ {order?.customer?.email}
547
+ </OText>
548
+
549
+ <OText numberOfLines={1} mBottom={4} ellipsizeMode="tail">
550
+ {order?.customer?.cellphone}
551
+ </OText>
552
+
553
+ <OText numberOfLines={1} mBottom={4} ellipsizeMode="tail">
554
+ {order?.customer?.address}
555
+ </OText>
556
+ </OrderCustomer>
557
+
558
+ <OrderProducts>
559
+ <OText style={{ marginBottom: 5 }} size={16} weight="600">
560
+ {t('ORDER_DETAILS', 'Order Details')}
561
+ </OText>
562
+
563
+ {order?.products?.length &&
564
+ order?.products.map((product: any, i: number) => (
565
+ <ProductItemAccordion
566
+ key={product?.id || i}
567
+ product={product}
568
+ comment={order.comment ? order.comment : ' '}
569
+ />
570
+ ))}
571
+ </OrderProducts>
572
+
573
+ <OrderBill>
574
+ <Table>
575
+ <OText mBottom={4}>{t('SUBTOTAL', 'Subtotal')}</OText>
576
+
577
+ <OText mBottom={4}>{parsePrice(order?.subtotal)}</OText>
578
+ </Table>
579
+
580
+ {order?.tax_type !== 1 && (
581
+ <Table>
582
+ <OText mBottom={4}>
583
+ {t('TAX', 'Tax')}
584
+ {`(${verifyDecimals(order?.tax, parseNumber)}%)`}
585
+ </OText>
586
+
587
+ <OText mBottom={4}>
588
+ {parsePrice(order?.summary?.tax || order?.totalTax)}
589
+ </OText>
590
+ </Table>
591
+ )}
592
+
593
+ {(order?.summary?.discount > 0 || order?.discount > 0) && (
594
+ <Table>
595
+ {order?.offer_type === 1 ? (
596
+ <OText mBottom={4}>
597
+ <OText>{t('DISCOUNT', 'Discount')}</OText>
598
+
599
+ <OText>
600
+ {`(${verifyDecimals(
601
+ order?.offer_rate,
602
+ parsePrice,
603
+ )}%)`}
604
+ </OText>
605
+ </OText>
606
+ ) : (
607
+ <OText mBottom={4}>{t('DISCOUNT', 'Discount')}</OText>
608
+ )}
609
+
610
+ <OText mBottom={4}>
611
+ -{' '}
612
+ {parsePrice(
613
+ order?.summary?.discount || order?.discount,
614
+ )}
615
+ </OText>
616
+ </Table>
617
+ )}
618
+
619
+ {(order?.summary?.delivery_price > 0 ||
620
+ order?.deliveryFee > 0) && (
621
+ <Table>
622
+ <OText mBottom={4}>
623
+ {t('DELIVERY_FEE', 'Delivery Fee')}
624
+ </OText>
625
+
626
+ <OText mBottom={4}>
627
+ {parsePrice(
628
+ order?.summary?.delivery_price || order?.deliveryFee,
629
+ )}
630
+ </OText>
631
+ </Table>
632
+ )}
633
+
634
+ <Table>
635
+ <OText mBottom={4}>
636
+ {t('DRIVER_TIP', 'Driver tip')}
637
+ {(order?.summary?.driver_tip > 0 ||
638
+ order?.driver_tip > 0) &&
639
+ parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
640
+ !parseInt(configs?.driver_tip_use_custom?.value, 10) &&
641
+ `(${verifyDecimals(order?.driver_tip, parseNumber)}%)`}
642
+ </OText>
643
+
644
+ <OText mBottom={4}>
645
+ {parsePrice(
646
+ order?.summary?.driver_tip || order?.totalDriverTip,
647
+ )}
648
+ </OText>
649
+ </Table>
650
+
651
+ <Table>
652
+ <OText mBottom={4}>
653
+ {t('SERVICE_FEE', 'Service Fee')}
654
+ {`(${verifyDecimals(order?.service_fee, parseNumber)}%)`}
655
+ </OText>
656
+
657
+ <OText mBottom={4}>
658
+ {parsePrice(
659
+ order?.summary?.service_fee || order?.serviceFee || 0,
660
+ )}
661
+ </OText>
662
+ </Table>
663
+
664
+ <Total>
665
+ <Table>
666
+ <OText mBottom={4} style={styles.textBold}>
667
+ {t('TOTAL', 'Total')}
668
+ </OText>
669
+
670
+ <OText
671
+ mBottom={4}
672
+ style={styles.textBold}
673
+ color={theme.colors.primary}>
674
+ {parsePrice(order?.summary?.total || order?.total)}
675
+ </OText>
676
+ </Table>
677
+ </Total>
678
+ </OrderBill>
679
+ </OrderContent>
680
+
681
+ {order?.status === 8 && order?.delivery_type === 1 && (
682
+ <Pickup>
683
+ <OButton
684
+ style={styles.btnPickUp}
685
+ textStyle={{ color: theme.colors.primary }}
686
+ text={t('ARRIVED_TO_BUSINESS', 'Arrived to bussiness')}
687
+ onClick={() =>
688
+ handleChangeOrderStatus && handleChangeOrderStatus(3)
689
+ }
690
+ imgLeftStyle={{ tintColor: theme.colors.backArrow }}
691
+ />
692
+ </Pickup>
693
+ )}
694
+ </>
695
+
696
+ <OModal
697
+ open={openModalForBusiness}
698
+ order={order}
699
+ title={`${t('INVOICE_ORDER_NO', 'Order No.')} ${order.id}`}
700
+ entireModal
701
+ onClose={() => handleCloseModal()}>
702
+ <Chat
703
+ type={
704
+ openModalForBusiness ? USER_TYPE.BUSINESS : USER_TYPE.DRIVER
705
+ }
706
+ orderId={order?.id}
707
+ messages={messages}
708
+ order={order}
709
+ setMessages={setMessages}
710
+ />
711
+ </OModal>
712
+
713
+ <OModal
714
+ open={openModalForAccept}
715
+ onClose={() => setOpenModalForAccept(false)}
716
+ entireModal
717
+ customClose>
718
+ <AcceptOrRejectOrder
719
+ handleUpdateOrder={handleChangeOrderStatus}
720
+ closeModal={setOpenModalForAccept}
721
+ customerCellphone={order?.customer?.cellphone}
722
+ loading={loading}
723
+ action={actionOrder}
724
+ orderId={order?.id}
725
+ notShowCustomerPhone={false}
726
+ actions={actions}
727
+ titleAccept={titleAccept}
728
+ titleReject={titleReject}
729
+ appTitle={appTitle}
730
+ />
731
+ </OModal>
732
+
733
+ <OModal
734
+ open={openModalForMapView}
735
+ onClose={() => handleOpenMapView()}
736
+ entireModal
737
+ customClose>
738
+ <DriverMap
739
+ navigation={navigation}
740
+ order={order}
741
+ orderStatus={getOrderStatus(order?.status)?.value || ''}
742
+ location={locationMarker}
743
+ readOnly
744
+ handleViewActionOrder={handleViewActionOrder}
745
+ isBusinessMarker={isBusinessMarker}
746
+ isToFollow={isToFollow}
747
+ showAcceptOrReject={
748
+ showFloatButtonsAcceptOrReject[order?.status]
749
+ }
750
+ handleOpenMapView={handleOpenMapView}
751
+ />
752
+ </OModal>
753
+
754
+ <View style={{ height: 30 }} />
755
+ </OrderDetailsContainer>
756
+
757
+ {showFloatButtonsPickUp[order?.status] && (
758
+ <FloatingButton
759
+ disabled={loading}
760
+ btnText={t('FAILED', 'Failed')}
761
+ isSecondaryBtn={false}
762
+ secondButtonClick={() =>
763
+ handleChangeOrderStatus && handleChangeOrderStatus(9)
764
+ }
765
+ firstButtonClick={() =>
766
+ handleChangeOrderStatus && handleChangeOrderStatus(12)
767
+ }
768
+ secondBtnText={t('PICKUP_COMPLETE', 'Pickup complete')}
769
+ secondButton={true}
770
+ firstColorCustom={theme.colors.red}
771
+ secondColorCustom={theme.colors.green}
772
+ />
773
+ )}
774
+ {order?.status === 9 && (
775
+ <FloatingButton
776
+ disabled={loading}
777
+ btnText={t('FAILED', 'Failed')}
778
+ isSecondaryBtn={false}
779
+ secondButtonClick={() =>
780
+ handleChangeOrderStatus && handleChangeOrderStatus(11)
781
+ }
782
+ firstButtonClick={() =>
783
+ handleChangeOrderStatus && handleChangeOrderStatus(12)
784
+ }
785
+ secondBtnText={t('DELIVERY_COMPLETE', 'Delivery complete')}
786
+ secondButton={true}
787
+ firstColorCustom={theme.colors.red}
788
+ secondColorCustom={theme.colors.green}
789
+ />
790
+ )}
791
+ {showFloatButtonsAcceptOrReject[order?.status] && (
792
+ <FloatingButton
793
+ btnText={t('REJECT', 'Reject')}
794
+ isSecondaryBtn={false}
795
+ secondButtonClick={() => handleViewActionOrder('accept')}
796
+ firstButtonClick={() => handleViewActionOrder('reject')}
797
+ secondBtnText={t('ACCEPT', 'Accept')}
798
+ secondButton={true}
799
+ firstColorCustom={theme.colors.red}
800
+ secondColorCustom={theme.colors.green}
801
+ />
802
+ )}
803
+ </>
804
+ )}
805
+ </>
806
+ );
807
+ };
808
+
809
+ export const OrderDetailsDelivery = (props: OrderDetailsParams) => {
810
+ const orderDetailsProps = {
811
+ ...props,
812
+ driverAndBusinessId: true,
813
+ UIComponent: OrderDetailsUI,
814
+ };
815
+ return <OrderDetailsConTableoller {...orderDetailsProps} />;
816
+ };