ordering-ui-react-native 0.23.74-test4 → 0.23.75-test
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 } from 'react';
|
|
1
|
+
import React, { useState, useEffect, useRef, useCallback, useMemo } 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,7 +30,7 @@ const MapViewComponent = (props: MapViewParams) => {
|
|
|
30
30
|
const [, t] = useLanguage();
|
|
31
31
|
const [{ user }] = useSession()
|
|
32
32
|
const { width, height } = Dimensions.get('window');
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
const mapRef = useRef<MapView | any>(null);
|
|
35
35
|
const following = useRef<boolean>(true);
|
|
36
36
|
const [isFocused, setIsFocused] = useState(false)
|
|
@@ -44,6 +44,15 @@ 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 .3 // Valor predeterminado o manejo de error
|
|
52
|
+
}
|
|
53
|
+
return width / height;
|
|
54
|
+
}, [width, height])
|
|
55
|
+
|
|
47
56
|
const closeAlert = () => {
|
|
48
57
|
setAlertState({
|
|
49
58
|
open: false,
|
|
@@ -51,7 +60,7 @@ const MapViewComponent = (props: MapViewParams) => {
|
|
|
51
60
|
});
|
|
52
61
|
};
|
|
53
62
|
|
|
54
|
-
const fitCoordinates = (location?: any) => {
|
|
63
|
+
/* const fitCoordinates = (location?: any) => {
|
|
55
64
|
if (mapRef.current && typeof location.latitude === 'number' && !Number.isNaN(location.latitude) && typeof location.longitude === 'number' && !Number.isNaN(location.longitude)) {
|
|
56
65
|
const isSendCoordinates =
|
|
57
66
|
location &&
|
|
@@ -73,7 +82,7 @@ const MapViewComponent = (props: MapViewParams) => {
|
|
|
73
82
|
},
|
|
74
83
|
);
|
|
75
84
|
}
|
|
76
|
-
};
|
|
85
|
+
}; */
|
|
77
86
|
|
|
78
87
|
const onPressZoomIn = () => {
|
|
79
88
|
const lastRegion = mapRef?.current?.__lastRegion
|
|
@@ -93,9 +102,9 @@ const MapViewComponent = (props: MapViewParams) => {
|
|
|
93
102
|
})
|
|
94
103
|
}
|
|
95
104
|
|
|
96
|
-
useEffect(() => {
|
|
105
|
+
/* useEffect(() => {
|
|
97
106
|
fitCoordinates(locationSelected || userLocation);
|
|
98
|
-
}, [userLocation, locationSelected]);
|
|
107
|
+
}, [userLocation, locationSelected]); */
|
|
99
108
|
|
|
100
109
|
|
|
101
110
|
useEffect(() => {
|
|
@@ -257,8 +266,8 @@ const MapViewComponent = (props: MapViewParams) => {
|
|
|
257
266
|
ref={mapRef}
|
|
258
267
|
provider={PROVIDER_GOOGLE}
|
|
259
268
|
initialRegion={{
|
|
260
|
-
latitude: initialPosition?.latitude
|
|
261
|
-
longitude: initialPosition?.longitude
|
|
269
|
+
latitude: initialPosition?.latitude ?? 0,
|
|
270
|
+
longitude: initialPosition?.longitude ?? 0,
|
|
262
271
|
latitudeDelta: haveOrders ? 0.01 : 0.1,
|
|
263
272
|
longitudeDelta: haveOrders ? 0.01 * ASPECT_RATIO : 0.1 * ASPECT_RATIO,
|
|
264
273
|
}}
|
|
@@ -271,7 +280,7 @@ const MapViewComponent = (props: MapViewParams) => {
|
|
|
271
280
|
onTouchStart={() => (following.current = false)}
|
|
272
281
|
>
|
|
273
282
|
<>
|
|
274
|
-
{
|
|
283
|
+
{Object.values(markerGroups).length ? (Object.values(markerGroups).map((marker: any) => (
|
|
275
284
|
<RenderMarker
|
|
276
285
|
key={marker[0]?.business_id}
|
|
277
286
|
marker={marker[0]}
|
|
@@ -285,7 +294,7 @@ const MapViewComponent = (props: MapViewParams) => {
|
|
|
285
294
|
orderIds={marker.map((order: any) => order.id).join(', ')}
|
|
286
295
|
customer
|
|
287
296
|
/>
|
|
288
|
-
))) : null}
|
|
297
|
+
))) : null}
|
|
289
298
|
{typeof location.lat === 'number' && !Number.isNaN(location.lat) && typeof location.lng === 'number' && !Number.isNaN(location.lng) ? (
|
|
290
299
|
<Marker
|
|
291
300
|
coordinate={{
|
|
@@ -73,6 +73,7 @@ const CartUI = (props: any) => {
|
|
|
73
73
|
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null, type: '' })
|
|
74
74
|
const [openPlaceModal, setOpenPlaceModal] = useState(false)
|
|
75
75
|
const [maxDate, setMaxDate] = useState<any>(null)
|
|
76
|
+
const [comment] = useState<any>(cart?.comment ?? '')
|
|
76
77
|
const isCartPending = cart?.status === 2
|
|
77
78
|
const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled
|
|
78
79
|
const business: any = (orderState?.carts && Object.values(orderState.carts).find((_cart: any) => _cart?.uuid === props.cartuuid)) ?? {}
|
|
@@ -523,7 +524,7 @@ const CartUI = (props: any) => {
|
|
|
523
524
|
<OText size={16} lineHeight={18}>{t('COMMENTS', 'Comments')}</OText>
|
|
524
525
|
<View style={{ flex: 1, width: '100%' }}>
|
|
525
526
|
<OInput
|
|
526
|
-
value={cart?.comment}
|
|
527
|
+
value={comment || cart?.comment}
|
|
527
528
|
placeholder={t('SPECIAL_COMMENTS', 'Special Comments')}
|
|
528
529
|
onChange={(value: string) => handleChangeComment(value)}
|
|
529
530
|
style={{
|
|
@@ -649,6 +650,7 @@ const CartUI = (props: any) => {
|
|
|
649
650
|
export const Cart = (props: any) => {
|
|
650
651
|
const cartProps = {
|
|
651
652
|
...props,
|
|
653
|
+
disablePreviousComment: true,
|
|
652
654
|
UIComponent: CartUI
|
|
653
655
|
}
|
|
654
656
|
|
|
@@ -59,6 +59,7 @@ const OrderSummaryUI = (props: any) => {
|
|
|
59
59
|
const [{ parsePrice, parseNumber }] = useUtils();
|
|
60
60
|
const commentRef = useRef()
|
|
61
61
|
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null, type: '' })
|
|
62
|
+
const [comment] = useState<any>(orderState?.carts?.[`businessId:${props.cart.business_id}`].comment ?? '')
|
|
62
63
|
const hideCartDiscount = hideCouponByValidationCheckout
|
|
63
64
|
const hideCartComments = hideCommentsByValidationCheckout
|
|
64
65
|
|
|
@@ -349,7 +350,7 @@ const OrderSummaryUI = (props: any) => {
|
|
|
349
350
|
<OText size={12}>{t('COMMENTS', 'Comments')}</OText>
|
|
350
351
|
<View style={{ flex: 1, width: '100%' }}>
|
|
351
352
|
<OInput
|
|
352
|
-
value={cart?.comment}
|
|
353
|
+
value={comment || cart?.comment}
|
|
353
354
|
placeholder={t('SPECIAL_COMMENTS', 'Special Comments')}
|
|
354
355
|
onChange={(value: string) => handleChangeComment(value)}
|
|
355
356
|
style={{
|
|
@@ -416,6 +417,7 @@ const OrderSummaryUI = (props: any) => {
|
|
|
416
417
|
export const OrderSummary = (props: any) => {
|
|
417
418
|
const orderSummaryProps = {
|
|
418
419
|
...props,
|
|
420
|
+
disablePreviousComment: true,
|
|
419
421
|
UIComponent: OrderSummaryUI
|
|
420
422
|
}
|
|
421
423
|
|