ordering-ui-react-native 0.23.77-test → 0.23.77-test1
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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef, useCallback
|
|
1
|
+
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
|
2
2
|
import { Dimensions, SafeAreaView, StyleSheet, View } from 'react-native';
|
|
3
3
|
import { useFocusEffect } from '@react-navigation/native'
|
|
4
4
|
import MapView, {
|
|
@@ -30,8 +30,8 @@ const MapViewComponent = (props: MapViewParams) => {
|
|
|
30
30
|
const [, t] = useLanguage();
|
|
31
31
|
const [{ user }] = useSession()
|
|
32
32
|
const { width, height } = Dimensions.get('window');
|
|
33
|
-
|
|
34
|
-
const mapRef = useRef<any>(null);
|
|
33
|
+
const ASPECT_RATIO = width / height;
|
|
34
|
+
const mapRef = useRef<MapView | any>(null);
|
|
35
35
|
const following = useRef<boolean>(true);
|
|
36
36
|
const [isFocused, setIsFocused] = useState(false)
|
|
37
37
|
const [locationSelected, setLocationSelected] = useState<any>(null)
|
|
@@ -44,15 +44,6 @@ const MapViewComponent = (props: MapViewParams) => {
|
|
|
44
44
|
|
|
45
45
|
const location = { lat: userLocation?.latitude, lng: userLocation?.longitude }
|
|
46
46
|
const haveOrders = Object.values(markerGroups)?.length > 0 && Object.values(customerMarkerGroups)?.length > 0
|
|
47
|
-
|
|
48
|
-
const ASPECT_RATIO = useMemo(() => {
|
|
49
|
-
if (typeof width !== 'number' || typeof height !== 'number' || height === 0) {
|
|
50
|
-
console.error('Invalid screen dimensions');
|
|
51
|
-
return 0.3 // Valor predeterminado o manejo de error
|
|
52
|
-
}
|
|
53
|
-
return width / height;
|
|
54
|
-
}, [width, height])
|
|
55
|
-
|
|
56
47
|
const closeAlert = () => {
|
|
57
48
|
setAlertState({
|
|
58
49
|
open: false,
|
|
@@ -107,7 +98,7 @@ const MapViewComponent = (props: MapViewParams) => {
|
|
|
107
98
|
}, [userLocation, locationSelected]);
|
|
108
99
|
|
|
109
100
|
|
|
110
|
-
|
|
101
|
+
useEffect(() => {
|
|
111
102
|
if (isFocused) {
|
|
112
103
|
getBusinessLocations()
|
|
113
104
|
}
|
|
@@ -121,14 +112,6 @@ const MapViewComponent = (props: MapViewParams) => {
|
|
|
121
112
|
};
|
|
122
113
|
}, [isFocused]);
|
|
123
114
|
|
|
124
|
-
useEffect(() => {
|
|
125
|
-
return () => {
|
|
126
|
-
if (mapRef) {
|
|
127
|
-
mapRef.current = null
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}, [])
|
|
131
|
-
|
|
132
115
|
useFocusEffect(
|
|
133
116
|
useCallback(() => {
|
|
134
117
|
setIsFocused(true)
|
|
@@ -138,7 +121,7 @@ const MapViewComponent = (props: MapViewParams) => {
|
|
|
138
121
|
setLocationSelected(null)
|
|
139
122
|
}
|
|
140
123
|
}, [])
|
|
141
|
-
)
|
|
124
|
+
)
|
|
142
125
|
|
|
143
126
|
const styles = StyleSheet.create({
|
|
144
127
|
image: {
|
|
@@ -273,8 +256,8 @@ const MapViewComponent = (props: MapViewParams) => {
|
|
|
273
256
|
ref={mapRef}
|
|
274
257
|
provider={PROVIDER_GOOGLE}
|
|
275
258
|
initialRegion={{
|
|
276
|
-
latitude: initialPosition?.latitude
|
|
277
|
-
longitude: initialPosition?.longitude
|
|
259
|
+
latitude: initialPosition?.latitude || 0,
|
|
260
|
+
longitude: initialPosition?.longitude || 0,
|
|
278
261
|
latitudeDelta: haveOrders ? 0.01 : 0.1,
|
|
279
262
|
longitudeDelta: haveOrders ? 0.01 * ASPECT_RATIO : 0.1 * ASPECT_RATIO,
|
|
280
263
|
}}
|
|
@@ -287,44 +270,42 @@ const MapViewComponent = (props: MapViewParams) => {
|
|
|
287
270
|
onTouchStart={() => (following.current = false)}
|
|
288
271
|
>
|
|
289
272
|
<>
|
|
290
|
-
{Object.values(markerGroups).
|
|
273
|
+
{Object.values(markerGroups).map((marker: any) => (
|
|
291
274
|
<RenderMarker
|
|
292
275
|
key={marker[0]?.business_id}
|
|
293
276
|
marker={marker[0]}
|
|
294
277
|
orderIds={marker.map((order: any) => order.id).join(', ')}
|
|
295
278
|
/>
|
|
296
|
-
))
|
|
297
|
-
{Object.values(customerMarkerGroups).
|
|
279
|
+
))}
|
|
280
|
+
{Object.values(customerMarkerGroups).map((marker: any) => (
|
|
298
281
|
<RenderMarker
|
|
299
282
|
key={marker[0]?.customer_id}
|
|
300
283
|
marker={marker[0]}
|
|
301
284
|
orderIds={marker.map((order: any) => order.id).join(', ')}
|
|
302
285
|
customer
|
|
303
286
|
/>
|
|
304
|
-
))
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
287
|
+
))}
|
|
288
|
+
<Marker
|
|
289
|
+
coordinate={{
|
|
290
|
+
latitude: typeof location.lat === 'number' && !Number.isNaN(location.lat) ? location.lat : 0,
|
|
291
|
+
longitude: typeof location.lng === 'number' && !Number.isNaN(location.lng) ? location.lng : 0,
|
|
292
|
+
}}
|
|
293
|
+
title={t('YOUR_LOCATION', 'Your Location')}
|
|
294
|
+
>
|
|
295
|
+
<Icon
|
|
296
|
+
name="map-marker"
|
|
297
|
+
size={50}
|
|
298
|
+
color={theme.colors.primary}
|
|
299
|
+
/>
|
|
300
|
+
<View style={styles.view}>
|
|
301
|
+
<OIcon
|
|
302
|
+
style={styles.image}
|
|
303
|
+
src={{ uri: user.photo }}
|
|
304
|
+
width={25}
|
|
305
|
+
height={25}
|
|
317
306
|
/>
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
style={styles.image}
|
|
321
|
-
src={{ uri: user.photo }}
|
|
322
|
-
width={25}
|
|
323
|
-
height={25}
|
|
324
|
-
/>
|
|
325
|
-
</View>
|
|
326
|
-
</Marker>
|
|
327
|
-
) : null}
|
|
307
|
+
</View>
|
|
308
|
+
</Marker>
|
|
328
309
|
</>
|
|
329
310
|
</MapView>
|
|
330
311
|
<OFab
|