ordering-ui-react-native 0.15.52 → 0.15.54-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.
Files changed (188) hide show
  1. package/package.json +5 -3
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/AddressForm/index.tsx +18 -2
  4. package/src/components/BusinessController/index.tsx +16 -8
  5. package/src/components/BusinessTypeFilter/index.tsx +3 -1
  6. package/src/components/BusinessesListing/index.tsx +1 -1
  7. package/src/components/Checkout/index.tsx +23 -2
  8. package/src/components/DriverTips/index.tsx +11 -6
  9. package/src/components/LanguageSelector/index.tsx +7 -2
  10. package/src/components/LoginForm/index.tsx +120 -30
  11. package/src/components/LoginForm/styles.tsx +6 -0
  12. package/src/components/OrderDetails/index.tsx +9 -23
  13. package/src/components/PaymentOptions/index.tsx +67 -50
  14. package/src/components/PaymentOptionsWebView/index.tsx +123 -124
  15. package/src/components/SignupForm/index.tsx +145 -61
  16. package/src/components/SingleProductCard/index.tsx +16 -4
  17. package/src/components/StripeMethodForm/index.tsx +1 -2
  18. package/src/components/UpsellingProducts/index.tsx +1 -1
  19. package/src/components/UserProfileForm/index.tsx +63 -6
  20. package/src/components/UserProfileForm/styles.tsx +8 -0
  21. package/src/components/VerifyPhone/styles.tsx +1 -2
  22. package/src/components/shared/OModal.tsx +1 -1
  23. package/src/hooks/useCountdownTimer.tsx +26 -0
  24. package/src/navigators/CheckoutNavigator.tsx +6 -0
  25. package/src/navigators/HomeNavigator.tsx +12 -0
  26. package/src/pages/BusinessesListing.tsx +1 -1
  27. package/src/pages/MultiCheckout.tsx +31 -0
  28. package/src/pages/MultiOrdersDetails.tsx +27 -0
  29. package/src/pages/Sessions.tsx +22 -0
  30. package/src/theme.json +0 -1
  31. package/src/types/index.tsx +18 -11
  32. package/src/utils/index.tsx +68 -1
  33. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +103 -15
  34. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -0
  35. package/themes/business/src/components/Chat/index.tsx +42 -90
  36. package/themes/business/src/components/DriverMap/index.tsx +6 -5
  37. package/themes/business/src/components/Home/index.tsx +128 -55
  38. package/themes/business/src/components/Home/styles.tsx +8 -1
  39. package/themes/business/src/components/LoginForm/index.tsx +89 -2
  40. package/themes/business/src/components/LoginForm/styles.tsx +6 -0
  41. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  42. package/themes/business/src/components/NewOrderNotification/index.tsx +79 -105
  43. package/themes/business/src/components/OrderDetails/Business.tsx +2 -2
  44. package/themes/business/src/components/OrderDetails/Delivery.tsx +35 -18
  45. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +159 -91
  46. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +6 -0
  47. package/themes/business/src/components/OrderDetails/styles.tsx +7 -0
  48. package/themes/business/src/components/OrdersListManager/index.tsx +1 -1
  49. package/themes/business/src/components/OrdersOption/index.tsx +5 -2
  50. package/themes/business/src/components/ProductItemAccordion/index.tsx +2 -2
  51. package/themes/business/src/components/shared/OModal.tsx +1 -1
  52. package/themes/business/src/types/index.tsx +5 -1
  53. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  54. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  55. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  56. package/themes/kiosk/src/components/BusinessMenu/index.tsx +39 -28
  57. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -3
  58. package/themes/kiosk/src/components/Cart/index.tsx +99 -26
  59. package/themes/kiosk/src/components/Cart/styles.tsx +6 -0
  60. package/themes/kiosk/src/components/CartBottomSheet/index.tsx +9 -2
  61. package/themes/kiosk/src/components/CartContent/index.tsx +0 -11
  62. package/themes/kiosk/src/components/CartItem/index.tsx +4 -3
  63. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +107 -62
  64. package/themes/kiosk/src/components/Checkout/index.tsx +40 -22
  65. package/themes/kiosk/src/components/CustomerName/index.tsx +0 -6
  66. package/themes/kiosk/src/components/DrawerView/index.tsx +1 -0
  67. package/themes/kiosk/src/components/DrawerView/styles.tsx +2 -2
  68. package/themes/kiosk/src/components/NavBar/index.tsx +29 -20
  69. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  70. package/themes/kiosk/src/components/OrderDetails/index.tsx +165 -65
  71. package/themes/kiosk/src/components/OrderDetails/styles.tsx +5 -0
  72. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +9 -11
  73. package/themes/kiosk/src/components/PaymentOptions/index.tsx +56 -54
  74. package/themes/kiosk/src/components/ProductForm/index.tsx +7 -8
  75. package/themes/kiosk/src/components/ProductItemAccordion/index.tsx +2 -2
  76. package/themes/kiosk/src/components/ProductOption/index.tsx +1 -1
  77. package/themes/kiosk/src/components/ProductOptionSubOption/index.tsx +3 -1
  78. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +16 -5
  79. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  80. package/themes/kiosk/src/types/index.d.ts +3 -0
  81. package/themes/original/index.tsx +169 -4
  82. package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
  83. package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
  84. package/themes/original/src/components/AddressForm/index.tsx +1 -1
  85. package/themes/original/src/components/AddressList/index.tsx +30 -18
  86. package/themes/original/src/components/AppleLogin/index.tsx +54 -21
  87. package/themes/original/src/components/BusinessBasicInformation/index.tsx +136 -45
  88. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +4 -0
  89. package/themes/original/src/components/BusinessController/index.tsx +48 -11
  90. package/themes/original/src/components/BusinessController/styles.tsx +27 -0
  91. package/themes/original/src/components/BusinessFeaturedController/index.tsx +20 -1
  92. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +23 -0
  93. package/themes/original/src/components/BusinessItemAccordion/index.tsx +8 -5
  94. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -1
  95. package/themes/original/src/components/BusinessListingSearch/index.tsx +196 -58
  96. package/themes/original/src/components/BusinessListingSearch/styles.tsx +22 -2
  97. package/themes/original/src/components/BusinessPreorder/index.tsx +1 -1
  98. package/themes/original/src/components/BusinessProductsCategories/index.tsx +2 -2
  99. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  100. package/themes/original/src/components/BusinessProductsList/index.tsx +119 -35
  101. package/themes/original/src/components/BusinessProductsList/styles.tsx +12 -4
  102. package/themes/original/src/components/BusinessProductsListing/index.tsx +109 -21
  103. package/themes/original/src/components/BusinessProductsListing/styles.tsx +22 -0
  104. package/themes/original/src/components/BusinessReviews/index.tsx +10 -26
  105. package/themes/original/src/components/BusinessTypeFilter/index.tsx +1 -2
  106. package/themes/original/src/components/BusinessesListing/index.tsx +127 -66
  107. package/themes/original/src/components/BusinessesListing/styles.tsx +11 -3
  108. package/themes/original/src/components/Cart/index.tsx +60 -41
  109. package/themes/original/src/components/Checkout/index.tsx +48 -32
  110. package/themes/original/src/components/DriverTips/index.tsx +17 -12
  111. package/themes/original/src/components/Favorite/index.tsx +92 -0
  112. package/themes/original/src/components/Favorite/styles.tsx +22 -0
  113. package/themes/original/src/components/FavoriteList/index.tsx +298 -0
  114. package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
  115. package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
  116. package/themes/original/src/components/GPSButton/index.tsx +15 -8
  117. package/themes/original/src/components/GoogleMap/index.tsx +1 -0
  118. package/themes/original/src/components/Help/index.tsx +21 -4
  119. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +18 -1
  120. package/themes/original/src/components/Home/index.tsx +1 -1
  121. package/themes/original/src/components/LastOrders/index.tsx +12 -1
  122. package/themes/original/src/components/LoginForm/Otp/index.tsx +91 -0
  123. package/themes/original/src/components/LoginForm/Otp/styles.tsx +7 -0
  124. package/themes/original/src/components/LoginForm/index.tsx +332 -164
  125. package/themes/original/src/components/LoginForm/styles.tsx +1 -3
  126. package/themes/original/src/components/MessageListing/index.tsx +10 -1
  127. package/themes/original/src/components/Messages/index.tsx +1 -1
  128. package/themes/original/src/components/MomentOption/index.tsx +10 -1
  129. package/themes/original/src/components/MomentOption/styles.tsx +1 -1
  130. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +243 -0
  131. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/styles.tsx +46 -0
  132. package/themes/original/src/components/MultiCheckout/index.tsx +298 -0
  133. package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
  134. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +372 -0
  135. package/themes/original/src/components/MultiOrdersDetails/index.tsx +258 -0
  136. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
  137. package/themes/original/src/components/MyOrders/index.tsx +120 -32
  138. package/themes/original/src/components/MyOrders/styles.tsx +8 -1
  139. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +167 -0
  140. package/themes/original/src/components/OrderDetails/index.tsx +117 -46
  141. package/themes/original/src/components/OrderDetails/styles.tsx +1 -2
  142. package/themes/original/src/components/OrderSummary/index.tsx +3 -3
  143. package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -2
  144. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +153 -0
  145. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
  146. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +53 -0
  147. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
  148. package/themes/original/src/components/OrdersOption/index.tsx +130 -38
  149. package/themes/original/src/components/OrdersOption/styles.tsx +4 -1
  150. package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
  151. package/themes/original/src/components/PaymentOptionWallet/index.tsx +17 -23
  152. package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
  153. package/themes/original/src/components/PaymentOptions/index.tsx +57 -36
  154. package/themes/original/src/components/PhoneInputNumber/index.tsx +1 -1
  155. package/themes/original/src/components/PreviousOrders/index.tsx +18 -147
  156. package/themes/original/src/components/ProductForm/index.tsx +70 -62
  157. package/themes/original/src/components/ProductForm/styles.tsx +0 -1
  158. package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
  159. package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -12
  160. package/themes/original/src/components/Promotions/index.tsx +151 -133
  161. package/themes/original/src/components/Promotions/styles.tsx +3 -23
  162. package/themes/original/src/components/SearchBar/index.tsx +10 -4
  163. package/themes/original/src/components/Sessions/index.tsx +160 -0
  164. package/themes/original/src/components/Sessions/styles.tsx +15 -0
  165. package/themes/original/src/components/SignupForm/index.tsx +335 -128
  166. package/themes/original/src/components/SingleOrderCard/index.tsx +282 -0
  167. package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
  168. package/themes/original/src/components/SingleProductCard/index.tsx +59 -17
  169. package/themes/original/src/components/StripeElementsForm/index.tsx +16 -8
  170. package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
  171. package/themes/original/src/components/UpsellingProducts/index.tsx +86 -74
  172. package/themes/original/src/components/UserDetails/index.tsx +5 -96
  173. package/themes/original/src/components/UserFormDetails/index.tsx +34 -24
  174. package/themes/original/src/components/UserProfile/index.tsx +53 -6
  175. package/themes/original/src/components/UserProfileForm/index.tsx +20 -18
  176. package/themes/original/src/components/UserVerification/index.tsx +178 -192
  177. package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
  178. package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
  179. package/themes/original/src/components/Wallets/index.tsx +76 -9
  180. package/themes/original/src/components/Wallets/styles.tsx +21 -0
  181. package/themes/original/src/components/shared/OModal.tsx +4 -2
  182. package/themes/original/src/config/constants.tsx +6 -6
  183. package/themes/original/src/types/index.tsx +193 -32
  184. package/themes/original/src/utils/index.tsx +85 -2
  185. package/themes/single-business/src/components/AddressList/index.tsx +1 -1
  186. package/themes/single-business/src/components/OrderTypeSelector/index.tsx +1 -1
  187. package/themes/single-business/src/components/UserProfile/index.tsx +1 -1
  188. 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 { OText, OButton, OInput, OModal } from '../shared';
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
- const showInputPhoneNumber = (validationFields?.fields?.checkout?.cellphone?.enabled ?? false) || configs?.verification_phone_required?.value === '1'
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 handleChangeTab = (val: string) => {
199
- setSignupTab(val);
200
- setPasswordSee(false);
201
- };
239
+ const handleSignUpTab = (tab: string) => {
240
+ setSignUpTab && setSignUpTab(tab)
241
+ clearErrors()
242
+ }
202
243
 
