ordering-ui-react-native 0.15.52 → 0.15.53-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 +333 -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 +139 -15
  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,90 @@ 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
+ {(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(val)}
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
- <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
-
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
- {signupTab !== 'cellphone' && (
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
- {signupTab === 'cellphone' &&
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 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}
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} />;