ordering-ui-react-native 0.17.66 → 0.17.68
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/shared/OToast.tsx +2 -2
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +31 -27
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +3 -3
- package/themes/business/src/components/OrdersOption/index.tsx +14 -58
- package/themes/business/src/components/PreviousOrders/OrderItem.tsx +250 -0
- package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +115 -0
- package/themes/business/src/components/PreviousOrders/index.tsx +332 -242
- package/themes/business/src/components/PreviousOrders/styles.tsx +30 -2
- package/themes/business/src/components/ReviewCustomer/index.tsx +12 -2
- package/themes/business/src/components/shared/OLink.tsx +24 -12
- package/themes/business/src/components/shared/OText.tsx +3 -2
- package/themes/business/src/types/index.tsx +6 -1
- package/themes/original/index.tsx +2 -0
- package/themes/original/src/components/BusinessController/index.tsx +16 -2
- package/themes/original/src/components/BusinessController/styles.tsx +13 -1
- package/themes/original/src/components/BusinessInformation/index.tsx +10 -31
- package/themes/original/src/components/BusinessProductsListing/index.tsx +1 -0
- package/themes/original/src/components/Cart/index.tsx +31 -2
- package/themes/original/src/components/FloatingButton/index.tsx +13 -11
- package/themes/original/src/components/LoginForm/Otp/index.tsx +0 -6
- package/themes/original/src/components/LoginForm/Otp/styles.tsx +0 -1
- package/themes/original/src/components/Messages/index.tsx +15 -0
- package/themes/original/src/components/MultiCart/index.tsx +63 -0
- package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +6 -7
- package/themes/original/src/components/MultiCheckout/index.tsx +4 -2
- package/themes/original/src/components/MultiOrdersDetails/index.tsx +14 -0
- package/themes/original/src/components/OrdersOption/index.tsx +32 -2
- package/themes/original/src/components/ReviewOrder/index.tsx +26 -9
- package/themes/original/src/components/ReviewOrder/styles.tsx +7 -0
- package/themes/original/src/components/ReviewTrigger/index.tsx +27 -9
- package/themes/original/src/components/ReviewTrigger/styles.tsx +8 -1
- package/themes/original/src/components/ScheduleAccordion/index.tsx +68 -0
- package/themes/original/src/components/ScheduleAccordion/styles.tsx +14 -0
- package/themes/original/src/components/SingleOrderCard/index.tsx +54 -19
- package/themes/original/src/components/SingleOrderCard/styles.tsx +10 -1
- package/themes/original/src/types/index.tsx +2 -0
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { Animated, StyleSheet, Text, View } from "react-native";
|
|
2
|
+
import { Animated, StyleSheet, Text, View, Platform } from "react-native";
|
|
3
3
|
import { ToastType, useToast, useLanguage } from "ordering-components/native";
|
|
4
4
|
import { useTheme } from 'styled-components/native';
|
|
5
5
|
import { getTraduction } from '../../utils'
|
|
6
6
|
|
|
7
7
|
const fadeDuration = 300;
|
|
8
|
-
const topPosition = 20
|
|
8
|
+
const topPosition = Platform.OS === 'ios' ? 40 : 20
|
|
9
9
|
|
|
10
10
|
export const Toast = (props: any) => {
|
|
11
11
|
const [toastConfig, { hideToast }] = useToast();
|
|
@@ -91,6 +91,10 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
91
91
|
return order?.taxes?.filter((tax: any) => tax?.type === 1)?.reduce((carry: number, tax: any) => carry + (tax?.summary?.tax_after_discount ?? tax?.summary?.tax), 0)
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
const containsOnlyNumbers = (str: string) => {
|
|
95
|
+
return /^\d+$/.test(str);
|
|
96
|
+
}
|
|
97
|
+
|
|
94
98
|
return (
|
|
95
99
|
<OrderContent isOrderGroup={isOrderGroup} lastOrder={lastOrder}>
|
|
96
100
|
{isOrderGroup && (
|
|
@@ -148,7 +152,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
148
152
|
<View style={styles.linkWithIcons}>
|
|
149
153
|
<OLink
|
|
150
154
|
PressStyle={styles.linkWithIcons}
|
|
151
|
-
url={`tel:${order?.business?.cellphone}`}
|
|
155
|
+
url={`tel:${containsOnlyNumbers(order?.business?.cellphone) ? order?.business?.cellphone : 'invalid'}`}
|
|
152
156
|
shorcut={`${order?.business?.cellphone}`}
|
|
153
157
|
TextStyle={styles.textLink}
|
|
154
158
|
/>
|
|
@@ -159,7 +163,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
159
163
|
<View style={styles.linkWithIcons}>
|
|
160
164
|
<OLink
|
|
161
165
|
PressStyle={styles.linkWithIcons}
|
|
162
|
-
url={`tel:${order?.business?.phone}`}
|
|
166
|
+
url={`tel:${containsOnlyNumbers(order?.business?.cellphone) ? order?.business?.phone : 'invalid'}`}
|
|
163
167
|
shorcut={order?.business?.phone}
|
|
164
168
|
TextStyle={styles.textLink}
|
|
165
169
|
/>
|
|
@@ -274,7 +278,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
274
278
|
<View style={styles.linkWithIcons}>
|
|
275
279
|
<OLink
|
|
276
280
|
PressStyle={styles.linkWithIcons}
|
|
277
|
-
url={`tel:${!!order?.customer?.country_phone_code ? '+' + order?.customer?.country_phone_code : ''} ${order?.customer?.cellphone}`}
|
|
281
|
+
url={`tel:${!!order?.customer?.country_phone_code ? '+' + order?.customer?.country_phone_code : ''} ${containsOnlyNumbers(order?.customer?.cellphone) ? order?.customer?.cellphone : 'invalid'}`}
|
|
278
282
|
shorcut={`${!!order?.customer?.country_phone_code ? '+' + order?.customer?.country_phone_code : ''} ${order?.customer?.cellphone}`}
|
|
279
283
|
TextStyle={styles.textLink}
|
|
280
284
|
/>
|
|
@@ -285,7 +289,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
285
289
|
<View style={styles.linkWithIcons}>
|
|
286
290
|
<OLink
|
|
287
291
|
PressStyle={styles.linkWithIcons}
|
|
288
|
-
url={`tel:${order?.customer?.phone}`}
|
|
292
|
+
url={`tel:${containsOnlyNumbers(order?.customer?.phone) ? order?.customer?.phone : 'invalid'}`}
|
|
289
293
|
shorcut={order?.customer?.phone}
|
|
290
294
|
TextStyle={styles.textLink}
|
|
291
295
|
/>
|
|
@@ -333,7 +337,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
333
337
|
<View style={{ marginTop: 10 }}>
|
|
334
338
|
{order?.delivery_option !== undefined && order?.delivery_type === 1 && (
|
|
335
339
|
<OText>
|
|
336
|
-
{order?.delivery_option?.name}
|
|
340
|
+
{t(order?.delivery_option?.name?.toUpperCase()?.replace(/ /g, '_'), order?.delivery_option?.name)}
|
|
337
341
|
</OText>
|
|
338
342
|
)}
|
|
339
343
|
{!!order?.comment && (
|
|
@@ -378,7 +382,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
378
382
|
<Table>
|
|
379
383
|
<OText mBottom={4}>{t('SUBTOTAL', 'Subtotal')}</OText>
|
|
380
384
|
<OText mBottom={4}>
|
|
381
|
-
{parsePrice(((order?.summary?.subtotal ?? order?.subtotal) + getIncludedTaxes()), { currency: order?.currency})}
|
|
385
|
+
{parsePrice(((order?.summary?.subtotal ?? order?.subtotal) + getIncludedTaxes()), { currency: order?.currency })}
|
|
382
386
|
</OText>
|
|
383
387
|
</Table>
|
|
384
388
|
{(order?.summary?.discount > 0 ?? order?.discount > 0) && order?.offers?.length === 0 && (
|
|
@@ -391,7 +395,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
391
395
|
) : (
|
|
392
396
|
<OText mBottom={4}>{t('DISCOUNT', theme?.defaultLanguages?.DISCOUNT || 'Discount')}</OText>
|
|
393
397
|
)}
|
|
394
|
-
<OText>- {parsePrice(order?.summary?.discount ?? order?.discount, { currency: order?.currency})}</OText>
|
|
398
|
+
<OText>- {parsePrice(order?.summary?.discount ?? order?.discount, { currency: order?.currency })}</OText>
|
|
395
399
|
</Table>
|
|
396
400
|
)}
|
|
397
401
|
{
|
|
@@ -399,13 +403,13 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
399
403
|
<Table key={offer.id}>
|
|
400
404
|
<OSRow>
|
|
401
405
|
<OText mBottom={4}>
|
|
402
|
-
{offer.name}
|
|
406
|
+
{t(offer.name?.toUpperCase()?.replace(/ /g, '_'), offer.name)}
|
|
403
407
|
{offer.rate_type === 1 && (
|
|
404
408
|
<OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
405
409
|
)}
|
|
406
410
|
</OText>
|
|
407
411
|
</OSRow>
|
|
408
|
-
<OText mBottom={4}>- {parsePrice(offer?.summary?.discount, { currency: order?.currency})}</OText>
|
|
412
|
+
<OText mBottom={4}>- {parsePrice(offer?.summary?.discount, { currency: order?.currency })}</OText>
|
|
409
413
|
</Table>
|
|
410
414
|
))
|
|
411
415
|
}
|
|
@@ -413,9 +417,9 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
413
417
|
<Table>
|
|
414
418
|
<OText mBottom={4}>{t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')}</OText>
|
|
415
419
|
{order?.tax_type === 1 ? (
|
|
416
|
-
<OText mBottom={4}>{parsePrice((order?.summary?.subtotal_with_discount + getIncludedTaxesDiscounts() ?? 0), { currency: order?.currency})}</OText>
|
|
420
|
+
<OText mBottom={4}>{parsePrice((order?.summary?.subtotal_with_discount + getIncludedTaxesDiscounts() ?? 0), { currency: order?.currency })}</OText>
|
|
417
421
|
) : (
|
|
418
|
-
<OText mBottom={4}>{parsePrice(order?.summary?.subtotal_with_discount ?? 0, { currency: order?.currency})}</OText>
|
|
422
|
+
<OText mBottom={4}>{parsePrice(order?.summary?.subtotal_with_discount ?? 0, { currency: order?.currency })}</OText>
|
|
419
423
|
)}
|
|
420
424
|
</Table>
|
|
421
425
|
)}
|
|
@@ -425,7 +429,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
425
429
|
{t('TAX', 'Tax')} {`(${verifyDecimals(order?.tax, parseNumber)}%)`}
|
|
426
430
|
</OText>
|
|
427
431
|
<OText mBottom={4}>
|
|
428
|
-
{parsePrice(order?.summary?.tax ?? 0, { currency: order?.currency})}
|
|
432
|
+
{parsePrice(order?.summary?.tax ?? 0, { currency: order?.currency })}
|
|
429
433
|
</OText>
|
|
430
434
|
</Table>
|
|
431
435
|
)}
|
|
@@ -436,7 +440,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
436
440
|
{t('SERVICE_FEE', 'Service fee')}
|
|
437
441
|
{`(${verifyDecimals(order?.service_fee, parseNumber)}%)`}
|
|
438
442
|
</OText>
|
|
439
|
-
<OText mBottom={4}>{parsePrice(order?.summary?.service_fee ?? 0, { currency: order?.currency})}</OText>
|
|
443
|
+
<OText mBottom={4}>{parsePrice(order?.summary?.service_fee ?? 0, { currency: order?.currency })}</OText>
|
|
440
444
|
</Table>
|
|
441
445
|
)
|
|
442
446
|
}
|
|
@@ -445,11 +449,11 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
445
449
|
<Table key={tax.id}>
|
|
446
450
|
<OSRow>
|
|
447
451
|
<OText mBottom={4}>
|
|
448
|
-
{tax
|
|
452
|
+
{t(tax?.name?.toUpperCase()?.replace(/ /g, '_'), tax?.name) || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
|
|
449
453
|
{`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
|
|
450
454
|
</OText>
|
|
451
455
|
</OSRow>
|
|
452
|
-
<OText mBottom={4}>{parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0, { currency: order?.currency})}</OText>
|
|
456
|
+
<OText mBottom={4}>{parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0, { currency: order?.currency })}</OText>
|
|
453
457
|
</Table>
|
|
454
458
|
))
|
|
455
459
|
}
|
|
@@ -458,11 +462,11 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
458
462
|
<Table key={fee.id}>
|
|
459
463
|
<OSRow>
|
|
460
464
|
<OText mBottom={4}>
|
|
461
|
-
{fee
|
|
462
|
-
({fee?.fixed > 0 && `${parsePrice(fee?.fixed, { currency: order?.currency})} + `}{fee.percentage}%){' '}
|
|
465
|
+
{t(fee?.name?.toUpperCase()?.replace(/ /g, '_'), fee?.name) || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
|
|
466
|
+
({fee?.fixed > 0 && `${parsePrice(fee?.fixed, { currency: order?.currency })} + `}{fee.percentage}%){' '}
|
|
463
467
|
</OText>
|
|
464
468
|
</OSRow>
|
|
465
|
-
<OText mBottom={4}>{parsePrice(fee?.summary?.fixed + (fee?.summary?.percentage_after_discount ?? fee?.summary?.percentage) ?? 0, { currency: order?.currency})}</OText>
|
|
469
|
+
<OText mBottom={4}>{parsePrice(fee?.summary?.fixed + (fee?.summary?.percentage_after_discount ?? fee?.summary?.percentage) ?? 0, { currency: order?.currency })}</OText>
|
|
466
470
|
</Table>
|
|
467
471
|
))
|
|
468
472
|
}
|
|
@@ -471,13 +475,13 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
471
475
|
<Table key={offer.id}>
|
|
472
476
|
<OSRow>
|
|
473
477
|
<OText mBottom={4}>
|
|
474
|
-
{offer.name}
|
|
478
|
+
{t(offer.name?.toUpperCase()?.replace(/ /g, '_'), offer.name)}
|
|
475
479
|
{offer.rate_type === 1 && (
|
|
476
480
|
<OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
477
481
|
)}
|
|
478
482
|
</OText>
|
|
479
483
|
</OSRow>
|
|
480
|
-
<OText mBottom={4}>- {parsePrice(offer?.summary?.discount, { currency: order?.currency})}</OText>
|
|
484
|
+
<OText mBottom={4}>- {parsePrice(offer?.summary?.discount, { currency: order?.currency })}</OText>
|
|
481
485
|
</Table>
|
|
482
486
|
))
|
|
483
487
|
}
|
|
@@ -489,7 +493,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
489
493
|
</OText>
|
|
490
494
|
|
|
491
495
|
<OText mBottom={4}>
|
|
492
|
-
{parsePrice(order?.summary?.delivery_price, { currency: order?.currency})}
|
|
496
|
+
{parsePrice(order?.summary?.delivery_price, { currency: order?.currency })}
|
|
493
497
|
</OText>
|
|
494
498
|
</Table>
|
|
495
499
|
)
|
|
@@ -499,13 +503,13 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
499
503
|
<Table key={offer.id}>
|
|
500
504
|
<OSRow>
|
|
501
505
|
<OText mBottom={4}>
|
|
502
|
-
{offer.name}
|
|
506
|
+
{t(offer.name?.toUpperCase()?.replace(/ /g, '_'), offer.name)}
|
|
503
507
|
{offer.rate_type === 1 && (
|
|
504
508
|
<OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
505
509
|
)}
|
|
506
510
|
</OText>
|
|
507
511
|
</OSRow>
|
|
508
|
-
<OText mBottom={4}>- {parsePrice(offer?.summary?.discount, { currency: order?.currency})}</OText>
|
|
512
|
+
<OText mBottom={4}>- {parsePrice(offer?.summary?.discount, { currency: order?.currency })}</OText>
|
|
509
513
|
</Table>
|
|
510
514
|
))
|
|
511
515
|
}
|
|
@@ -520,7 +524,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
520
524
|
`(${verifyDecimals(order?.summary?.driver_tip, parseNumber)}%)`
|
|
521
525
|
)}
|
|
522
526
|
</OText>
|
|
523
|
-
<OText mBottom={4}>{parsePrice(order?.summary?.driver_tip ?? order?.totalDriverTip, { currency: order?.currency})}</OText>
|
|
527
|
+
<OText mBottom={4}>{parsePrice(order?.summary?.driver_tip ?? order?.totalDriverTip, { currency: order?.currency })}</OText>
|
|
524
528
|
</Table>
|
|
525
529
|
)}
|
|
526
530
|
|
|
@@ -534,7 +538,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
534
538
|
mBottom={4}
|
|
535
539
|
style={styles.textBold}
|
|
536
540
|
color={theme.colors.primary}>
|
|
537
|
-
{parsePrice(order?.summary?.total ?? order?.total, { currency: order?.currency})}
|
|
541
|
+
{parsePrice(order?.summary?.total ?? order?.total, { currency: order?.currency })}
|
|
538
542
|
</OText>
|
|
539
543
|
</Table>
|
|
540
544
|
</Total>
|
|
@@ -568,7 +572,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
568
572
|
<OText>
|
|
569
573
|
{event?.wallet_event
|
|
570
574
|
? walletName[event?.wallet_event?.wallet?.type]?.name
|
|
571
|
-
: event?.paymethod?.name}
|
|
575
|
+
: t(event?.paymethod?.name?.toUpperCase()?.replace(/ /g, '_'), event?.paymethod?.name)}
|
|
572
576
|
</OText>
|
|
573
577
|
{event?.data?.charge_id && (
|
|
574
578
|
<OText>
|
|
@@ -577,7 +581,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
577
581
|
)}
|
|
578
582
|
</View>
|
|
579
583
|
<OText>
|
|
580
|
-
-{parsePrice(event.amount, { currency: order?.currency})}
|
|
584
|
+
-{parsePrice(event.amount, { currency: order?.currency })}
|
|
581
585
|
</OText>
|
|
582
586
|
</View>
|
|
583
587
|
))}
|
|
@@ -271,7 +271,7 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
|
|
|
271
271
|
{order?.delivery_option && (
|
|
272
272
|
<OText size={13}>
|
|
273
273
|
<OText size={13} weight='bold'>{`${t('DELIVERY_PREFERENCE', 'Delivery Preference')}: `}</OText>
|
|
274
|
-
{order?.delivery_option?.name}
|
|
274
|
+
{t(order?.delivery_option?.name?.toUpperCase()?.replace(/ /g, '_'), order?.delivery_option?.name)}
|
|
275
275
|
</OText>
|
|
276
276
|
)}
|
|
277
277
|
{order?.payment_events?.length > 0 && (
|
|
@@ -286,8 +286,8 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
|
|
|
286
286
|
? `${walletName[event?.wallet_event?.wallet?.type]?.name} - `
|
|
287
287
|
: walletName[event?.wallet_event?.wallet?.type]?.name
|
|
288
288
|
: idx < order?.payment_events?.length - 1
|
|
289
|
-
? `${event?.paymethod?.name} - `
|
|
290
|
-
: event?.paymethod?.name
|
|
289
|
+
? `${t(event?.paymethod?.name?.toUpperCase()?.replace(/ /g, '_'), event?.paymethod?.name)} - `
|
|
290
|
+
: t(event?.paymethod?.name?.toUpperCase()?.replace(/ /g, '_'), event?.paymethod?.name)
|
|
291
291
|
})}
|
|
292
292
|
</OText>
|
|
293
293
|
</View>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useState, useRef } from 'react';
|
|
2
|
-
import { View, Pressable, StyleSheet, ScrollView, RefreshControl,
|
|
3
|
-
import { useLanguage, useUtils, useToast,
|
|
2
|
+
import { View, Pressable, StyleSheet, ScrollView, RefreshControl, Platform } from 'react-native';
|
|
3
|
+
import { useLanguage, useUtils, useToast, OrderListGroups, useConfig } from 'ordering-components/native';
|
|
4
4
|
import SelectDropdown from 'react-native-select-dropdown'
|
|
5
5
|
import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
|
|
6
6
|
import FeatherIcon from 'react-native-vector-icons/Feather';
|
|
@@ -20,7 +20,6 @@ import {
|
|
|
20
20
|
IconWrapper,
|
|
21
21
|
ModalContainer,
|
|
22
22
|
ModalTitle,
|
|
23
|
-
FilterBtnWrapper,
|
|
24
23
|
TabPressable,
|
|
25
24
|
OrderStatus,
|
|
26
25
|
SlaOption,
|
|
@@ -34,42 +33,17 @@ import {
|
|
|
34
33
|
ItemContent,
|
|
35
34
|
TimerInputWrapper,
|
|
36
35
|
OverLine,
|
|
37
|
-
Actions,
|
|
38
36
|
InputContainer
|
|
39
37
|
} from './styles';
|
|
40
38
|
import { PreviousOrders } from '../PreviousOrders';
|
|
41
39
|
import { OrdersOptionParams } from '../../types';
|
|
42
40
|
|
|
43
|
-
import { TouchableOpacity } from 'react-native-gesture-handler';
|
|
44
|
-
import GestureRecognizer from 'react-native-swipe-gestures';
|
|
45
|
-
import ODropDown from '../shared/ODropDown';
|
|
46
|
-
import { OrdersOptionStatus } from '../OrdersOptionStatus'
|
|
47
41
|
import { OrdersOptionCity } from '../OrdersOptionCity';
|
|
48
42
|
import { OrdersOptionBusiness } from '../OrdersOptionBusiness';
|
|
49
43
|
import { OrdersOptionDelivery } from '../OrdersOptionDelivery';
|
|
50
44
|
import { OrdersOptionPaymethod } from '../OrdersOptionPaymethod';
|
|
51
45
|
import { OrdersOptionDriver } from '../OrdersOptionDriver';
|
|
52
46
|
import { OrdersOptionDate } from '../OrdersOptionDate';
|
|
53
|
-
import { GestureEvent, GestureDetector } from 'react-native-gesture-handler'
|
|
54
|
-
const tabsList: any = {
|
|
55
|
-
pending: 1,
|
|
56
|
-
inProgress: 2,
|
|
57
|
-
completed: 3,
|
|
58
|
-
cancelled: 4
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const tabsListText: any = {
|
|
62
|
-
1: 'pending',
|
|
63
|
-
2: 'inProgress',
|
|
64
|
-
3: 'completed',
|
|
65
|
-
4: 'cancelled'
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const swipeConfig = {
|
|
69
|
-
velocityThreshold: 0.3,
|
|
70
|
-
directionalOffsetThreshold: 80
|
|
71
|
-
};
|
|
72
|
-
|
|
73
47
|
const { useDeviceOrientation, PORTRAIT } = DeviceOrientationMethods
|
|
74
48
|
|
|
75
49
|
const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
@@ -81,10 +55,10 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
81
55
|
ordersGroup,
|
|
82
56
|
setOrdersGroup,
|
|
83
57
|
orderStatus,
|
|
58
|
+
ordersGroupedFormatted,
|
|
84
59
|
loadOrders,
|
|
85
60
|
loadMoreOrders,
|
|
86
61
|
onNavigationRedirect,
|
|
87
|
-
filtered,
|
|
88
62
|
onFiltered,
|
|
89
63
|
handleClickOrder,
|
|
90
64
|
isBusinessApp,
|
|
@@ -92,7 +66,9 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
92
66
|
logisticOrders,
|
|
93
67
|
loadLogisticOrders,
|
|
94
68
|
isLogisticActivated,
|
|
95
|
-
isAlsea
|
|
69
|
+
isAlsea,
|
|
70
|
+
handleChangeOrderStatus,
|
|
71
|
+
handleSendCustomerReview
|
|
96
72
|
} = props;
|
|
97
73
|
|
|
98
74
|
const defaultSearchList = {
|
|
@@ -346,26 +322,6 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
346
322
|
})
|
|
347
323
|
}
|
|
348
324
|
|
|
349
|
-
const onSwipeLeft = () => {
|
|
350
|
-
let currentTab = tabsList[currentTabSelected]
|
|
351
|
-
currentTab = currentTab >= 4 ? null : currentTab + 1
|
|
352
|
-
|
|
353
|
-
if (!currentTab) return
|
|
354
|
-
|
|
355
|
-
const nextTab = tabsListText[currentTab]
|
|
356
|
-
nextTab && setCurrentTabSelected(nextTab)
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
const onSwipeRight = () => {
|
|
360
|
-
let currentTab = tabsList[currentTabSelected]
|
|
361
|
-
currentTab = currentTab <= 1 ? null : currentTab - 1
|
|
362
|
-
|
|
363
|
-
if (!currentTab) return
|
|
364
|
-
|
|
365
|
-
const nextTab = tabsListText[currentTab]
|
|
366
|
-
nextTab && setCurrentTabSelected(nextTab)
|
|
367
|
-
}
|
|
368
|
-
|
|
369
325
|
const calculateDate = (type: any, from: any, to: any) => {
|
|
370
326
|
switch (type) {
|
|
371
327
|
case 'today':
|
|
@@ -419,14 +375,8 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
419
375
|
useEffect(() => {
|
|
420
376
|
setSelectedTabStatus(deliveryStatus)
|
|
421
377
|
}, [])
|
|
422
|
-
|
|
378
|
+
|
|
423
379
|
return (
|
|
424
|
-
// <GestureRecognizer
|
|
425
|
-
// onSwipeLeft={onSwipeLeft}
|
|
426
|
-
// onSwipeRight={onSwipeRight}
|
|
427
|
-
// config={swipeConfig}
|
|
428
|
-
// style={{ flex: 1 }}
|
|
429
|
-
// >
|
|
430
380
|
<>
|
|
431
381
|
<View style={styles.header}>
|
|
432
382
|
<OText style={styles.title}>{t('MY_ORDERS', 'My orders')}</OText>
|
|
@@ -636,11 +586,18 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
636
586
|
(
|
|
637
587
|
<PreviousOrders
|
|
638
588
|
orders={currentOrdersGroup?.orders}
|
|
589
|
+
navigation={props.navigation}
|
|
590
|
+
ordersGrouped={ordersGroupedFormatted}
|
|
639
591
|
onNavigationRedirect={onNavigationRedirect}
|
|
640
592
|
getOrderStatus={getOrderStatus}
|
|
641
593
|
handleClickOrder={handleClickOrder}
|
|
642
594
|
slaSettingTime={slaSettingTime}
|
|
643
595
|
currentTabSelected={currentTabSelected}
|
|
596
|
+
appTitle={props.orderDetailsProps?.appTitle}
|
|
597
|
+
actions={props.orderDetailsProps?.actions}
|
|
598
|
+
orderTitle={props.orderDetailsProps?.orderTitle}
|
|
599
|
+
handleChangeOrderStatus={handleChangeOrderStatus}
|
|
600
|
+
handleSendCustomerReview={handleSendCustomerReview}
|
|
644
601
|
/>
|
|
645
602
|
)}
|
|
646
603
|
{!logisticOrders?.error?.length &&
|
|
@@ -730,7 +687,6 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
730
687
|
)}
|
|
731
688
|
</ScrollView>
|
|
732
689
|
</View>
|
|
733
|
-
{/* </GestureRecognizer> */}
|
|
734
690
|
|
|
735
691
|
{isBusinessApp && (
|
|
736
692
|
<NewOrderNotification isBusinessApp={isBusinessApp} />
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { Platform, PlatformIOSStatic, StyleSheet, TouchableOpacity, View } from 'react-native';
|
|
3
|
+
import DeviceInfo from 'react-native-device-info';
|
|
4
|
+
import { useTheme } from 'styled-components/native';
|
|
5
|
+
import { useLanguage, useUtils, useConfig } from 'ordering-components/native';
|
|
6
|
+
import EntypoIcon from 'react-native-vector-icons/Entypo'
|
|
7
|
+
import FastImage from 'react-native-fast-image'
|
|
8
|
+
import moment from 'moment'
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
Card,
|
|
12
|
+
Logo,
|
|
13
|
+
Information,
|
|
14
|
+
MyOrderOptions,
|
|
15
|
+
NotificationIcon,
|
|
16
|
+
Timestatus
|
|
17
|
+
} from './styles'
|
|
18
|
+
|
|
19
|
+
import { OText } from '../shared';
|
|
20
|
+
import { DeviceOrientationMethods } from '../../../../../src/hooks/DeviceOrientation'
|
|
21
|
+
|
|
22
|
+
const { useDeviceOrientation, PORTRAIT } = DeviceOrientationMethods
|
|
23
|
+
|
|
24
|
+
export const OrderItem = (props: any) => {
|
|
25
|
+
const {
|
|
26
|
+
order,
|
|
27
|
+
_order,
|
|
28
|
+
isLogisticOrder,
|
|
29
|
+
currentTabSelected,
|
|
30
|
+
getOrderStatus,
|
|
31
|
+
handlePressOrder
|
|
32
|
+
} = props
|
|
33
|
+
|
|
34
|
+
const theme = useTheme()
|
|
35
|
+
const [, t] = useLanguage()
|
|
36
|
+
const [configState] = useConfig()
|
|
37
|
+
const [{ parseDate, optimizeImage }] = useUtils();
|
|
38
|
+
const [orientationState] = useDeviceOrientation();
|
|
39
|
+
|
|
40
|
+
const [allowColumns, setAllowColumns] = useState({
|
|
41
|
+
timer: configState?.configs?.order_deadlines_enabled?.value === '1',
|
|
42
|
+
slaBar: configState?.configs?.order_deadlines_enabled?.value === '1',
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
const IS_PORTRAIT = orientationState.orientation === PORTRAIT
|
|
46
|
+
const platformIOS = Platform as PlatformIOSStatic
|
|
47
|
+
|
|
48
|
+
const isIpad = platformIOS.isPad
|
|
49
|
+
const isTablet = DeviceInfo.isTablet();
|
|
50
|
+
|
|
51
|
+
const styles = StyleSheet.create({
|
|
52
|
+
cardButton: {
|
|
53
|
+
flex: 1,
|
|
54
|
+
paddingVertical: (isIpad || isTablet) ? 20 : 0,
|
|
55
|
+
marginBottom: IS_PORTRAIT ? 25 : 0,
|
|
56
|
+
marginLeft: 3,
|
|
57
|
+
},
|
|
58
|
+
icon: {
|
|
59
|
+
borderRadius: 7.6,
|
|
60
|
+
width: 60,
|
|
61
|
+
height: 60
|
|
62
|
+
},
|
|
63
|
+
logo: {
|
|
64
|
+
borderRadius: 10,
|
|
65
|
+
shadowColor: "#0000006e",
|
|
66
|
+
shadowRadius: 10,
|
|
67
|
+
elevation: 15,
|
|
68
|
+
justifyContent: 'center',
|
|
69
|
+
alignItems: 'center',
|
|
70
|
+
marginLeft: 3,
|
|
71
|
+
},
|
|
72
|
+
title: {
|
|
73
|
+
marginBottom: 6,
|
|
74
|
+
fontFamily: 'Poppins',
|
|
75
|
+
fontStyle: 'normal',
|
|
76
|
+
fontWeight: '600',
|
|
77
|
+
fontSize: 16,
|
|
78
|
+
color: theme.colors.textGray,
|
|
79
|
+
},
|
|
80
|
+
date: {
|
|
81
|
+
marginBottom: 6,
|
|
82
|
+
fontFamily: 'Poppins',
|
|
83
|
+
fontStyle: 'normal',
|
|
84
|
+
fontWeight: 'normal',
|
|
85
|
+
fontSize: 12,
|
|
86
|
+
},
|
|
87
|
+
orderType: {
|
|
88
|
+
fontSize: 12,
|
|
89
|
+
fontFamily: 'Poppins',
|
|
90
|
+
fontStyle: 'normal',
|
|
91
|
+
fontWeight: 'normal',
|
|
92
|
+
color: theme.colors.orderTypeColor,
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const getDelayMinutes = (order: any) => {
|
|
97
|
+
const offset = 300
|
|
98
|
+
const cdtToutc = moment(order?.delivery_datetime).add(offset, 'minutes').format('YYYY-MM-DD HH:mm:ss')
|
|
99
|
+
const _delivery = order?.delivery_datetime_utc
|
|
100
|
+
? parseDate(order?.delivery_datetime_utc, { outputFormat: 'YYYY-MM-DD hh:mm A' })
|
|
101
|
+
: parseDate(cdtToutc, { outputFormat: 'YYYY-MM-DD hh:mm A' })
|
|
102
|
+
const _eta = order?.eta_time
|
|
103
|
+
const diffTimeAsSeconds = moment(_delivery, 'YYYY-MM-DD hh:mm A').add(_eta, 'minutes').diff(moment().utc(), 'seconds')
|
|
104
|
+
return Math.ceil(diffTimeAsSeconds / 60)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const displayDelayedTime = (order: any) => {
|
|
108
|
+
let tagetedMin = getDelayMinutes(order)
|
|
109
|
+
// get day, hour and minutes
|
|
110
|
+
const sign = tagetedMin >= 0 ? '' : '- '
|
|
111
|
+
tagetedMin = Math.abs(tagetedMin)
|
|
112
|
+
let day: string | number = Math.floor(tagetedMin / 1440)
|
|
113
|
+
const restMinOfTargetedMin = tagetedMin - 1440 * day
|
|
114
|
+
let restHours: string | number = Math.floor(restMinOfTargetedMin / 60)
|
|
115
|
+
let restMins: string | number = restMinOfTargetedMin - 60 * restHours
|
|
116
|
+
// make standard time format
|
|
117
|
+
day = day === 0 ? '' : day + 'day '
|
|
118
|
+
restHours = restHours < 10 ? '0' + restHours : restHours
|
|
119
|
+
restMins = restMins < 10 ? '0' + restMins : restMins
|
|
120
|
+
|
|
121
|
+
const finalTaget = sign + day + restHours + ':' + restMins
|
|
122
|
+
return finalTaget
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const getStatusClassName = (minutes: number) => {
|
|
126
|
+
if (isNaN(Number(minutes))) return 'in_time'
|
|
127
|
+
const delayTime = configState?.configs?.order_deadlines_delayed_time?.value
|
|
128
|
+
return minutes > 0 ? 'in_time' : Math.abs(minutes) <= delayTime ? 'at_risk' : 'delayed'
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
const slaSettings = configState?.configs?.order_deadlines_enabled?.value === '1'
|
|
133
|
+
setAllowColumns({
|
|
134
|
+
...allowColumns,
|
|
135
|
+
timer: slaSettings,
|
|
136
|
+
slaBar: slaSettings
|
|
137
|
+
})
|
|
138
|
+
}, [configState.loading])
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
<TouchableOpacity
|
|
142
|
+
activeOpacity={1}
|
|
143
|
+
disabled={order?.locked && isLogisticOrder}
|
|
144
|
+
style={styles.cardButton}
|
|
145
|
+
onPress={() => handlePressOrder({ ...order, logistic_order_id: _order?.id })}
|
|
146
|
+
>
|
|
147
|
+
<Card key={order.id}>
|
|
148
|
+
{allowColumns?.slaBar && (
|
|
149
|
+
<Timestatus
|
|
150
|
+
style={{
|
|
151
|
+
backgroundColor: getStatusClassName(getDelayMinutes(order)) === 'in_time'
|
|
152
|
+
? '#00D27A'
|
|
153
|
+
: getStatusClassName(getDelayMinutes(order)) === 'at_risk'
|
|
154
|
+
? '#FFC700'
|
|
155
|
+
: getStatusClassName(getDelayMinutes(order)) === 'delayed'
|
|
156
|
+
? '#E63757'
|
|
157
|
+
: ''
|
|
158
|
+
}}
|
|
159
|
+
/>
|
|
160
|
+
)}
|
|
161
|
+
<Logo style={styles.logo}>
|
|
162
|
+
<FastImage
|
|
163
|
+
style={styles.icon}
|
|
164
|
+
source={order.business?.logo ? {
|
|
165
|
+
uri: optimizeImage(order.business?.logo, 'h_100,c_limit'),
|
|
166
|
+
priority: FastImage.priority.normal,
|
|
167
|
+
} : theme?.images?.dummies?.businessLogo}
|
|
168
|
+
resizeMode={FastImage.resizeMode.cover}
|
|
169
|
+
/>
|
|
170
|
+
</Logo>
|
|
171
|
+
<Information>
|
|
172
|
+
{!!order?.order_group_id && (
|
|
173
|
+
<OText>
|
|
174
|
+
<OText>{(t('INVOICE_GROUP_NO', 'Group No.') + order?.order_group_id)}</OText>
|
|
175
|
+
</OText>
|
|
176
|
+
)}
|
|
177
|
+
{!!order.business?.name && (
|
|
178
|
+
<OText numberOfLines={1} style={styles.title}>
|
|
179
|
+
{order.business?.name}
|
|
180
|
+
</OText>
|
|
181
|
+
)}
|
|
182
|
+
{!!order?.showNotification && (
|
|
183
|
+
<NotificationIcon>
|
|
184
|
+
<EntypoIcon
|
|
185
|
+
name="dot-single"
|
|
186
|
+
size={32}
|
|
187
|
+
color={theme.colors.primary}
|
|
188
|
+
/>
|
|
189
|
+
</NotificationIcon>
|
|
190
|
+
)}
|
|
191
|
+
<View style={{ flexDirection: 'row', flexWrap: 'wrap' }}>
|
|
192
|
+
<OText
|
|
193
|
+
style={styles.date}
|
|
194
|
+
color={theme.colors.unselectText}
|
|
195
|
+
numberOfLines={1}
|
|
196
|
+
adjustsFontSizeToFit
|
|
197
|
+
>
|
|
198
|
+
{(order?.order_group_id && order?.order_group && isLogisticOrder
|
|
199
|
+
? `${order?.order_group?.orders?.length} ${t('ORDERS', 'Orders')}`
|
|
200
|
+
: (t('NO', 'Order No.') + order.id)
|
|
201
|
+
) + ' · '}
|
|
202
|
+
{order?.delivery_datetime_utc
|
|
203
|
+
? parseDate(order?.delivery_datetime_utc, { outputFormat: 'MM/DD/YY · HH:mm a' })
|
|
204
|
+
: parseDate(order?.delivery_datetime, { utc: false })}
|
|
205
|
+
</OText>
|
|
206
|
+
{((currentTabSelected === 'pending' || currentTabSelected === 'inProgress') && allowColumns?.timer) && (
|
|
207
|
+
<>
|
|
208
|
+
<OText> · </OText>
|
|
209
|
+
<OText
|
|
210
|
+
style={styles.date}
|
|
211
|
+
color={
|
|
212
|
+
getStatusClassName(getDelayMinutes(order)) === 'in_time'
|
|
213
|
+
? '#00D27A'
|
|
214
|
+
: getStatusClassName(getDelayMinutes(order)) === 'at_risk'
|
|
215
|
+
? '#FFC700'
|
|
216
|
+
: getStatusClassName(getDelayMinutes(order)) === 'delayed'
|
|
217
|
+
? '#E63757'
|
|
218
|
+
: ''}
|
|
219
|
+
>
|
|
220
|
+
{displayDelayedTime(order)}
|
|
221
|
+
</OText>
|
|
222
|
+
</>
|
|
223
|
+
)}
|
|
224
|
+
</View>
|
|
225
|
+
{!isLogisticOrder && (
|
|
226
|
+
<MyOrderOptions>
|
|
227
|
+
<OText
|
|
228
|
+
style={styles.orderType}
|
|
229
|
+
mRight={5}
|
|
230
|
+
numberOfLines={1}
|
|
231
|
+
adjustsFontSizeToFit
|
|
232
|
+
>
|
|
233
|
+
{order.delivery_type === 1
|
|
234
|
+
? t('DELIVERY', 'Delivery')
|
|
235
|
+
: order.delivery_type === 2
|
|
236
|
+
? t('PICKUP', 'Pickup')
|
|
237
|
+
: order.delivery_type === 3
|
|
238
|
+
? t('EAT_IN', 'Eat in')
|
|
239
|
+
: order.delivery_type === 4
|
|
240
|
+
? t('CURBSIDE', 'Curbside')
|
|
241
|
+
: t('DRIVER_THRU', 'Driver thru')}
|
|
242
|
+
{` · ${getOrderStatus(order.status)}`}
|
|
243
|
+
</OText>
|
|
244
|
+
</MyOrderOptions>
|
|
245
|
+
)}
|
|
246
|
+
</Information>
|
|
247
|
+
</Card>
|
|
248
|
+
</TouchableOpacity>
|
|
249
|
+
)
|
|
250
|
+
}
|