ordering-ui-react-native 0.16.87-release → 0.16.88-release
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/themes/original/src/components/OrderDetails/OrderEta.tsx +59 -0
- package/themes/original/src/components/OrderDetails/index.tsx +8 -9
- package/themes/original/src/components/OrderProgress/index.tsx +3 -11
- package/themes/original/src/components/SingleOrderCard/index.tsx +2 -2
package/package.json
CHANGED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
|
+
import { useUtils } from 'ordering-components/native'
|
|
3
|
+
import moment from 'moment'
|
|
4
|
+
|
|
5
|
+
export const OrderEta = (props: any) => {
|
|
6
|
+
const {
|
|
7
|
+
order,
|
|
8
|
+
outputFormat
|
|
9
|
+
} = props
|
|
10
|
+
|
|
11
|
+
const [{ parseDate }] = useUtils()
|
|
12
|
+
const [estimatedDeliveryTime, setEstimatedDeliveryTime] = useState(null)
|
|
13
|
+
|
|
14
|
+
const getEstimatedDeliveryTime = () => {
|
|
15
|
+
let _estimatedTime
|
|
16
|
+
let totalEta = 0
|
|
17
|
+
const _delivery = order?.delivery_datetime_utc
|
|
18
|
+
? order?.delivery_datetime_utc
|
|
19
|
+
: order?.delivery_datetime
|
|
20
|
+
if (order?.eta_current_status_time) {
|
|
21
|
+
const currentStatueEta = order?.eta_current_status_time
|
|
22
|
+
totalEta += currentStatueEta
|
|
23
|
+
let nextStatusTimes = 0
|
|
24
|
+
if (order?.eta_next_status_times) {
|
|
25
|
+
Object.keys(order.eta_next_status_times).map(key => {
|
|
26
|
+
if (!key.includes('status_penalty')) {
|
|
27
|
+
nextStatusTimes += order.eta_next_status_times[key]
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
totalEta += nextStatusTimes
|
|
33
|
+
|
|
34
|
+
const diffTimeAsSeconds = moment.utc(order?.reporting_data?.at[`status:${order.status}`]).add(order?.eta_current_status_time, 'minutes').diff(moment().utc(), 'seconds')
|
|
35
|
+
const diffTimeAsMinutes = Math.ceil(diffTimeAsSeconds / 60)
|
|
36
|
+
if (diffTimeAsMinutes <= 0) {
|
|
37
|
+
totalEta += (Math.floor(Math.abs(diffTimeAsMinutes / order?.eta_current_status_time) + 1) * order?.eta_current_status_penalty_time)
|
|
38
|
+
}
|
|
39
|
+
_estimatedTime = parseDate(moment(_delivery).add(totalEta, 'minutes'))
|
|
40
|
+
} else {
|
|
41
|
+
_estimatedTime = parseDate(moment(_delivery).add(order?.eta_time, 'minutes'))
|
|
42
|
+
}
|
|
43
|
+
setEstimatedDeliveryTime(_estimatedTime)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
getEstimatedDeliveryTime()
|
|
48
|
+
const interval = setInterval(() => {
|
|
49
|
+
getEstimatedDeliveryTime()
|
|
50
|
+
}, 1000)
|
|
51
|
+
return () => clearInterval(interval)
|
|
52
|
+
}, [order])
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<>
|
|
56
|
+
{!outputFormat ? estimatedDeliveryTime : moment(estimatedDeliveryTime).format(outputFormat)}
|
|
57
|
+
</>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
@@ -48,6 +48,7 @@ import { Placeholder, PlaceholderLine } from 'rn-placeholder';
|
|
|
48
48
|
import NavBar from '../NavBar'
|
|
49
49
|
import { OrderHistory } from './OrderHistory';
|
|
50
50
|
import { PlaceSpot } from '../PlaceSpot'
|
|
51
|
+
import { OrderEta } from './OrderEta'
|
|
51
52
|
export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
52
53
|
const {
|
|
53
54
|
navigation,
|
|
@@ -120,7 +121,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
120
121
|
const directionTypes = [2, 3, 4, 5]
|
|
121
122
|
const activeStatus = [0, 3, 4, 7, 8, 9, 14, 18, 19, 20, 21, 22, 23]
|
|
122
123
|
const enabledPoweredByOrdering = configs?.powered_by_ordering_module?.value
|
|
123
|
-
|
|
124
|
+
const hideDeliveryDate = theme?.confirmation?.components?.order?.components?.date?.hidden
|
|
124
125
|
const walletName: any = {
|
|
125
126
|
cash: {
|
|
126
127
|
name: t('PAY_WITH_CASH_WALLET', 'Pay with Cash Wallet'),
|
|
@@ -396,14 +397,12 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
396
397
|
style={{ marginTop: Platform.OS === 'ios' ? 0 : 20 }}
|
|
397
398
|
titleWrapStyle={{ paddingHorizontal: 0 }}
|
|
398
399
|
titleStyle={{ marginRight: 0, marginLeft: 0 }}
|
|
399
|
-
subTitle={<OText size={12} lineHeight={18} color={theme.colors.textNormal}>
|
|
400
|
-
{
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
: parseDate(order?.delivery_datetime, { utc: false })
|
|
406
|
-
}
|
|
400
|
+
subTitle={!hideDeliveryDate && <OText size={12} lineHeight={18} color={theme.colors.textNormal}>
|
|
401
|
+
{activeStatus.includes(order?.status) ? (
|
|
402
|
+
<OrderEta order={order} />
|
|
403
|
+
) : (
|
|
404
|
+
parseDate(order?.reporting_data?.at[`status:${order.status}`])
|
|
405
|
+
)}
|
|
407
406
|
</OText>}
|
|
408
407
|
/>
|
|
409
408
|
{enabledPoweredByOrdering && (
|
|
@@ -12,6 +12,7 @@ import { NotFoundSource } from '../NotFoundSource'
|
|
|
12
12
|
import { View, StyleSheet, TouchableOpacity, Platform } from 'react-native'
|
|
13
13
|
import { Placeholder, Fade, PlaceholderLine } from "rn-placeholder";
|
|
14
14
|
import FastImage from 'react-native-fast-image'
|
|
15
|
+
import { OrderEta } from '../OrderDetails/OrderEta'
|
|
15
16
|
import {
|
|
16
17
|
ProgressContentWrapper,
|
|
17
18
|
ProgressBar,
|
|
@@ -33,7 +34,7 @@ const OrderProgressUI = (props: any) => {
|
|
|
33
34
|
const theme = useTheme();
|
|
34
35
|
|
|
35
36
|
const [, t] = useLanguage()
|
|
36
|
-
const [{ optimizeImage,
|
|
37
|
+
const [{ optimizeImage, parseTime }] = useUtils()
|
|
37
38
|
const [lastOrder, setLastOrder] = useState<any>(null)
|
|
38
39
|
const imageFails = theme.images.general.emptyActiveOrders
|
|
39
40
|
const [initialLoaded, setInitialLoaded] = useState(false)
|
|
@@ -76,15 +77,6 @@ const OrderProgressUI = (props: any) => {
|
|
|
76
77
|
}
|
|
77
78
|
});
|
|
78
79
|
|
|
79
|
-
const convertDiffToHours = (order: any) => {
|
|
80
|
-
const minute = order?.eta_time
|
|
81
|
-
const deliveryTime = order?.delivery_datetime_utc
|
|
82
|
-
? parseDate(order?.delivery_datetime_utc, { outputFormat: 'YYYY-MM-DD HH:mm' })
|
|
83
|
-
: parseDate(order?.delivery_datetime, { utc: false, outputFormat: 'YYYY-MM-DD HH:mm' })
|
|
84
|
-
const returnedDate = moment(deliveryTime).add(minute, 'minutes').format('hh:mm A')
|
|
85
|
-
return returnedDate
|
|
86
|
-
}
|
|
87
|
-
|
|
88
80
|
const handleGoToOrder = (index: string) => {
|
|
89
81
|
navigation && navigation.navigate(index)
|
|
90
82
|
}
|
|
@@ -171,7 +163,7 @@ const OrderProgressUI = (props: any) => {
|
|
|
171
163
|
? parseTime(lastOrder?.delivery_datetime_utc, { outputFormat: 'hh:mm A' })
|
|
172
164
|
: parseTime(lastOrder?.delivery_datetime, { utc: false })}
|
|
173
165
|
-
|
|
174
|
-
{
|
|
166
|
+
<OrderEta order={lastOrder} outputFormat='hh:mm A' />
|
|
175
167
|
</OText>
|
|
176
168
|
</TimeWrapper>
|
|
177
169
|
</ProgressTextWrapper>
|
|
@@ -10,7 +10,7 @@ import { useTheme } from 'styled-components/native';
|
|
|
10
10
|
import { OIcon, OText, OButton } from '../shared';
|
|
11
11
|
import { SingleOrderCardParams } from '../../types';
|
|
12
12
|
import { OAlert } from '../../../../../src/components/shared'
|
|
13
|
-
|
|
13
|
+
import { OrderEta } from '../OrderDetails/OrderEta'
|
|
14
14
|
import {
|
|
15
15
|
InnerContainer,
|
|
16
16
|
Logo,
|
|
@@ -333,7 +333,7 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
|
|
|
333
333
|
{
|
|
334
334
|
pastOrders
|
|
335
335
|
? order?.delivery_datetime_utc ? parseDate(order?.delivery_datetime_utc) : parseDate(order?.delivery_datetime, { utc: false })
|
|
336
|
-
: order
|
|
336
|
+
: <OrderEta order={order} />
|
|
337
337
|
}
|
|
338
338
|
</OText>
|
|
339
339
|
)}
|