ordering-ui-react-native 0.12.18 → 0.12.19
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/config.json +2 -2
- package/themes/business/src/components 2/AcceptOrRejectOrder/index.tsx +0 -389
- package/themes/business/src/components 2/AcceptOrRejectOrder/styles.tsx +0 -36
- package/themes/business/src/components 2/BusinessController/index.tsx +0 -155
- package/themes/business/src/components 2/BusinessController/styles.tsx +0 -19
- package/themes/business/src/components 2/Chat/index.tsx +0 -1152
- package/themes/business/src/components 2/Chat/styles.tsx +0 -12
- package/themes/business/src/components 2/Contacts/index.tsx +0 -299
- package/themes/business/src/components 2/Contacts/styles.tsx +0 -42
- package/themes/business/src/components 2/DriverMap/index.tsx +0 -525
- package/themes/business/src/components 2/FloatingButton/index.tsx +0 -141
- package/themes/business/src/components 2/FloatingButton/styles.tsx +0 -35
- package/themes/business/src/components 2/ForgotPasswordForm/index.tsx +0 -204
- package/themes/business/src/components 2/ForgotPasswordForm/styles.tsx +0 -11
- package/themes/business/src/components 2/GoogleMap/index.tsx +0 -347
- package/themes/business/src/components 2/Home/index.tsx +0 -111
- package/themes/business/src/components 2/Home/styles.tsx +0 -27
- package/themes/business/src/components 2/LanguageSelector/index.tsx +0 -124
- package/themes/business/src/components 2/LanguageSelector/lang_country.json +0 -152
- package/themes/business/src/components 2/LanguageSelector/styles.tsx +0 -17
- package/themes/business/src/components 2/LoginForm/index.tsx +0 -663
- package/themes/business/src/components 2/LoginForm/styles.tsx +0 -48
- package/themes/business/src/components 2/LogoutButton/index.tsx +0 -63
- package/themes/business/src/components 2/MapView/index.tsx +0 -317
- package/themes/business/src/components 2/MessagesOption/index.tsx +0 -337
- package/themes/business/src/components 2/MessagesOption/styles.tsx +0 -27
- package/themes/business/src/components 2/NewOrderNotification/index.tsx +0 -167
- package/themes/business/src/components 2/NewOrderNotification/styles.tsx +0 -8
- package/themes/business/src/components 2/NotFoundSource/index.tsx +0 -52
- package/themes/business/src/components 2/NotFoundSource/styles.tsx +0 -17
- package/themes/business/src/components 2/OrderDetails/Business.tsx +0 -683
- package/themes/business/src/components 2/OrderDetails/Delivery.tsx +0 -454
- package/themes/business/src/components 2/OrderDetails/OrderContentComponent.tsx +0 -391
- package/themes/business/src/components 2/OrderDetails/OrderHeaderComponent.tsx +0 -148
- package/themes/business/src/components 2/OrderDetails/styles.tsx +0 -84
- package/themes/business/src/components 2/OrderMessage/index.tsx +0 -344
- package/themes/business/src/components 2/OrderMessage/styles.tsx +0 -5
- package/themes/business/src/components 2/OrderSummary/index.tsx +0 -700
- package/themes/business/src/components 2/OrderSummary/styles.tsx +0 -61
- package/themes/business/src/components 2/OrdersOption/index.tsx +0 -755
- package/themes/business/src/components 2/OrdersOption/styles.tsx +0 -54
- package/themes/business/src/components 2/OrdersOptionBusiness/index.tsx +0 -51
- package/themes/business/src/components 2/OrdersOptionBusiness/styles.tsx +0 -8
- package/themes/business/src/components 2/OrdersOptionCity/index.tsx +0 -52
- package/themes/business/src/components 2/OrdersOptionCity/styles.tsx +0 -8
- package/themes/business/src/components 2/OrdersOptionDate/index.tsx +0 -52
- package/themes/business/src/components 2/OrdersOptionDate/styles.tsx +0 -8
- package/themes/business/src/components 2/OrdersOptionDelivery/index.tsx +0 -35
- package/themes/business/src/components 2/OrdersOptionDelivery/styles.tsx +0 -8
- package/themes/business/src/components 2/OrdersOptionDriver/index.tsx +0 -50
- package/themes/business/src/components 2/OrdersOptionDriver/styles.tsx +0 -8
- package/themes/business/src/components 2/OrdersOptionPaymethod/index.tsx +0 -49
- package/themes/business/src/components 2/OrdersOptionPaymethod/styles.tsx +0 -8
- package/themes/business/src/components 2/OrdersOptionStatus/index.tsx +0 -46
- package/themes/business/src/components 2/OrdersOptionStatus/styles.tsx +0 -8
- package/themes/business/src/components 2/PhoneInputNumber/index.tsx +0 -160
- package/themes/business/src/components 2/PhoneInputNumber/styles.tsx +0 -3
- package/themes/business/src/components 2/PreviousMessages/index.tsx +0 -304
- package/themes/business/src/components 2/PreviousMessages/styles.tsx +0 -32
- package/themes/business/src/components 2/PreviousOrders/index.tsx +0 -180
- package/themes/business/src/components 2/PreviousOrders/styles.tsx +0 -38
- package/themes/business/src/components 2/ProductItemAccordion/index.tsx +0 -301
- package/themes/business/src/components 2/ProductItemAccordion/styles.tsx +0 -61
- package/themes/business/src/components 2/SearchBar/index.tsx +0 -112
- package/themes/business/src/components 2/SignupForm/index.tsx +0 -530
- package/themes/business/src/components 2/SignupForm/styles.tsx +0 -16
- package/themes/business/src/components 2/StoresList/index.tsx +0 -208
- package/themes/business/src/components 2/StoresList/styles.tsx +0 -26
- package/themes/business/src/components 2/UserFormDetails/index.tsx +0 -513
- package/themes/business/src/components 2/UserFormDetails/styles.tsx +0 -40
- package/themes/business/src/components 2/UserProfileForm/index.tsx +0 -496
- package/themes/business/src/components 2/UserProfileForm/styles.tsx +0 -36
- package/themes/business/src/components 2/VerifyPhone/index.tsx +0 -201
- package/themes/business/src/components 2/VerifyPhone/styles.tsx +0 -43
- package/themes/business/src/components 2/shared/OAlert.tsx +0 -52
- package/themes/business/src/components 2/shared/OButton.tsx +0 -149
- package/themes/business/src/components 2/shared/OChatBubble.tsx +0 -100
- package/themes/business/src/components 2/shared/ODropDown.tsx +0 -195
- package/themes/business/src/components 2/shared/ODropDownCalendar.tsx +0 -328
- package/themes/business/src/components 2/shared/OFab.tsx +0 -54
- package/themes/business/src/components 2/shared/OIcon.tsx +0 -67
- package/themes/business/src/components 2/shared/OIconButton.tsx +0 -127
- package/themes/business/src/components 2/shared/OInput.tsx +0 -144
- package/themes/business/src/components 2/shared/OLink.tsx +0 -76
- package/themes/business/src/components 2/shared/OModal.tsx +0 -275
- package/themes/business/src/components 2/shared/OSegment.tsx +0 -86
- package/themes/business/src/components 2/shared/OText.tsx +0 -55
- package/themes/business/src/components 2/shared/OTextarea.tsx +0 -46
- package/themes/business/src/components 2/shared/OToast.tsx +0 -92
- package/themes/business/src/components 2/shared/index.tsx +0 -27
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { TouchableOpacity, StyleSheet } from 'react-native';
|
|
3
|
-
import { LogoutAction } from 'ordering-components/native';
|
|
4
|
-
import { useLanguage } from 'ordering-components/native';
|
|
5
|
-
import { useTheme } from 'styled-components/native';
|
|
6
|
-
import { OIcon, OText } from '../shared';
|
|
7
|
-
import { _retrieveStoreData, _clearStoreData } from '../../providers/StoreUtil';
|
|
8
|
-
|
|
9
|
-
const LogoutButtonUI = (props: any) => {
|
|
10
|
-
const { handleLogoutClick } = props;
|
|
11
|
-
const [, t] = useLanguage();
|
|
12
|
-
const theme = useTheme();
|
|
13
|
-
|
|
14
|
-
const handleClick = async () => {
|
|
15
|
-
const data = await _retrieveStoreData('notification_state');
|
|
16
|
-
const res = await handleLogoutClick(data);
|
|
17
|
-
if (res) {
|
|
18
|
-
_clearStoreData({ excludedKeys: ['project_name'] });
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const styles = StyleSheet.create({
|
|
23
|
-
container: {
|
|
24
|
-
alignItems: 'center',
|
|
25
|
-
justifyContent: 'flex-start',
|
|
26
|
-
flexDirection: 'row',
|
|
27
|
-
marginBottom: 40,
|
|
28
|
-
},
|
|
29
|
-
text: {
|
|
30
|
-
color: theme.colors.textGray,
|
|
31
|
-
fontFamily: 'Poppins',
|
|
32
|
-
fontStyle: 'normal',
|
|
33
|
-
fontWeight: '600',
|
|
34
|
-
fontSize: 16,
|
|
35
|
-
marginRight: 10,
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<TouchableOpacity style={styles.container} onPress={() => handleClick()}>
|
|
41
|
-
<OText space style={styles.text}>
|
|
42
|
-
{t('LOGOUT', 'logout')}
|
|
43
|
-
</OText>
|
|
44
|
-
|
|
45
|
-
<OIcon
|
|
46
|
-
src={theme.images.general.menulogout}
|
|
47
|
-
width={18}
|
|
48
|
-
height={18}
|
|
49
|
-
color={theme.colors.disabledContrast}
|
|
50
|
-
/>
|
|
51
|
-
</TouchableOpacity>
|
|
52
|
-
);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export const LogoutButton = (props: any) => {
|
|
56
|
-
const logoutProps = {
|
|
57
|
-
...props,
|
|
58
|
-
isNative: true,
|
|
59
|
-
UIComponent: LogoutButtonUI,
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
return <LogoutAction {...logoutProps} />;
|
|
63
|
-
};
|
|
@@ -1,317 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
|
2
|
-
import { Dimensions, SafeAreaView, StyleSheet, View } from 'react-native';
|
|
3
|
-
import { useFocusEffect } from '@react-navigation/native'
|
|
4
|
-
import MapView, {
|
|
5
|
-
PROVIDER_GOOGLE,
|
|
6
|
-
Marker,
|
|
7
|
-
Callout
|
|
8
|
-
} from 'react-native-maps';
|
|
9
|
-
import { useLanguage, useSession, MapView as MapViewController } from 'ordering-components/native';
|
|
10
|
-
import { MapViewParams } from '../../types';
|
|
11
|
-
import Alert from '../../providers/AlertProvider';
|
|
12
|
-
import { useTheme } from 'styled-components/native';
|
|
13
|
-
import { useLocation } from '../../hooks/useLocation';
|
|
14
|
-
import Icon from 'react-native-vector-icons/FontAwesome5';
|
|
15
|
-
import { OIcon, OText, OFab } from '../shared'
|
|
16
|
-
const MapViewComponent = (props: MapViewParams) => {
|
|
17
|
-
|
|
18
|
-
const {
|
|
19
|
-
isLoadingBusinessMarkers,
|
|
20
|
-
markerGroups,
|
|
21
|
-
customerMarkerGroups,
|
|
22
|
-
alertState,
|
|
23
|
-
setAlertState,
|
|
24
|
-
onNavigationRedirect,
|
|
25
|
-
getBusinessLocations,
|
|
26
|
-
} = props;
|
|
27
|
-
|
|
28
|
-
const theme = useTheme();
|
|
29
|
-
const [, t] = useLanguage();
|
|
30
|
-
const [{ user }] = useSession()
|
|
31
|
-
const { width, height } = Dimensions.get('window');
|
|
32
|
-
const ASPECT_RATIO = width / height;
|
|
33
|
-
const mapRef = useRef<MapView | any>(null);
|
|
34
|
-
const following = useRef<boolean>(true);
|
|
35
|
-
const [isFocused, setIsFocused] = useState(false)
|
|
36
|
-
const [locationSelected, setLocationSelected] = useState<any>(null)
|
|
37
|
-
const {
|
|
38
|
-
initialPosition,
|
|
39
|
-
userLocation,
|
|
40
|
-
stopFollowUserLocation,
|
|
41
|
-
followUserLocation
|
|
42
|
-
} = useLocation();
|
|
43
|
-
|
|
44
|
-
const location = { lat: userLocation.latitude, lng: userLocation.longitude }
|
|
45
|
-
const haveOrders = Object.values(markerGroups)?.length > 0 && Object.values(customerMarkerGroups)?.length > 0
|
|
46
|
-
const closeAlert = () => {
|
|
47
|
-
setAlertState({
|
|
48
|
-
open: false,
|
|
49
|
-
content: [],
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const fitCoordinates = (location?: any) => {
|
|
54
|
-
if (mapRef.current) {
|
|
55
|
-
mapRef.current.fitToCoordinates(
|
|
56
|
-
[
|
|
57
|
-
{ latitude: location.latitude, longitude: location.longitude },
|
|
58
|
-
{
|
|
59
|
-
latitude: userLocation.latitude,
|
|
60
|
-
longitude: userLocation.longitude,
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
{
|
|
64
|
-
edgePadding: { top: 120, right: 120, bottom: 120, left: 120 },
|
|
65
|
-
},
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const onPressZoomIn = () => {
|
|
71
|
-
const lastRegion = mapRef?.current?.__lastRegion
|
|
72
|
-
mapRef?.current && mapRef.current.animateToRegion({
|
|
73
|
-
...mapRef?.current?.__lastRegion,
|
|
74
|
-
longitudeDelta: lastRegion.longitudeDelta / 8,
|
|
75
|
-
latitudeDelta: lastRegion.longitudeDelta / 8
|
|
76
|
-
})
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const onPressZoomOut = () => {
|
|
80
|
-
const lastRegion = mapRef?.current?.__lastRegion
|
|
81
|
-
mapRef?.current && mapRef.current.animateToRegion({
|
|
82
|
-
...lastRegion,
|
|
83
|
-
longitudeDelta: lastRegion.longitudeDelta * 8,
|
|
84
|
-
latitudeDelta: lastRegion.longitudeDelta * 8
|
|
85
|
-
})
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
useEffect(() => {
|
|
89
|
-
fitCoordinates(locationSelected || userLocation);
|
|
90
|
-
}, [userLocation, locationSelected]);
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
useEffect(() => {
|
|
94
|
-
if (isFocused) {
|
|
95
|
-
getBusinessLocations()
|
|
96
|
-
}
|
|
97
|
-
}, [isFocused])
|
|
98
|
-
|
|
99
|
-
useEffect(() => {
|
|
100
|
-
followUserLocation();
|
|
101
|
-
|
|
102
|
-
return () => {
|
|
103
|
-
stopFollowUserLocation();
|
|
104
|
-
};
|
|
105
|
-
}, []);
|
|
106
|
-
|
|
107
|
-
useFocusEffect(
|
|
108
|
-
useCallback(() => {
|
|
109
|
-
setIsFocused(true)
|
|
110
|
-
return () => {
|
|
111
|
-
stopFollowUserLocation()
|
|
112
|
-
setIsFocused(false)
|
|
113
|
-
setLocationSelected(null)
|
|
114
|
-
}
|
|
115
|
-
}, [])
|
|
116
|
-
)
|
|
117
|
-
|
|
118
|
-
const styles = StyleSheet.create({
|
|
119
|
-
image: {
|
|
120
|
-
borderRadius: 50,
|
|
121
|
-
},
|
|
122
|
-
view: {
|
|
123
|
-
width: 25,
|
|
124
|
-
position: 'absolute',
|
|
125
|
-
top: 6,
|
|
126
|
-
left: 6,
|
|
127
|
-
bottom: 0,
|
|
128
|
-
right: 0,
|
|
129
|
-
},
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
const RenderMarker = ({ marker, customer, orderIds }: { marker: any, customer?: boolean, orderIds?: Array<number> }) => {
|
|
133
|
-
const markerRef = useRef<any>()
|
|
134
|
-
useEffect(() => {
|
|
135
|
-
if (
|
|
136
|
-
markerRef?.current?.props?.coordinate?.latitude === locationSelected?.latitude &&
|
|
137
|
-
markerRef?.current?.props?.coordinate?.longitude === locationSelected?.longitude
|
|
138
|
-
) {
|
|
139
|
-
markerRef?.current?.showCallout()
|
|
140
|
-
}
|
|
141
|
-
}, [locationSelected])
|
|
142
|
-
|
|
143
|
-
return (
|
|
144
|
-
<Marker
|
|
145
|
-
key={customer ? marker?.customer?.id : marker?.business?.id}
|
|
146
|
-
coordinate={{
|
|
147
|
-
latitude: customer ? marker?.customer?.location?.lat : marker?.business?.location?.lat,
|
|
148
|
-
longitude: customer ? marker?.customer?.location?.lng : marker?.business?.location?.lng
|
|
149
|
-
}}
|
|
150
|
-
onPress={() =>
|
|
151
|
-
setLocationSelected({
|
|
152
|
-
latitude: customer ? marker?.customer?.location?.lat : marker?.business?.location?.lat,
|
|
153
|
-
longitude: customer ? marker?.customer?.location?.lng : marker?.business?.location?.lng
|
|
154
|
-
})
|
|
155
|
-
}
|
|
156
|
-
ref={(ref) => markerRef.current = ref}
|
|
157
|
-
>
|
|
158
|
-
<Icon
|
|
159
|
-
name="map-marker"
|
|
160
|
-
size={50}
|
|
161
|
-
color={theme.colors.primary}
|
|
162
|
-
/>
|
|
163
|
-
<View style={styles.view}>
|
|
164
|
-
<OIcon
|
|
165
|
-
style={styles.image}
|
|
166
|
-
src={{ uri: customer ? marker?.customer?.photo : marker?.business?.logo }}
|
|
167
|
-
width={25}
|
|
168
|
-
height={25}
|
|
169
|
-
/>
|
|
170
|
-
</View>
|
|
171
|
-
<Callout
|
|
172
|
-
onPress={() => !!orderIds && orderIds.toString().includes(',') ? onNavigationRedirect('Orders') : onNavigationRedirect('OrderDetails', { order: marker })}
|
|
173
|
-
>
|
|
174
|
-
<View style={{ flex: 1, width: 200, padding: 5 }}>
|
|
175
|
-
<OText weight='bold'>{customer ? `${marker?.customer?.name} ${marker?.customer?.lastname}` : marker?.business?.name}</OText>
|
|
176
|
-
<OText>
|
|
177
|
-
{!!orderIds && orderIds.toString().includes(',') ? (
|
|
178
|
-
<>
|
|
179
|
-
{t('ORDER_NUMBERS', 'Order Numbers')} {orderIds}
|
|
180
|
-
</>
|
|
181
|
-
) : (
|
|
182
|
-
<>
|
|
183
|
-
{t('ORDER_NUMBER', 'Order No.')} {marker?.id}
|
|
184
|
-
</>
|
|
185
|
-
)}
|
|
186
|
-
</OText>
|
|
187
|
-
<OText>{customer ? marker?.customer?.address : marker?.business?.address}</OText>
|
|
188
|
-
{((customer && marker?.customer?.city?.address_notes) || !customer) && (
|
|
189
|
-
<OText>{customer ? marker?.customer?.city?.address_notes : marker?.business?.city?.name}</OText>
|
|
190
|
-
)}
|
|
191
|
-
{((customer && marker?.business?.zipcode) || (!customer && marker?.business?.zipcode)) && (
|
|
192
|
-
<OText>{customer ? marker?.customer?.zipcode : marker?.business?.zipcode}</OText>
|
|
193
|
-
)}
|
|
194
|
-
{customer && marker?.customer?.internal_number && (
|
|
195
|
-
<OText>{marker?.customer?.internal_number}</OText>
|
|
196
|
-
)}
|
|
197
|
-
<OText textDecorationLine='underline' color={theme.colors.primary}>
|
|
198
|
-
{!!orderIds && orderIds.toString().includes(',') ? (
|
|
199
|
-
<>
|
|
200
|
-
{t('SHOW_ORDERS', 'Show orders')}
|
|
201
|
-
</>
|
|
202
|
-
) : (
|
|
203
|
-
<>
|
|
204
|
-
{t('MORE_INFO', 'More info')}
|
|
205
|
-
</>
|
|
206
|
-
)}
|
|
207
|
-
</OText>
|
|
208
|
-
</View>
|
|
209
|
-
</Callout>
|
|
210
|
-
</Marker>
|
|
211
|
-
)
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
return (
|
|
215
|
-
<SafeAreaView style={{ flex: 1 }}>
|
|
216
|
-
<View style={{ flex: 1 }}>
|
|
217
|
-
{!isLoadingBusinessMarkers && isFocused && (
|
|
218
|
-
<View style={{ flex: 1 }}>
|
|
219
|
-
<MapView
|
|
220
|
-
ref={mapRef}
|
|
221
|
-
provider={PROVIDER_GOOGLE}
|
|
222
|
-
initialRegion={{
|
|
223
|
-
latitude: initialPosition.latitude,
|
|
224
|
-
longitude: initialPosition.longitude,
|
|
225
|
-
latitudeDelta: haveOrders ? 0.01 : 0.1,
|
|
226
|
-
longitudeDelta: haveOrders ? 0.01 * ASPECT_RATIO : 0.1 * ASPECT_RATIO,
|
|
227
|
-
}}
|
|
228
|
-
style={{ flex: 1 }}
|
|
229
|
-
zoomTapEnabled
|
|
230
|
-
zoomEnabled
|
|
231
|
-
zoomControlEnabled
|
|
232
|
-
cacheEnabled
|
|
233
|
-
moveOnMarkerPress
|
|
234
|
-
onTouchStart={() => (following.current = false)}
|
|
235
|
-
>
|
|
236
|
-
<>
|
|
237
|
-
{Object.values(markerGroups).map((marker: any) => (
|
|
238
|
-
<RenderMarker
|
|
239
|
-
key={marker[0]?.business_id}
|
|
240
|
-
marker={marker[0]}
|
|
241
|
-
orderIds={marker.map((order: any) => order.id).join(', ')}
|
|
242
|
-
/>
|
|
243
|
-
))}
|
|
244
|
-
{Object.values(customerMarkerGroups).map((marker: any) => (
|
|
245
|
-
<RenderMarker
|
|
246
|
-
key={marker[0]?.customer_id}
|
|
247
|
-
marker={marker[0]}
|
|
248
|
-
orderIds={marker.map((order: any) => order.id).join(', ')}
|
|
249
|
-
customer
|
|
250
|
-
/>
|
|
251
|
-
))}
|
|
252
|
-
<Marker
|
|
253
|
-
coordinate={{
|
|
254
|
-
latitude: location.lat,
|
|
255
|
-
longitude: location.lng,
|
|
256
|
-
}}
|
|
257
|
-
title={t('YOUR_LOCATION', 'Your Location')}
|
|
258
|
-
>
|
|
259
|
-
<Icon
|
|
260
|
-
name="map-marker"
|
|
261
|
-
size={50}
|
|
262
|
-
color={theme.colors.primary}
|
|
263
|
-
/>
|
|
264
|
-
<View style={styles.view}>
|
|
265
|
-
<OIcon
|
|
266
|
-
style={styles.image}
|
|
267
|
-
src={{ uri: user.photo }}
|
|
268
|
-
width={25}
|
|
269
|
-
height={25}
|
|
270
|
-
/>
|
|
271
|
-
</View>
|
|
272
|
-
</Marker>
|
|
273
|
-
</>
|
|
274
|
-
</MapView>
|
|
275
|
-
<OFab
|
|
276
|
-
materialIcon
|
|
277
|
-
iconName="plus"
|
|
278
|
-
onPress={() => onPressZoomIn()}
|
|
279
|
-
style={{
|
|
280
|
-
position: 'absolute',
|
|
281
|
-
bottom: 75,
|
|
282
|
-
right: 20,
|
|
283
|
-
}}
|
|
284
|
-
/>
|
|
285
|
-
<OFab
|
|
286
|
-
materialIcon
|
|
287
|
-
iconName="minus"
|
|
288
|
-
onPress={() => onPressZoomOut()}
|
|
289
|
-
style={{
|
|
290
|
-
position: 'absolute',
|
|
291
|
-
bottom: 35,
|
|
292
|
-
right: 20,
|
|
293
|
-
}}
|
|
294
|
-
/>
|
|
295
|
-
</View>
|
|
296
|
-
)}
|
|
297
|
-
</View>
|
|
298
|
-
<View>
|
|
299
|
-
<Alert
|
|
300
|
-
open={alertState.open}
|
|
301
|
-
onAccept={closeAlert}
|
|
302
|
-
onClose={closeAlert}
|
|
303
|
-
content={alertState.content}
|
|
304
|
-
title={t('ERROR', 'Error')}
|
|
305
|
-
/>
|
|
306
|
-
</View>
|
|
307
|
-
</SafeAreaView >
|
|
308
|
-
);
|
|
309
|
-
};
|
|
310
|
-
|
|
311
|
-
export const MapViewUI = (props: any) => {
|
|
312
|
-
const MapViewProps = {
|
|
313
|
-
...props,
|
|
314
|
-
UIComponent: MapViewComponent
|
|
315
|
-
}
|
|
316
|
-
return <MapViewController {...MapViewProps} />
|
|
317
|
-
}
|
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
View,
|
|
4
|
-
Pressable,
|
|
5
|
-
StyleSheet,
|
|
6
|
-
Dimensions,
|
|
7
|
-
ScrollView,
|
|
8
|
-
} from 'react-native';
|
|
9
|
-
import { Contacts, useLanguage } from 'ordering-components/native';
|
|
10
|
-
import { useTheme } from 'styled-components/native';
|
|
11
|
-
import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
|
|
12
|
-
import { OText, OButton } from '../shared';
|
|
13
|
-
import { NotFoundSource } from '../NotFoundSource';
|
|
14
|
-
import { PreviousMessages } from '../PreviousMessages';
|
|
15
|
-
// import { Contacts } from '../Contacts';
|
|
16
|
-
import { FiltersTab, TabsContainer, TagsContainer, Tag } from './styles';
|
|
17
|
-
import { MessagesOptionParams } from '../../types';
|
|
18
|
-
import { useDeviceOrientation } from '../../../../../src/hooks/DeviceOrientation';
|
|
19
|
-
const MessagesOptionUI = (props: MessagesOptionParams) => {
|
|
20
|
-
const {
|
|
21
|
-
orders,
|
|
22
|
-
setOrders,
|
|
23
|
-
loadMore,
|
|
24
|
-
pagination,
|
|
25
|
-
messages,
|
|
26
|
-
onNavigationRedirect,
|
|
27
|
-
setSortBy,
|
|
28
|
-
} = props;
|
|
29
|
-
|
|
30
|
-
const theme = useTheme();
|
|
31
|
-
const [, t] = useLanguage();
|
|
32
|
-
|
|
33
|
-
const { loading, error, data: values } = orders;
|
|
34
|
-
const [{ dimensions }] = useDeviceOrientation();
|
|
35
|
-
const tabs = [
|
|
36
|
-
{ key: 0, text: t('ORDERS', 'Orders'), tags: [0, 1] },
|
|
37
|
-
// { key: 1, text: t('CONTACTS', 'Contacts'), tags: [2, 3, 4] },
|
|
38
|
-
];
|
|
39
|
-
|
|
40
|
-
const tags = [
|
|
41
|
-
{
|
|
42
|
-
key: 0,
|
|
43
|
-
text: t('NEWEST', 'Newest'),
|
|
44
|
-
sortBy: { param: 'last_direct_message_at', direction: 'asc' },
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
key: 1,
|
|
48
|
-
text: t('ORDER_NUMBER', 'Order number'),
|
|
49
|
-
sortBy: { param: 'id', direction: 'desc' },
|
|
50
|
-
},
|
|
51
|
-
{ key: 2, text: t('BUSINESSES', 'Businesses') },
|
|
52
|
-
{ key: 3, text: t('CUSTOMERS', 'Customers') },
|
|
53
|
-
{ key: 4, text: t('DRIVERS', 'Drivers') },
|
|
54
|
-
];
|
|
55
|
-
|
|
56
|
-
const [tabsFilter, setTabsFilter] = useState(tabs[0].tags);
|
|
57
|
-
const [activeTag, setActiveTag] = useState(tags[0].key);
|
|
58
|
-
const [reload, setReload] = useState(false);
|
|
59
|
-
const [unreadMessages, setUnreadMessages] = useState(
|
|
60
|
-
values?.reduce(
|
|
61
|
-
(total: number, order: any) => total + order.unread_count,
|
|
62
|
-
0,
|
|
63
|
-
),
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
const [orientation, setOrientation] = useState(
|
|
67
|
-
Dimensions.get('window').width < Dimensions.get('window').height
|
|
68
|
-
? 'Portrait'
|
|
69
|
-
: 'Landscape',
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
const getTagFilter = (key: number) => {
|
|
73
|
-
return tags.find(value => value.key === key)?.text;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const handleChangeTab = (tags: number[]) => {
|
|
77
|
-
const key = tags[0];
|
|
78
|
-
|
|
79
|
-
setTabsFilter(tags);
|
|
80
|
-
setActiveTag(key);
|
|
81
|
-
|
|
82
|
-
if (tabs[0].tags.includes(key)) {
|
|
83
|
-
setSortBy({ param: 'last_direct_message_at', direction: 'asc' });
|
|
84
|
-
setReload(true);
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const handleChangeTag = (key: number) => {
|
|
89
|
-
if (activeTag !== key) {
|
|
90
|
-
const tag = tags.find(tag => tag.key === key);
|
|
91
|
-
setActiveTag(key);
|
|
92
|
-
|
|
93
|
-
if (tabs[0].tags.includes(key)) {
|
|
94
|
-
setSortBy(tag?.sortBy);
|
|
95
|
-
setReload(true);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
useEffect(() => {
|
|
101
|
-
if (reload && !loading) {
|
|
102
|
-
setReload(!reload);
|
|
103
|
-
}
|
|
104
|
-
}, [loading]);
|
|
105
|
-
|
|
106
|
-
useEffect(() => {
|
|
107
|
-
setUnreadMessages(
|
|
108
|
-
values?.reduce(
|
|
109
|
-
(total: number, order: any) => total + order.unread_count,
|
|
110
|
-
0,
|
|
111
|
-
),
|
|
112
|
-
);
|
|
113
|
-
}, [orders]);
|
|
114
|
-
|
|
115
|
-
Dimensions.addEventListener('change', ({ window: { width, height } }) => {
|
|
116
|
-
if (width < height) {
|
|
117
|
-
setOrientation('Portrait');
|
|
118
|
-
} else {
|
|
119
|
-
setOrientation('Landscape');
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
const styles = StyleSheet.create({
|
|
124
|
-
header: {
|
|
125
|
-
marginBottom: 25,
|
|
126
|
-
flexDirection: 'row',
|
|
127
|
-
justifyContent: 'space-between',
|
|
128
|
-
},
|
|
129
|
-
title: {
|
|
130
|
-
fontFamily: 'Poppins',
|
|
131
|
-
fontStyle: 'normal',
|
|
132
|
-
fontWeight: '600',
|
|
133
|
-
fontSize: 26,
|
|
134
|
-
color: theme.colors.textGray,
|
|
135
|
-
},
|
|
136
|
-
icons: {
|
|
137
|
-
flexDirection: 'row',
|
|
138
|
-
},
|
|
139
|
-
tab: {
|
|
140
|
-
fontFamily: 'Poppins',
|
|
141
|
-
fontStyle: 'normal',
|
|
142
|
-
fontSize: 16,
|
|
143
|
-
paddingBottom: 5,
|
|
144
|
-
marginBottom: -1,
|
|
145
|
-
zIndex: 100,
|
|
146
|
-
borderColor: theme.colors.textGray,
|
|
147
|
-
},
|
|
148
|
-
tagsContainer: {
|
|
149
|
-
marginBottom: 20,
|
|
150
|
-
},
|
|
151
|
-
tag: {
|
|
152
|
-
fontFamily: 'Poppins',
|
|
153
|
-
fontStyle: 'normal',
|
|
154
|
-
fontWeight: 'normal',
|
|
155
|
-
fontSize: 14,
|
|
156
|
-
},
|
|
157
|
-
pressable: {
|
|
158
|
-
alignItems: 'center',
|
|
159
|
-
},
|
|
160
|
-
loadButton: {
|
|
161
|
-
borderRadius: 7.6,
|
|
162
|
-
height: 44,
|
|
163
|
-
marginRight: 10,
|
|
164
|
-
marginBottom: 10,
|
|
165
|
-
marginTop: 5,
|
|
166
|
-
},
|
|
167
|
-
loadButtonText: {
|
|
168
|
-
color: theme.colors.white,
|
|
169
|
-
fontFamily: 'Poppins',
|
|
170
|
-
fontStyle: 'normal',
|
|
171
|
-
fontWeight: 'normal',
|
|
172
|
-
fontSize: 18,
|
|
173
|
-
},
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
return (
|
|
177
|
-
<>
|
|
178
|
-
<View style={styles.header}>
|
|
179
|
-
<OText style={styles.title}>{t('MESSAGES', 'Messages')}</OText>
|
|
180
|
-
</View>
|
|
181
|
-
|
|
182
|
-
<FiltersTab>
|
|
183
|
-
<TabsContainer width={dimensions.width - 42}>
|
|
184
|
-
{tabs.map((tab: any) => (
|
|
185
|
-
<Pressable
|
|
186
|
-
key={tab.key}
|
|
187
|
-
style={{
|
|
188
|
-
...styles.tab,
|
|
189
|
-
borderBottomWidth: 1,
|
|
190
|
-
}}
|
|
191
|
-
onPress={() => handleChangeTab(tab.tags)}>
|
|
192
|
-
<OText
|
|
193
|
-
style={styles.tab}
|
|
194
|
-
color={
|
|
195
|
-
JSON.stringify(tabsFilter) === JSON.stringify(tab.tags)
|
|
196
|
-
? theme.colors.textGray
|
|
197
|
-
: theme.colors.unselectText
|
|
198
|
-
}
|
|
199
|
-
weight={
|
|
200
|
-
JSON.stringify(tabsFilter) === JSON.stringify(tab.tags)
|
|
201
|
-
? '600'
|
|
202
|
-
: 'normal'
|
|
203
|
-
}>
|
|
204
|
-
{tab.text}
|
|
205
|
-
{` ${tab.key === 0 ? `(${unreadMessages || 0})` : ''}`}
|
|
206
|
-
</OText>
|
|
207
|
-
</Pressable>
|
|
208
|
-
))}
|
|
209
|
-
</TabsContainer>
|
|
210
|
-
</FiltersTab>
|
|
211
|
-
|
|
212
|
-
<View>
|
|
213
|
-
<TagsContainer
|
|
214
|
-
showsVerticalScrollIndicator={false}
|
|
215
|
-
showsHorizontalScrollIndicator={false}
|
|
216
|
-
contentContainerStyle={styles.tagsContainer}
|
|
217
|
-
horizontal>
|
|
218
|
-
{tabsFilter.map((key: number) => (
|
|
219
|
-
<Tag
|
|
220
|
-
key={key}
|
|
221
|
-
onPress={() => handleChangeTag(key)}
|
|
222
|
-
isSelected={
|
|
223
|
-
activeTag === key ? theme.colors.primary : theme.colors.tabBar
|
|
224
|
-
}>
|
|
225
|
-
<OText
|
|
226
|
-
style={styles.tag}
|
|
227
|
-
color={
|
|
228
|
-
activeTag === key ? theme.colors.white : theme.colors.black
|
|
229
|
-
}>
|
|
230
|
-
{getTagFilter(key)}
|
|
231
|
-
</OText>
|
|
232
|
-
</Tag>
|
|
233
|
-
))}
|
|
234
|
-
</TagsContainer>
|
|
235
|
-
</View>
|
|
236
|
-
|
|
237
|
-
{!loading && (values.length === 0 || error) && (
|
|
238
|
-
<NotFoundSource
|
|
239
|
-
content={
|
|
240
|
-
!error
|
|
241
|
-
? t('NO_RESULTS_FOUND', 'Sorry, no results found')
|
|
242
|
-
: error[0]?.message ||
|
|
243
|
-
error[0] ||
|
|
244
|
-
t('NETWORK_ERROR', 'Network Error')
|
|
245
|
-
}
|
|
246
|
-
image={theme.images.general.notFound}
|
|
247
|
-
conditioned={false}
|
|
248
|
-
/>
|
|
249
|
-
)}
|
|
250
|
-
|
|
251
|
-
<ScrollView showsVerticalScrollIndicator={false} style={{ flex: 1 }}>
|
|
252
|
-
{!reload &&
|
|
253
|
-
!error &&
|
|
254
|
-
values.length > 0 &&
|
|
255
|
-
JSON.stringify(tabsFilter) === JSON.stringify(tabs[0].tags) && (
|
|
256
|
-
<PreviousMessages
|
|
257
|
-
orders={values}
|
|
258
|
-
setOrders={setOrders}
|
|
259
|
-
messages={messages}
|
|
260
|
-
onNavigationRedirect={onNavigationRedirect}
|
|
261
|
-
/>
|
|
262
|
-
)}
|
|
263
|
-
|
|
264
|
-
{/* {!reload &&
|
|
265
|
-
!error &&
|
|
266
|
-
orders.length > 0 &&
|
|
267
|
-
JSON.stringify(tabsFilter) === JSON.stringify(tabs[1].tags) && (
|
|
268
|
-
<Contacts
|
|
269
|
-
orders={values}
|
|
270
|
-
activeTag={activeTag}
|
|
271
|
-
messages={messages}
|
|
272
|
-
setMessages={setMessages}
|
|
273
|
-
loadMessages={loadMessages}
|
|
274
|
-
onNavigationRedirect={onNavigationRedirect}
|
|
275
|
-
/>
|
|
276
|
-
)} */}
|
|
277
|
-
|
|
278
|
-
{(loading || reload) && (
|
|
279
|
-
<>
|
|
280
|
-
<View>
|
|
281
|
-
{[...Array(5)].map((item, i) => (
|
|
282
|
-
<Placeholder key={i} Animation={Fade}>
|
|
283
|
-
<View
|
|
284
|
-
style={{
|
|
285
|
-
width: '100%',
|
|
286
|
-
flexDirection: 'row',
|
|
287
|
-
marginBottom: 10,
|
|
288
|
-
}}>
|
|
289
|
-
<PlaceholderLine
|
|
290
|
-
width={orientation === 'Portrait' ? 22 : 11}
|
|
291
|
-
height={74}
|
|
292
|
-
style={{
|
|
293
|
-
marginRight: 20,
|
|
294
|
-
marginBottom: 20,
|
|
295
|
-
borderRadius: 7.6,
|
|
296
|
-
}}
|
|
297
|
-
/>
|
|
298
|
-
<Placeholder>
|
|
299
|
-
<PlaceholderLine width={30} style={{ marginTop: 5 }} />
|
|
300
|
-
<PlaceholderLine width={50} />
|
|
301
|
-
<PlaceholderLine width={20} />
|
|
302
|
-
</Placeholder>
|
|
303
|
-
</View>
|
|
304
|
-
</Placeholder>
|
|
305
|
-
))}
|
|
306
|
-
</View>
|
|
307
|
-
</>
|
|
308
|
-
)}
|
|
309
|
-
|
|
310
|
-
{pagination?.totalPages &&
|
|
311
|
-
!loading &&
|
|
312
|
-
!reload &&
|
|
313
|
-
JSON.stringify(tabsFilter) === JSON.stringify(tabs[0].tags) &&
|
|
314
|
-
pagination?.currentPage < pagination?.totalPages && (
|
|
315
|
-
<OButton
|
|
316
|
-
onClick={() => loadMore && loadMore()}
|
|
317
|
-
text={t('LOAD_MORE_ORDERS', 'Load more orders')}
|
|
318
|
-
imgRightSrc={null}
|
|
319
|
-
textStyle={styles.loadButtonText}
|
|
320
|
-
style={styles.loadButton}
|
|
321
|
-
bgColor={theme.colors.primary}
|
|
322
|
-
borderColor={theme.colors.primary}
|
|
323
|
-
/>
|
|
324
|
-
)}
|
|
325
|
-
</ScrollView>
|
|
326
|
-
</>
|
|
327
|
-
);
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
export const MessagesOption = (props: MessagesOptionParams) => {
|
|
331
|
-
const MyOrdersProps = {
|
|
332
|
-
...props,
|
|
333
|
-
UIComponent: MessagesOptionUI,
|
|
334
|
-
};
|
|
335
|
-
|
|
336
|
-
return <Contacts {...MyOrdersProps} />;
|
|
337
|
-
};
|