ordering-ui-react-native 0.21.80 → 0.21.82
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
CHANGED
|
@@ -16,7 +16,8 @@ import {
|
|
|
16
16
|
useApi,
|
|
17
17
|
useEvent,
|
|
18
18
|
useLanguage,
|
|
19
|
-
useSession
|
|
19
|
+
useSession,
|
|
20
|
+
useConfig
|
|
20
21
|
} from 'ordering-components/native'
|
|
21
22
|
|
|
22
23
|
import { OIcon, OText } from '../shared'
|
|
@@ -95,9 +96,14 @@ const NewOrderNotificationUI = (props: any) => {
|
|
|
95
96
|
const [events] = useEvent()
|
|
96
97
|
const [{ user, token }] = useSession()
|
|
97
98
|
const [ordering] = useApi()
|
|
99
|
+
const [{ configs }] = useConfig()
|
|
98
100
|
const { getCurrentLocation } = useLocation()
|
|
99
101
|
const [currentEvent, setCurrentEvent] = useState<any>(null)
|
|
100
102
|
|
|
103
|
+
const orderStatus = !!isBusinessApp
|
|
104
|
+
? configs?.notification_business_states?.value.split('|').map((value: any) => Number(value)) || []
|
|
105
|
+
: configs?.notification_driver_states?.value.split('|').map((value: any) => Number(value)) || []
|
|
106
|
+
|
|
101
107
|
const handleEventNotification = async (evtType: number, value: any) => {
|
|
102
108
|
if (value?.driver) {
|
|
103
109
|
try {
|
|
@@ -105,18 +111,26 @@ const NewOrderNotificationUI = (props: any) => {
|
|
|
105
111
|
await fetch(`${ordering.root}/users/${user.id}/locations`, {
|
|
106
112
|
method: 'POST',
|
|
107
113
|
body: JSON.stringify({
|
|
108
|
-
location: JSON.stringify({
|
|
114
|
+
location: JSON.stringify({
|
|
115
|
+
location: `{
|
|
116
|
+
lat: ${location.latitude},
|
|
117
|
+
lng: ${location.longitude}
|
|
118
|
+
}`
|
|
119
|
+
})
|
|
109
120
|
}),
|
|
110
|
-
headers: {
|
|
121
|
+
headers: {
|
|
122
|
+
'Content-Type': 'application/json',
|
|
123
|
+
Authorization: `Bearer ${token}`
|
|
124
|
+
}
|
|
111
125
|
})
|
|
112
126
|
} catch { }
|
|
113
127
|
const duration = moment.duration(moment().diff(moment.utc(value?.last_driver_assigned_at)))
|
|
114
128
|
const assignedSecondsDiff = duration.asSeconds()
|
|
115
|
-
if (assignedSecondsDiff < 5 && !isBusinessApp && !value?.logistic_status) {
|
|
129
|
+
if (assignedSecondsDiff < 5 && !isBusinessApp && !value?.logistic_status && orderStatus.includes(value.status)) {
|
|
116
130
|
setCurrentEvent({ evt: 2, orderId: value?.id ?? value?.order_id })
|
|
117
131
|
}
|
|
118
132
|
}
|
|
119
|
-
if ((
|
|
133
|
+
if (!orderStatus.includes(value.status) || value?.author_id === user.id) return
|
|
120
134
|
setCurrentEvent({
|
|
121
135
|
evt: evtType,
|
|
122
136
|
orderId: value?.driver
|