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
|
@@ -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,
|
|
@@ -69,20 +69,26 @@ export const DriverMap = (props: GoogleMapsParams) => {
|
|
|
69
69
|
stopFollowUserLocation,
|
|
70
70
|
} = useLocation();
|
|
71
71
|
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
const parsedInitialPosition = useCallback(() => {
|
|
73
|
+
return {
|
|
74
|
+
latitude: typeof initialPosition.latitude === 'string' ? parseFloat(initialPosition.latitude) || 0 : initialPosition.latitude || 0,
|
|
75
|
+
longitude: typeof initialPosition.longitude === 'string' ? parseFloat(initialPosition.longitude) || 0 : initialPosition.longitude || 0,
|
|
76
|
+
}
|
|
77
|
+
}, [JSON.stringify(initialPosition)])
|
|
76
78
|
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
const parsedUserLocation = useCallback(() => {
|
|
80
|
+
return {
|
|
81
|
+
latitude: typeof userLocation?.latitude === 'string' ? parseFloat(userLocation?.latitude) || 0 : userLocation?.latitude || 0,
|
|
82
|
+
longitude: typeof userLocation?.longitude === 'string' ? parseFloat(userLocation?.longitude) || 0 : userLocation?.longitude || 0
|
|
83
|
+
}
|
|
84
|
+
}, [JSON.stringify(userLocation)])
|
|
81
85
|
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
const parsedDestination = useCallback(() => {
|
|
87
|
+
return {
|
|
88
|
+
latitude: typeof location?.lat === 'string' ? parseFloat(location?.lat) || 0 : location?.lat || 0,
|
|
89
|
+
longitude: typeof location?.lng === 'string' ? parseFloat(location?.lng) || 0 : location?.lng || 0
|
|
90
|
+
}
|
|
91
|
+
}, [JSON.stringify(location)])
|
|
86
92
|
|
|
87
93
|
useEffect(() => {
|
|
88
94
|
if (isToFollow) {
|
|
@@ -170,21 +176,21 @@ export const DriverMap = (props: GoogleMapsParams) => {
|
|
|
170
176
|
if (driverUpdateLocation.error) return;
|
|
171
177
|
|
|
172
178
|
calculateDistance(
|
|
173
|
-
{ lat: parsedUserLocation
|
|
174
|
-
|
|
179
|
+
{ lat: parsedUserLocation()?.latitude, lng: parsedUserLocation()?.longitude },
|
|
180
|
+
parsedDestination(),
|
|
175
181
|
);
|
|
176
182
|
// geocodePosition(userLocation);
|
|
177
183
|
|
|
178
184
|
if (!following.current) return;
|
|
179
185
|
fitCoordinates();
|
|
180
186
|
|
|
181
|
-
const { latitude, longitude } = parsedUserLocation;
|
|
187
|
+
const { latitude, longitude } = parsedUserLocation();
|
|
182
188
|
|
|
183
189
|
mapRef.current?.animateCamera({
|
|
184
190
|
center: { latitude, longitude },
|
|
185
191
|
});
|
|
186
192
|
|
|
187
|
-
}, [
|
|
193
|
+
}, [JSON.stringify(userLocation)]);
|
|
188
194
|
|
|
189
195
|
const handleArrowBack: any = () => {
|
|
190
196
|
setDriverUpdateLocation?.({
|
|
@@ -230,6 +236,11 @@ export const DriverMap = (props: GoogleMapsParams) => {
|
|
|
230
236
|
19: theme.colors.statusOrderBlue,
|
|
231
237
|
20: theme.colors.statusOrderBlue,
|
|
232
238
|
21: theme.colors.statusOrderBlue,
|
|
239
|
+
22: theme.colors.statusOrderBlue,
|
|
240
|
+
23: theme.colors.statusOrderBlue,
|
|
241
|
+
24: theme.colors.statusOrderBlue,
|
|
242
|
+
25: theme.colors.statusOrderBlue,
|
|
243
|
+
26: theme.colors.statusOrderBlue,
|
|
233
244
|
//GREEN
|
|
234
245
|
1: theme.colors.statusOrderGreen,
|
|
235
246
|
11: theme.colors.statusOrderGreen,
|
|
@@ -250,8 +261,8 @@ export const DriverMap = (props: GoogleMapsParams) => {
|
|
|
250
261
|
[
|
|
251
262
|
{ latitude: location.lat, longitude: location.lng },
|
|
252
263
|
{
|
|
253
|
-
latitude: parsedInitialPosition
|
|
254
|
-
longitude: parsedInitialPosition
|
|
264
|
+
latitude: parsedInitialPosition()?.latitude,
|
|
265
|
+
longitude: parsedInitialPosition()?.longitude,
|
|
255
266
|
},
|
|
256
267
|
],
|
|
257
268
|
{
|
|
@@ -264,7 +275,7 @@ export const DriverMap = (props: GoogleMapsParams) => {
|
|
|
264
275
|
|
|
265
276
|
useEffect(() => {
|
|
266
277
|
const interval = setInterval(() => {
|
|
267
|
-
if (parsedInitialPosition
|
|
278
|
+
if (parsedInitialPosition()?.latitude !== 0 && autoFit.current) {
|
|
268
279
|
if (mapRef.current) {
|
|
269
280
|
fitCoordinates();
|
|
270
281
|
autoFit.current = false;
|
|
@@ -272,7 +283,7 @@ export const DriverMap = (props: GoogleMapsParams) => {
|
|
|
272
283
|
}
|
|
273
284
|
}, 1000);
|
|
274
285
|
return () => clearInterval(interval);
|
|
275
|
-
}, [parsedInitialPosition]);
|
|
286
|
+
}, [parsedInitialPosition()]);
|
|
276
287
|
|
|
277
288
|
const fitCoordinatesZoom = () => {
|
|
278
289
|
following.current = false;
|
|
@@ -355,8 +366,8 @@ export const DriverMap = (props: GoogleMapsParams) => {
|
|
|
355
366
|
ref={mapRef}
|
|
356
367
|
provider={PROVIDER_GOOGLE}
|
|
357
368
|
initialRegion={{
|
|
358
|
-
latitude: parsedInitialPosition
|
|
359
|
-
longitude: parsedInitialPosition
|
|
369
|
+
latitude: parsedInitialPosition()?.latitude,
|
|
370
|
+
longitude: parsedInitialPosition()?.longitude,
|
|
360
371
|
latitudeDelta: 0.001,
|
|
361
372
|
longitudeDelta: 0.001 * ASPECT_RATIO,
|
|
362
373
|
}}
|
|
@@ -378,8 +389,8 @@ export const DriverMap = (props: GoogleMapsParams) => {
|
|
|
378
389
|
<>
|
|
379
390
|
<Marker
|
|
380
391
|
coordinate={{
|
|
381
|
-
latitude:
|
|
382
|
-
longitude:
|
|
392
|
+
latitude: parsedDestination()?.latitude,
|
|
393
|
+
longitude: parsedDestination()?.longitude
|
|
383
394
|
}}
|
|
384
395
|
title={location.title}>
|
|
385
396
|
<Icon
|
|
@@ -397,8 +408,8 @@ export const DriverMap = (props: GoogleMapsParams) => {
|
|
|
397
408
|
</View>
|
|
398
409
|
</Marker>
|
|
399
410
|
<Marker coordinate={{
|
|
400
|
-
latitude:
|
|
401
|
-
longitude:
|
|
411
|
+
latitude: userLocation?.latitude,
|
|
412
|
+
longitude: userLocation?.longitude
|
|
402
413
|
}}>
|
|
403
414
|
<View style={styles.driverIcon}>
|
|
404
415
|
<OIcon
|
|
@@ -413,8 +424,8 @@ export const DriverMap = (props: GoogleMapsParams) => {
|
|
|
413
424
|
) : (
|
|
414
425
|
<Marker
|
|
415
426
|
coordinate={{
|
|
416
|
-
latitude:
|
|
417
|
-
longitude:
|
|
427
|
+
latitude: parsedUserLocation()?.latitude,
|
|
428
|
+
longitude: parsedUserLocation()?.longitude
|
|
418
429
|
}}
|
|
419
430
|
title={markerTitle || t('YOUR_LOCATION', 'Your Location')}
|
|
420
431
|
/>
|
|
@@ -526,10 +537,10 @@ export const DriverMap = (props: GoogleMapsParams) => {
|
|
|
526
537
|
animationIn: 'slideInUp'
|
|
527
538
|
}}
|
|
528
539
|
options={{
|
|
529
|
-
latitude:
|
|
530
|
-
longitude:
|
|
531
|
-
sourceLatitude: parsedUserLocation
|
|
532
|
-
sourceLongitude: parsedUserLocation
|
|
540
|
+
latitude: parsedDestination()?.latitude,
|
|
541
|
+
longitude: parsedDestination()?.longitude,
|
|
542
|
+
sourceLatitude: parsedUserLocation()?.latitude,
|
|
543
|
+
sourceLongitude: parsedUserLocation()?.longitude,
|
|
533
544
|
naverCallerName: 'com.deliveryapp',
|
|
534
545
|
dialogTitle: t('SHOW_IN_OTHER_MAPS', 'Show in other maps'),
|
|
535
546
|
dialogMessage: t('WHAT_APP_WOULD_YOU_USE', 'What app would you like to use?'),
|
|
@@ -25,14 +25,15 @@ const FloatingButtonUI = (props: FloatingButtonParams) => {
|
|
|
25
25
|
secondButton,
|
|
26
26
|
widthButton,
|
|
27
27
|
isPadding,
|
|
28
|
-
isHideRejectButtons
|
|
28
|
+
isHideRejectButtons,
|
|
29
|
+
principalButtonColor
|
|
29
30
|
} = props;
|
|
30
31
|
|
|
31
32
|
const theme = useTheme();
|
|
32
33
|
|
|
33
34
|
const styles = StyleSheet.create({
|
|
34
35
|
primaryBtn: {
|
|
35
|
-
backgroundColor: theme.colors.primary,
|
|
36
|
+
backgroundColor: principalButtonColor ?? theme.colors.primary,
|
|
36
37
|
},
|
|
37
38
|
secodaryBtn: {
|
|
38
39
|
backgroundColor: theme.colors.textSecondary,
|
|
@@ -49,7 +49,7 @@ const LanguageSelectorUI = (props: LanguageSelectorParams) => {
|
|
|
49
49
|
},
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
return (
|
|
52
|
+
return !languagesState?.loading && languagesState?.languages?.length > 1 && (
|
|
53
53
|
<Container style={{ backgroundColor: theme.colors.inputChat }}>
|
|
54
54
|
{languagesState?.languages && (
|
|
55
55
|
<CountryPicker
|
|
@@ -6,6 +6,9 @@ import {
|
|
|
6
6
|
View,
|
|
7
7
|
Dimensions,
|
|
8
8
|
ScrollView,
|
|
9
|
+
Platform,
|
|
10
|
+
NativeModules,
|
|
11
|
+
Alert as AlertReactNative
|
|
9
12
|
} from 'react-native';
|
|
10
13
|
import { useForm, Controller } from 'react-hook-form';
|
|
11
14
|
import Recaptcha from 'react-native-recaptcha-that-works'
|
|
@@ -62,11 +65,12 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
62
65
|
enableReCaptcha,
|
|
63
66
|
|
|
64
67
|
useLoginOtp,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
otpType,
|
|
69
|
+
setOtpType,
|
|
70
|
+
generateOtpCode,
|
|
71
|
+
useLoginOtpEmail,
|
|
72
|
+
useLoginOtpCellphone,
|
|
73
|
+
validateDeveloperMode
|
|
70
74
|
} = props;
|
|
71
75
|
|
|
72
76
|
const [ordering, { setOrdering }] = useApi();
|
|
@@ -112,7 +116,7 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
112
116
|
const [willVerifyOtpState, setWillVerifyOtpState] = useState(false)
|
|
113
117
|
const [alertState, setAlertState] = useState({ open: false, title: '', content: [] })
|
|
114
118
|
const isOtpEmail = loginTab === 'otp' && otpType === 'email'
|
|
115
|
-
|
|
119
|
+
const isOtpCellphone = loginTab === 'otp' && otpType === 'cellphone'
|
|
116
120
|
|
|
117
121
|
|
|
118
122
|
const handleOpenRecaptcha = () => {
|
|
@@ -229,37 +233,58 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
229
233
|
|
|
230
234
|
const mainLogin = (values) => {
|
|
231
235
|
if (loginTab === 'otp') {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
236
|
+
if (phoneInputData.error && (loginTab !== 'otp' || (otpType === 'cellphone' && loginTab === 'otp'))) {
|
|
237
|
+
showToast(ToastType.Error, t('INVALID_PHONE_NUMBER', 'Invalid phone number'));
|
|
238
|
+
return
|
|
239
|
+
}
|
|
240
|
+
if (loginTab === 'otp') {
|
|
241
|
+
generateOtpCode({
|
|
242
|
+
...values,
|
|
243
|
+
...phoneInputData.phone
|
|
244
|
+
})
|
|
245
|
+
}
|
|
246
|
+
setWillVerifyOtpState(true)
|
|
247
|
+
} else {
|
|
248
|
+
if (phoneInputData.error) {
|
|
249
|
+
showToast(ToastType.Error, phoneInputData.error);
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
handleButtonLoginClick({
|
|
253
|
+
...values,
|
|
254
|
+
...phoneInputData.phone,
|
|
255
|
+
});
|
|
256
|
+
}
|
|
253
257
|
}
|
|
254
258
|
|
|
255
|
-
const
|
|
259
|
+
const isDeveloperModeEnabled = async (): Promise<boolean> => {
|
|
260
|
+
if (Platform.OS === 'android') {
|
|
261
|
+
return NativeModules.DeveloperOptions?.isDeveloperModeEnabled?.();
|
|
262
|
+
}
|
|
263
|
+
return false
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const onSubmit = async (values: any) => {
|
|
256
267
|
Keyboard.dismiss();
|
|
257
268
|
|
|
258
269
|
if (phoneInputData.error) {
|
|
259
270
|
showToast(ToastType.Error, phoneInputData.error);
|
|
260
271
|
return;
|
|
261
272
|
}
|
|
262
|
-
|
|
273
|
+
if (validateDeveloperMode) {
|
|
274
|
+
const isDeveloperMode = await isDeveloperModeEnabled()
|
|
275
|
+
if (isDeveloperMode) {
|
|
276
|
+
AlertReactNative.alert(
|
|
277
|
+
t('DEVELOPER_MODE', 'Developer mode'),
|
|
278
|
+
t('PLEASE_DISABLE_DEVELOPER_MODE', 'Please disable developer mode for sign in'),
|
|
279
|
+
[{
|
|
280
|
+
text: t('GO_TO_SETTINGS', 'Go to settings'),
|
|
281
|
+
onPress: async () => await NativeModules.DeveloperOptions?.openDeveloperSettings(),
|
|
282
|
+
},
|
|
283
|
+
{ text: 'OK', onPress: () => { } },]
|
|
284
|
+
)
|
|
285
|
+
return
|
|
286
|
+
}
|
|
287
|
+
}
|
|
263
288
|
if (values?.project_name) {
|
|
264
289
|
setOrdering({
|
|
265
290
|
...ordering,
|
|
@@ -274,21 +299,21 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
274
299
|
};
|
|
275
300
|
|
|
276
301
|
const handleChangeOtpType = (type: string) => {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
302
|
+
handleChangeTab('otp', type)
|
|
303
|
+
setOtpType(type)
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const handleLoginOtp = (code: string) => {
|
|
307
|
+
handleButtonLoginClick({ code })
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const closeAlert = () => {
|
|
311
|
+
setAlertState({
|
|
312
|
+
open: false,
|
|
313
|
+
title: '',
|
|
314
|
+
content: []
|
|
315
|
+
})
|
|
316
|
+
}
|
|
292
317
|
|
|
293
318
|
const handleVerifyCodeClick = () => {
|
|
294
319
|
if (phoneInputData.error) {
|
|
@@ -411,14 +436,14 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
411
436
|
}, [ordering, submitted])
|
|
412
437
|
|
|
413
438
|
useEffect(() => {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
439
|
+
if (checkPhoneCodeState?.result?.error) {
|
|
440
|
+
setAlertState({
|
|
441
|
+
open: true,
|
|
442
|
+
content: t(checkPhoneCodeState?.result?.error, checkPhoneCodeState?.result?.error),
|
|
443
|
+
title: ''
|
|
444
|
+
})
|
|
445
|
+
}
|
|
446
|
+
}, [checkPhoneCodeState])
|
|
422
447
|
|
|
423
448
|
Dimensions.addEventListener('change', ({ window: { width, height } }) => {
|
|
424
449
|
setWindowWidth(
|
|
@@ -477,7 +502,7 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
477
502
|
borderColor: theme.colors.inputSignup,
|
|
478
503
|
backgroundColor: theme.colors.transparent,
|
|
479
504
|
minHeight: 50,
|
|
480
|
-
maxHeight
|
|
505
|
+
maxHeight: 50
|
|
481
506
|
},
|
|
482
507
|
btn: {
|
|
483
508
|
borderRadius: 7.6,
|
|
@@ -506,23 +531,23 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
506
531
|
},
|
|
507
532
|
|
|
508
533
|
borderStyleBase: {
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
534
|
+
width: 30,
|
|
535
|
+
height: 45
|
|
536
|
+
},
|
|
537
|
+
borderStyleHighLighted: {
|
|
538
|
+
borderColor: "#03DAC6",
|
|
539
|
+
},
|
|
540
|
+
underlineStyleBase: {
|
|
541
|
+
width: 45,
|
|
542
|
+
height: 60,
|
|
543
|
+
borderWidth: 1,
|
|
544
|
+
fontSize: 16
|
|
545
|
+
},
|
|
546
|
+
underlineStyleHighLighted: {
|
|
547
|
+
borderColor: theme.colors.primary,
|
|
548
|
+
color: theme.colors.primary,
|
|
549
|
+
fontSize: 16
|
|
550
|
+
},
|
|
526
551
|
});
|
|
527
552
|
|
|
528
553
|
return (
|
|
@@ -602,7 +627,7 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
602
627
|
)}
|
|
603
628
|
|
|
604
629
|
{useLoginOtpEmail && (
|
|
605
|
-
|
|
630
|
+
<Pressable
|
|
606
631
|
style={styles.btnTab}
|
|
607
632
|
onPress={() => handleChangeOtpType('email')}>
|
|
608
633
|
<OText
|
|
@@ -624,10 +649,10 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
624
649
|
: theme.colors.tabBar,
|
|
625
650
|
borderBottomWidth: 2,
|
|
626
651
|
}} />
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
652
|
+
</Pressable>
|
|
653
|
+
)}
|
|
654
|
+
{useLoginOtpCellphone && (
|
|
655
|
+
<Pressable
|
|
631
656
|
style={styles.btnTab}
|
|
632
657
|
onPress={() => handleChangeOtpType('cellphone')}>
|
|
633
658
|
<OText
|
|
@@ -644,13 +669,13 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
644
669
|
style={{
|
|
645
670
|
width: '100%',
|
|
646
671
|
borderBottomColor:
|
|
647
|
-
|
|
672
|
+
isOtpCellphone
|
|
648
673
|
? theme.colors.textGray
|
|
649
674
|
: theme.colors.tabBar,
|
|
650
675
|
borderBottomWidth: 2,
|
|
651
676
|
}} />
|
|
652
|
-
|
|
653
|
-
|
|
677
|
+
</Pressable>
|
|
678
|
+
)}
|
|
654
679
|
</TabsContainer>
|
|
655
680
|
</ScrollView>
|
|
656
681
|
</LoginWith>
|
|
@@ -908,28 +933,28 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
908
933
|
/>
|
|
909
934
|
</OModal>
|
|
910
935
|
<OModal
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
936
|
+
open={willVerifyOtpState}
|
|
937
|
+
onClose={() => setWillVerifyOtpState(false)}
|
|
938
|
+
entireModal
|
|
914
939
|
hideIcons
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
940
|
+
title={t('ENTER_VERIFICATION_CODE', 'Enter verification code')}
|
|
941
|
+
>
|
|
942
|
+
<Otp
|
|
943
|
+
willVerifyOtpState={willVerifyOtpState}
|
|
944
|
+
setWillVerifyOtpState={setWillVerifyOtpState}
|
|
945
|
+
handleLoginOtp={handleLoginOtp}
|
|
946
|
+
onSubmit={handleLogin}
|
|
947
|
+
setAlertState={setAlertState}
|
|
923
948
|
formState={formState}
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
949
|
+
/>
|
|
950
|
+
</OModal>
|
|
951
|
+
<Alert
|
|
952
|
+
open={alertState.open}
|
|
953
|
+
content={alertState.content}
|
|
954
|
+
title={alertState.title || ''}
|
|
955
|
+
onAccept={closeAlert}
|
|
956
|
+
onClose={closeAlert}
|
|
957
|
+
/>
|
|
933
958
|
</View>
|
|
934
959
|
);
|
|
935
960
|
};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
2
|
import { TouchableOpacity, StyleSheet } from 'react-native';
|
|
3
|
-
import { LogoutAction } from 'ordering-components/native';
|
|
4
|
-
import { useLanguage } from 'ordering-components/native';
|
|
3
|
+
import { LogoutAction, ToastType, useToast } from 'ordering-components/native';
|
|
4
|
+
import { useLanguage, useSession } from 'ordering-components/native';
|
|
5
5
|
import { useTheme } from 'styled-components/native';
|
|
6
6
|
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, formState } = props;
|
|
11
11
|
const [, t] = useLanguage();
|
|
12
|
+
const [, { showToast }] = useToast()
|
|
12
13
|
const theme = useTheme();
|
|
13
14
|
|
|
14
15
|
const handleClick = async () => {
|
|
@@ -19,6 +20,12 @@ const LogoutButtonUI = (props: any) => {
|
|
|
19
20
|
}
|
|
20
21
|
};
|
|
21
22
|
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (formState?.result?.error) {
|
|
25
|
+
showToast(ToastType.Error, t(formState?.result?.result))
|
|
26
|
+
}
|
|
27
|
+
}, [formState?.result])
|
|
28
|
+
|
|
22
29
|
const styles = StyleSheet.create({
|
|
23
30
|
container: {
|
|
24
31
|
alignItems: 'center',
|
|
@@ -53,9 +60,11 @@ const LogoutButtonUI = (props: any) => {
|
|
|
53
60
|
};
|
|
54
61
|
|
|
55
62
|
export const LogoutButton = (props: any) => {
|
|
63
|
+
const [{ user }] = useSession()
|
|
56
64
|
const logoutProps = {
|
|
57
65
|
...props,
|
|
58
66
|
isNative: true,
|
|
67
|
+
isDriverApp: user?.level === 4,
|
|
59
68
|
UIComponent: LogoutButtonUI,
|
|
60
69
|
};
|
|
61
70
|
|