203
- const onSubmit = (values: any) => {
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
- validationFields?.fields?.checkout?.cellphone?.required) ||
213
- configs?.verification_phone_required?.value === '1')
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 (signupTab === 'email' || !useSignupByCellphone) {
225
- handleButtonSignupClick &&
226
- handleButtonSignupClick({
227
- ...values,
228
- ...((phoneInputData.phone.cellphone !== null && phoneInputData.phone.country_phone_code !== null) && {...phoneInputData.phone}),
229
- });
230
- if (
231
- !formState.loading &&
232
- formState.result.result &&
233
- !formState.result.error
234
- ) {
235
- handleSuccessSignup && handleSuccessSignup(formState.result.result);
236
- }
237
- return;
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
- register('cellphone', {
305
- required: isRequiredField('cellphone')
306
- ? t('VALIDATION_ERROR_MOBILE_PHONE_REQUIRED', 'The field Mobile phone is required').replace('_attribute_', t('CELLPHONE', 'Cellphone'))
307
- : null
308
- })
309
- }, [register])
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,92 @@ const SignupFormUI = (props: SignupParams) => {
346
443
  titleStyle={{ marginLeft: 0, marginRight: 0 }}
347
444
  />
348
445
  <FormSide>
349
- {useSignupByEmail &&
350
- useSignupByCellphone &&
351
- configs &&
352
- Object.keys(configs).length > 0 &&
353
- (configs?.twilio_service_enabled?.value === 'true' ||
354
- configs?.twilio_service_enabled?.value === '1') && (
355
- <SignupWith style={{ paddingBottom: 25 }}>
356
- <OTabs>
357
- {useSignupByEmail && (
358
- <Pressable onPress={() => handleChangeTab('email')}>
359
- <OTab>
360
- <OText
361
- size={18}
362
- color={
363
- signupTab === 'email'
364
- ? theme.colors.primary
365
- : theme.colors.disabled
366
- }>
367
- {t('SIGNUP_BY_EMAIL', 'Signup by Email')}
368
- </OText>
369
- </OTab>
370
- </Pressable>
371
- )}
372
- {useSignupByCellphone && (
373
- <Pressable onPress={() => handleChangeTab('cellphone')}>
374
- <OTab>
375
- <OText
376
- size={18}
377
- color={
378
- signupTab === 'cellphone'
379
- ? theme.colors.primary
380
- : theme.colors.disabled
381
- }>
382
- {t('SIGNUP_BY_PHONE', 'Signup by Phone')}
383
- </OText>
384
- </OTab>
385
- </Pressable>
386
- )}
387
- </OTabs>
388
- </SignupWith>
389
- )}
446
+ {((Number(useSignUpFullDetails) + Number(useSignUpOtpEmail) + Number(useSignUpOtpCellphone)) > 1) && (
447
+ <SignupWith>
448
+ <OTabs
449
+ horizontal
450
+ showsHorizontalScrollIndicator={false}
451
+ ref={tabsRef}
452
+ >
453
+ {useSignUpFullDetails && (
454
+ <TabBtn
455
+ onPress={() => handleSignUpTab('default')}
456
+ onLayout={(event: any) => handleOnLayout(event, 'default')}
457
+ >
458
+ <OTab
459
+ style={{
460
+ borderBottomColor:
461
+ signUpTab === 'default'
462
+ ? theme.colors.textNormal
463
+ : theme.colors.border,
464
+ }}>
465
+ <OText
466
+ size={14}
467
+ color={
468
+ signUpTab === 'default'
469
+ ? theme.colors.textNormal
470
+ : theme.colors.disabled
471
+ }
472
+ weight={signUpTab === 'default' ? 'bold' : 'normal'}>
473
+ {t('DEFAULT', 'Default')}
474
+ </OText>
475
+ </OTab>
476
+ </TabBtn>
477
+ )}
478
+ {useSignUpOtpEmail && (
479
+ <TabBtn
480
+ onPress={() => handleSignUpTab('otpEmail')}
481
+ onLayout={(event: any) => handleOnLayout(event, 'otpEmail')}
482
+ >
483
+ <OTab
484
+ style={{
485
+ borderBottomColor:
486
+ signUpTab === 'otpEmail'
487
+ ? theme.colors.textNormal
488
+ : theme.colors.border,
489
+ }}>
490
+ <OText
491
+ size={14}
492
+ color={
493
+ signUpTab === 'otpEmail'
494
+ ? theme.colors.textNormal
495
+ : theme.colors.disabled
496
+ }
497
+ weight={signUpTab === 'otpEmail' ? 'bold' : 'normal'}>
498
+ {t('BY_OTP_EMAIL', 'by Otp Email')}
499
+ </OText>
500
+ </OTab>
501
+ </TabBtn>
502
+
503
+ )}
504
+ {useSignUpOtpCellphone && (
505
+ <TabBtn
506
+ onPress={() => handleSignUpTab('otpCellphone')}
507
+ onLayout={(event: any) => handleOnLayout(event, 'otpCellphone')}
508
+ >
509
+ <OTab
510
+ style={{
511
+ borderBottomColor:
512
+ signUpTab === 'otpCellphone'
513
+ ? theme.colors.textNormal
514
+ : theme.colors.border,
515
+ }}>
516
+ <OText
517
+ size={14}
518
+ color={
519
+ signUpTab === 'otpCellphone'
520
+ ? theme.colors.textNormal
521
+ : theme.colors.disabled
522
+ }
523
+ weight={signUpTab === 'otpCellphone' ? 'bold' : 'normal'}>
524
+ {t('BY_OTP_CELLPHONE', 'by Otp Cellphone')}
525
+ </OText>
526
+ </OTab>
527
+ </TabBtn>
528
+ )}
529
+ </OTabs>
530
+ </SignupWith>
531
+ )}
390
532
  <FormInput>
391
533
  {!(useChekoutFileds && validationFields?.loading) ? (
392
534
  <>
@@ -396,7 +538,9 @@ const SignupFormUI = (props: SignupParams) => {
396
538
  (field: any, i: number) =>
397
539
  !notValidationFields.includes(field.code) &&
398
540
  showField &&
399
- showField(field.code) && (
541
+ showField(field.code) &&
542
+ (signUpTab === 'default' ||
543
+ (signUpTab === 'otpEmail' && field.code === 'email')) && (
400
544
  <React.Fragment key={field.id}>
401
545
  {errors?.[`${field.code}`] && (
402
546
  <OText
@@ -420,7 +564,7 @@ const SignupFormUI = (props: SignupParams) => {
420
564
  value={value}
421
565
  onChange={(val: any) =>
422
566
  field.code !== 'email'
423
- ? onChange(val)
567
+ ? (onChange(val))
424
568
  : handleChangeInputEmail(val, onChange)
425
569
  }
426
570
  autoCapitalize={
@@ -452,12 +596,28 @@ const SignupFormUI = (props: SignupParams) => {
452
596
  ),
453
597
  )}
454
598
 
455
- {!!showInputPhoneNumber && (
599
+ {(!!showInputPhoneNumber && (signUpTab === 'default' || signUpTab === 'otpCellphone')) && (
456
600
  <View style={{ marginBottom: 25 }}>
457
601
  <PhoneInputNumber
458
602
  data={phoneInputData}
459
- handleData={(val: any) => setPhoneInputData(val)}
603
+ handleData={(val: any) => setPhoneInputData({
604
+ ...phoneInputData,
605
+ ...val,
606
+ phone: {
607
+ ...phoneInputData.phone,
608
+ ...val.phone,
609
+ country_code: phoneInputData.phone.country_code
610
+ }
611
+ })}
460
612
  forwardRef={phoneRef}
613
+ defaultCode={formState?.country_code ?? formState?.country_phone_code ?? null}
614
+ changeCountry={(val: any) => setPhoneInputData({
615
+ ...phoneInputData,
616
+ phone: {
617
+ ...phoneInputData.phone,
618
+ country_code: val.cca2
619
+ }
620
+ })}
461
621
  textInputProps={{
462
622
  returnKeyType: 'next',
463
623
  onSubmitEditing: () => passwordRef?.current?.focus?.(),
@@ -467,33 +627,66 @@ const SignupFormUI = (props: SignupParams) => {
467
627
  </View>
468
628
  )}
469
629
 
470
- <View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 20 }}>
471
- <Controller
472
- control={control}
473
- render={({ onChange, value }: any) => (
474
- <CheckBox
475
- value={value}
476
- onValueChange={newValue => {
477
- onChange(newValue)
478
- handleChangePromotions()
479
- }}
480
- boxType={'square'}
481
- tintColors={{
482
- true: theme.colors.primary,
483
- false: theme.colors.disabled
484
- }}
485
- tintColor={theme.colors.disabled}
486
- onCheckColor={theme.colors.primary}
487
- onTintColor={theme.colors.primary}
488
- style={Platform.OS === 'ios' && style.checkBoxStyle}
489
- />
490
- )}
491
- name='promotions'
492
- defaultValue={false}
493
- />
494
- <OText style={{ fontSize: 14, paddingHorizontal: 5 }}>{t('RECEIVE_NEWS_EXCLUSIVE_PROMOTIONS', 'Receive newsletters and exclusive promotions')}</OText>
495
- </View>
496
-
630
+ {enableReCaptcha && (
631
+ <>
632
+ <TouchableOpacity
633
+ onPress={handleOpenRecaptcha}
634
+ style={{ marginHorizontal: 4, marginBottom: 10 }}
635
+ >
636
+ <RecaptchaButton>
637
+ {recaptchaVerified ? (
638
+ <MaterialCommunityIcons
639
+ name="checkbox-marked"
640
+ size={23}
641
+ color={theme.colors.primary}
642
+ />
643
+ ) : (
644
+ <MaterialCommunityIcons
645
+ name="checkbox-blank-outline"
646
+ size={23}
647
+ color={theme.colors.disabled}
648
+ />
649
+ )}
650
+ <OText size={14} mLeft={8}>{t('VERIFY_ReCAPTCHA', 'Verify reCAPTCHA')}</OText>
651
+ </RecaptchaButton>
652
+ </TouchableOpacity>
653
+ <Recaptcha
654
+ ref={recaptchaRef}
655
+ siteKey={recaptchaConfig?.siteKey}
656
+ baseUrl={recaptchaConfig?.baseUrl}
657
+ onVerify={onRecaptchaVerify}
658
+ onExpire={() => setRecaptchaVerified(false)}
659
+ />
660
+ </>
661
+ )}
662
+ {(signUpTab === 'default') && (
663
+ <View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 20 }}>
664
+ <Controller
665
+ control={control}
666
+ render={({ onChange, value }: any) => (
667
+ <CheckBox
668
+ value={value}
669
+ onValueChange={newValue => {
670
+ onChange(newValue)
671
+ handleChangePromotions()
672
+ }}
673
+ boxType={'square'}
674
+ tintColors={{
675
+ true: theme.colors.primary,
676
+ false: theme.colors.disabled
677
+ }}
678
+ tintColor={theme.colors.disabled}
679
+ onCheckColor={theme.colors.primary}
680
+ onTintColor={theme.colors.primary}
681
+ style={Platform.OS === 'ios' && style.checkBoxStyle}
682
+ />
683
+ )}
684
+ name='promotions'
685
+ defaultValue={false}
686
+ />
687
+ <OText style={{ fontSize: 14, paddingHorizontal: 5 }}>{t('RECEIVE_NEWS_EXCLUSIVE_PROMOTIONS', 'Receive newsletters and exclusive promotions')}</OText>
688
+ </View>
689
+ )}
497
690
  {configs?.terms_and_conditions?.value === 'true' && (
498
691
  <>
499
692
  {errors?.termsAccept && (
@@ -545,7 +738,7 @@ const SignupFormUI = (props: SignupParams) => {
545
738
 
546
739
  )}
547
740
 
548
- {signupTab !== 'cellphone' && (
741
+ {signUpTab === 'default' && (
549
742
  <>
550
743
  {errors?.password && (
551
744
  <OText
@@ -617,9 +810,7 @@ const SignupFormUI = (props: SignupParams) => {
617
810
  <Spinner visible />
618
811
  )}
619
812
 
620
- {signupTab === 'cellphone' &&
621
- useSignupByEmail &&
622
- useSignupByCellphone ? (
813
+ {(signUpTab === 'otpEmail' || signUpTab === 'otpCellphone') ? (
623
814
  <OButton
624
815
  onClick={handleSubmit(onSubmit)}
625
816
  text={t('GET_VERIFY_CODE', 'Get Verify Code')}
@@ -684,7 +875,9 @@ const SignupFormUI = (props: SignupParams) => {
684
875
  <ButtonsWrapper>
685
876
  <SocialButtons>
686
877
  {(configs?.facebook_login?.value === 'true' || configs?.facebook_login?.value === '1') &&
687
- configs?.facebook_id?.value && (
878
+ configs?.facebook_id?.value &&
879
+ facebookLoginEnabled &&
880
+ (
688
881
  <FacebookLogin
689
882
  notificationState={notificationState}
690
883
  handleErrors={(err: any) => showToast(ToastType.Error, err)}
@@ -692,7 +885,7 @@ const SignupFormUI = (props: SignupParams) => {
692
885
  handleSuccessFacebookLogin={handleSuccessFacebook}
693
886
  />
694
887
  )}
695
- {(configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) && (
888
+ {(configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) && googleLoginEnabled && (
696
889
  <GoogleLogin
697
890
  notificationState={notificationState}
698
891
  webClientId={configs?.google_login_client_id?.value}
@@ -701,7 +894,7 @@ const SignupFormUI = (props: SignupParams) => {
701
894
  handleSuccessGoogleLogin={handleSuccessFacebook}
702
895
  />
703
896
  )}
704
- {(configs?.apple_login_client_id?.value !== '' && configs?.apple_login_client_id?.value !== null) && (
897
+ {(configs?.apple_login_client_id?.value !== '' && configs?.apple_login_client_id?.value !== null) && appleLoginEnabled && (
705
898
  <AppleLogin
706
899
  notificationState={notificationState}
707
900
  handleErrors={(err: any) => showToast(ToastType.Error, err)}
@@ -715,27 +908,41 @@ const SignupFormUI = (props: SignupParams) => {
715
908
  )}
716
909
 
717
910
  </FormSide>
718
- <OModal open={isModalVisible} onClose={() => setIsModalVisible(false)}>
719
- <VerifyPhone
720
- phone={phoneInputData.phone}
721
- formValues={formValues}
722
- verifyPhoneState={verifyPhoneState}
723
- checkPhoneCodeState={checkPhoneCodeState}
724
- handleCheckPhoneCode={handleCheckPhoneCode}
725
- setCheckPhoneCodeState={setCheckPhoneCodeState}
726
- handleVerifyCodeClick={onSubmit}
911
+ <OModal
912
+ open={willVerifyOtpState}
913
+ onClose={() => setWillVerifyOtpState && setWillVerifyOtpState(false)}
914
+ entireModal
915
+ title={t('ENTER_VERIFICATION_CODE', 'Enter verification code')}
916
+ >
917
+ <Otp
918
+ pinCount={numOtpInputs || 6}
919
+ willVerifyOtpState={willVerifyOtpState || false}
920
+ setWillVerifyOtpState={() => setWillVerifyOtpState && setWillVerifyOtpState(false)}
921
+ handleLoginOtp={handleSingUpOtp}
922
+ onSubmit={onSubmit}
923
+ setAlertState={setAlertState}
727
924
  />
728
925
  </OModal>
729
926
  <Spinner
730
927
  visible={formState.loading || validationFields.loading || isFBLoading}
731
928
  />
929
+ <Alert
930
+ open={alertState.open}
931
+ content={alertState.content}
932
+ title={alertState.title || ''}
933
+ onAccept={closeAlert}
934
+ onClose={closeAlert}
935
+ />
732
936
  </View>
733
937
  );
734
938
  };
735
939
 
736
940
  export const SignupForm = (props: any) => {
941
+ const _numOtpInputs = 6
737
942
  const signupProps = {
738
943
  ...props,
944
+ numOtpInputs: _numOtpInputs,
945
+ isRecaptchaEnable: true,
739
946
  UIComponent: SignupFormUI,
740
947
  };
741
948
  return <SignUpController {...signupProps} />;