ordering-ui-react-native 0.22.75 → 0.22.76-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 +5 -7
- package/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/Checkout/index.tsx +40 -39
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/context/OfflineActions/index.tsx +236 -0
- package/src/providers/AlertProvider.tsx +3 -1
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +5 -3
- package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +1 -0
- package/themes/business/src/components/BusinessController/index.tsx +8 -3
- package/themes/business/src/components/BusinessProductList/index.tsx +3 -2
- package/themes/business/src/components/Chat/index.tsx +15 -3
- package/themes/business/src/components/DriverMap/index.tsx +44 -33
- package/themes/business/src/components/FloatingButton/index.tsx +3 -2
- package/themes/business/src/components/LanguageSelector/index.tsx +1 -1
- package/themes/business/src/components/LoginForm/index.tsx +123 -98
- package/themes/business/src/components/LogoutButton/index.tsx +13 -4
- package/themes/business/src/components/MapView/RenderMarker.tsx +146 -0
- package/themes/business/src/components/MapView/index.tsx +68 -142
- package/themes/business/src/components/NewOrderNotification/index.tsx +38 -54
- package/themes/business/src/components/OrderDetails/Business.tsx +56 -20
- package/themes/business/src/components/OrderDetails/Delivery.tsx +111 -42
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +146 -36
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +51 -28
- package/themes/business/src/components/OrderDetails/styles.tsx +39 -3
- package/themes/business/src/components/OrderDetails/usePrinterCommands.tsx +17 -16
- package/themes/business/src/components/OrderDetailsLogistic/index.tsx +3 -2
- package/themes/business/src/components/OrderSummary/index.tsx +271 -176
- package/themes/business/src/components/OrdersListManager/index.tsx +13 -1
- package/themes/business/src/components/OrdersOption/index.tsx +207 -144
- package/themes/business/src/components/OrdersOption/styles.tsx +14 -0
- package/themes/business/src/components/PreviousMessages/index.tsx +26 -3
- package/themes/business/src/components/PreviousOrders/OrderItem.tsx +20 -8
- package/themes/business/src/components/PreviousOrders/index.tsx +74 -66
- package/themes/business/src/components/PreviousOrders/styles.tsx +2 -1
- package/themes/business/src/components/PrinterEdition/MessageAlert.tsx +33 -0
- package/themes/business/src/components/PrinterEdition/index.tsx +143 -75
- package/themes/business/src/components/PrinterEdition/printerList.tsx +23 -0
- package/themes/business/src/components/PrinterSettings/index.tsx +1 -1
- package/themes/business/src/components/ProductItemAccordion/index.tsx +15 -16
- package/themes/business/src/components/ReviewCustomer/index.tsx +2 -0
- package/themes/business/src/components/StoresList/index.tsx +2 -2
- package/themes/business/src/components/UserProfileForm/index.tsx +48 -10
- package/themes/business/src/components/UserProfileForm/styles.tsx +7 -0
- package/themes/business/src/components/WebsocketStatus/index.tsx +2 -2
- package/themes/business/src/config/currency.tsx +1010 -0
- package/themes/business/src/hooks/useLocation.tsx +16 -12
- package/themes/business/src/layouts/SafeAreaContainer.tsx +35 -19
- package/themes/business/src/types/index.tsx +26 -4
- package/themes/business/src/utils/index.tsx +26 -2
- package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
- package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/kiosk/src/components/Checkout/index.tsx +9 -5
- package/themes/kiosk/src/components/CustomerName/index.tsx +1 -1
- package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
- package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
- package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
- package/themes/kiosk/src/components/PaymentOptions/index.tsx +121 -57
- package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
- package/themes/original/index.tsx +223 -219
- package/themes/original/src/components/AddressForm/index.tsx +56 -17
- package/themes/original/src/components/AppleLogin/index.tsx +3 -4
- package/themes/original/src/components/BusinessController/index.tsx +4 -2
- package/themes/original/src/components/BusinessItemAccordion/index.tsx +8 -3
- package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +102 -90
- package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +7 -3
- package/themes/original/src/components/BusinessListingSearch/index.tsx +8 -13
- package/themes/original/src/components/BusinessPreorder/index.tsx +30 -17
- package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +72 -69
- package/themes/original/src/components/BusinessProductsList/index.tsx +4 -5
- package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
- package/themes/original/src/components/BusinessProductsListing/index.tsx +5 -4
- package/themes/original/src/components/BusinessesListing/Layout/Appointment/styles.tsx +1 -0
- package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +2 -1
- package/themes/original/src/components/Cart/index.tsx +43 -12
- package/themes/original/src/components/Checkout/index.tsx +126 -98
- package/themes/original/src/components/FloatingButton/index.tsx +1 -1
- package/themes/original/src/components/GPSButton/index.tsx +2 -1
- package/themes/original/src/components/GoogleMap/index.tsx +3 -2
- package/themes/original/src/components/Help/functions.tsx +76 -0
- package/themes/original/src/components/Help/index.tsx +74 -29
- package/themes/original/src/components/Help/styles.tsx +4 -1
- package/themes/original/src/components/HelpOptions/index.tsx +53 -0
- package/themes/original/src/components/HighestRatedBusinesses/index.tsx +1 -1
- package/themes/original/src/components/Home/index.tsx +36 -11
- package/themes/original/src/components/LastOrder/index.tsx +1 -1
- package/themes/original/src/components/LoginForm/index.tsx +11 -5
- package/themes/original/src/components/MessageListing/index.tsx +1 -1
- package/themes/original/src/components/Messages/index.tsx +562 -555
- package/themes/original/src/components/MomentOption/TimeListItem.tsx +56 -0
- package/themes/original/src/components/MomentOption/index.tsx +141 -61
- package/themes/original/src/components/MomentOption/styles.tsx +1 -1
- package/themes/original/src/components/MomentSelector/index.tsx +5 -2
- package/themes/original/src/components/MultiCheckout/index.tsx +78 -33
- package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +2 -2
- package/themes/original/src/components/MultiOrdersDetails/index.tsx +2 -2
- package/themes/original/src/components/NavBar/index.tsx +6 -2
- package/themes/original/src/components/NotFoundSource/index.tsx +40 -39
- package/themes/original/src/components/NotFoundSource/styles.tsx +18 -9
- package/themes/original/src/components/OrderDetails/OrderEta.tsx +4 -3
- package/themes/original/src/components/OrderDetails/OrderHistory.tsx +11 -4
- package/themes/original/src/components/OrderDetails/index.tsx +44 -20
- package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
- package/themes/original/src/components/OrderProgress/index.tsx +5 -4
- package/themes/original/src/components/OrderSummary/index.tsx +32 -11
- package/themes/original/src/components/OrderTypeSelector/index.tsx +120 -120
- package/themes/original/src/components/OrdersOption/index.tsx +325 -325
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +1 -0
- package/themes/original/src/components/PaymentOptions/index.tsx +471 -459
- package/themes/original/src/components/PhoneInputNumber/index.tsx +92 -7
- package/themes/original/src/components/ProductItemAccordion/index.tsx +28 -37
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +15 -14
- package/themes/original/src/components/ServiceForm/index.tsx +2 -2
- package/themes/original/src/components/SignupForm/index.tsx +40 -24
- package/themes/original/src/components/SingleOrderCard/index.tsx +8 -5
- package/themes/original/src/components/SingleProductCard/index.tsx +2 -1
- package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
- package/themes/original/src/components/StripeCardsList/index.tsx +7 -1
- package/themes/original/src/components/StripeElementsForm/index.tsx +2 -2
- package/themes/original/src/components/TaxInformation/index.tsx +3 -2
- package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +7 -2
- package/themes/original/src/components/UserDetails/index.tsx +17 -16
- package/themes/original/src/components/UserFormDetails/index.tsx +109 -67
- package/themes/original/src/components/UserVerification/index.tsx +18 -5
- package/themes/original/src/components/VerifyPhone/index.tsx +1 -1
- package/themes/original/src/components/shared/OInput.tsx +97 -97
- package/themes/original/src/components/shared/OModal.tsx +7 -2
- package/themes/original/src/providers/AlertProvider.tsx +1 -1
- package/themes/original/src/types/index.tsx +700 -695
- package/themes/original/src/utils/index.tsx +50 -34
- package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/original/src/components/HelpAccountAndPayment/index.tsx +0 -62
- package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +0 -12
- package/themes/original/src/components/HelpGuide/index.tsx +0 -68
- package/themes/original/src/components/HelpGuide/styles.tsx +0 -12
- package/themes/original/src/components/HelpOrder/index.tsx +0 -71
- package/themes/original/src/components/HelpOrder/styles.tsx +0 -13
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react'
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
|
+
import { Callout, Marker } from 'react-native-maps'
|
|
4
|
+
import Icon from 'react-native-vector-icons/FontAwesome5';
|
|
5
|
+
import FastImage from 'react-native-fast-image';
|
|
6
|
+
import { useTheme } from 'styled-components/native';
|
|
7
|
+
|
|
8
|
+
import { useLanguage } from 'ordering-components/native';
|
|
9
|
+
import { OText } from '../shared';
|
|
10
|
+
import { RenderMarkerParams } from '../../types'
|
|
11
|
+
|
|
12
|
+
const styles = StyleSheet.create({
|
|
13
|
+
image: {
|
|
14
|
+
borderRadius: 50,
|
|
15
|
+
width: 25,
|
|
16
|
+
height: 25
|
|
17
|
+
},
|
|
18
|
+
view: {
|
|
19
|
+
width: 25,
|
|
20
|
+
position: 'absolute',
|
|
21
|
+
top: 6,
|
|
22
|
+
left: 6,
|
|
23
|
+
bottom: 0,
|
|
24
|
+
right: 0,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export const RenderMarker = (props: RenderMarkerParams) => {
|
|
29
|
+
const {
|
|
30
|
+
marker,
|
|
31
|
+
customer,
|
|
32
|
+
orderIds,
|
|
33
|
+
onNavigationRedirect,
|
|
34
|
+
initialPosition,
|
|
35
|
+
locationSelected,
|
|
36
|
+
setLocationSelected
|
|
37
|
+
} = props
|
|
38
|
+
const markerRef = useRef<any>()
|
|
39
|
+
const theme = useTheme()
|
|
40
|
+
const [, t] = useLanguage()
|
|
41
|
+
|
|
42
|
+
const [imageLoaded, setImageLoaded] = useState(false)
|
|
43
|
+
|
|
44
|
+
let coordinateLat = (customer
|
|
45
|
+
? typeof marker?.customer?.location?.lat === 'number' && !Number.isNaN(marker?.customer?.location?.lat)
|
|
46
|
+
? marker?.customer?.location?.lat
|
|
47
|
+
: 0
|
|
48
|
+
: typeof marker?.business?.location?.lat === 'number' && !Number.isNaN(marker?.business?.location?.lat)
|
|
49
|
+
? marker?.business?.location?.lat
|
|
50
|
+
: 0) ?? (initialPosition?.latitude || 0)
|
|
51
|
+
let coordinateLng = (customer
|
|
52
|
+
? typeof marker?.customer?.location?.lng === 'number' && !Number.isNaN(marker?.customer?.location?.lng)
|
|
53
|
+
? marker?.customer?.location?.lng
|
|
54
|
+
: 0
|
|
55
|
+
: typeof marker?.business?.location?.lng === 'number' && !Number.isNaN(marker?.business?.location?.lng)
|
|
56
|
+
? marker?.business?.location?.lng
|
|
57
|
+
: 0) ?? (initialPosition?.longitude || 0)
|
|
58
|
+
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (
|
|
61
|
+
markerRef?.current?.props?.coordinate?.latitude === locationSelected?.latitude &&
|
|
62
|
+
markerRef?.current?.props?.coordinate?.longitude === locationSelected?.longitude
|
|
63
|
+
) {
|
|
64
|
+
markerRef?.current?.showCallout()
|
|
65
|
+
}
|
|
66
|
+
}, [locationSelected])
|
|
67
|
+
|
|
68
|
+
const markerImage = customer ? marker?.customer?.photo ?? theme?.images?.dummies?.customerPhoto : marker?.business?.logo ?? theme?.images?.dummies?.businessLogo
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<Marker
|
|
72
|
+
key={customer ? marker?.customer?.id : marker?.business?.id}
|
|
73
|
+
coordinate={{
|
|
74
|
+
latitude: coordinateLat,
|
|
75
|
+
longitude: coordinateLng
|
|
76
|
+
}}
|
|
77
|
+
onPress={() =>
|
|
78
|
+
setLocationSelected({
|
|
79
|
+
latitude: coordinateLat,
|
|
80
|
+
longitude: coordinateLng
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
ref={(ref) => markerRef.current = ref}
|
|
84
|
+
tracksViewChanges={!imageLoaded}
|
|
85
|
+
>
|
|
86
|
+
<Icon
|
|
87
|
+
name="map-marker"
|
|
88
|
+
size={50}
|
|
89
|
+
color={theme.colors.primary}
|
|
90
|
+
/>
|
|
91
|
+
{!!markerImage && (
|
|
92
|
+
<View style={styles.view}>
|
|
93
|
+
<FastImage
|
|
94
|
+
style={styles.image}
|
|
95
|
+
source={markerImage?.includes('https') ? {
|
|
96
|
+
uri: markerImage,
|
|
97
|
+
priority: FastImage.priority.high,
|
|
98
|
+
cache: FastImage.cacheControl.immutable
|
|
99
|
+
} : markerImage}
|
|
100
|
+
resizeMode={FastImage.resizeMode.cover}
|
|
101
|
+
onLoadEnd={() => setImageLoaded(true)}
|
|
102
|
+
/>
|
|
103
|
+
</View>
|
|
104
|
+
)}
|
|
105
|
+
<Callout
|
|
106
|
+
onPress={() => !!orderIds && orderIds.toString().includes(',') ? onNavigationRedirect('Orders') : onNavigationRedirect('OrderDetails', { order: marker })}
|
|
107
|
+
>
|
|
108
|
+
<View style={{ flex: 1, width: 200, padding: 5 }}>
|
|
109
|
+
<OText weight='bold'>{customer ? `${marker?.customer?.name} ${marker?.customer?.lastname}` : marker?.business?.name}</OText>
|
|
110
|
+
<OText>
|
|
111
|
+
{!!orderIds && orderIds.toString().includes(',') ? (
|
|
112
|
+
<>
|
|
113
|
+
{t('ORDER_NUMBERS', 'Order Numbers')} {orderIds}
|
|
114
|
+
</>
|
|
115
|
+
) : (
|
|
116
|
+
<>
|
|
117
|
+
{t('ORDER_NUMBER', 'Order No.')} {marker?.id}
|
|
118
|
+
</>
|
|
119
|
+
)}
|
|
120
|
+
</OText>
|
|
121
|
+
<OText>{customer ? marker?.customer?.address : marker?.business?.address}</OText>
|
|
122
|
+
{((customer && marker?.customer?.city?.address_notes) || !customer) && (
|
|
123
|
+
<OText>{customer ? marker?.customer?.city?.address_notes : marker?.business?.city?.name}</OText>
|
|
124
|
+
)}
|
|
125
|
+
{((customer && !!marker?.business?.zipcode) || (!customer && !!marker?.business?.zipcode)) && (
|
|
126
|
+
<OText>{customer ? marker?.customer?.zipcode ?? '' : marker?.business?.zipcode ?? ''}</OText>
|
|
127
|
+
)}
|
|
128
|
+
{customer && !!marker?.customer?.internal_number && (
|
|
129
|
+
<OText>{marker?.customer?.internal_number}</OText>
|
|
130
|
+
)}
|
|
131
|
+
<OText textDecorationLine='underline' color={theme.colors.primary}>
|
|
132
|
+
{!!orderIds && orderIds.toString().includes(',') ? (
|
|
133
|
+
<>
|
|
134
|
+
{t('SHOW_ORDERS', 'Show orders')}
|
|
135
|
+
</>
|
|
136
|
+
) : (
|
|
137
|
+
<>
|
|
138
|
+
{t('MORE_INFO', 'More info')}
|
|
139
|
+
</>
|
|
140
|
+
)}
|
|
141
|
+
</OText>
|
|
142
|
+
</View>
|
|
143
|
+
</Callout>
|
|
144
|
+
</Marker>
|
|
145
|
+
)
|
|
146
|
+
}
|
|
@@ -1,20 +1,37 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
|
2
|
-
import { Dimensions, SafeAreaView, StyleSheet, View } from 'react-native';
|
|
1
|
+
import React, { useState, useEffect, useRef, useCallback, useMemo } from 'react';
|
|
2
|
+
import { Dimensions, Platform, SafeAreaView, StyleSheet, View } from 'react-native';
|
|
3
3
|
import { useFocusEffect } from '@react-navigation/native'
|
|
4
4
|
import MapView, {
|
|
5
5
|
PROVIDER_GOOGLE,
|
|
6
|
-
Marker
|
|
7
|
-
Callout
|
|
6
|
+
Marker
|
|
8
7
|
} from 'react-native-maps';
|
|
8
|
+
import FastImage from 'react-native-fast-image'
|
|
9
9
|
import { useLanguage, useSession, MapView as MapViewController } from 'ordering-components/native';
|
|
10
10
|
import { MapViewParams } from '../../types';
|
|
11
11
|
import Alert from '../../providers/AlertProvider';
|
|
12
12
|
import { useTheme } from 'styled-components/native';
|
|
13
13
|
import { useLocation } from '../../hooks/useLocation';
|
|
14
14
|
import Icon from 'react-native-vector-icons/FontAwesome5';
|
|
15
|
-
import {
|
|
16
|
-
|
|
15
|
+
import { OFab } from '../shared'
|
|
16
|
+
import { RenderMarker } from './RenderMarker'
|
|
17
|
+
|
|
18
|
+
const styles = StyleSheet.create({
|
|
19
|
+
image: {
|
|
20
|
+
borderRadius: 50,
|
|
21
|
+
width: 25,
|
|
22
|
+
height: 25
|
|
23
|
+
},
|
|
24
|
+
view: {
|
|
25
|
+
width: 25,
|
|
26
|
+
position: 'absolute',
|
|
27
|
+
top: 6,
|
|
28
|
+
left: 6,
|
|
29
|
+
bottom: 0,
|
|
30
|
+
right: 0,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
17
33
|
|
|
34
|
+
const MapViewComponent = (props: MapViewParams) => {
|
|
18
35
|
const {
|
|
19
36
|
isLoadingBusinessMarkers,
|
|
20
37
|
markerGroups,
|
|
@@ -24,6 +41,7 @@ const MapViewComponent = (props: MapViewParams) => {
|
|
|
24
41
|
setDriverLocation,
|
|
25
42
|
onNavigationRedirect,
|
|
26
43
|
getBusinessLocations,
|
|
44
|
+
isDeliveryApp
|
|
27
45
|
} = props;
|
|
28
46
|
|
|
29
47
|
const theme = useTheme();
|
|
@@ -35,6 +53,7 @@ const MapViewComponent = (props: MapViewParams) => {
|
|
|
35
53
|
const following = useRef<boolean>(true);
|
|
36
54
|
const [isFocused, setIsFocused] = useState(false)
|
|
37
55
|
const [locationSelected, setLocationSelected] = useState<any>(null)
|
|
56
|
+
const [imageLoaded, setImageLoaded] = useState(false)
|
|
38
57
|
const {
|
|
39
58
|
initialPosition,
|
|
40
59
|
userLocation,
|
|
@@ -42,7 +61,10 @@ const MapViewComponent = (props: MapViewParams) => {
|
|
|
42
61
|
followUserLocation
|
|
43
62
|
} = useLocation();
|
|
44
63
|
|
|
45
|
-
const location =
|
|
64
|
+
const location = useMemo(() => {
|
|
65
|
+
return { lat: userLocation?.latitude, lng: userLocation?.longitude }
|
|
66
|
+
}, [userLocation?.latitude, userLocation?.longitude])
|
|
67
|
+
|
|
46
68
|
const haveOrders = Object.values(markerGroups)?.length > 0 && Object.values(customerMarkerGroups)?.length > 0
|
|
47
69
|
const closeAlert = () => {
|
|
48
70
|
setAlertState({
|
|
@@ -53,19 +75,23 @@ const MapViewComponent = (props: MapViewParams) => {
|
|
|
53
75
|
|
|
54
76
|
const fitCoordinates = (location?: any) => {
|
|
55
77
|
if (mapRef.current) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
78
|
+
const isSendCoordinates =
|
|
79
|
+
location &&
|
|
80
|
+
userLocation &&
|
|
81
|
+
location.latitude !== userLocation.latitude &&
|
|
82
|
+
location.longitude !== userLocation.longitude &&
|
|
83
|
+
location.latitude !== 0 &&
|
|
84
|
+
location.longitude !== 0 &&
|
|
85
|
+
userLocation.latitude !== 0 &&
|
|
86
|
+
userLocation.longitude !== 0
|
|
87
|
+
|
|
88
|
+
isSendCoordinates && mapRef.current.fitToCoordinates(
|
|
89
|
+
[location, userLocation].map(_location => ({
|
|
90
|
+
latitude: _location.latitude,
|
|
91
|
+
longitude: _location.longitude
|
|
92
|
+
})),
|
|
67
93
|
{
|
|
68
|
-
edgePadding: { top: 120, right: 120, bottom: 120, left: 120 }
|
|
94
|
+
edgePadding: { top: 120, right: 120, bottom: 120, left: 120 }
|
|
69
95
|
},
|
|
70
96
|
);
|
|
71
97
|
}
|
|
@@ -119,120 +145,6 @@ const MapViewComponent = (props: MapViewParams) => {
|
|
|
119
145
|
}, [])
|
|
120
146
|
)
|
|
121
147
|
|
|
122
|
-
const styles = StyleSheet.create({
|
|
123
|
-
image: {
|
|
124
|
-
borderRadius: 50,
|
|
125
|
-
},
|
|
126
|
-
view: {
|
|
127
|
-
width: 25,
|
|
128
|
-
position: 'absolute',
|
|
129
|
-
top: 6,
|
|
130
|
-
left: 6,
|
|
131
|
-
bottom: 0,
|
|
132
|
-
right: 0,
|
|
133
|
-
},
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
const RenderMarker = ({ marker, customer, orderIds }: { marker: any, customer?: boolean, orderIds?: Array<number> }) => {
|
|
137
|
-
const markerRef = useRef<any>()
|
|
138
|
-
|
|
139
|
-
let coordinateLat = (customer
|
|
140
|
-
? typeof marker?.customer?.location?.lat === 'number' && !Number.isNaN(marker?.customer?.location?.lat)
|
|
141
|
-
? marker?.customer?.location?.lat
|
|
142
|
-
: 0
|
|
143
|
-
: typeof marker?.business?.location?.lat === 'number' && !Number.isNaN(marker?.business?.location?.lat)
|
|
144
|
-
? marker?.business?.location?.lat
|
|
145
|
-
: 0) ?? (initialPosition?.latitude || 0)
|
|
146
|
-
let coordinateLng = (customer
|
|
147
|
-
? typeof marker?.customer?.location?.lng === 'number' && !Number.isNaN(marker?.customer?.location?.lng)
|
|
148
|
-
? marker?.customer?.location?.lng
|
|
149
|
-
: 0
|
|
150
|
-
: typeof marker?.business?.location?.lng === 'number' && !Number.isNaN(marker?.business?.location?.lng)
|
|
151
|
-
? marker?.business?.location?.lng
|
|
152
|
-
: 0) ?? (initialPosition?.longitude || 0)
|
|
153
|
-
|
|
154
|
-
useEffect(() => {
|
|
155
|
-
if (
|
|
156
|
-
markerRef?.current?.props?.coordinate?.latitude === locationSelected?.latitude &&
|
|
157
|
-
markerRef?.current?.props?.coordinate?.longitude === locationSelected?.longitude
|
|
158
|
-
) {
|
|
159
|
-
markerRef?.current?.showCallout()
|
|
160
|
-
}
|
|
161
|
-
}, [locationSelected])
|
|
162
|
-
|
|
163
|
-
return (
|
|
164
|
-
<Marker
|
|
165
|
-
key={customer ? marker?.customer?.id : marker?.business?.id}
|
|
166
|
-
coordinate={{
|
|
167
|
-
latitude: coordinateLat,
|
|
168
|
-
longitude: coordinateLng
|
|
169
|
-
}}
|
|
170
|
-
onPress={() =>
|
|
171
|
-
setLocationSelected({
|
|
172
|
-
latitude: coordinateLat,
|
|
173
|
-
longitude: coordinateLng
|
|
174
|
-
})
|
|
175
|
-
}
|
|
176
|
-
ref={(ref) => markerRef.current = ref}
|
|
177
|
-
>
|
|
178
|
-
<Icon
|
|
179
|
-
name="map-marker"
|
|
180
|
-
size={50}
|
|
181
|
-
color={theme.colors.primary}
|
|
182
|
-
/>
|
|
183
|
-
{(!!marker?.customer?.photo || !!marker?.business?.logo) && (
|
|
184
|
-
<View style={styles.view}>
|
|
185
|
-
<OIcon
|
|
186
|
-
style={styles.image}
|
|
187
|
-
src={{ uri: customer ? marker?.customer?.photo : marker?.business?.logo }}
|
|
188
|
-
width={25}
|
|
189
|
-
height={25}
|
|
190
|
-
/>
|
|
191
|
-
</View>
|
|
192
|
-
)}
|
|
193
|
-
<Callout
|
|
194
|
-
onPress={() => !!orderIds && orderIds.toString().includes(',') ? onNavigationRedirect('Orders') : onNavigationRedirect('OrderDetails', { order: marker })}
|
|
195
|
-
>
|
|
196
|
-
<View style={{ flex: 1, width: 200, padding: 5 }}>
|
|
197
|
-
<OText weight='bold'>{customer ? `${marker?.customer?.name} ${marker?.customer?.lastname}` : marker?.business?.name}</OText>
|
|
198
|
-
<OText>
|
|
199
|
-
{!!orderIds && orderIds.toString().includes(',') ? (
|
|
200
|
-
<>
|
|
201
|
-
{t('ORDER_NUMBERS', 'Order Numbers')} {orderIds}
|
|
202
|
-
</>
|
|
203
|
-
) : (
|
|
204
|
-
<>
|
|
205
|
-
{t('ORDER_NUMBER', 'Order No.')} {marker?.id}
|
|
206
|
-
</>
|
|
207
|
-
)}
|
|
208
|
-
</OText>
|
|
209
|
-
<OText>{customer ? marker?.customer?.address : marker?.business?.address}</OText>
|
|
210
|
-
{((customer && marker?.customer?.city?.address_notes) || !customer) && (
|
|
211
|
-
<OText>{customer ? marker?.customer?.city?.address_notes : marker?.business?.city?.name}</OText>
|
|
212
|
-
)}
|
|
213
|
-
{((customer && !!marker?.business?.zipcode) || (!customer && !!marker?.business?.zipcode)) && (
|
|
214
|
-
<OText>{customer ? marker?.customer?.zipcode ?? '' : marker?.business?.zipcode ?? ''}</OText>
|
|
215
|
-
)}
|
|
216
|
-
{customer && !!marker?.customer?.internal_number && (
|
|
217
|
-
<OText>{marker?.customer?.internal_number}</OText>
|
|
218
|
-
)}
|
|
219
|
-
<OText textDecorationLine='underline' color={theme.colors.primary}>
|
|
220
|
-
{!!orderIds && orderIds.toString().includes(',') ? (
|
|
221
|
-
<>
|
|
222
|
-
{t('SHOW_ORDERS', 'Show orders')}
|
|
223
|
-
</>
|
|
224
|
-
) : (
|
|
225
|
-
<>
|
|
226
|
-
{t('MORE_INFO', 'More info')}
|
|
227
|
-
</>
|
|
228
|
-
)}
|
|
229
|
-
</OText>
|
|
230
|
-
</View>
|
|
231
|
-
</Callout>
|
|
232
|
-
</Marker>
|
|
233
|
-
)
|
|
234
|
-
}
|
|
235
|
-
|
|
236
148
|
useEffect(() => {
|
|
237
149
|
if (userLocation?.latitude !== 0 && userLocation?.longitude !== 0) {
|
|
238
150
|
const location = {
|
|
@@ -243,31 +155,39 @@ const MapViewComponent = (props: MapViewParams) => {
|
|
|
243
155
|
}
|
|
244
156
|
}, [userLocation])
|
|
245
157
|
|
|
158
|
+
const renderMarkerDefaultProps = {
|
|
159
|
+
onNavigationRedirect: onNavigationRedirect,
|
|
160
|
+
initialPosition: initialPosition,
|
|
161
|
+
locationSelected: locationSelected,
|
|
162
|
+
setLocationSelected: setLocationSelected
|
|
163
|
+
}
|
|
164
|
+
|
|
246
165
|
return (
|
|
247
166
|
<SafeAreaView style={{ flex: 1 }}>
|
|
248
167
|
<View style={{ flex: 1 }}>
|
|
249
|
-
{!isLoadingBusinessMarkers && isFocused && (
|
|
168
|
+
{(isDeliveryApp || (!isLoadingBusinessMarkers && isFocused)) && !!initialPosition?.latitude && !!initialPosition?.longitude && (
|
|
250
169
|
<View style={{ flex: 1 }}>
|
|
251
170
|
<MapView
|
|
252
171
|
ref={mapRef}
|
|
253
172
|
provider={PROVIDER_GOOGLE}
|
|
254
173
|
initialRegion={{
|
|
255
|
-
latitude: initialPosition?.latitude
|
|
256
|
-
longitude: initialPosition?.longitude
|
|
174
|
+
latitude: initialPosition?.latitude,
|
|
175
|
+
longitude: initialPosition?.longitude,
|
|
257
176
|
latitudeDelta: haveOrders ? 0.01 : 0.1,
|
|
258
177
|
longitudeDelta: haveOrders ? 0.01 * ASPECT_RATIO : 0.1 * ASPECT_RATIO,
|
|
259
178
|
}}
|
|
260
179
|
style={{ flex: 1 }}
|
|
261
180
|
zoomTapEnabled
|
|
262
181
|
zoomEnabled
|
|
263
|
-
zoomControlEnabled
|
|
264
|
-
cacheEnabled
|
|
182
|
+
zoomControlEnabled={!(isDeliveryApp && Platform.OS === 'android')}
|
|
183
|
+
cacheEnabled={(isDeliveryApp && Platform.OS === 'android' && isFocused) || Platform.OS === 'ios' || !isDeliveryApp}
|
|
265
184
|
moveOnMarkerPress
|
|
266
185
|
onTouchStart={() => (following.current = false)}
|
|
267
186
|
>
|
|
268
187
|
<>
|
|
269
188
|
{Object.values(markerGroups).map((marker: any) => (
|
|
270
189
|
<RenderMarker
|
|
190
|
+
{...renderMarkerDefaultProps}
|
|
271
191
|
key={marker[0]?.business_id}
|
|
272
192
|
marker={marker[0]}
|
|
273
193
|
orderIds={marker.map((order: any) => order.id).join(', ')}
|
|
@@ -275,6 +195,7 @@ const MapViewComponent = (props: MapViewParams) => {
|
|
|
275
195
|
))}
|
|
276
196
|
{Object.values(customerMarkerGroups).map((marker: any) => (
|
|
277
197
|
<RenderMarker
|
|
198
|
+
{...renderMarkerDefaultProps}
|
|
278
199
|
key={marker[0]?.customer_id}
|
|
279
200
|
marker={marker[0]}
|
|
280
201
|
orderIds={marker.map((order: any) => order.id).join(', ')}
|
|
@@ -282,6 +203,7 @@ const MapViewComponent = (props: MapViewParams) => {
|
|
|
282
203
|
/>
|
|
283
204
|
))}
|
|
284
205
|
<Marker
|
|
206
|
+
tracksViewChanges={!imageLoaded}
|
|
285
207
|
coordinate={{
|
|
286
208
|
latitude: typeof location.lat === 'number' && !Number.isNaN(location.lat) ? location.lat : 0,
|
|
287
209
|
longitude: typeof location.lng === 'number' && !Number.isNaN(location.lng) ? location.lng : 0,
|
|
@@ -294,11 +216,15 @@ const MapViewComponent = (props: MapViewParams) => {
|
|
|
294
216
|
color={theme.colors.primary}
|
|
295
217
|
/>
|
|
296
218
|
<View style={styles.view}>
|
|
297
|
-
<
|
|
219
|
+
<FastImage
|
|
298
220
|
style={styles.image}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
221
|
+
source={user.photo?.includes('https') ? {
|
|
222
|
+
uri: user.photo,
|
|
223
|
+
priority: FastImage.priority.high,
|
|
224
|
+
cache: FastImage.cacheControl.immutable
|
|
225
|
+
} : user.photo ?? theme?.images?.dummies?.driverPhoto}
|
|
226
|
+
resizeMode={FastImage.resizeMode.cover}
|
|
227
|
+
onLoadEnd={() => setImageLoaded(true)}
|
|
302
228
|
/>
|
|
303
229
|
</View>
|
|
304
230
|
</Marker>
|
|
@@ -4,10 +4,7 @@ import {
|
|
|
4
4
|
View,
|
|
5
5
|
StyleSheet,
|
|
6
6
|
Dimensions,
|
|
7
|
-
TouchableOpacity
|
|
8
|
-
NativeModules,
|
|
9
|
-
PermissionsAndroid,
|
|
10
|
-
Platform
|
|
7
|
+
TouchableOpacity
|
|
11
8
|
} from 'react-native';
|
|
12
9
|
import { useTheme } from 'styled-components/native'
|
|
13
10
|
import moment from 'moment'
|
|
@@ -20,7 +17,6 @@ import {
|
|
|
20
17
|
useEvent,
|
|
21
18
|
useLanguage,
|
|
22
19
|
useSession,
|
|
23
|
-
useConfig,
|
|
24
20
|
useToast,
|
|
25
21
|
ToastType
|
|
26
22
|
} from 'ordering-components/native'
|
|
@@ -36,48 +32,25 @@ const SoundPlayerComponent = (props: any) => {
|
|
|
36
32
|
const { evtList, currentEvent, handleCloseEvents } = props
|
|
37
33
|
|
|
38
34
|
const theme = useTheme()
|
|
39
|
-
const
|
|
40
|
-
const [isEnabledReadStorage, setIsEnabledReadStorage] = useState(true)
|
|
41
|
-
const URL_SOUND = 'https://d33aymufw4jvwf.cloudfront.net/notification.mp3' ?? theme.sounds.notification
|
|
35
|
+
const URL_SOUND = 'https://d33aymufw4jvwf.cloudfront.net/notification.mp3'
|
|
42
36
|
|
|
43
37
|
useEffect(() => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const playSound = async () => {
|
|
38
|
+
if (!currentEvent?.orderId) return
|
|
39
|
+
const playSound = () => {
|
|
47
40
|
try {
|
|
48
41
|
SoundPlayer.playUrl(URL_SOUND)
|
|
49
|
-
|
|
50
|
-
SoundPlayer.stop()
|
|
51
|
-
} catch (err: any) {
|
|
42
|
+
} catch (e) {
|
|
52
43
|
console.log('Sound Error - ', err.message)
|
|
53
44
|
}
|
|
54
45
|
}
|
|
55
|
-
if (NativeModules?.RNSoundPlayer?.playUrl && typeof URL_SOUND === 'string' && isEnabledReadStorage) {
|
|
56
|
-
playSound()
|
|
57
|
-
}
|
|
58
46
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
SoundPlayer.stop()
|
|
63
|
-
} catch (err: any) {
|
|
64
|
-
console.log('Sound Error - ', err.message)
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}, [count, isEnabledReadStorage])
|
|
47
|
+
const interval = setInterval(() => {
|
|
48
|
+
playSound()
|
|
49
|
+
}, DELAY_SOUND)
|
|
68
50
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (Platform.OS === 'android') {
|
|
72
|
-
const enabled = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE)
|
|
73
|
-
setIsEnabledReadStorage(enabled)
|
|
74
|
-
} else {
|
|
75
|
-
setIsEnabledReadStorage(true)
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
// checkSoundMedia()
|
|
51
|
+
return () => clearInterval(interval)
|
|
52
|
+
}, [currentEvent?.orderId])
|
|
79
53
|
|
|
80
|
-
}, [])
|
|
81
54
|
return (
|
|
82
55
|
<Modal
|
|
83
56
|
animationType='slide'
|
|
@@ -129,7 +102,7 @@ const NewOrderNotificationUI = (props: any) => {
|
|
|
129
102
|
const handleEventNotification = async (evtType: number, value: any, orderStatus?: any) => {
|
|
130
103
|
if (value?.driver) {
|
|
131
104
|
try {
|
|
132
|
-
const location = await getCurrentLocation()
|
|
105
|
+
const location: any = await getCurrentLocation()
|
|
133
106
|
if (!location?.latitude || !location?.longitude) {
|
|
134
107
|
showToast(t('ERROR_UPDATING_COORDS', 'Error updating coords'), ToastType.Error)
|
|
135
108
|
return
|
|
@@ -140,7 +113,8 @@ const NewOrderNotificationUI = (props: any) => {
|
|
|
140
113
|
location: JSON.stringify({
|
|
141
114
|
location: `{
|
|
142
115
|
lat: ${location.latitude},
|
|
143
|
-
lng: ${location.longitude}
|
|
116
|
+
lng: ${location.longitude},
|
|
117
|
+
mock: ${location.mocked}
|
|
144
118
|
}`
|
|
145
119
|
})
|
|
146
120
|
}),
|
|
@@ -153,35 +127,45 @@ const NewOrderNotificationUI = (props: any) => {
|
|
|
153
127
|
const duration = moment.duration(moment().diff(moment.utc(value?.last_driver_assigned_at)))
|
|
154
128
|
const assignedSecondsDiff = duration.asSeconds()
|
|
155
129
|
if (assignedSecondsDiff < 5 && !isBusinessApp && !value?.logistic_status) {
|
|
156
|
-
setCurrentEvent({ evt: 2, orderId: value?.id ?? value?.order_id })
|
|
130
|
+
setCurrentEvent(() => ({ evt: 2, orderId: value?.id ?? value?.order_id }))
|
|
157
131
|
}
|
|
158
132
|
}
|
|
159
|
-
if ((!orderStatus.includes(value.status) && evtType !== 1 && isBusinessApp) || value?.author_id === user.id) return
|
|
160
|
-
setCurrentEvent({
|
|
133
|
+
if ((!orderStatus.includes(value.status) && evtType !== 1 && isBusinessApp && orderStatus?.length > 0) || value?.author_id === user.id) return
|
|
134
|
+
setCurrentEvent(() => ({
|
|
161
135
|
evt: evtType,
|
|
162
136
|
orderId: value?.driver
|
|
163
137
|
? value?.order_id ?? value?.id
|
|
164
138
|
: evtList(currentEvent)[evtType].event === 'messages'
|
|
165
139
|
? value?.order?.id
|
|
166
140
|
: value?.order_id ?? value?.id
|
|
167
|
-
})
|
|
141
|
+
}))
|
|
168
142
|
}
|
|
169
143
|
|
|
170
144
|
useEffect(() => {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
145
|
+
const handleEventTypeOne = (o: any) => {
|
|
146
|
+
handleEventNotification(1, o, orderStatus)
|
|
147
|
+
}
|
|
148
|
+
const handleEventTypeTwo = (o: any) => {
|
|
149
|
+
handleEventNotification(2, o, orderStatus)
|
|
150
|
+
}
|
|
151
|
+
const handleEventTypeThree = (o: any) => {
|
|
152
|
+
handleEventNotification(3, o, orderStatus)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
events.on('message_added_notification', handleEventTypeOne)
|
|
156
|
+
events.on('order_added_notification', handleEventTypeTwo)
|
|
157
|
+
events.on('order_updated_notification', handleEventTypeThree)
|
|
158
|
+
events.on('request_register_notification', handleEventTypeTwo)
|
|
159
|
+
events.on('request_update_notification', handleEventTypeThree)
|
|
176
160
|
|
|
177
161
|
return () => {
|
|
178
|
-
events.off('message_added_notification',
|
|
179
|
-
events.off('order_added_notification',
|
|
180
|
-
events.off('order_updated_notification',
|
|
181
|
-
events.off('request_register_notification',
|
|
182
|
-
events.off('request_update_notification',
|
|
162
|
+
events.off('message_added_notification', handleEventTypeOne)
|
|
163
|
+
events.off('order_added_notification', handleEventTypeTwo)
|
|
164
|
+
events.off('order_updated_notification', handleEventTypeThree)
|
|
165
|
+
events.off('request_register_notification', handleEventTypeTwo)
|
|
166
|
+
events.off('request_update_notification', handleEventTypeThree)
|
|
183
167
|
}
|
|
184
|
-
}, [orderStatus])
|
|
168
|
+
}, [orderStatus, events])
|
|
185
169
|
|
|
186
170
|
useEffect(() => {
|
|
187
171
|
return () => setCurrentEvent(null)
|