ordering-ui-react-native 0.16.9 → 0.16.10-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 (219) hide show
  1. package/package.json +8 -4
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/ActiveOrders/index.tsx +61 -63
  4. package/src/components/ActiveOrders/styles.tsx +8 -14
  5. package/src/components/AddressForm/index.tsx +18 -2
  6. package/src/components/BusinessBasicInformation/index.tsx +11 -19
  7. package/src/components/BusinessController/index.tsx +10 -8
  8. package/src/components/BusinessInformation/index.tsx +22 -0
  9. package/src/components/BusinessTypeFilter/index.tsx +1 -2
  10. package/src/components/BusinessesListing/index.tsx +1 -1
  11. package/src/components/Checkout/index.tsx +2 -1
  12. package/src/components/LanguageSelector/index.tsx +21 -16
  13. package/src/components/LoginForm/index.tsx +118 -30
  14. package/src/components/LoginForm/styles.tsx +6 -0
  15. package/src/components/Messages/index.tsx +2 -2
  16. package/src/components/NotificationSetting/index.tsx +85 -0
  17. package/src/components/OrderDetails/index.tsx +7 -21
  18. package/src/components/OrdersOption/index.tsx +54 -56
  19. package/src/components/PaymentOptions/index.tsx +335 -365
  20. package/src/components/PaymentOptionsWebView/index.tsx +120 -121
  21. package/src/components/ReviewDriver/index.tsx +1 -1
  22. package/src/components/ReviewOrder/index.tsx +2 -1
  23. package/src/components/ReviewProducts/index.tsx +11 -0
  24. package/src/components/SignupForm/index.tsx +143 -61
  25. package/src/components/SingleProductReview/index.tsx +8 -5
  26. package/src/components/StripeElementsForm/index.tsx +25 -16
  27. package/src/components/StripeMethodForm/index.tsx +1 -2
  28. package/src/components/VerifyPhone/styles.tsx +1 -2
  29. package/src/components/shared/OBottomPopup.tsx +6 -2
  30. package/src/index.tsx +2 -0
  31. package/src/navigators/CheckoutNavigator.tsx +6 -0
  32. package/src/navigators/HomeNavigator.tsx +6 -0
  33. package/src/pages/BusinessesListing.tsx +7 -6
  34. package/src/pages/MultiCheckout.tsx +31 -0
  35. package/src/pages/MultiOrdersDetails.tsx +27 -0
  36. package/src/pages/OrderDetails.tsx +1 -1
  37. package/src/pages/ReviewDriver.tsx +2 -2
  38. package/src/pages/ReviewOrder.tsx +2 -2
  39. package/src/theme.json +0 -1
  40. package/src/types/@fatnlazycat/react-native-recaptcha-v3/index.d.ts +1 -0
  41. package/src/types/index.tsx +13 -9
  42. package/src/utils/index.tsx +0 -1
  43. package/themes/business/index.tsx +4 -0
  44. package/themes/business/src/components/BusinessController/index.tsx +2 -2
  45. package/themes/business/src/components/Chat/index.tsx +42 -34
  46. package/themes/business/src/components/DriverMap/index.tsx +13 -10
  47. package/themes/business/src/components/DriverSchedule/index.tsx +71 -0
  48. package/themes/business/src/components/DriverSchedule/styles.tsx +6 -0
  49. package/themes/business/src/components/LoginForm/index.tsx +111 -74
  50. package/themes/business/src/components/MapView/index.tsx +1 -1
  51. package/themes/business/src/components/MessagesOption/index.tsx +11 -1
  52. package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
  53. package/themes/business/src/components/OrderDetails/Delivery.tsx +3 -3
  54. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +19 -18
  55. package/themes/business/src/components/OrdersListManager/index.tsx +10 -3
  56. package/themes/business/src/components/OrdersOption/index.tsx +65 -21
  57. package/themes/business/src/components/OrdersOption/styles.tsx +5 -1
  58. package/themes/business/src/components/OrdersOptionBusiness/index.tsx +15 -1
  59. package/themes/business/src/components/OrdersOptionCity/index.tsx +15 -1
  60. package/themes/business/src/components/OrdersOptionDate/index.tsx +19 -6
  61. package/themes/business/src/components/OrdersOptionDelivery/index.tsx +15 -1
  62. package/themes/business/src/components/OrdersOptionDriver/index.tsx +15 -1
  63. package/themes/business/src/components/OrdersOptionPaymethod/index.tsx +15 -1
  64. package/themes/business/src/components/OrdersOptionStatus/index.tsx +10 -1
  65. package/themes/business/src/components/PreviousMessages/index.tsx +17 -18
  66. package/themes/business/src/components/PreviousOrders/index.tsx +21 -23
  67. package/themes/business/src/components/ProductItemAccordion/index.tsx +5 -4
  68. package/themes/business/src/components/ReviewCustomer/index.tsx +1 -1
  69. package/themes/business/src/components/ScheduleBlocked/index.tsx +53 -0
  70. package/themes/business/src/components/UserFormDetails/index.tsx +5 -2
  71. package/themes/business/src/components/UserProfileForm/index.tsx +28 -4
  72. package/themes/business/src/components/shared/ODropDown.tsx +42 -8
  73. package/themes/business/src/components/shared/ODropDownCalendar.tsx +36 -7
  74. package/themes/business/src/components/shared/OModal.tsx +40 -37
  75. package/themes/business/src/types/index.tsx +14 -9
  76. package/themes/business/src/utils/index.tsx +10 -0
  77. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  78. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  79. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  80. package/themes/kiosk/src/components/BusinessMenu/index.tsx +2 -1
  81. package/themes/kiosk/src/components/CartItem/index.tsx +4 -3
  82. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +1 -0
  83. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  84. package/themes/kiosk/src/components/DrawerView/index.tsx +1 -0
  85. package/themes/kiosk/src/components/DrawerView/styles.tsx +2 -2
  86. package/themes/kiosk/src/components/LoginForm/index.tsx +121 -10
  87. package/themes/kiosk/src/components/LoginForm/styles.tsx +5 -0
  88. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  89. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  90. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  91. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  92. package/themes/kiosk/src/types/index.d.ts +2 -0
  93. package/themes/original/index.tsx +22 -0
  94. package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
  95. package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
  96. package/themes/original/src/components/AddressForm/index.tsx +136 -133
  97. package/themes/original/src/components/AddressList/index.tsx +1 -1
  98. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  99. package/themes/original/src/components/BusinessBasicInformation/index.tsx +302 -160
  100. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +6 -2
  101. package/themes/original/src/components/BusinessController/index.tsx +179 -96
  102. package/themes/original/src/components/BusinessController/styles.tsx +5 -0
  103. package/themes/original/src/components/BusinessItemAccordion/index.tsx +12 -9
  104. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -1
  105. package/themes/original/src/components/BusinessListingSearch/BusinessControllerSkeletons/index.tsx +57 -0
  106. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +59 -0
  107. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/styles.tsx +13 -0
  108. package/themes/original/src/components/BusinessListingSearch/index.tsx +106 -126
  109. package/themes/original/src/components/BusinessListingSearch/styles.tsx +18 -13
  110. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  111. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +87 -0
  112. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/styles.tsx +12 -0
  113. package/themes/original/src/components/BusinessProductsList/index.tsx +65 -72
  114. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  115. package/themes/original/src/components/BusinessProductsListing/index.tsx +290 -178
  116. package/themes/original/src/components/BusinessProductsListing/styles.tsx +18 -0
  117. package/themes/original/src/components/BusinessReviews/index.tsx +6 -1
  118. package/themes/original/src/components/BusinessTypeFilter/index.tsx +106 -38
  119. package/themes/original/src/components/BusinessTypeFilter/styles.tsx +2 -0
  120. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +561 -0
  121. package/themes/original/src/components/BusinessesListing/{styles.tsx → Layout/Appointment/styles.tsx} +24 -2
  122. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +673 -0
  123. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +137 -0
  124. package/themes/original/src/components/BusinessesListing/index.tsx +102 -464
  125. package/themes/original/src/components/Cart/index.tsx +81 -36
  126. package/themes/original/src/components/Cart/styles.tsx +4 -0
  127. package/themes/original/src/components/CartContent/index.tsx +22 -16
  128. package/themes/original/src/components/Checkout/index.tsx +106 -66
  129. package/themes/original/src/components/Checkout/styles.tsx +0 -1
  130. package/themes/original/src/components/DriverTips/index.tsx +4 -4
  131. package/themes/original/src/components/DriverTips/styles.tsx +2 -1
  132. package/themes/original/src/components/Favorite/index.tsx +92 -0
  133. package/themes/original/src/components/Favorite/styles.tsx +22 -0
  134. package/themes/original/src/components/FavoriteList/index.tsx +317 -0
  135. package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
  136. package/themes/original/src/components/GPSButton/index.tsx +25 -17
  137. package/themes/original/src/components/GoogleMap/index.tsx +20 -12
  138. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +8 -3
  139. package/themes/original/src/components/HelpGuide/index.tsx +8 -3
  140. package/themes/original/src/components/HelpOrder/index.tsx +8 -3
  141. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +18 -1
  142. package/themes/original/src/components/LoginForm/Otp/index.tsx +3 -2
  143. package/themes/original/src/components/LoginForm/index.tsx +79 -42
  144. package/themes/original/src/components/Messages/index.tsx +17 -17
  145. package/themes/original/src/components/MomentSelector/index.tsx +197 -0
  146. package/themes/original/src/components/MomentSelector/styles.tsx +6 -0
  147. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +243 -0
  148. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/styles.tsx +46 -0
  149. package/themes/original/src/components/MultiCheckout/index.tsx +304 -0
  150. package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
  151. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +372 -0
  152. package/themes/original/src/components/MultiOrdersDetails/index.tsx +262 -0
  153. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
  154. package/themes/original/src/components/MyOrders/index.tsx +177 -27
  155. package/themes/original/src/components/MyOrders/styles.tsx +8 -1
  156. package/themes/original/src/components/NavBar/index.tsx +11 -5
  157. package/themes/original/src/components/NotFoundSource/index.tsx +2 -1
  158. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +167 -0
  159. package/themes/original/src/components/OrderDetails/index.tsx +125 -40
  160. package/themes/original/src/components/OrderDetails/styles.tsx +5 -2
  161. package/themes/original/src/components/OrderItAgain/index.tsx +75 -0
  162. package/themes/original/src/components/OrderItAgain/styles.tsx +10 -0
  163. package/themes/original/src/components/OrderProgress/index.tsx +8 -2
  164. package/themes/original/src/components/OrderSummary/index.tsx +1 -34
  165. package/themes/original/src/components/OrderTypeSelector/index.tsx +84 -36
  166. package/themes/original/src/components/OrderTypeSelector/styles.tsx +19 -1
  167. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +144 -0
  168. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
  169. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +56 -0
  170. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
  171. package/themes/original/src/components/OrdersOption/index.tsx +130 -37
  172. package/themes/original/src/components/OrdersOption/styles.tsx +4 -1
  173. package/themes/original/src/components/PaymentOptions/index.tsx +57 -37
  174. package/themes/original/src/components/PhoneInputNumber/index.tsx +4 -10
  175. package/themes/original/src/components/PlaceSpot/index.tsx +243 -47
  176. package/themes/original/src/components/PlaceSpot/styles.tsx +0 -2
  177. package/themes/original/src/components/PreviousOrders/index.tsx +18 -147
  178. package/themes/original/src/components/ProductForm/index.tsx +712 -655
  179. package/themes/original/src/components/ProductForm/styles.tsx +9 -7
  180. package/themes/original/src/components/ProductItemAccordion/index.tsx +37 -24
  181. package/themes/original/src/components/ProductOption/index.tsx +1 -1
  182. package/themes/original/src/components/ProfessionalFilter/index.tsx +129 -0
  183. package/themes/original/src/components/ProfessionalFilter/styles.tsx +0 -0
  184. package/themes/original/src/components/ProfessionalProfile/index.tsx +309 -0
  185. package/themes/original/src/components/ProfessionalProfile/styles.tsx +46 -0
  186. package/themes/original/src/components/ReviewDriver/index.tsx +6 -6
  187. package/themes/original/src/components/ReviewOrder/index.tsx +18 -3
  188. package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
  189. package/themes/original/src/components/ReviewTrigger/index.tsx +118 -0
  190. package/themes/original/src/components/ReviewTrigger/styles.tsx +34 -0
  191. package/themes/original/src/components/SearchBar/index.tsx +10 -5
  192. package/themes/original/src/components/ServiceForm/index.tsx +608 -0
  193. package/themes/original/src/components/ServiceForm/styles.tsx +50 -0
  194. package/themes/original/src/components/SignupForm/index.tsx +301 -158
  195. package/themes/original/src/components/SingleOrderCard/index.tsx +316 -0
  196. package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
  197. package/themes/original/src/components/SingleProductCard/index.tsx +215 -95
  198. package/themes/original/src/components/SingleProductCard/styles.tsx +2 -2
  199. package/themes/original/src/components/SingleProductReview/index.tsx +30 -3
  200. package/themes/original/src/components/SingleProductReview/styles.tsx +12 -0
  201. package/themes/original/src/components/StripeElementsForm/index.tsx +25 -9
  202. package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
  203. package/themes/original/src/components/UpsellingProducts/index.tsx +14 -4
  204. package/themes/original/src/components/UserDetails/index.tsx +32 -18
  205. package/themes/original/src/components/UserFormDetails/index.tsx +107 -73
  206. package/themes/original/src/components/UserProfile/index.tsx +12 -1
  207. package/themes/original/src/components/UserProfileForm/index.tsx +15 -10
  208. package/themes/original/src/components/WalletTransactions/index.tsx +76 -0
  209. package/themes/original/src/components/WalletTransactions/styles.tsx +13 -0
  210. package/themes/original/src/components/Wallets/index.tsx +176 -162
  211. package/themes/original/src/components/Wallets/styles.tsx +10 -8
  212. package/themes/original/src/components/shared/OBottomPopup.tsx +47 -14
  213. package/themes/original/src/components/shared/OButton.tsx +10 -3
  214. package/themes/original/src/components/shared/OInput.tsx +3 -2
  215. package/themes/original/src/components/shared/OModal.tsx +3 -1
  216. package/themes/original/src/layouts/FloatingBottomContainer.tsx +5 -1
  217. package/themes/original/src/types/index.tsx +200 -46
  218. package/themes/original/src/utils/index.tsx +77 -0
  219. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -7,6 +7,7 @@ import CheckBox from '@react-native-community/checkbox';
