ordering-ui-react-native 0.22.95 → 0.22.97
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/context/OfflineActions/index.tsx +58 -16
- package/themes/business/src/components/Chat/index.tsx +1 -1
- package/themes/business/src/components/DriverMap/index.tsx +16 -14
- package/themes/business/src/components/LogoutButton/index.tsx +2 -1
- package/themes/business/src/components/OrderDetails/Delivery.tsx +35 -16
- package/themes/business/src/components/OrdersOption/index.tsx +2 -3
- package/themes/business/src/components/PreviousOrders/index.tsx +13 -6
- package/themes/business/src/components/UserProfileForm/index.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState, createContext, useEffect, useContext } from 'react';
|
|
2
|
-
import { useApi, useSession, useEvent } from 'ordering-components/native'
|
|
2
|
+
import { useApi, useSession, useEvent, useWebsocket } from 'ordering-components/native'
|
|
3
3
|
import { useNetInfo } from '@react-native-community/netinfo';
|
|
4
4
|
|
|
5
5
|
import { _retrieveStoreData, _setStoreData, _removeStoreData } from '../../providers/StoreUtil'
|
|
@@ -8,7 +8,7 @@ type State = {
|
|
|
8
8
|
isNetConnected: boolean | null
|
|
9
9
|
isCombinedTabs: boolean | null
|
|
10
10
|
canSaveChangesOffline: boolean | null
|
|
11
|
-
actions:
|
|
11
|
+
actions: { [key: string]: any }
|
|
12
12
|
orders: { [key: string]: any } | null
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -22,7 +22,7 @@ const defaultState = {
|
|
|
22
22
|
isNetConnected: null,
|
|
23
23
|
isCombinedTabs: null,
|
|
24
24
|
canSaveChangesOffline: false,
|
|
25
|
-
actions:
|
|
25
|
+
actions: {},
|
|
26
26
|
orders: null,
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -41,6 +41,7 @@ export const OfflineActionsProvider = (props: any) => {
|
|
|
41
41
|
const [ordering] = useApi()
|
|
42
42
|
const [{ token }] = useSession()
|
|
43
43
|
const [events] = useEvent()
|
|
44
|
+
const socket = useWebsocket()
|
|
44
45
|
|
|
45
46
|
const [state, setState] = useState<State>({
|
|
46
47
|
isNetConnected: netInfo.isConnected,
|
|
@@ -77,7 +78,14 @@ export const OfflineActionsProvider = (props: any) => {
|
|
|
77
78
|
const applyOffAction = async (changes: any) => {
|
|
78
79
|
if (state.canSaveChangesOffline === false) return false
|
|
79
80
|
|
|
80
|
-
|
|
81
|
+
let _actions: any = state.actions?.[changes?.data?.orderId] ?? []
|
|
82
|
+
|
|
83
|
+
if (state.actions?.[changes?.data?.orderId]) {
|
|
84
|
+
_actions.push(changes)
|
|
85
|
+
} else {
|
|
86
|
+
_actions = [changes]
|
|
87
|
+
}
|
|
88
|
+
const actions = { ...state.actions, [changes?.data?.orderId]: _actions }
|
|
81
89
|
|
|
82
90
|
setState(state => ({ ...state, actions }))
|
|
83
91
|
await _setStoreData('offline_actions_array', actions)
|
|
@@ -127,30 +135,40 @@ export const OfflineActionsProvider = (props: any) => {
|
|
|
127
135
|
}
|
|
128
136
|
|
|
129
137
|
const syncChanges = async (changes: any) => {
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
138
|
+
const ordersIdUpdated: any = []
|
|
139
|
+
|
|
140
|
+
Object.keys(changes).forEach(async (orderId) => {
|
|
141
|
+
const arr = changes[orderId]
|
|
142
|
+
|
|
143
|
+
const [lastChange, ...restOfChanges] = arr.reverse();
|
|
144
|
+
|
|
145
|
+
if (restOfChanges.length > 0) {
|
|
146
|
+
const ordersString = restOfChanges
|
|
147
|
+
.map((obj: any) => (
|
|
148
|
+
Object.entries(obj?.data?.body).map(([clave, valor]) => `${clave}: '${valor}'`).join(', ')
|
|
149
|
+
))
|
|
150
|
+
.join(', ')
|
|
151
|
+
handleSendMessage({ message: ordersString, orderId })
|
|
136
152
|
}
|
|
137
|
-
|
|
138
|
-
|
|
153
|
+
const id = await updateOrderStatus({ orderId, body: lastChange?.data?.body })
|
|
154
|
+
id && ordersIdUpdated.push(id);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
ordersIdUpdated.length && events.emit('offline_order_updated', ordersIdUpdated)
|
|
139
158
|
await _removeStoreData('offline_actions_array');
|
|
140
159
|
setState(state => ({ ...state, actions: [] }));
|
|
141
160
|
}
|
|
142
161
|
|
|
143
162
|
const actionsFromStorage = async (isConnected: boolean) => {
|
|
144
163
|
setState(state => ({ ...state, isNetConnected: isConnected }))
|
|
145
|
-
const
|
|
146
|
-
const storedActions: any = [...new Set(_storedActions)]
|
|
164
|
+
const storedActions = await _retrieveStoreData('offline_actions_array');
|
|
147
165
|
|
|
148
|
-
if (isConnected && storedActions?.length) {
|
|
166
|
+
if (isConnected && Object.keys(storedActions)?.length) {
|
|
149
167
|
syncChanges(storedActions)
|
|
150
168
|
return
|
|
151
169
|
}
|
|
152
170
|
|
|
153
|
-
storedActions?.length && setState(state => ({ ...state, actions: storedActions }));
|
|
171
|
+
Object.keys(storedActions)?.length && setState(state => ({ ...state, actions: storedActions }));
|
|
154
172
|
}
|
|
155
173
|
|
|
156
174
|
useEffect(() => {
|
|
@@ -177,6 +195,30 @@ export const OfflineActionsProvider = (props: any) => {
|
|
|
177
195
|
}
|
|
178
196
|
}
|
|
179
197
|
|
|
198
|
+
const handleSendMessage = async (offlineData: any) => {
|
|
199
|
+
try {
|
|
200
|
+
const _canRead = [0, 2, 3, 4]
|
|
201
|
+
const body = {
|
|
202
|
+
comment: offlineData?.message,
|
|
203
|
+
type: 2,
|
|
204
|
+
can_see: _canRead.join(',')
|
|
205
|
+
}
|
|
206
|
+
const response = await fetch(`${ordering.root}/orders/${offlineData?.orderId}/messages`, {
|
|
207
|
+
method: 'POST',
|
|
208
|
+
headers: {
|
|
209
|
+
'Content-Type': 'application/json',
|
|
210
|
+
Authorization: `Bearer ${token}`,
|
|
211
|
+
'X-App-X': ordering.appId,
|
|
212
|
+
'X-Socket-Id-X': socket?.getId()
|
|
213
|
+
},
|
|
214
|
+
body: JSON.stringify(body)
|
|
215
|
+
})
|
|
216
|
+
const { error, result } = await response.json()
|
|
217
|
+
} catch {
|
|
218
|
+
return null
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
180
222
|
const eventsDictiorary: any = {
|
|
181
223
|
evt_off_change_order_status: updateOrderStatus
|
|
182
224
|
}
|
|
@@ -767,7 +767,7 @@ const ChatUI = (props: MessagesParams) => {
|
|
|
767
767
|
color: '#414954'
|
|
768
768
|
}}
|
|
769
769
|
style={{ ...styles.editButton }}
|
|
770
|
-
onClick={() => handleClickQuickMessage(message?.length > 0 ? ' ' + quickMessage.text : quickMessage.text)}
|
|
770
|
+
onClick={() => handleClickQuickMessage((message?.length ?? 0) > 0 ? ' ' + quickMessage.text : quickMessage.text)}
|
|
771
771
|
/>
|
|
772
772
|
</React.Fragment>
|
|
773
773
|
))}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef } from 'react';
|
|
1
|
+
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
|
2
2
|
import { Dimensions, Platform, SafeAreaView, StyleSheet, View } from 'react-native';
|
|
3
3
|
import MapView, {
|
|
4
4
|
PROVIDER_GOOGLE,
|
|
@@ -79,10 +79,12 @@ export const DriverMap = (props: GoogleMapsParams) => {
|
|
|
79
79
|
longitude: typeof initialPosition.longitude === 'string' ? parseFloat(initialPosition.longitude) || 0 : initialPosition.longitude || 0,
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
const parsedUserLocation = {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
const parsedUserLocation = useCallback(() => {
|
|
83
|
+
return {
|
|
84
|
+
latitude: typeof userLocation?.latitude === 'string' ? parseFloat(userLocation?.latitude) || 0 : userLocation?.latitude || 0,
|
|
85
|
+
longitude: typeof userLocation?.longitude === 'string' ? parseFloat(userLocation?.longitude) || 0 : userLocation?.longitude || 0
|
|
86
|
+
}
|
|
87
|
+
}, [JSON.stringify(userLocation)])
|
|
86
88
|
|
|
87
89
|
useEffect(() => {
|
|
88
90
|
if (isToFollow) {
|
|
@@ -170,7 +172,7 @@ export const DriverMap = (props: GoogleMapsParams) => {
|
|
|
170
172
|
if (driverUpdateLocation.error) return;
|
|
171
173
|
|
|
172
174
|
calculateDistance(
|
|
173
|
-
{ lat: parsedUserLocation.latitude, lng: parsedUserLocation.longitude },
|
|
175
|
+
{ lat: parsedUserLocation().latitude, lng: parsedUserLocation().longitude },
|
|
174
176
|
destination,
|
|
175
177
|
);
|
|
176
178
|
// geocodePosition(userLocation);
|
|
@@ -178,13 +180,13 @@ export const DriverMap = (props: GoogleMapsParams) => {
|
|
|
178
180
|
if (!following.current) return;
|
|
179
181
|
fitCoordinates();
|
|
180
182
|
|
|
181
|
-
const { latitude, longitude } = parsedUserLocation;
|
|
183
|
+
const { latitude, longitude } = parsedUserLocation();
|
|
182
184
|
|
|
183
185
|
mapRef.current?.animateCamera({
|
|
184
186
|
center: { latitude, longitude },
|
|
185
187
|
});
|
|
186
188
|
|
|
187
|
-
}, [
|
|
189
|
+
}, [JSON.stringify(userLocation)]);
|
|
188
190
|
|
|
189
191
|
const handleArrowBack: any = () => {
|
|
190
192
|
setDriverUpdateLocation?.({
|
|
@@ -397,8 +399,8 @@ export const DriverMap = (props: GoogleMapsParams) => {
|
|
|
397
399
|
</View>
|
|
398
400
|
</Marker>
|
|
399
401
|
<Marker coordinate={{
|
|
400
|
-
latitude:
|
|
401
|
-
longitude:
|
|
402
|
+
latitude: userLocation?.latitude,
|
|
403
|
+
longitude: userLocation?.longitude
|
|
402
404
|
}}>
|
|
403
405
|
<View style={styles.driverIcon}>
|
|
404
406
|
<OIcon
|
|
@@ -413,8 +415,8 @@ export const DriverMap = (props: GoogleMapsParams) => {
|
|
|
413
415
|
) : (
|
|
414
416
|
<Marker
|
|
415
417
|
coordinate={{
|
|
416
|
-
latitude: typeof parsedUserLocation?.latitude !== 'object' ? parsedUserLocation?.latitude : 0,
|
|
417
|
-
longitude: typeof parsedUserLocation?.longitude !== 'object' ? parsedUserLocation?.latitude : 0
|
|
418
|
+
latitude: typeof parsedUserLocation()?.latitude !== 'object' ? parsedUserLocation()?.latitude : 0,
|
|
419
|
+
longitude: typeof parsedUserLocation()?.longitude !== 'object' ? parsedUserLocation()?.latitude : 0
|
|
418
420
|
}}
|
|
419
421
|
title={markerTitle || t('YOUR_LOCATION', 'Your Location')}
|
|
420
422
|
/>
|
|
@@ -528,8 +530,8 @@ export const DriverMap = (props: GoogleMapsParams) => {
|
|
|
528
530
|
options={{
|
|
529
531
|
latitude: destination.latitude,
|
|
530
532
|
longitude: destination.longitude,
|
|
531
|
-
sourceLatitude: parsedUserLocation.latitude,
|
|
532
|
-
sourceLongitude: parsedUserLocation.longitude,
|
|
533
|
+
sourceLatitude: parsedUserLocation().latitude,
|
|
534
|
+
sourceLongitude: parsedUserLocation().longitude,
|
|
533
535
|
naverCallerName: 'com.deliveryapp',
|
|
534
536
|
dialogTitle: t('SHOW_IN_OTHER_MAPS', 'Show in other maps'),
|
|
535
537
|
dialogMessage: t('WHAT_APP_WOULD_YOU_USE', 'What app would you like to use?'),
|
|
@@ -7,7 +7,7 @@ import { OIcon, OText } from '../shared';
|
|
|
7
7
|
import { _retrieveStoreData, _clearStoreData } from '../../providers/StoreUtil';
|
|
8
8
|
|
|
9
9
|
const LogoutButtonUI = (props: any) => {
|
|
10
|
-
const { handleLogoutClick } = props;
|
|
10
|
+
const { handleLogoutClick, setRootState } = props;
|
|
11
11
|
const [, t] = useLanguage();
|
|
12
12
|
const theme = useTheme();
|
|
13
13
|
|
|
@@ -16,6 +16,7 @@ const LogoutButtonUI = (props: any) => {
|
|
|
16
16
|
const res = await handleLogoutClick(data);
|
|
17
17
|
if (res) {
|
|
18
18
|
_clearStoreData({ excludedKeys: ['isTutorial', 'language'] });
|
|
19
|
+
setRootState && setRootState({ isAuth: false, token: null })
|
|
19
20
|
}
|
|
20
21
|
};
|
|
21
22
|
|
|
@@ -30,6 +30,7 @@ import { verifyDecimals, getProductPrice, getOrderStatus } from '../../utils';
|
|
|
30
30
|
import { OrderHeaderComponent } from './OrderHeaderComponent';
|
|
31
31
|
import { OrderContentComponent } from './OrderContentComponent';
|
|
32
32
|
import { OrderDetailsContainer, Pickup } from './styles';
|
|
33
|
+
import { useOfflineActions } from '../../../../../src/context/OfflineActions';
|
|
33
34
|
|
|
34
35
|
export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
35
36
|
const {
|
|
@@ -38,7 +39,6 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
38
39
|
setMessages,
|
|
39
40
|
readMessages,
|
|
40
41
|
messagesReadList,
|
|
41
|
-
handleChangeOrderStatus,
|
|
42
42
|
permissions,
|
|
43
43
|
askLocationPermission,
|
|
44
44
|
driverLocation,
|
|
@@ -69,6 +69,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
69
69
|
const theme = useTheme();
|
|
70
70
|
const [, t] = useLanguage();
|
|
71
71
|
const [session] = useSession();
|
|
72
|
+
const [{ isNetConnected, canSaveChangesOffline }, { applyOffAction, registerOffOrder }] = useOfflineActions()
|
|
73
|
+
|
|
72
74
|
const [actionOrder, setActionOrder] = useState('');
|
|
73
75
|
const [unreadAlert, setUnreadAlert] = useState({
|
|
74
76
|
business: false,
|
|
@@ -83,6 +85,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
83
85
|
key?: string | null;
|
|
84
86
|
}>({ open: false, content: [], key: null });
|
|
85
87
|
|
|
88
|
+
const disabledActionsByInternet = !isNetConnected && canSaveChangesOffline === false
|
|
89
|
+
|
|
86
90
|
const validStatusComplete = [9, 19, 23]
|
|
87
91
|
|
|
88
92
|
const pendingOrderStatus = [1, 4, 7, 13]
|
|
@@ -102,13 +106,23 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
102
106
|
14: true
|
|
103
107
|
};
|
|
104
108
|
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
const handleChangeOrderStatus = async (status: number) => {
|
|
110
|
+
if (!isNetConnected && canSaveChangesOffline !== false) {
|
|
111
|
+
const result = applyOffAction({
|
|
112
|
+
event: 'evt_off_change_order_status',
|
|
113
|
+
data: { orderId: order?.id, body: { status } }
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const dataToSave: any = !isNetConnected && canSaveChangesOffline !== false
|
|
118
|
+
? { dataToSave: { status, unsync: true } }
|
|
119
|
+
: null
|
|
120
|
+
const orderUpdated = await props.handleChangeOrderStatus(status, {}, dataToSave)
|
|
121
|
+
|
|
122
|
+
if (!isNetConnected && canSaveChangesOffline !== false) {
|
|
123
|
+
await registerOffOrder(orderUpdated)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
112
126
|
|
|
113
127
|
const handleOpenMessagesForBusiness = () => {
|
|
114
128
|
setOpenModalForBusiness(true);
|
|
@@ -491,8 +505,9 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
491
505
|
style={styles.btnPickUp}
|
|
492
506
|
textStyle={{ color: theme.colors.primary }}
|
|
493
507
|
text={t('ARRIVED_TO_BUSINESS', 'Arrived to bussiness')}
|
|
508
|
+
isDisabled={disabledActionsByInternet}
|
|
494
509
|
onClick={() =>
|
|
495
|
-
|
|
510
|
+
isGrantedPermissions ? handleChangeOrderStatus(3) : goToPermissionPage()
|
|
496
511
|
}
|
|
497
512
|
imgLeftStyle={{ tintColor: theme.colors.backArrow }}
|
|
498
513
|
/>
|
|
@@ -590,11 +605,11 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
590
605
|
</OrderDetailsContainer>
|
|
591
606
|
{showFloatButtonsPickUp[order?.status] && (
|
|
592
607
|
<FloatingButton
|
|
593
|
-
disabled={props.order?.loading}
|
|
608
|
+
disabled={props.order?.loading || disabledActionsByInternet}
|
|
594
609
|
btnText={t('PICKUP_FAILED', 'Pickup failed')}
|
|
595
610
|
isSecondaryBtn={false}
|
|
596
611
|
secondButtonClick={() =>
|
|
597
|
-
|
|
612
|
+
isGrantedPermissions ? handleChangeOrderStatus(9) : goToPermissionPage()
|
|
598
613
|
}
|
|
599
614
|
firstButtonClick={() =>
|
|
600
615
|
handleViewActionOrder && handleViewActionOrder('pickupFailed')
|
|
@@ -610,11 +625,11 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
610
625
|
{(validStatusComplete.includes(order?.status)) && (
|
|
611
626
|
<>
|
|
612
627
|
<FloatingButton
|
|
613
|
-
disabled={props.order?.loading}
|
|
628
|
+
disabled={props.order?.loading || disabledActionsByInternet}
|
|
614
629
|
btnText={t('DELIVERY_FAILED', 'Delivery Failed')}
|
|
615
630
|
isSecondaryBtn={false}
|
|
616
631
|
secondButtonClick={() =>
|
|
617
|
-
|
|
632
|
+
isGrantedPermissions ? handleChangeOrderStatus(11) : goToPermissionPage()
|
|
618
633
|
}
|
|
619
634
|
firstButtonClick={() =>
|
|
620
635
|
handleViewActionOrder && handleViewActionOrder('deliveryFailed')
|
|
@@ -630,7 +645,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
630
645
|
)}
|
|
631
646
|
{showFloatButtonsAcceptOrReject[order?.status] && (
|
|
632
647
|
<FloatingButton
|
|
633
|
-
disabled={props.order?.loading}
|
|
648
|
+
disabled={props.order?.loading || disabledActionsByInternet}
|
|
634
649
|
widthButton={isHideRejectButtons ? '100%' : '45%'}
|
|
635
650
|
isHideRejectButtons={isHideRejectButtons}
|
|
636
651
|
btnText={t('REJECT', 'Reject')}
|
|
@@ -642,7 +657,11 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
642
657
|
isSecondaryBtn={false}
|
|
643
658
|
secondButton={true}
|
|
644
659
|
secondBtnText={t('ACCEPT', 'Accept')}
|
|
645
|
-
secondButtonClick={() => hideTimer
|
|
660
|
+
secondButtonClick={() => hideTimer
|
|
661
|
+
? handleChangeOrderStatus(8)
|
|
662
|
+
: (order?.isLogistic && (order?.order_group || logisticOrderStatus.includes(order?.status)))
|
|
663
|
+
? handleAcceptLogisticOrder(order)
|
|
664
|
+
: handleViewActionOrder('accept')}
|
|
646
665
|
secondColorCustom={theme.colors.green}
|
|
647
666
|
/>
|
|
648
667
|
)}
|
|
@@ -698,7 +717,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
698
717
|
entireModal
|
|
699
718
|
customClose>
|
|
700
719
|
<AcceptOrRejectOrder
|
|
701
|
-
handleUpdateOrder={handleChangeOrderStatus}
|
|
720
|
+
handleUpdateOrder={props.handleChangeOrderStatus}
|
|
702
721
|
closeModal={setOpenModalForAccept}
|
|
703
722
|
customerCellphone={order?.customer?.cellphone}
|
|
704
723
|
loading={props.order?.loading}
|
|
@@ -629,11 +629,11 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
629
629
|
>
|
|
630
630
|
{`${t('LAST_UPDATE', 'Last Update')}: ${lastDateConnection}`}
|
|
631
631
|
</OText>
|
|
632
|
-
{offlineActionsState?.actions?.length > 0 && (
|
|
632
|
+
{Object.keys(offlineActionsState?.actions)?.length > 0 && (
|
|
633
633
|
<OText
|
|
634
634
|
style={{ color: 'white', textAlign: 'center' }}
|
|
635
635
|
>
|
|
636
|
-
{t('NUMBER_CHANGES_PENDING_SYNC', '_value_ changes pending sync').replace('_value_', offlineActionsState?.actions?.length)}
|
|
636
|
+
{t('NUMBER_CHANGES_PENDING_SYNC', '_value_ changes pending sync').replace('_value_', Object.keys(offlineActionsState?.actions)?.length)}
|
|
637
637
|
</OText>
|
|
638
638
|
)}
|
|
639
639
|
</View>
|
|
@@ -1080,7 +1080,6 @@ export const OrdersOption = (props: OrdersOptionParams) => {
|
|
|
1080
1080
|
const ordersProps = {
|
|
1081
1081
|
...props,
|
|
1082
1082
|
UIComponent: OrdersOptionUI,
|
|
1083
|
-
useDefualtSessionManager: true,
|
|
1084
1083
|
asDashboard: true,
|
|
1085
1084
|
combineTabs,
|
|
1086
1085
|
isIos: Platform.OS === 'ios',
|
|
@@ -11,6 +11,7 @@ import { OrdersList } from './OrderList';
|
|
|
11
11
|
import { AcceptOrRejectOrder } from '../AcceptOrRejectOrder';
|
|
12
12
|
import { ReviewCustomer } from '../ReviewCustomer';
|
|
13
13
|
import { GoogleMap } from '../GoogleMap';
|
|
14
|
+
import { useOfflineActions } from '../../../../../src/context/OfflineActions';
|
|
14
15
|
|
|
15
16
|
export const PreviousOrders = (props: any) => {
|
|
16
17
|
const {
|
|
@@ -32,7 +33,7 @@ export const PreviousOrders = (props: any) => {
|
|
|
32
33
|
const [, t] = useLanguage();
|
|
33
34
|
const theme = useTheme();
|
|
34
35
|
const [{ configs }] = useConfig();
|
|
35
|
-
|
|
36
|
+
const [{ isNetConnected, canSaveChangesOffline }] = useOfflineActions()
|
|
36
37
|
|
|
37
38
|
// const [, setCurrentTime] = useState()
|
|
38
39
|
const [openModal, setOpenModal] = useState(false)
|
|
@@ -47,6 +48,7 @@ export const PreviousOrders = (props: any) => {
|
|
|
47
48
|
const isHideRejectButtons = configs?.reject_orders_enabled && configs?.reject_orders_enabled?.value !== '1' && !isBusinessApp
|
|
48
49
|
const isEnabledOrderNotReady = configs?.order_not_ready_enabled?.value === '1'
|
|
49
50
|
const isEnabledFailedPickupDriver = configs?.failed_pickup_by_driver_enabled?.value === '1'
|
|
51
|
+
const disabledActionsByInternet = !isNetConnected && canSaveChangesOffline === false
|
|
50
52
|
|
|
51
53
|
const handlePressOrder = (order: any) => {
|
|
52
54
|
if (order?.locked && isLogisticOrder) return
|
|
@@ -172,7 +174,7 @@ export const PreviousOrders = (props: any) => {
|
|
|
172
174
|
}
|
|
173
175
|
)
|
|
174
176
|
}
|
|
175
|
-
{_ordersGrouped[k][0]?.status === 0 && (
|
|
177
|
+
{_ordersGrouped[k][0]?.status === 0 && !disabledActionsByInternet && (
|
|
176
178
|
<AcceptOrRejectOrderStyle>
|
|
177
179
|
{!isHideRejectButtons && (
|
|
178
180
|
<OButton
|
|
@@ -208,7 +210,7 @@ export const PreviousOrders = (props: any) => {
|
|
|
208
210
|
/>
|
|
209
211
|
</AcceptOrRejectOrderStyle>
|
|
210
212
|
)}
|
|
211
|
-
{_ordersGrouped[k][0]?.status === 7 && (
|
|
213
|
+
{_ordersGrouped[k][0]?.status === 7 && !disabledActionsByInternet && (
|
|
212
214
|
<View>
|
|
213
215
|
<OButton
|
|
214
216
|
text={t('READY_FOR_PICKUP', 'Ready for pickup')}
|
|
@@ -226,7 +228,7 @@ export const PreviousOrders = (props: any) => {
|
|
|
226
228
|
</View>
|
|
227
229
|
)}
|
|
228
230
|
{(_ordersGrouped[k][0]?.status === 8 || _ordersGrouped[k][0]?.status === 18) &&
|
|
229
|
-
_ordersGrouped[k][0]?.delivery_type === 1 &&
|
|
231
|
+
_ordersGrouped[k][0]?.delivery_type === 1 && !disabledActionsByInternet &&
|
|
230
232
|
(
|
|
231
233
|
<AcceptOrRejectOrderStyle>
|
|
232
234
|
<OButton
|
|
@@ -245,6 +247,7 @@ export const PreviousOrders = (props: any) => {
|
|
|
245
247
|
</AcceptOrRejectOrderStyle>
|
|
246
248
|
)}
|
|
247
249
|
{_ordersGrouped[k][0]?.status === 3 && _ordersGrouped[k][0]?.delivery_type === 1 && !isHideRejectButtons && isEnabledOrderNotReady &&
|
|
250
|
+
!disabledActionsByInternet &&
|
|
248
251
|
(
|
|
249
252
|
<AcceptOrRejectOrderStyle>
|
|
250
253
|
<OButton
|
|
@@ -282,6 +285,7 @@ export const PreviousOrders = (props: any) => {
|
|
|
282
285
|
)}
|
|
283
286
|
{_ordersGrouped[k][0]?.status === 4 &&
|
|
284
287
|
![1].includes(_ordersGrouped[k][0]?.delivery_type) &&
|
|
288
|
+
!disabledActionsByInternet &&
|
|
285
289
|
(
|
|
286
290
|
<AcceptOrRejectOrderStyle>
|
|
287
291
|
{!isHideRejectButtons && (
|
|
@@ -316,6 +320,7 @@ export const PreviousOrders = (props: any) => {
|
|
|
316
320
|
)}
|
|
317
321
|
{!_ordersGrouped[k][0]?.user_review &&
|
|
318
322
|
pastOrderStatuses.includes(_ordersGrouped[k][0]?.status) &&
|
|
323
|
+
!disabledActionsByInternet &&
|
|
319
324
|
(
|
|
320
325
|
<OButton
|
|
321
326
|
text={t('REVIEW_CUSTOMER', 'Review customer')}
|
|
@@ -332,7 +337,8 @@ export const PreviousOrders = (props: any) => {
|
|
|
332
337
|
})}
|
|
333
338
|
/>
|
|
334
339
|
)}
|
|
335
|
-
{!!deliveryPickupBtn && deliveryPickupBtn?.includes(_ordersGrouped[k][0]?.status) && isEnabledFailedPickupDriver &&
|
|
340
|
+
{!!deliveryPickupBtn && deliveryPickupBtn?.includes(_ordersGrouped[k][0]?.status) && isEnabledFailedPickupDriver &&
|
|
341
|
+
!disabledActionsByInternet && (
|
|
336
342
|
<AcceptOrRejectOrderStyle>
|
|
337
343
|
{!isHideRejectButtons && isEnabledOrderNotReady && (
|
|
338
344
|
<OButton
|
|
@@ -366,7 +372,8 @@ export const PreviousOrders = (props: any) => {
|
|
|
366
372
|
/>
|
|
367
373
|
</AcceptOrRejectOrderStyle>
|
|
368
374
|
)}
|
|
369
|
-
{!!deliveryStatusCompleteBtn && deliveryStatusCompleteBtn.includes(_ordersGrouped[k][0]?.status) &&
|
|
375
|
+
{!!deliveryStatusCompleteBtn && deliveryStatusCompleteBtn.includes(_ordersGrouped[k][0]?.status) &&
|
|
376
|
+
!disabledActionsByInternet && (
|
|
370
377
|
<AcceptOrRejectOrderStyle>
|
|
371
378
|
{!isHideRejectButtons && (
|
|
372
379
|
<OButton
|