ordering-ui-react-native 0.16.8 → 0.16.9-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 +66 -73
  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 +83 -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 +698 -650
  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 +305 -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);
@@ -136,6 +152,16 @@ const SignupFormUI = (props: SignupParams) => {
136
152
 
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
155
+ const facebookLoginEnabled = configs?.facebook_login_enabled?.value === '1' || !configs?.facebook_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
+ }
139
165
 
140
166
  const handleRefs = (ref: any, code: string) => {
141
167
  switch (code) {
@@ -161,6 +187,13 @@ const SignupFormUI = (props: SignupParams) => {
161
187
  }
162
188
  };
163
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
+
164
197
  const handleFocusRef = (code: string) => {
165
198
  switch (code) {
166
199
  case 'name': {
@@ -204,13 +237,13 @@ const SignupFormUI = (props: SignupParams) => {
204
237
  navigation.navigate('Home');
205
238
  };
206
239
 
207
- const handleChangeTab = (val: string) => {
208
- setSignupTab(val);
209
- setPasswordSee(false);
210
- };
240
+ const handleSignUpTab = (tab: string) => {
241
+ setSignUpTab && setSignUpTab(tab)
242
+ clearErrors()
243
+ }
211
244
 
212
- const onSubmit = (values: any) => {
213
- if (phoneInputData.error) {
245
+ const onSubmit = (values?: any) => {
246
+ if (phoneInputData.error && signUpTab !== 'otpEmail') {
214
247
  showToast(ToastType.Error, phoneInputData.error);
215
248
  return;
216
249
  }
@@ -219,7 +252,8 @@ const SignupFormUI = (props: SignupParams) => {
219
252
  !phoneInputData.phone.cellphone &&
220
253
  ((validationFields?.fields?.checkout?.cellphone?.enabled &&
221
254
  validationFields?.fields?.checkout?.cellphone?.required) ||
222
- configs?.verification_phone_required?.value === '1')
255
+ configs?.verification_phone_required?.value === '1') &&
256
+ signUpTab !== 'otpEmail'
223
257
  ) {
224
258
  showToast(
225
259
  ToastType.Error,
@@ -230,26 +264,29 @@ const SignupFormUI = (props: SignupParams) => {
230
264
  );
231
265
  return;
232
266
  }
233
- if (signupTab === 'email' || !useSignupByCellphone) {
234
- handleButtonSignupClick &&
235
- handleButtonSignupClick({
236
- ...values,
237
- ...((phoneInputData.phone.cellphone !== null && phoneInputData.phone.country_phone_code !== null) && { ...phoneInputData.phone }),
238
- country_code: phoneInputData.phone.country_code
239
- });
240
- if (
241
- !formState.loading &&
242
- formState.result.result &&
243
- !formState.result.error
244
- ) {
245
- handleSuccessSignup && handleSuccessSignup(formState.result.result);
246
- }
247
- 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);
248
283
  }
249
- setFormValues(values);
250
- handleVerifyCodeClick(values);
251
284
  };
252
285
 
286
+ const handleSingUpOtp = (value: string) => {
287
+ setOtpState && setOtpState(value)
288
+ }
289
+
253
290
  const handleVerifyCodeClick = (values: any) => {
254
291
  const formData = values || formValues;
255
292
  handleSendVerifyCode &&
@@ -311,20 +348,44 @@ const SignupFormUI = (props: SignupParams) => {
311
348
 
312
349
  const onRecaptchaVerify = (token: any) => {
313
350
  setRecaptchaVerified(true)
314
- handleReCaptcha(token)
351
+ handleReCaptcha && handleReCaptcha({ code: token, version: recaptchaConfig?.version })
315
352
  }
316
353
 
317
354
  useEffect(() => {
318
355
  if (configs && Object.keys(configs).length > 0 && enableReCaptcha) {
319
- setRecaptchaConfig({
320
- siteKey: configs?.security_recaptcha_site_key?.value || null,
321
- baseUrl: configs?.security_recaptcha_base_url?.value || null
322
- })
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
+ }
323
374
  }
324
375
  }, [configs, enableReCaptcha])
325
376
 
326
377
  useEffect(() => {
327
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
+ }
328
389
  formState.result?.result &&
329
390
  showToast(ToastType.Error, formState.result?.result[0]);
330
391
  setIsLoadingVerifyModal(false);
@@ -335,15 +396,19 @@ const SignupFormUI = (props: SignupParams) => {
335
396
  if (Object.keys(errors).length > 0) {
336
397
  setIsLoadingVerifyModal(false);
337
398
  }
338
- }, [errors]);
399
+ }, [errors])
339
400
 
340
401
  useEffect(() => {
341
- register('cellphone', {
342
- required: isRequiredField('cellphone')
343
- ? t('VALIDATION_ERROR_MOBILE_PHONE_REQUIRED', 'The field Mobile phone is required').replace('_attribute_', t('CELLPHONE', 'Cellphone'))
344
- : null
345
- })
346
- }, [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])
347
412
 
348
413
  useEffect(() => {
349
414
  if (phoneInputData?.phone?.cellphone) setValue('cellphone', phoneInputData?.phone?.cellphone, '')
@@ -380,6 +445,16 @@ const SignupFormUI = (props: SignupParams) => {
380
445
  })
381
446
  }, [configs])
382
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
+
383
458
  return (
384
459
  <View>
385
460
  <NavBar
@@ -393,47 +468,92 @@ const SignupFormUI = (props: SignupParams) => {
393
468
  titleStyle={{ marginLeft: 0, marginRight: 0 }}
394
469
  />
395
470
  <FormSide>
396
- {useSignupByEmail &&
397
- useSignupByCellphone &&
398
- configs &&
399
- Object.keys(configs).length > 0 &&
400
- (configs?.twilio_service_enabled?.value === 'true' ||
401
- configs?.twilio_service_enabled?.value === '1') && (
402
- <SignupWith style={{ paddingBottom: 25 }}>
403
- <OTabs>
404
- {useSignupByEmail && (
405
- <Pressable onPress={() => handleChangeTab('email')}>
406
- <OTab>
407
- <OText
408
- size={18}
409
- color={
410
- signupTab === 'email'
411
- ? theme.colors.primary
412
- : theme.colors.disabled
413
- }>
414
- {t('SIGNUP_BY_EMAIL', 'Signup by Email')}
415
- </OText>
416
- </OTab>
417
- </Pressable>
418
- )}
419
- {useSignupByCellphone && (
420
- <Pressable onPress={() => handleChangeTab('cellphone')}>
421
- <OTab>
422
- <OText
423
- size={18}
424
- color={
425
- signupTab === 'cellphone'
426
- ? theme.colors.primary
427
- : theme.colors.disabled
428
- }>
429
- {t('SIGNUP_BY_PHONE', 'Signup by Phone')}
430
- </OText>
431
- </OTab>
432
- </Pressable>
433
- )}
434
- </OTabs>
435
- </SignupWith>
436
- )}
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
+ )}
437
557
  <FormInput>
438
558
  {!(useChekoutFileds && validationFields?.loading) ? (
439
559
  <>
@@ -443,7 +563,9 @@ const SignupFormUI = (props: SignupParams) => {
443
563
  (field: any, i: number) =>
444
564
  !notValidationFields.includes(field.code) &&
445
565
  showField &&
446
- showField(field.code) && (
566
+ showField(field.code) &&
567
+ (signUpTab === 'default' ||
568
+ (signUpTab === 'otpEmail' && field.code === 'email')) && (
447
569
  <React.Fragment key={field.id}>
448
570
  {errors?.[`${field.code}`] && (
449
571
  <OText
@@ -467,7 +589,7 @@ const SignupFormUI = (props: SignupParams) => {
467
589
  value={value}
468
590
  onChange={(val: any) =>
469
591
  field.code !== 'email'
470
- ? onChange(val)
592
+ ? (onChange(val))
471
593
  : handleChangeInputEmail(val, onChange)
472
594
  }
473
595
  autoCapitalize={
@@ -499,7 +621,7 @@ const SignupFormUI = (props: SignupParams) => {
499
621
  ),
500
622
  )}
501
623
 
502
- {!!showInputPhoneNumber && (
624
+ {(!!showInputPhoneNumber && (signUpTab === 'default' || signUpTab === 'otpCellphone')) && (
503
625
  <View style={{ marginBottom: 25 }}>
504
626
  <PhoneInputNumber
505
627
  data={phoneInputData}
@@ -513,7 +635,6 @@ const SignupFormUI = (props: SignupParams) => {
513
635
  }
514
636
  })}
515
637
  forwardRef={phoneRef}
516
- defaultCode={formState?.country_code ?? formState?.country_phone_code ?? null}
517
638
  changeCountry={(val: any) => setPhoneInputData({
518
639
  ...phoneInputData,
519
640
  phone: {
@@ -530,66 +651,79 @@ const SignupFormUI = (props: SignupParams) => {
530
651
  </View>
531
652
  )}
532
653
 
533
- {enableReCaptcha && (
654
+ {(enableReCaptcha && recaptchaConfig?.version) && (
534
655
  <>
535
- <TouchableOpacity
536
- onPress={handleOpenRecaptcha}
537
- style={{ marginHorizontal: 4, marginBottom: 10 }}
538
- >
539
- <RecaptchaButton>
540
- {recaptchaVerified ? (
541
- <MaterialCommunityIcons
542
- name="checkbox-marked"
543
- size={23}
544
- color={theme.colors.primary}
545
- />
546
- ) : (
547
- <MaterialCommunityIcons
548
- name="checkbox-blank-outline"
549
- size={23}
550
- color={theme.colors.disabled}
551
- />
552
- )}
553
- <OText size={14} mLeft={8}>{t('VERIFY_ReCAPTCHA', 'Verify reCAPTCHA')}</OText>
554
- </RecaptchaButton>
555
- </TouchableOpacity>
556
- <Recaptcha
557
- ref={recaptchaRef}
558
- siteKey={recaptchaConfig?.siteKey}
559
- baseUrl={recaptchaConfig?.baseUrl}
560
- onVerify={onRecaptchaVerify}
561
- onExpire={() => setRecaptchaVerified(false)}
562
- />
563
- </>
564
- )}
565
-
566
- <View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 20 }}>
567
- <Controller
568
- control={control}
569
- render={({ onChange, value }: any) => (
570
- <CheckBox
571
- value={value}
572
- onValueChange={newValue => {
573
- onChange(newValue)
574
- handleChangePromotions()
575
- }}
576
- boxType={'square'}
577
- tintColors={{
578
- true: theme.colors.primary,
579
- false: theme.colors.disabled
580
- }}
581
- tintColor={theme.colors.disabled}
582
- onCheckColor={theme.colors.primary}
583
- onTintColor={theme.colors.primary}
584
- 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}
585
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
+ </>
586
695
  )}
587
- name='promotions'
588
- defaultValue={false}
589
- />
590
- <OText style={{ fontSize: 14, paddingHorizontal: 5 }}>{t('RECEIVE_NEWS_EXCLUSIVE_PROMOTIONS', 'Receive newsletters and exclusive promotions')}</OText>
591
- </View>
592
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
+ )}
593
727
  {configs?.terms_and_conditions?.value === 'true' && (
594
728
  <>
595
729
  {errors?.termsAccept && (
@@ -641,7 +775,7 @@ const SignupFormUI = (props: SignupParams) => {
641
775
 
642
776
  )}
643
777
 
644
- {signupTab !== 'cellphone' && (
778
+ {signUpTab === 'default' && (
645
779
  <>
646
780
  {errors?.password && (
647
781
  <OText
@@ -713,9 +847,7 @@ const SignupFormUI = (props: SignupParams) => {
713
847
  <Spinner visible />
714
848
  )}
715
849
 
716
- {signupTab === 'cellphone' &&
717
- useSignupByEmail &&
718
- useSignupByCellphone ? (
850
+ {(signUpTab === 'otpEmail' || signUpTab === 'otpCellphone') ? (
719
851
  <OButton
720
852
  onClick={handleSubmit(onSubmit)}
721
853
  text={t('GET_VERIFY_CODE', 'Get Verify Code')}
@@ -780,7 +912,9 @@ const SignupFormUI = (props: SignupParams) => {
780
912
  <ButtonsWrapper>
781
913
  <SocialButtons>
782
914
  {(configs?.facebook_login?.value === 'true' || configs?.facebook_login?.value === '1') &&
783
- configs?.facebook_id?.value && (
915
+ configs?.facebook_id?.value &&
916
+ facebookLoginEnabled &&
917
+ (
784
918
  <FacebookLogin
785
919
  notificationState={notificationState}
786
920
  handleErrors={(err: any) => showToast(ToastType.Error, err)}
@@ -797,7 +931,7 @@ const SignupFormUI = (props: SignupParams) => {
797
931
  handleSuccessGoogleLogin={handleSuccessFacebook}
798
932
  />
799
933
  )}
800
- {(configs?.apple_login_client_id?.value !== '' && configs?.apple_login_client_id?.value !== null) && (
934
+ {(configs?.apple_login_client_id?.value !== '' && configs?.apple_login_client_id?.value !== null) && appleLoginEnabled && (
801
935
  <AppleLogin
802
936
  notificationState={notificationState}
803
937
  handleErrors={(err: any) => showToast(ToastType.Error, err)}
@@ -811,27 +945,40 @@ const SignupFormUI = (props: SignupParams) => {
811
945
  )}
812
946
 
813
947
  </FormSide>
814
- <OModal open={isModalVisible} onClose={() => setIsModalVisible(false)}>
815
- <VerifyPhone
816
- phone={phoneInputData.phone}
817
- formValues={formValues}
818
- verifyPhoneState={verifyPhoneState}
819
- checkPhoneCodeState={checkPhoneCodeState}
820
- handleCheckPhoneCode={handleCheckPhoneCode}
821
- setCheckPhoneCodeState={setCheckPhoneCodeState}
822
- 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}
823
961
  />
824
962
  </OModal>
825
963
  <Spinner
826
964
  visible={formState.loading || validationFields.loading || isFBLoading}
827
965
  />
966
+ <Alert
967
+ open={alertState.open}
968
+ content={alertState.content}
969
+ title={alertState.title || ''}
970
+ onAccept={closeAlert}
971
+ onClose={closeAlert}
972
+ />
828
973
  </View>
829
974
  );
830
975
  };
831
976
 
832
977
  export const SignupForm = (props: any) => {
978
+ const _numOtpInputs = 6
833
979
  const signupProps = {
834
980
  ...props,
981
+ numOtpInputs: _numOtpInputs,
835
982
  isRecaptchaEnable: true,
836
983
  UIComponent: SignupFormUI,
837
984
  };