ordering-ui-react-native 0.15.47 → 0.15.49-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 +6 -3
- package/src/DeliveryApp.tsx +43 -1
- package/src/components/AddressForm/index.tsx +18 -2
- package/src/components/BusinessController/index.tsx +16 -8
- package/src/components/BusinessTypeFilter/index.tsx +3 -1
- package/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/Checkout/index.tsx +23 -2
- package/src/components/DriverTips/index.tsx +11 -6
- package/src/components/LanguageSelector/index.tsx +7 -2
- package/src/components/LoginForm/index.tsx +120 -30
- package/src/components/LoginForm/styles.tsx +6 -0
- package/src/components/OrderDetails/index.tsx +9 -23
- package/src/components/PaymentOptions/index.tsx +1 -1
- package/src/components/PaymentOptionsWebView/index.tsx +123 -124
- package/src/components/SignupForm/index.tsx +145 -61
- package/src/components/SingleProductCard/index.tsx +16 -4
- package/src/components/StripeMethodForm/index.tsx +1 -2
- package/src/components/UpsellingProducts/index.tsx +1 -1
- package/src/components/UserProfileForm/index.tsx +63 -6
- package/src/components/UserProfileForm/styles.tsx +8 -0
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/components/shared/OModal.tsx +1 -1
- package/src/hooks/useCountdownTimer.tsx +26 -0
- package/src/navigators/CheckoutNavigator.tsx +6 -0
- package/src/navigators/HomeNavigator.tsx +12 -0
- package/src/pages/BusinessesListing.tsx +1 -1
- package/src/pages/MultiCheckout.tsx +31 -0
- package/src/pages/MultiOrdersDetails.tsx +27 -0
- package/src/pages/Sessions.tsx +22 -0
- package/src/theme.json +0 -1
- package/src/types/index.tsx +18 -11
- package/src/utils/index.tsx +68 -1
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +103 -15
- package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -0
- package/themes/business/src/components/Chat/index.tsx +42 -90
- package/themes/business/src/components/DriverMap/index.tsx +6 -5
- package/themes/business/src/components/Home/index.tsx +128 -55
- package/themes/business/src/components/Home/styles.tsx +8 -1
- package/themes/business/src/components/LoginForm/index.tsx +89 -2
- package/themes/business/src/components/LoginForm/styles.tsx +6 -0
- package/themes/business/src/components/LogoutButton/index.tsx +1 -1
- package/themes/business/src/components/NewOrderNotification/index.tsx +79 -105
- package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
- package/themes/business/src/components/OrderDetails/Delivery.tsx +35 -18
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +159 -91
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +6 -0
- package/themes/business/src/components/OrderDetails/styles.tsx +7 -0
- package/themes/business/src/components/OrdersListManager/index.tsx +1 -1
- package/themes/business/src/components/OrdersOption/index.tsx +5 -2
- package/themes/business/src/components/PreviousOrders/index.tsx +7 -5
- package/themes/business/src/components/ProductItemAccordion/index.tsx +2 -2
- package/themes/business/src/components/shared/OModal.tsx +1 -1
- package/themes/business/src/types/index.tsx +5 -1
- 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/BusinessMenu/index.tsx +39 -28
- package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -3
- package/themes/kiosk/src/components/Cart/index.tsx +99 -26
- package/themes/kiosk/src/components/Cart/styles.tsx +6 -0
- package/themes/kiosk/src/components/CartBottomSheet/index.tsx +9 -2
- package/themes/kiosk/src/components/CartContent/index.tsx +0 -11
- package/themes/kiosk/src/components/CartItem/index.tsx +4 -3
- package/themes/kiosk/src/components/CategoriesMenu/index.tsx +107 -62
- package/themes/kiosk/src/components/Checkout/index.tsx +40 -22
- package/themes/kiosk/src/components/CustomerName/index.tsx +0 -6
- package/themes/kiosk/src/components/DrawerView/index.tsx +1 -0
- package/themes/kiosk/src/components/DrawerView/styles.tsx +2 -2
- package/themes/kiosk/src/components/NavBar/index.tsx +29 -20
- package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
- package/themes/kiosk/src/components/OrderDetails/index.tsx +165 -65
- package/themes/kiosk/src/components/OrderDetails/styles.tsx +5 -0
- package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +9 -11
- package/themes/kiosk/src/components/PaymentOptions/index.tsx +56 -54
- package/themes/kiosk/src/components/ProductForm/index.tsx +7 -8
- package/themes/kiosk/src/components/ProductItemAccordion/index.tsx +2 -2
- package/themes/kiosk/src/components/ProductOption/index.tsx +1 -1
- package/themes/kiosk/src/components/ProductOptionSubOption/index.tsx +3 -1
- package/themes/kiosk/src/components/UpsellingProducts/index.tsx +16 -5
- package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
- package/themes/kiosk/src/types/index.d.ts +3 -0
- package/themes/original/index.tsx +169 -4
- package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
- package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
- package/themes/original/src/components/AddressForm/index.tsx +1 -1
- package/themes/original/src/components/AddressList/index.tsx +30 -18
- package/themes/original/src/components/AppleLogin/index.tsx +117 -78
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +136 -45
- package/themes/original/src/components/BusinessBasicInformation/styles.tsx +4 -0
- package/themes/original/src/components/BusinessController/index.tsx +48 -11
- package/themes/original/src/components/BusinessController/styles.tsx +27 -0
- package/themes/original/src/components/BusinessFeaturedController/index.tsx +20 -1
- package/themes/original/src/components/BusinessFeaturedController/styles.tsx +23 -0
- package/themes/original/src/components/BusinessItemAccordion/index.tsx +8 -5
- package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -1
- package/themes/original/src/components/BusinessListingSearch/index.tsx +196 -58
- package/themes/original/src/components/BusinessListingSearch/styles.tsx +22 -2
- package/themes/original/src/components/BusinessPreorder/index.tsx +1 -1
- package/themes/original/src/components/BusinessProductsCategories/index.tsx +2 -2
- package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
- package/themes/original/src/components/BusinessProductsList/index.tsx +119 -35
- package/themes/original/src/components/BusinessProductsList/styles.tsx +12 -4
- package/themes/original/src/components/BusinessProductsListing/index.tsx +109 -21
- package/themes/original/src/components/BusinessProductsListing/styles.tsx +22 -0
- package/themes/original/src/components/BusinessReviews/index.tsx +4 -25
- package/themes/original/src/components/BusinessTypeFilter/index.tsx +1 -2
- package/themes/original/src/components/BusinessesListing/index.tsx +127 -66
- package/themes/original/src/components/BusinessesListing/styles.tsx +11 -3
- package/themes/original/src/components/Cart/index.tsx +60 -41
- package/themes/original/src/components/Checkout/index.tsx +48 -32
- package/themes/original/src/components/DriverTips/index.tsx +17 -12
- package/themes/original/src/components/Favorite/index.tsx +92 -0
- package/themes/original/src/components/Favorite/styles.tsx +22 -0
- package/themes/original/src/components/FavoriteList/index.tsx +298 -0
- package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
- package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
- package/themes/original/src/components/GPSButton/index.tsx +15 -8
- package/themes/original/src/components/GoogleMap/index.tsx +1 -0
- package/themes/original/src/components/Help/index.tsx +21 -4
- package/themes/original/src/components/HighestRatedBusinesses/index.tsx +18 -1
- package/themes/original/src/components/Home/index.tsx +1 -1
- package/themes/original/src/components/LastOrders/index.tsx +12 -1
- package/themes/original/src/components/LoginForm/Otp/index.tsx +91 -0
- package/themes/original/src/components/LoginForm/Otp/styles.tsx +7 -0
- package/themes/original/src/components/LoginForm/index.tsx +394 -155
- package/themes/original/src/components/LoginForm/styles.tsx +7 -4
- package/themes/original/src/components/LogoutButton/index.tsx +7 -1
- package/themes/original/src/components/MessageListing/index.tsx +10 -1
- package/themes/original/src/components/Messages/index.tsx +1 -1
- package/themes/original/src/components/MomentOption/index.tsx +10 -1
- package/themes/original/src/components/MomentOption/styles.tsx +1 -1
- package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +243 -0
- package/themes/original/src/components/MultiCartsPaymethodsAndWallets/styles.tsx +46 -0
- package/themes/original/src/components/MultiCheckout/index.tsx +298 -0
- package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
- package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +372 -0
- package/themes/original/src/components/MultiOrdersDetails/index.tsx +258 -0
- package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
- package/themes/original/src/components/MyOrders/index.tsx +120 -32
- package/themes/original/src/components/MyOrders/styles.tsx +8 -1
- package/themes/original/src/components/OrderDetails/index.tsx +64 -42
- package/themes/original/src/components/OrderDetails/styles.tsx +1 -2
- package/themes/original/src/components/OrderProgress/index.tsx +1 -1
- package/themes/original/src/components/OrderProgress/styles.tsx +1 -0
- package/themes/original/src/components/OrderSummary/index.tsx +3 -3
- package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -2
- package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +153 -0
- package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
- package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +53 -0
- package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
- package/themes/original/src/components/OrdersOption/index.tsx +133 -41
- package/themes/original/src/components/OrdersOption/styles.tsx +4 -7
- package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +17 -23
- package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
- package/themes/original/src/components/PaymentOptions/index.tsx +16 -14
- package/themes/original/src/components/PhoneInputNumber/index.tsx +1 -1
- package/themes/original/src/components/PreviousOrders/index.tsx +18 -147
- package/themes/original/src/components/ProductForm/index.tsx +70 -62
- package/themes/original/src/components/ProductForm/styles.tsx +0 -1
- package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -12
- package/themes/original/src/components/Promotions/index.tsx +250 -0
- package/themes/original/src/components/Promotions/styles.tsx +60 -0
- package/themes/original/src/components/SearchBar/index.tsx +10 -4
- package/themes/original/src/components/Sessions/index.tsx +160 -0
- package/themes/original/src/components/Sessions/styles.tsx +15 -0
- package/themes/original/src/components/SignupForm/index.tsx +333 -128
- package/themes/original/src/components/SingleOrderCard/index.tsx +282 -0
- package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
- package/themes/original/src/components/SingleProductCard/index.tsx +59 -17
- package/themes/original/src/components/StripeElementsForm/index.tsx +16 -8
- package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
- package/themes/original/src/components/UpsellingProducts/index.tsx +86 -74
- package/themes/original/src/components/UserDetails/index.tsx +5 -96
- package/themes/original/src/components/UserFormDetails/index.tsx +34 -24
- package/themes/original/src/components/UserProfile/index.tsx +59 -5
- package/themes/original/src/components/UserProfileForm/index.tsx +20 -18
- package/themes/original/src/components/UserVerification/index.tsx +178 -192
- package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
- package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
- package/themes/original/src/components/Wallets/index.tsx +76 -9
- package/themes/original/src/components/Wallets/styles.tsx +21 -0
- package/themes/original/src/components/shared/HeaderTitle.tsx +2 -1
- package/themes/original/src/components/shared/OModal.tsx +4 -2
- package/themes/original/src/config/constants.tsx +6 -6
- package/themes/original/src/types/index.tsx +144 -9
- package/themes/original/src/utils/index.tsx +19 -2
- package/themes/single-business/src/components/AddressList/index.tsx +1 -1
- package/themes/single-business/src/components/OrderTypeSelector/index.tsx +1 -1
- package/themes/single-business/src/components/UserProfile/index.tsx +1 -1
- package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { View, Pressable, StyleSheet, Linking, Platform } from 'react-native';
|
|
2
|
+
import { View, Pressable, StyleSheet, Linking, Platform, TouchableOpacity } from 'react-native';
|
|
3
3
|
import { useForm, Controller } from 'react-hook-form';
|
|
4
4
|
import Spinner from 'react-native-loading-spinner-overlay';
|
|
5
5
|
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
|
|
6
6
|
import CheckBox from '@react-native-community/checkbox';
|
|
7
7
|
import { PhoneInputNumber } from '../PhoneInputNumber';
|
|
8
8
|
import { FacebookLogin } from '../FacebookLogin';
|
|
9
|
+
import Recaptcha from 'react-native-recaptcha-that-works'
|
|
9
10
|
|
|
10
11
|
import {
|
|
11
12
|
SignupForm as SignUpController,
|
|
@@ -17,18 +18,23 @@ import {
|
|
|
17
18
|
} from 'ordering-components/native';
|
|
18
19
|
import { useTheme } from 'styled-components/native';
|
|
19
20
|
import { FormSide, FormInput, SocialButtons } from './styles';
|
|
21
|
+
import { Otp } from '../LoginForm/Otp'
|
|
20
22
|
|
|
21
23
|
import {
|
|
22
24
|
ButtonsWrapper,
|
|
23
25
|
LoginWith as SignupWith,
|
|
26
|
+
TabBtn,
|
|
24
27
|
OTab,
|
|
25
28
|
OTabs,
|
|
29
|
+
RecaptchaButton
|
|
26
30
|
} from '../LoginForm/styles';
|
|
27
31
|
|
|
28
32
|
import NavBar from '../NavBar';
|
|
29
33
|
import { VerifyPhone } from '../VerifyPhone';
|
|
30
34
|
|
|
31
|
-
import
|
|
35
|
+
import Alert from '../../../../../src/providers/AlertProvider'
|
|
36
|
+
import { OText, OButton, OInput } from '../shared';
|
|
37
|
+
import { OModal } from '../../../../../src/components/shared';
|
|
32
38
|
import { SignupParams } from '../../types';
|
|
33
39
|
import { sortInputFields } from '../../utils';
|
|
34
40
|
import { GoogleLogin } from '../GoogleLogin';
|
|
@@ -63,7 +69,20 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
63
69
|
handleSendVerifyCode,
|
|
64
70
|
handleCheckPhoneCode,
|
|
65
71
|
notificationState,
|
|
66
|
-
handleChangePromotions
|
|
72
|
+
handleChangePromotions,
|
|
73
|
+
enableReCaptcha,
|
|
74
|
+
handleReCaptcha,
|
|
75
|
+
generateOtpCode,
|
|
76
|
+
numOtpInputs,
|
|
77
|
+
setWillVerifyOtpState,
|
|
78
|
+
handleChangeInput,
|
|
79
|
+
willVerifyOtpState,
|
|
80
|
+
setOtpState,
|
|
81
|
+
setSignUpTab,
|
|
82
|
+
signUpTab,
|
|
83
|
+
useSignUpFullDetails,
|
|
84
|
+
useSignUpOtpEmail,
|
|
85
|
+
useSignUpOtpCellphone
|
|
67
86
|
} = props;
|
|
68
87
|
|
|
69
88
|
const theme = useTheme();
|
|
@@ -100,24 +119,27 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
100
119
|
const [, t] = useLanguage();
|
|
101
120
|
const [, { login }] = useSession();
|
|
102
121
|
const [{ configs }] = useConfig();
|
|
103
|
-
const { control, handleSubmit, errors, register, setValue } = useForm();
|
|
122
|
+
const { control, handleSubmit, clearErrors, errors, register, unregister, setValue } = useForm();
|
|
104
123
|
|
|
105
124
|
const [passwordSee, setPasswordSee] = useState(false);
|
|
106
125
|
const [formValues, setFormValues] = useState(null);
|
|
107
126
|
const [isModalVisible, setIsModalVisible] = useState(false);
|
|
108
127
|
const [isLoadingVerifyModal, setIsLoadingVerifyModal] = useState(false);
|
|
109
|
-
const [signupTab, setSignupTab] = useState(
|
|
110
|
-
useSignupByCellphone && !useSignupByEmail ? 'cellphone' : 'email',
|
|
111
|
-
);
|
|
112
128
|
const [isFBLoading, setIsFBLoading] = useState(false);
|
|
113
129
|
const [phoneInputData, setPhoneInputData] = useState({
|
|
114
130
|
error: '',
|
|
115
131
|
phone: {
|
|
116
132
|
country_phone_code: null,
|
|
117
133
|
cellphone: null,
|
|
134
|
+
country_code: null
|
|
118
135
|
},
|
|
119
136
|
});
|
|
137
|
+
const [alertState, setAlertState] = useState({ open: false, title: '', content: [] })
|
|
138
|
+
const [recaptchaConfig, setRecaptchaConfig] = useState<any>({})
|
|
139
|
+
const [recaptchaVerified, setRecaptchaVerified] = useState(false)
|
|
140
|
+
const [tabLayouts, setTabLayouts] = useState<any>({})
|
|
120
141
|
|
|
142
|
+
const tabsRef = useRef<any>(null)
|
|
121
143
|
const nameRef = useRef<any>(null);
|
|
122
144
|
const lastnameRef = useRef<any>(null);
|
|
123
145
|
const middleNameRef = useRef<any>(null);
|
|
@@ -125,8 +147,20 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
125
147
|
const emailRef = useRef<any>(null);
|
|
126
148
|
const phoneRef = useRef<any>(null);
|
|
127
149
|
const passwordRef = useRef<any>(null);
|
|
128
|
-
|
|
129
|
-
|
|
150
|
+
const recaptchaRef = useRef<any>({});
|
|
151
|
+
|
|
152
|
+
const showInputPhoneNumber = (validationFields?.fields?.checkout?.cellphone?.enabled ?? false) || configs?.verification_phone_required?.value === '1'
|
|
153
|
+
const googleLoginEnabled = configs?.google_login_enabled?.value === '1' || !configs?.google_login_enabled?.enabled
|
|
154
|
+
const facebookLoginEnabled = configs?.facebook_login_enabled?.value === '1' || !configs?.facebook_login_enabled?.enabled
|
|
155
|
+
const appleLoginEnabled = configs?.apple_login_enabled?.value === '1' || !configs?.apple_login_enabled?.enabled
|
|
156
|
+
|
|
157
|
+
const closeAlert = () => {
|
|
158
|
+
setAlertState({
|
|
159
|
+
open: false,
|
|
160
|
+
title: '',
|
|
161
|
+
content: []
|
|
162
|
+
})
|
|
163
|
+
}
|
|
130
164
|
|
|
131
165
|
const handleRefs = (ref: any, code: string) => {
|
|
132
166
|
switch (code) {
|
|
@@ -152,6 +186,13 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
152
186
|
}
|
|
153
187
|
};
|
|
154
188
|
|
|
189
|
+
const handleOnLayout = (event: any, opc: string) => {
|
|
190
|
+
const _tabLayouts = { ...tabLayouts }
|
|
191
|
+
const categoryKey = opc
|
|
192
|
+
_tabLayouts[categoryKey] = event.nativeEvent.layout
|
|
193
|
+
setTabLayouts(_tabLayouts)
|
|
194
|
+
}
|
|
195
|
+
|
|
155
196
|
const handleFocusRef = (code: string) => {
|
|
156
197
|
switch (code) {
|
|
157
198
|
case 'name': {
|
|
@@ -195,13 +236,13 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
195
236
|
navigation.navigate('Home');
|
|
196
237
|
};
|
|
197
238
|
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
239
|
+
const handleSignUpTab = (tab: string) => {
|
|
240
|
+
setSignUpTab && setSignUpTab(tab)
|
|
241
|
+
clearErrors()
|
|
242
|
+
}
|
|
202
243
|
|
|
203
|
-
const onSubmit = (values
|
|
204
|
-
if (phoneInputData.error) {
|
|
244
|
+
const onSubmit = (values?: any) => {
|
|
245
|
+
if (phoneInputData.error && signUpTab !== 'otpEmail') {
|
|
205
246
|
showToast(ToastType.Error, phoneInputData.error);
|
|
206
247
|
return;
|
|
207
248
|
}
|
|
@@ -209,8 +250,9 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
209
250
|
!phoneInputData.phone.country_phone_code &&
|
|
210
251
|
!phoneInputData.phone.cellphone &&
|
|
211
252
|
((validationFields?.fields?.checkout?.cellphone?.enabled &&
|
|
212
|
-
|
|
213
|
-
|
|
253
|
+
validationFields?.fields?.checkout?.cellphone?.required) ||
|
|
254
|
+
configs?.verification_phone_required?.value === '1') &&
|
|
255
|
+
signUpTab !== 'otpEmail'
|
|
214
256
|
) {
|
|
215
257
|
showToast(
|
|
216
258
|
ToastType.Error,
|
|
@@ -221,25 +263,29 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
221
263
|
);
|
|
222
264
|
return;
|
|
223
265
|
}
|
|
224
|
-
if (
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
266
|
+
if (signUpTab === 'otpEmail' || signUpTab === 'otpCellphone') {
|
|
267
|
+
generateOtpCode && generateOtpCode({
|
|
268
|
+
...values,
|
|
269
|
+
...((phoneInputData.phone.cellphone !== null && phoneInputData.phone.country_phone_code !== null) && { ...phoneInputData.phone }),
|
|
270
|
+
country_code: phoneInputData.phone.country_code
|
|
271
|
+
})
|
|
272
|
+
return
|
|
273
|
+
}
|
|
274
|
+
handleButtonSignupClick &&
|
|
275
|
+
handleButtonSignupClick({
|
|
276
|
+
...values,
|
|
277
|
+
...((phoneInputData.phone.cellphone !== null && phoneInputData.phone.country_phone_code !== null) && { ...phoneInputData.phone }),
|
|
278
|
+
country_code: phoneInputData.phone.country_code
|
|
279
|
+
});
|
|
280
|
+
if (!formState.loading && formState.result.result && !formState.result.error) {
|
|
281
|
+
handleSuccessSignup && handleSuccessSignup(formState.result.result);
|
|
238
282
|
}
|
|
239
|
-
setFormValues(values);
|
|
240
|
-
handleVerifyCodeClick(values);
|
|
241
283
|
};
|
|
242
284
|
|
|
285
|
+
const handleSingUpOtp = (value: string) => {
|
|
286
|
+
setOtpState && setOtpState(value)
|
|
287
|
+
}
|
|
288
|
+
|
|
243
289
|
const handleVerifyCodeClick = (values: any) => {
|
|
244
290
|
const formData = values || formValues;
|
|
245
291
|
handleSendVerifyCode &&
|
|
@@ -286,6 +332,33 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
286
332
|
}
|
|
287
333
|
}
|
|
288
334
|
|
|
335
|
+
const handleOpenRecaptcha = () => {
|
|
336
|
+
setRecaptchaVerified(false)
|
|
337
|
+
if (!recaptchaConfig?.siteKey) {
|
|
338
|
+
showToast(ToastType.Error, t('NO_RECAPTCHA_SITE_KEY', 'The config doesn\'t have recaptcha site key'));
|
|
339
|
+
return
|
|
340
|
+
}
|
|
341
|
+
if (!recaptchaConfig?.baseUrl) {
|
|
342
|
+
showToast(ToastType.Error, t('NO_RECAPTCHA_BASE_URL', 'The config doesn\'t have recaptcha base url'));
|
|
343
|
+
return
|
|
344
|
+
}
|
|
345
|
+
recaptchaRef.current.open()
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const onRecaptchaVerify = (token: any) => {
|
|
349
|
+
setRecaptchaVerified(true)
|
|
350
|
+
handleReCaptcha && handleReCaptcha(token)
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
useEffect(() => {
|
|
354
|
+
if (configs && Object.keys(configs).length > 0 && enableReCaptcha) {
|
|
355
|
+
setRecaptchaConfig({
|
|
356
|
+
siteKey: configs?.security_recaptcha_site_key?.value || null,
|
|
357
|
+
baseUrl: configs?.security_recaptcha_base_url?.value || null
|
|
358
|
+
})
|
|
359
|
+
}
|
|
360
|
+
}, [configs, enableReCaptcha])
|
|
361
|
+
|
|
289
362
|
useEffect(() => {
|
|
290
363
|
if (!formState.loading && formState.result?.error) {
|
|
291
364
|
formState.result?.result &&
|
|
@@ -298,15 +371,19 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
298
371
|
if (Object.keys(errors).length > 0) {
|
|
299
372
|
setIsLoadingVerifyModal(false);
|
|
300
373
|
}
|
|
301
|
-
}, [errors])
|
|
374
|
+
}, [errors])
|
|
302
375
|
|
|
303
376
|
useEffect(() => {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
377
|
+
if (signUpTab === 'default' || signUpTab === 'otpCellphone') {
|
|
378
|
+
register('cellphone', {
|
|
379
|
+
required: isRequiredField('cellphone')
|
|
380
|
+
? t('VALIDATION_ERROR_MOBILE_PHONE_REQUIRED', 'The field Mobile phone is required').replace('_attribute_', t('CELLPHONE', 'Cellphone'))
|
|
381
|
+
: null
|
|
382
|
+
})
|
|
383
|
+
} else {
|
|
384
|
+
unregister('cellphone')
|
|
385
|
+
}
|
|
386
|
+
}, [signUpTab])
|
|
310
387
|
|
|
311
388
|
useEffect(() => {
|
|
312
389
|
if (phoneInputData?.phone?.cellphone) setValue('cellphone', phoneInputData?.phone?.cellphone, '')
|
|
@@ -333,6 +410,26 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
333
410
|
}
|
|
334
411
|
}, [verifyPhoneState]);
|
|
335
412
|
|
|
413
|
+
useEffect(() => {
|
|
414
|
+
setPhoneInputData({
|
|
415
|
+
...phoneInputData,
|
|
416
|
+
phone: {
|
|
417
|
+
...phoneInputData.phone,
|
|
418
|
+
country_code: configs?.default_country_code?.value
|
|
419
|
+
}
|
|
420
|
+
})
|
|
421
|
+
}, [configs])
|
|
422
|
+
|
|
423
|
+
useEffect(() => {
|
|
424
|
+
if (checkPhoneCodeState?.result?.error) {
|
|
425
|
+
setAlertState({
|
|
426
|
+
open: true,
|
|
427
|
+
title: (typeof checkPhoneCodeState?.result?.result === 'string' ? checkPhoneCodeState?.result?.result : checkPhoneCodeState?.result?.result[0].toString()) || t('ERROR', 'Error'),
|
|
428
|
+
content: []
|
|
429
|
+
})
|
|
430
|
+
}
|
|
431
|
+
}, [checkPhoneCodeState])
|
|
432
|
+
|
|
336
433
|
return (
|
|
337
434
|
<View>
|
|
338
435
|
<NavBar
|
|
@@ -346,47 +443,90 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
346
443
|
titleStyle={{ marginLeft: 0, marginRight: 0 }}
|
|
347
444
|
/>
|
|
348
445
|
<FormSide>
|
|
349
|
-
{
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
<
|
|
357
|
-
{
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
446
|
+
{(useSignUpFullDetails) && (
|
|
447
|
+
<SignupWith>
|
|
448
|
+
<OTabs
|
|
449
|
+
horizontal
|
|
450
|
+
showsHorizontalScrollIndicator={false}
|
|
451
|
+
ref={tabsRef}
|
|
452
|
+
>
|
|
453
|
+
<TabBtn
|
|
454
|
+
onPress={() => handleSignUpTab('default')}
|
|
455
|
+
onLayout={(event: any) => handleOnLayout(event, 'default')}
|
|
456
|
+
>
|
|
457
|
+
<OTab
|
|
458
|
+
style={{
|
|
459
|
+
borderBottomColor:
|
|
460
|
+
signUpTab === 'default'
|
|
461
|
+
? theme.colors.textNormal
|
|
462
|
+
: theme.colors.border,
|
|
463
|
+
}}>
|
|
464
|
+
<OText
|
|
465
|
+
size={14}
|
|
466
|
+
color={
|
|
467
|
+
signUpTab === 'default'
|
|
468
|
+
? theme.colors.textNormal
|
|
469
|
+
: theme.colors.disabled
|
|
470
|
+
}
|
|
471
|
+
weight={signUpTab === 'default' ? 'bold' : 'normal'}>
|
|
472
|
+
{t('DEFAULT', 'Default')}
|
|
473
|
+
</OText>
|
|
474
|
+
</OTab>
|
|
475
|
+
</TabBtn>
|
|
476
|
+
{useSignUpOtpEmail && (
|
|
477
|
+
<TabBtn
|
|
478
|
+
onPress={() => handleSignUpTab('otpEmail')}
|
|
479
|
+
onLayout={(event: any) => handleOnLayout(event, 'otpEmail')}
|
|
480
|
+
>
|
|
481
|
+
<OTab
|
|
482
|
+
style={{
|
|
483
|
+
borderBottomColor:
|
|
484
|
+
signUpTab === 'otpEmail'
|
|
485
|
+
? theme.colors.textNormal
|
|
486
|
+
: theme.colors.border,
|
|
487
|
+
}}>
|
|
488
|
+
<OText
|
|
489
|
+
size={14}
|
|
490
|
+
color={
|
|
491
|
+
signUpTab === 'otpEmail'
|
|
492
|
+
? theme.colors.textNormal
|
|
493
|
+
: theme.colors.disabled
|
|
494
|
+
}
|
|
495
|
+
weight={signUpTab === 'otpEmail' ? 'bold' : 'normal'}>
|
|
496
|
+
{t('BY_OTP_EMAIL', 'by Otp Email')}
|
|
497
|
+
</OText>
|
|
498
|
+
</OTab>
|
|
499
|
+
</TabBtn>
|
|
500
|
+
|
|
501
|
+
)}
|
|
502
|
+
{useSignUpOtpCellphone && (
|
|
503
|
+
<TabBtn
|
|
504
|
+
onPress={() => handleSignUpTab('otpCellphone')}
|
|
505
|
+
onLayout={(event: any) => handleOnLayout(event, 'otpCellphone')}
|
|
506
|
+
>
|
|
507
|
+
<OTab
|
|
508
|
+
style={{
|
|
509
|
+
borderBottomColor:
|
|
510
|
+
signUpTab === 'otpCellphone'
|
|
511
|
+
? theme.colors.textNormal
|
|
512
|
+
: theme.colors.border,
|
|
513
|
+
}}>
|
|
514
|
+
<OText
|
|
515
|
+
size={14}
|
|
516
|
+
color={
|
|
517
|
+
signUpTab === 'otpCellphone'
|
|
518
|
+
? theme.colors.textNormal
|
|
519
|
+
: theme.colors.disabled
|
|
520
|
+
}
|
|
521
|
+
weight={signUpTab === 'otpCellphone' ? 'bold' : 'normal'}>
|
|
522
|
+
{t('BY_OTP_CELLPHONE', 'by Otp Cellphone')}
|
|
523
|
+
</OText>
|
|
524
|
+
</OTab>
|
|
525
|
+
</TabBtn>
|
|
526
|
+
)}
|
|
527
|
+
</OTabs>
|
|
528
|
+
</SignupWith>
|
|
529
|
+
)}
|
|
390
530
|
<FormInput>
|
|
391
531
|
{!(useChekoutFileds && validationFields?.loading) ? (
|
|
392
532
|
<>
|
|
@@ -396,7 +536,9 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
396
536
|
(field: any, i: number) =>
|
|
397
537
|
!notValidationFields.includes(field.code) &&
|
|
398
538
|
showField &&
|
|
399
|
-
showField(field.code) &&
|
|
539
|
+
showField(field.code) &&
|
|
540
|
+
(signUpTab === 'default' ||
|
|
541
|
+
(signUpTab === 'otpEmail' && field.code === 'email')) && (
|
|
400
542
|
<React.Fragment key={field.id}>
|
|
401
543
|
{errors?.[`${field.code}`] && (
|
|
402
544
|
<OText
|
|
@@ -420,7 +562,7 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
420
562
|
value={value}
|
|
421
563
|
onChange={(val: any) =>
|
|
422
564
|
field.code !== 'email'
|
|
423
|
-
? onChange(val)
|
|
565
|
+
? (onChange(val))
|
|
424
566
|
: handleChangeInputEmail(val, onChange)
|
|
425
567
|
}
|
|
426
568
|
autoCapitalize={
|
|
@@ -452,12 +594,28 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
452
594
|
),
|
|
453
595
|
)}
|
|
454
596
|
|
|
455
|
-
{!!showInputPhoneNumber && (
|
|
597
|
+
{(!!showInputPhoneNumber && (signUpTab === 'default' || signUpTab === 'otpCellphone')) && (
|
|
456
598
|
<View style={{ marginBottom: 25 }}>
|
|
457
599
|
<PhoneInputNumber
|
|
458
600
|
data={phoneInputData}
|
|
459
|
-
handleData={(val: any) => setPhoneInputData(
|
|
601
|
+
handleData={(val: any) => setPhoneInputData({
|
|
602
|
+
...phoneInputData,
|
|
603
|
+
...val,
|
|
604
|
+
phone: {
|
|
605
|
+
...phoneInputData.phone,
|
|
606
|
+
...val.phone,
|
|
607
|
+
country_code: phoneInputData.phone.country_code
|
|
608
|
+
}
|
|
609
|
+
})}
|
|
460
610
|
forwardRef={phoneRef}
|
|
611
|
+
defaultCode={formState?.country_code ?? formState?.country_phone_code ?? null}
|
|
612
|
+
changeCountry={(val: any) => setPhoneInputData({
|
|
613
|
+
...phoneInputData,
|
|
614
|
+
phone: {
|
|
615
|
+
...phoneInputData.phone,
|
|
616
|
+
country_code: val.cca2
|
|
617
|
+
}
|
|
618
|
+
})}
|
|
461
619
|
textInputProps={{
|
|
462
620
|
returnKeyType: 'next',
|
|
463
621
|
onSubmitEditing: () => passwordRef?.current?.focus?.(),
|
|
@@ -467,33 +625,66 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
467
625
|
</View>
|
|
468
626
|
)}
|
|
469
627
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
628
|
+
{enableReCaptcha && (
|
|
629
|
+
<>
|
|
630
|
+
<TouchableOpacity
|
|
631
|
+
onPress={handleOpenRecaptcha}
|
|
632
|
+
style={{ marginHorizontal: 4, marginBottom: 10 }}
|
|
633
|
+
>
|
|
634
|
+
<RecaptchaButton>
|
|
635
|
+
{recaptchaVerified ? (
|
|
636
|
+
<MaterialCommunityIcons
|
|
637
|
+
name="checkbox-marked"
|
|
638
|
+
size={23}
|
|
639
|
+
color={theme.colors.primary}
|
|
640
|
+
/>
|
|
641
|
+
) : (
|
|
642
|
+
<MaterialCommunityIcons
|
|
643
|
+
name="checkbox-blank-outline"
|
|
644
|
+
size={23}
|
|
645
|
+
color={theme.colors.disabled}
|
|
646
|
+
/>
|
|
647
|
+
)}
|
|
648
|
+
<OText size={14} mLeft={8}>{t('VERIFY_ReCAPTCHA', 'Verify reCAPTCHA')}</OText>
|
|
649
|
+
</RecaptchaButton>
|
|
650
|
+
</TouchableOpacity>
|
|
651
|
+
<Recaptcha
|
|
652
|
+
ref={recaptchaRef}
|
|
653
|
+
siteKey={recaptchaConfig?.siteKey}
|
|
654
|
+
baseUrl={recaptchaConfig?.baseUrl}
|
|
655
|
+
onVerify={onRecaptchaVerify}
|
|
656
|
+
onExpire={() => setRecaptchaVerified(false)}
|
|
657
|
+
/>
|
|
658
|
+
</>
|
|
659
|
+
)}
|
|
660
|
+
{(signUpTab === 'default') && (
|
|
661
|
+
<View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 20 }}>
|
|
662
|
+
<Controller
|
|
663
|
+
control={control}
|
|
664
|
+
render={({ onChange, value }: any) => (
|
|
665
|
+
<CheckBox
|
|
666
|
+
value={value}
|
|
667
|
+
onValueChange={newValue => {
|
|
668
|
+
onChange(newValue)
|
|
669
|
+
handleChangePromotions()
|
|
670
|
+
}}
|
|
671
|
+
boxType={'square'}
|
|
672
|
+
tintColors={{
|
|
673
|
+
true: theme.colors.primary,
|
|
674
|
+
false: theme.colors.disabled
|
|
675
|
+
}}
|
|
676
|
+
tintColor={theme.colors.disabled}
|
|
677
|
+
onCheckColor={theme.colors.primary}
|
|
678
|
+
onTintColor={theme.colors.primary}
|
|
679
|
+
style={Platform.OS === 'ios' && style.checkBoxStyle}
|
|
680
|
+
/>
|
|
681
|
+
)}
|
|
682
|
+
name='promotions'
|
|
683
|
+
defaultValue={false}
|
|
684
|
+
/>
|
|
685
|
+
<OText style={{ fontSize: 14, paddingHorizontal: 5 }}>{t('RECEIVE_NEWS_EXCLUSIVE_PROMOTIONS', 'Receive newsletters and exclusive promotions')}</OText>
|
|
686
|
+
</View>
|
|
687
|
+
)}
|
|
497
688
|
{configs?.terms_and_conditions?.value === 'true' && (
|
|
498
689
|
<>
|
|
499
690
|
{errors?.termsAccept && (
|
|
@@ -545,7 +736,7 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
545
736
|
|
|
546
737
|
)}
|
|
547
738
|
|
|
548
|
-
{
|
|
739
|
+
{signUpTab === 'default' && (
|
|
549
740
|
<>
|
|
550
741
|
{errors?.password && (
|
|
551
742
|
<OText
|
|
@@ -617,9 +808,7 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
617
808
|
<Spinner visible />
|
|
618
809
|
)}
|
|
619
810
|
|
|
620
|
-
{
|
|
621
|
-
useSignupByEmail &&
|
|
622
|
-
useSignupByCellphone ? (
|
|
811
|
+
{(signUpTab === 'otpEmail' || signUpTab === 'otpCellphone') ? (
|
|
623
812
|
<OButton
|
|
624
813
|
onClick={handleSubmit(onSubmit)}
|
|
625
814
|
text={t('GET_VERIFY_CODE', 'Get Verify Code')}
|
|
@@ -684,7 +873,9 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
684
873
|
<ButtonsWrapper>
|
|
685
874
|
<SocialButtons>
|
|
686
875
|
{(configs?.facebook_login?.value === 'true' || configs?.facebook_login?.value === '1') &&
|
|
687
|
-
configs?.facebook_id?.value &&
|
|
876
|
+
configs?.facebook_id?.value &&
|
|
877
|
+
facebookLoginEnabled &&
|
|
878
|
+
(
|
|
688
879
|
<FacebookLogin
|
|
689
880
|
notificationState={notificationState}
|
|
690
881
|
handleErrors={(err: any) => showToast(ToastType.Error, err)}
|
|
@@ -692,7 +883,7 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
692
883
|
handleSuccessFacebookLogin={handleSuccessFacebook}
|
|
693
884
|
/>
|
|
694
885
|
)}
|
|
695
|
-
{(configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) && (
|
|
886
|
+
{(configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) && googleLoginEnabled && (
|
|
696
887
|
<GoogleLogin
|
|
697
888
|
notificationState={notificationState}
|
|
698
889
|
webClientId={configs?.google_login_client_id?.value}
|
|
@@ -701,7 +892,7 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
701
892
|
handleSuccessGoogleLogin={handleSuccessFacebook}
|
|
702
893
|
/>
|
|
703
894
|
)}
|
|
704
|
-
{(configs?.apple_login_client_id?.value !== '' && configs?.apple_login_client_id?.value !== null) && (
|
|
895
|
+
{(configs?.apple_login_client_id?.value !== '' && configs?.apple_login_client_id?.value !== null) && appleLoginEnabled && (
|
|
705
896
|
<AppleLogin
|
|
706
897
|
notificationState={notificationState}
|
|
707
898
|
handleErrors={(err: any) => showToast(ToastType.Error, err)}
|
|
@@ -715,27 +906,41 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
715
906
|
)}
|
|
716
907
|
|
|
717
908
|
</FormSide>
|
|
718
|
-
<OModal
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
909
|
+
<OModal
|
|
910
|
+
open={willVerifyOtpState}
|
|
911
|
+
onClose={() => setWillVerifyOtpState && setWillVerifyOtpState(false)}
|
|
912
|
+
entireModal
|
|
913
|
+
title={t('ENTER_VERIFICATION_CODE', 'Enter verification code')}
|
|
914
|
+
>
|
|
915
|
+
<Otp
|
|
916
|
+
pinCount={numOtpInputs || 6}
|
|
917
|
+
willVerifyOtpState={willVerifyOtpState || false}
|
|
918
|
+
setWillVerifyOtpState={() => setWillVerifyOtpState && setWillVerifyOtpState(false)}
|
|
919
|
+
handleLoginOtp={handleSingUpOtp}
|
|
920
|
+
onSubmit={onSubmit}
|
|
921
|
+
setAlertState={setAlertState}
|
|
727
922
|
/>
|
|
728
923
|
</OModal>
|
|
729
924
|
<Spinner
|
|
730
925
|
visible={formState.loading || validationFields.loading || isFBLoading}
|
|
731
926
|
/>
|
|
927
|
+
<Alert
|
|
928
|
+
open={alertState.open}
|
|
929
|
+
content={alertState.content}
|
|
930
|
+
title={alertState.title || ''}
|
|
931
|
+
onAccept={closeAlert}
|
|
932
|
+
onClose={closeAlert}
|
|
933
|
+
/>
|
|
732
934
|
</View>
|
|
733
935
|
);
|
|
734
936
|
};
|
|
735
937
|
|
|
736
938
|
export const SignupForm = (props: any) => {
|
|
939
|
+
const _numOtpInputs = 6
|
|
737
940
|
const signupProps = {
|
|
738
941
|
...props,
|
|
942
|
+
numOtpInputs: _numOtpInputs,
|
|
943
|
+
isRecaptchaEnable: true,
|
|
739
944
|
UIComponent: SignupFormUI,
|
|
740
945
|
};
|
|
741
946
|
return <SignUpController {...signupProps} />;
|