7
7
  import { PhoneInputNumber } from '../PhoneInputNumber';
8
8
  import { FacebookLogin } from '../FacebookLogin';
9
9
  import Recaptcha from 'react-native-recaptcha-that-works'
10
+ import ReCaptcha from '@fatnlazycat/react-native-recaptcha-v3'
10
11
 
11
12
  import {
12
13
  SignupForm as SignUpController,
@@ -18,10 +19,12 @@ import {
18
19
  } from 'ordering-components/native';
19
20
  import { useTheme } from 'styled-components/native';
20
21
  import { FormSide, FormInput, SocialButtons } from './styles';
22
+ import { Otp } from '../LoginForm/Otp'
21
23
 
22
24
  import {
23
25
  ButtonsWrapper,
24
26
  LoginWith as SignupWith,
27
+ TabBtn,
25
28
  OTab,
26
29
  OTabs,
27
30
  RecaptchaButton
@@ -30,7 +33,9 @@ import {
30
33
  import NavBar from '../NavBar';
31
34
  import { VerifyPhone } from '../VerifyPhone';
32
35
 
33
- import { OText, OButton, OInput, OModal } from '../shared';
36
+ import Alert from '../../../../../src/providers/AlertProvider'
37
+ import { OText, OButton, OInput } from '../shared';
38
+ import { OModal } from '../../../../../src/components/shared';
34
39
  import { SignupParams } from '../../types';
35
40
  import { sortInputFields } from '../../utils';
36
41
  import { GoogleLogin } from '../GoogleLogin';
@@ -67,7 +72,18 @@ const SignupFormUI = (props: SignupParams) => {
67
72
  notificationState,
68
73
  handleChangePromotions,
69
74
  enableReCaptcha,
70
- handleReCaptcha
75
+ handleReCaptcha,
76
+ generateOtpCode,
77
+ numOtpInputs,
78
+ setWillVerifyOtpState,
79
+ handleChangeInput,
80
+ willVerifyOtpState,
81
+ setOtpState,
82
+ setSignUpTab,
83
+ signUpTab,
84
+ useSignUpFullDetails,
85
+ useSignUpOtpEmail,
86
+ useSignUpOtpCellphone
71
87
  } = props;
72
88
 
73
89
  const theme = useTheme();
@@ -104,15 +120,12 @@ const SignupFormUI = (props: SignupParams) => {
104
120
  const [, t] = useLanguage();
105
121
  const [, { login }] = useSession();
106
122
  const [{ configs }] = useConfig();
107
- const { control, handleSubmit, errors, register, setValue } = useForm();
123
+ const { control, handleSubmit, clearErrors, errors, register, unregister, setValue } = useForm();
108
124
 
109
125
  const [passwordSee, setPasswordSee] = useState(false);
110
126
  const [formValues, setFormValues] = useState(null);
111
127
  const [isModalVisible, setIsModalVisible] = useState(false);
112
128
  const [isLoadingVerifyModal, setIsLoadingVerifyModal] = useState(false);
113
- const [signupTab, setSignupTab] = useState(
114
- useSignupByCellphone && !useSignupByEmail ? 'cellphone' : 'email',
115
- );
116
129
  const [isFBLoading, setIsFBLoading] = useState(false);
117
130
  const [phoneInputData, setPhoneInputData] = useState({
118
131
  error: '',
@@ -122,9 +135,12 @@ const SignupFormUI = (props: SignupParams) => {
122
135
  country_code: null
123
136
  },
124
137
  });
138
+ const [alertState, setAlertState] = useState({ open: false, title: '', content: [] })
125
139
  const [recaptchaConfig, setRecaptchaConfig] = useState<any>({})
126
140
  const [recaptchaVerified, setRecaptchaVerified] = useState(false)
141
+ const [tabLayouts, setTabLayouts] = useState<any>({})
127
142
 
143
+ const tabsRef = useRef<any>(null)
128
144
  const nameRef = useRef<any>(null);
129
145
  const lastnameRef = useRef<any>(null);
130
146
  const middleNameRef = useRef<any>(null);
@@ -137,7 +153,15 @@ const SignupFormUI = (props: SignupParams) => {
137
153
  const showInputPhoneNumber = (validationFields?.fields?.checkout?.cellphone?.enabled ?? false) || configs?.verification_phone_required?.value === '1'
138
154
  const googleLoginEnabled = configs?.google_login_enabled?.value === '1' || !configs?.google_login_enabled?.enabled
139
155
  const facebookLoginEnabled = configs?.facebook_login_enabled?.value === '1' || !configs?.facebook_login_enabled?.enabled
140
- const appleLoginEnabled = configs?.apple_login_enabled?.value === '1' || !configs?.apple_login_enabled?.enabled
156
+ const appleLoginEnabled = configs?.apple_login_enabled?.value === '1' || !configs?.apple_login_enabled?.enabled
157
+
158
+ const closeAlert = () => {
159
+ setAlertState({
160
+ open: false,
161
+ title: '',
162
+ content: []
163
+ })
164
+ }
141
165
 
142
166
  const handleRefs = (ref: any, code: string) => {
143
167
  switch (code) {
@@ -163,6 +187,13 @@ const SignupFormUI = (props: SignupParams) => {
163
187
  }
164
188
  };
165
189
 
190
+ const handleOnLayout = (event: any, opc: string) => {
191
+ const _tabLayouts = { ...tabLayouts }
192
+ const categoryKey = opc
193
+ _tabLayouts[categoryKey] = event.nativeEvent.layout
194
+ setTabLayouts(_tabLayouts)
195
+ }
196
+
166
197
  const handleFocusRef = (code: string) => {
167
198
  switch (code) {
168
199
  case 'name': {
@@ -206,13 +237,13 @@ const SignupFormUI = (props: SignupParams) => {
206
237
  navigation.navigate('Home');
207
238
  };
208
239
 
209
- const handleChangeTab = (val: string) => {
210
- setSignupTab(val);
211
- setPasswordSee(false);
212
- };
240
+ const handleSignUpTab = (tab: string) => {
241
+ setSignUpTab && setSignUpTab(tab)
242
+ clearErrors()
243
+ }
213
244
 
214
- const onSubmit = (values: any) => {
215
- if (phoneInputData.error) {
245
+ const onSubmit = (values?: any) => {
246
+ if (phoneInputData.error && signUpTab !== 'otpEmail') {
216
247
  showToast(ToastType.Error, phoneInputData.error);
217
248
  return;
218
249
  }
@@ -221,7 +252,8 @@ const SignupFormUI = (props: SignupParams) => {
221
252
  !phoneInputData.phone.cellphone &&
222
253
  ((validationFields?.fields?.checkout?.cellphone?.enabled &&
223
254
  validationFields?.fields?.checkout?.cellphone?.required) ||
224
- configs?.verification_phone_required?.value === '1')
255
+ configs?.verification_phone_required?.value === '1') &&
256
+ signUpTab !== 'otpEmail'
225
257
  ) {
226
258
  showToast(
227
259
  ToastType.Error,
@@ -232,26 +264,29 @@ const SignupFormUI = (props: SignupParams) => {
232
264
  );
233
265
  return;
234
266
  }
235
- if (signupTab === 'email' || !useSignupByCellphone) {
236
- handleButtonSignupClick &&
237
- handleButtonSignupClick({
238
- ...values,
239
- ...((phoneInputData.phone.cellphone !== null && phoneInputData.phone.country_phone_code !== null) && { ...phoneInputData.phone }),
240
- country_code: phoneInputData.phone.country_code
241
- });
242
- if (
243
- !formState.loading &&
244
- formState.result.result &&
245
- !formState.result.error
246
- ) {
247
- handleSuccessSignup && handleSuccessSignup(formState.result.result);
248
- }
249
- return;
267
+ if (signUpTab === 'otpEmail' || signUpTab === 'otpCellphone') {
268
+ generateOtpCode && generateOtpCode({
269
+ ...values,
270
+ ...((phoneInputData.phone.cellphone !== null && phoneInputData.phone.country_phone_code !== null) && { ...phoneInputData.phone }),
271
+ country_code: phoneInputData.phone.country_code
272
+ })
273
+ return
274
+ }
275
+ handleButtonSignupClick &&
276
+ handleButtonSignupClick({
277
+ ...values,
278
+ ...((phoneInputData.phone.cellphone !== null && phoneInputData.phone.country_phone_code !== null) && { ...phoneInputData.phone }),
279
+ country_code: phoneInputData.phone.country_code
280
+ });
281
+ if (!formState.loading && formState.result.result && !formState.result.error) {
282
+ handleSuccessSignup && handleSuccessSignup(formState.result.result);
250
283
  }
251
- setFormValues(values);
252
- handleVerifyCodeClick(values);
253
284
  };
254
285
 
286
+ const handleSingUpOtp = (value: string) => {
287
+ setOtpState && setOtpState(value)
288
+ }
289
+
255
290
  const handleVerifyCodeClick = (values: any) => {
256
291
  const formData = values || formValues;
257
292
  handleSendVerifyCode &&
@@ -313,20 +348,44 @@ const SignupFormUI = (props: SignupParams) => {
313
348
 
314
349
  const onRecaptchaVerify = (token: any) => {
315
350
  setRecaptchaVerified(true)
316
- handleReCaptcha(token)
351
+ handleReCaptcha && handleReCaptcha({ code: token, version: recaptchaConfig?.version })
317
352
  }
318
353
 
319
354
  useEffect(() => {
320
355
  if (configs && Object.keys(configs).length > 0 && enableReCaptcha) {
321
- setRecaptchaConfig({
322
- siteKey: configs?.security_recaptcha_site_key?.value || null,
323
- baseUrl: configs?.security_recaptcha_base_url?.value || null
324
- })
356
+ if (configs?.security_recaptcha_type?.value === 'v3' &&
357
+ configs?.security_recaptcha_score_v3?.value > 0 &&
358
+ configs?.security_recaptcha_site_key_v3?.value
359
+ ) {
360
+ setRecaptchaConfig({
361
+ version: 'v3',
362
+ siteKey: configs?.security_recaptcha_site_key_v3?.value || null,
363
+ baseUrl: configs?.security_recaptcha_base_url?.value || null
364
+ })
365
+ return
366
+ }
367
+ if (configs?.security_recaptcha_site_key?.value) {
368
+ setRecaptchaConfig({
369
+ version: 'v2',
370
+ siteKey: configs?.security_recaptcha_site_key?.value || null,
371
+ baseUrl: configs?.security_recaptcha_base_url?.value || null
372
+ })
373
+ }
325
374
  }
326
375
  }, [configs, enableReCaptcha])
327
376
 
328
377
  useEffect(() => {
329
378
  if (!formState.loading && formState.result?.error) {
379
+ if (formState.result?.result?.[0] === 'ERROR_AUTH_VERIFICATION_CODE') {
380
+ setRecaptchaVerified(false)
381
+ setRecaptchaConfig({
382
+ version: 'v2',
383
+ siteKey: configs?.security_recaptcha_site_key?.value || null,
384
+ baseUrl: configs?.security_recaptcha_base_url?.value || null
385
+ })
386
+ showToast(ToastType.Info, t('TRY_AGAIN', 'Please try again'))
387
+ return
388
+ }
330
389
  formState.result?.result &&
331
390
  showToast(ToastType.Error, formState.result?.result[0]);
332
391
  setIsLoadingVerifyModal(false);
@@ -337,15 +396,19 @@ const SignupFormUI = (props: SignupParams) => {
337
396
  if (Object.keys(errors).length > 0) {
338
397
  setIsLoadingVerifyModal(false);
339
398
  }
340
- }, [errors]);
399
+ }, [errors])
341
400
 
342
401
  useEffect(() => {
343
- register('cellphone', {
344
- required: isRequiredField('cellphone')
345
- ? t('VALIDATION_ERROR_MOBILE_PHONE_REQUIRED', 'The field Mobile phone is required').replace('_attribute_', t('CELLPHONE', 'Cellphone'))
346
- : null
347
- })
348
- }, [register])
402
+ if (signUpTab === 'default' || signUpTab === 'otpCellphone') {
403
+ register('cellphone', {
404
+ required: isRequiredField('cellphone')
405
+ ? t('VALIDATION_ERROR_MOBILE_PHONE_REQUIRED', 'The field Mobile phone is required').replace('_attribute_', t('CELLPHONE', 'Cellphone'))
406
+ : null
407
+ })
408
+ } else {
409
+ unregister('cellphone')
410
+ }
411
+ }, [signUpTab])
349
412
 
350
413
  useEffect(() => {
351
414
  if (phoneInputData?.phone?.cellphone) setValue('cellphone', phoneInputData?.phone?.cellphone, '')
@@ -382,6 +445,16 @@ const SignupFormUI = (props: SignupParams) => {
382
445
  })
383
446
  }, [configs])
384
447
 
448
+ useEffect(() => {
449
+ if (checkPhoneCodeState?.result?.error) {
450
+ setAlertState({
451
+ open: true,
452
+ title: (typeof checkPhoneCodeState?.result?.result === 'string' ? checkPhoneCodeState?.result?.result : checkPhoneCodeState?.result?.result[0].toString()) || t('ERROR', 'Error'),
453
+ content: []
454
+ })
455
+ }
456
+ }, [checkPhoneCodeState])
457
+
385
458
  return (
386
459
  <View>
387
460
  <NavBar
@@ -395,47 +468,92 @@ const SignupFormUI = (props: SignupParams) => {
395
468
  titleStyle={{ marginLeft: 0, marginRight: 0 }}
396
469
  />
397
470
  <FormSide>
398
- {useSignupByEmail &&
399
- useSignupByCellphone &&
400
- configs &&
401
- Object.keys(configs).length > 0 &&
402
- (configs?.twilio_service_enabled?.value === 'true' ||
403
- configs?.twilio_service_enabled?.value === '1') && (
404
- <SignupWith style={{ paddingBottom: 25 }}>
405
- <OTabs>
406
- {useSignupByEmail && (
407
- <Pressable onPress={() => handleChangeTab('email')}>
408
- <OTab>
409
- <OText
410
- size={18}
411
- color={
412
- signupTab === 'email'
413
- ? theme.colors.primary
414
- : theme.colors.disabled
415
- }>
416
- {t('SIGNUP_BY_EMAIL', 'Signup by Email')}
417
- </OText>
418
- </OTab>
419
- </Pressable>
420
- )}
421
- {useSignupByCellphone && (
422
- <Pressable onPress={() => handleChangeTab('cellphone')}>
423
- <OTab>
424
- <OText
425
- size={18}
426
- color={
427
- signupTab === 'cellphone'
428
- ? theme.colors.primary
429
- : theme.colors.disabled
430
- }>
431
- {t('SIGNUP_BY_PHONE', 'Signup by Phone')}
432
- </OText>
433
- </OTab>
434
- </Pressable>
435
- )}
436
- </OTabs>
437
- </SignupWith>
438
- )}
471
+ {((Number(useSignUpFullDetails) + Number(useSignUpOtpEmail) + Number(useSignUpOtpCellphone)) > 1) && (
472
+ <SignupWith>
473
+ <OTabs
474
+ horizontal
475
+ showsHorizontalScrollIndicator={false}
476
+ ref={tabsRef}
477
+ >
478
+ {useSignUpFullDetails && (
479
+ <TabBtn
480
+ onPress={() => handleSignUpTab('default')}
481
+ onLayout={(event: any) => handleOnLayout(event, 'default')}
482
+ >
483
+ <OTab
484
+ style={{
485
+ borderBottomColor:
486
+ signUpTab === 'default'
487
+ ? theme.colors.textNormal
488
+ : theme.colors.border,
489
+ }}>
490
+ <OText
491
+ size={14}
492
+ color={
493
+ signUpTab === 'default'
494
+ ? theme.colors.textNormal
495
+ : theme.colors.disabled
496
+ }
497
+ weight={signUpTab === 'default' ? 'bold' : 'normal'}>
498
+ {t('DEFAULT', 'Default')}
499
+ </OText>
500
+ </OTab>
501
+ </TabBtn>
502
+ )}
503
+ {useSignUpOtpEmail && (
504
+ <TabBtn
505
+ onPress={() => handleSignUpTab('otpEmail')}
506
+ onLayout={(event: any) => handleOnLayout(event, 'otpEmail')}
507
+ >
508
+ <OTab
509
+ style={{
510
+ borderBottomColor:
511
+ signUpTab === 'otpEmail'
512
+ ? theme.colors.textNormal
513
+ : theme.colors.border,
514
+ }}>
515
+ <OText
516
+ size={14}
517
+ color={
518
+ signUpTab === 'otpEmail'
519
+ ? theme.colors.textNormal
520
+ : theme.colors.disabled
521
+ }
522
+ weight={signUpTab === 'otpEmail' ? 'bold' : 'normal'}>
523
+ {t('BY_OTP_EMAIL', 'by Otp Email')}
524
+ </OText>
525
+ </OTab>
526
+ </TabBtn>
527
+
528
+ )}
529
+ {useSignUpOtpCellphone && (
530
+ <TabBtn
531
+ onPress={() => handleSignUpTab('otpCellphone')}
532
+ onLayout={(event: any) => handleOnLayout(event, 'otpCellphone')}
533
+ >
534
+ <OTab
535
+ style={{
536
+ borderBottomColor:
537
+ signUpTab === 'otpCellphone'
538
+ ? theme.colors.textNormal
539
+ : theme.colors.border,
540
+ }}>
541
+ <OText
542
+ size={14}
543
+ color={
544
+ signUpTab === 'otpCellphone'
545
+ ? theme.colors.textNormal
546
+ : theme.colors.disabled
547
+ }
548
+ weight={signUpTab === 'otpCellphone' ? 'bold' : 'normal'}>
549
+ {t('BY_OTP_CELLPHONE', 'by Otp Cellphone')}
550
+ </OText>
551
+ </OTab>
552
+ </TabBtn>
553
+ )}
554
+ </OTabs>
555
+ </SignupWith>
556
+ )}
439
557
  <FormInput>
440
558
  {!(useChekoutFileds && validationFields?.loading) ? (
441
559
  <>
@@ -445,7 +563,9 @@ const SignupFormUI = (props: SignupParams) => {
445
563
  (field: any, i: number) =>
446
564
  !notValidationFields.includes(field.code) &&
447
565
  showField &&
448
- showField(field.code) && (
566
+ showField(field.code) &&
567
+ (signUpTab === 'default' ||
568
+ (signUpTab === 'otpEmail' && field.code === 'email')) && (
449
569
  <React.Fragment key={field.id}>
450
570
  {errors?.[`${field.code}`] && (
451
571
  <OText
@@ -469,7 +589,7 @@ const SignupFormUI = (props: SignupParams) => {
469
589
  value={value}
470
590
  onChange={(val: any) =>
471
591
  field.code !== 'email'
472
- ? onChange(val)
592
+ ? (onChange(val))
473
593
  : handleChangeInputEmail(val, onChange)
474
594
  }
475
595
  autoCapitalize={
@@ -501,7 +621,7 @@ const SignupFormUI = (props: SignupParams) => {
501
621
  ),
502
622
  )}
503
623
 
504
- {!!showInputPhoneNumber && (
624
+ {(!!showInputPhoneNumber && (signUpTab === 'default' || signUpTab === 'otpCellphone')) && (
505
625
  <View style={{ marginBottom: 25 }}>
506
626
  <PhoneInputNumber
507
627
  data={phoneInputData}
@@ -515,7 +635,6 @@ const SignupFormUI = (props: SignupParams) => {
515
635
  }
516
636
  })}
517
637
  forwardRef={phoneRef}
518
- defaultCode={formState?.country_code ?? formState?.country_phone_code ?? null}
519
638
  changeCountry={(val: any) => setPhoneInputData({
520
639
  ...phoneInputData,
521
640
  phone: {
@@ -532,66 +651,79 @@ const SignupFormUI = (props: SignupParams) => {
532
651
  </View>
533
652
  )}
534
653
 
535
- {enableReCaptcha && (
654
+ {(enableReCaptcha && recaptchaConfig?.version) && (
536
655
  <>
537
- <TouchableOpacity
538
- onPress={handleOpenRecaptcha}
539
- style={{ marginHorizontal: 4, marginBottom: 10 }}
540
- >
541
- <RecaptchaButton>
542
- {recaptchaVerified ? (
543
- <MaterialCommunityIcons
544
- name="checkbox-marked"
545
- size={23}
546
- color={theme.colors.primary}
547
- />
548
- ) : (
549
- <MaterialCommunityIcons
550
- name="checkbox-blank-outline"
551
- size={23}
552
- color={theme.colors.disabled}
553
- />
554
- )}
555
- <OText size={14} mLeft={8}>{t('VERIFY_ReCAPTCHA', 'Verify reCAPTCHA')}</OText>
556
- </RecaptchaButton>
557
- </TouchableOpacity>
558
- <Recaptcha
559
- ref={recaptchaRef}
560
- siteKey={recaptchaConfig?.siteKey}
561
- baseUrl={recaptchaConfig?.baseUrl}
562
- onVerify={onRecaptchaVerify}
563
- onExpire={() => setRecaptchaVerified(false)}
564
- />
565
- </>
566
- )}
567
-
568
- <View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 20 }}>
569
- <Controller
570
- control={control}
571
- render={({ onChange, value }: any) => (
572
- <CheckBox
573
- value={value}
574
- onValueChange={newValue => {
575
- onChange(newValue)
576
- handleChangePromotions()
577
- }}
578
- boxType={'square'}
579
- tintColors={{
580
- true: theme.colors.primary,
581
- false: theme.colors.disabled
582
- }}
583
- tintColor={theme.colors.disabled}
584
- onCheckColor={theme.colors.primary}
585
- onTintColor={theme.colors.primary}
586
- style={Platform.OS === 'ios' && style.checkBoxStyle}
656
+ {recaptchaConfig?.version === 'v3' ? (
657
+ <ReCaptcha
658
+ url={recaptchaConfig?.baseUrl}
659
+ siteKey={recaptchaConfig?.siteKey}
660
+ containerStyle={{ height: 40 }}
661
+ onExecute={onRecaptchaVerify}
662
+ reCaptchaType={1}
587
663
  />
664
+ ) : (
665
+ <>
666
+ <TouchableOpacity
667
+ onPress={handleOpenRecaptcha}
668
+ style={{ marginHorizontal: 4, marginBottom: 10 }}
669
+ >
670
+ <RecaptchaButton>
671
+ {recaptchaVerified ? (
672
+ <MaterialCommunityIcons
673
+ name="checkbox-marked"
674
+ size={23}
675
+ color={theme.colors.primary}
676
+ />
677
+ ) : (
678
+ <MaterialCommunityIcons
679
+ name="checkbox-blank-outline"
680
+ size={23}
681
+ color={theme.colors.disabled}
682
+ />
683
+ )}
684
+ <OText size={14} mLeft={8}>{t('VERIFY_ReCAPTCHA', 'Verify reCAPTCHA')}</OText>
685
+ </RecaptchaButton>
686
+ </TouchableOpacity>
687
+ <Recaptcha
688
+ ref={recaptchaRef}
689
+ siteKey={recaptchaConfig?.siteKey}
690
+ baseUrl={recaptchaConfig?.baseUrl}
691
+ onVerify={onRecaptchaVerify}
692
+ onExpire={() => setRecaptchaVerified(false)}
693
+ />
694
+ </>
588
695
  )}
589
- name='promotions'
590
- defaultValue={false}
591
- />
592
- <OText style={{ fontSize: 14, paddingHorizontal: 5 }}>{t('RECEIVE_NEWS_EXCLUSIVE_PROMOTIONS', 'Receive newsletters and exclusive promotions')}</OText>
593
- </View>
594
696
 
697
+ </>
698
+ )}
699
+ {(signUpTab === 'default') && (
700
+ <View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 20 }}>
701
+ <Controller
702
+ control={control}
703
+ render={({ onChange, value }: any) => (
704
+ <CheckBox
705
+ value={value}
706
+ onValueChange={newValue => {
707
+ onChange(newValue)
708
+ handleChangePromotions()
709
+ }}
710
+ boxType={'square'}
711
+ tintColors={{
712
+ true: theme.colors.primary,
713
+ false: theme.colors.disabled
714
+ }}
715
+ tintColor={theme.colors.disabled}
716
+ onCheckColor={theme.colors.primary}
717
+ onTintColor={theme.colors.primary}
718
+ style={Platform.OS === 'ios' && style.checkBoxStyle}
719
+ />
720
+ )}
721
+ name='promotions'
722
+ defaultValue={false}
723
+ />
724
+ <OText style={{ fontSize: 14, paddingHorizontal: 5 }}>{t('RECEIVE_NEWS_EXCLUSIVE_PROMOTIONS', 'Receive newsletters and exclusive promotions')}</OText>
725
+ </View>
726
+ )}
595
727
  {configs?.terms_and_conditions?.value === 'true' && (
596
728
  <>
597
729
  {errors?.termsAccept && (
@@ -643,7 +775,7 @@ const SignupFormUI = (props: SignupParams) => {
643
775
 
644
776
  )}
645
777
 
646
- {signupTab !== 'cellphone' && (
778
+ {signUpTab === 'default' && (
647
779
  <>
648
780
  {errors?.password && (
649
781
  <OText
@@ -715,9 +847,7 @@ const SignupFormUI = (props: SignupParams) => {
715
847
  <Spinner visible />
716
848
  )}
717
849
 
718
- {signupTab === 'cellphone' &&
719
- useSignupByEmail &&
720
- useSignupByCellphone ? (
850
+ {(signUpTab === 'otpEmail' || signUpTab === 'otpCellphone') ? (
721
851
  <OButton
722
852
  onClick={handleSubmit(onSubmit)}
723
853
  text={t('GET_VERIFY_CODE', 'Get Verify Code')}
@@ -782,7 +912,7 @@ const SignupFormUI = (props: SignupParams) => {
782
912
  <ButtonsWrapper>
783
913
  <SocialButtons>
784
914
  {(configs?.facebook_login?.value === 'true' || configs?.facebook_login?.value === '1') &&
785
- configs?.facebook_id?.value &&
915
+ configs?.facebook_id?.value &&
786
916
  facebookLoginEnabled &&
787
917
  (
788
918
  <FacebookLogin
@@ -815,27 +945,40 @@ const SignupFormUI = (props: SignupParams) => {
815
945
  )}
816
946
 
817
947
  </FormSide>
818
- <OModal open={isModalVisible} onClose={() => setIsModalVisible(false)}>
819
- <VerifyPhone
820
- phone={phoneInputData.phone}
821
- formValues={formValues}
822
- verifyPhoneState={verifyPhoneState}
823
- checkPhoneCodeState={checkPhoneCodeState}
824
- handleCheckPhoneCode={handleCheckPhoneCode}
825
- setCheckPhoneCodeState={setCheckPhoneCodeState}
826
- handleVerifyCodeClick={onSubmit}
948
+ <OModal
949
+ open={willVerifyOtpState}
950
+ onClose={() => setWillVerifyOtpState && setWillVerifyOtpState(false)}
951
+ entireModal
952
+ title={t('ENTER_VERIFICATION_CODE', 'Enter verification code')}
953
+ >
954
+ <Otp
955
+ pinCount={numOtpInputs || 6}
956
+ willVerifyOtpState={willVerifyOtpState || false}
957
+ setWillVerifyOtpState={() => setWillVerifyOtpState && setWillVerifyOtpState(false)}
958
+ handleLoginOtp={handleSingUpOtp}
959
+ onSubmit={onSubmit}
960
+ setAlertState={setAlertState}
827
961
  />
828
962
  </OModal>
829
963
  <Spinner
830
964
  visible={formState.loading || validationFields.loading || isFBLoading}
831
965
  />
966
+ <Alert
967
+ open={alertState.open}
968
+ content={alertState.content}
969
+ title={alertState.title || ''}
970
+ onAccept={closeAlert}
971
+ onClose={closeAlert}
972
+ />
832
973
  </View>
833
974
  );
834
975
  };
835
976
 
836
977
  export const SignupForm = (props: any) => {
978
+ const _numOtpInputs = 6
837
979
  const signupProps = {
838
980
  ...props,
981
+ numOtpInputs: _numOtpInputs,
839
982
  isRecaptchaEnable: true,
840
983
  UIComponent: SignupFormUI,
841
984
  };