ordering-ui-react-native 0.16.2 → 0.16.3-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 (228) 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/DriverTips/index.tsx +11 -6
  13. package/src/components/LanguageSelector/index.tsx +21 -16
  14. package/src/components/LoginForm/index.tsx +120 -30
  15. package/src/components/LoginForm/styles.tsx +6 -0
  16. package/src/components/Messages/index.tsx +2 -2
  17. package/src/components/NotificationSetting/index.tsx +85 -0
  18. package/src/components/OrderDetails/index.tsx +7 -21
  19. package/src/components/OrdersOption/index.tsx +54 -56
  20. package/src/components/PaymentOptions/index.tsx +335 -365
  21. package/src/components/PaymentOptionsWebView/index.tsx +120 -121
  22. package/src/components/ReviewDriver/index.tsx +1 -1
  23. package/src/components/ReviewOrder/index.tsx +2 -1
  24. package/src/components/ReviewProducts/index.tsx +11 -0
  25. package/src/components/SignupForm/index.tsx +145 -61
  26. package/src/components/SingleProductReview/index.tsx +8 -5
  27. package/src/components/StripeElementsForm/index.tsx +25 -16
  28. package/src/components/StripeMethodForm/index.tsx +1 -2
  29. package/src/components/UserProfileForm/index.tsx +63 -6
  30. package/src/components/UserProfileForm/styles.tsx +8 -0
  31. package/src/components/VerifyPhone/styles.tsx +1 -2
  32. package/src/components/shared/OBottomPopup.tsx +6 -2
  33. package/src/components/shared/OModal.tsx +1 -1
  34. package/src/index.tsx +2 -0
  35. package/src/navigators/CheckoutNavigator.tsx +6 -0
  36. package/src/navigators/HomeNavigator.tsx +6 -0
  37. package/src/pages/BusinessesListing.tsx +7 -6
  38. package/src/pages/MultiCheckout.tsx +31 -0
  39. package/src/pages/MultiOrdersDetails.tsx +27 -0
  40. package/src/pages/OrderDetails.tsx +1 -1
  41. package/src/pages/ReviewDriver.tsx +2 -2
  42. package/src/pages/ReviewOrder.tsx +2 -2
  43. package/src/theme.json +0 -1
  44. package/src/types/@fatnlazycat/react-native-recaptcha-v3/index.d.ts +1 -0
  45. package/src/types/index.tsx +15 -9
  46. package/src/utils/index.tsx +0 -1
  47. package/themes/business/index.tsx +4 -0
  48. package/themes/business/src/components/BusinessController/index.tsx +2 -2
  49. package/themes/business/src/components/Chat/index.tsx +42 -34
  50. package/themes/business/src/components/DriverMap/index.tsx +12 -8
  51. package/themes/business/src/components/DriverSchedule/index.tsx +71 -0
  52. package/themes/business/src/components/DriverSchedule/styles.tsx +6 -0
  53. package/themes/business/src/components/LoginForm/index.tsx +111 -74
  54. package/themes/business/src/components/MapView/index.tsx +1 -1
  55. package/themes/business/src/components/MessagesOption/index.tsx +11 -1
  56. package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
  57. package/themes/business/src/components/OrderDetails/Delivery.tsx +3 -3
  58. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +25 -18
  59. package/themes/business/src/components/OrdersListManager/index.tsx +10 -3
  60. package/themes/business/src/components/OrdersOption/index.tsx +65 -21
  61. package/themes/business/src/components/OrdersOption/styles.tsx +5 -1
  62. package/themes/business/src/components/OrdersOptionBusiness/index.tsx +15 -1
  63. package/themes/business/src/components/OrdersOptionCity/index.tsx +15 -1
  64. package/themes/business/src/components/OrdersOptionDate/index.tsx +19 -6
  65. package/themes/business/src/components/OrdersOptionDelivery/index.tsx +15 -1
  66. package/themes/business/src/components/OrdersOptionDriver/index.tsx +15 -1
  67. package/themes/business/src/components/OrdersOptionPaymethod/index.tsx +15 -1
  68. package/themes/business/src/components/OrdersOptionStatus/index.tsx +10 -1
  69. package/themes/business/src/components/PreviousMessages/index.tsx +17 -18
  70. package/themes/business/src/components/PreviousOrders/index.tsx +21 -23
  71. package/themes/business/src/components/ProductItemAccordion/index.tsx +5 -4
  72. package/themes/business/src/components/ReviewCustomer/index.tsx +1 -1
  73. package/themes/business/src/components/ScheduleBlocked/index.tsx +53 -0
  74. package/themes/business/src/components/UserFormDetails/index.tsx +5 -2
  75. package/themes/business/src/components/UserProfileForm/index.tsx +28 -4
  76. package/themes/business/src/components/shared/ODropDown.tsx +42 -8
  77. package/themes/business/src/components/shared/ODropDownCalendar.tsx +36 -7
  78. package/themes/business/src/components/shared/OModal.tsx +41 -38
  79. package/themes/business/src/types/index.tsx +14 -9
  80. package/themes/business/src/utils/index.tsx +10 -0
  81. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  82. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  83. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  84. package/themes/kiosk/src/components/BusinessMenu/index.tsx +2 -1
  85. package/themes/kiosk/src/components/CartItem/index.tsx +4 -3
  86. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +1 -0
  87. package/themes/kiosk/src/components/Checkout/index.tsx +18 -3
  88. package/themes/kiosk/src/components/CustomerName/index.tsx +0 -6
  89. package/themes/kiosk/src/components/DrawerView/index.tsx +1 -0
  90. package/themes/kiosk/src/components/DrawerView/styles.tsx +2 -2
  91. package/themes/kiosk/src/components/LoginForm/index.tsx +121 -10
  92. package/themes/kiosk/src/components/LoginForm/styles.tsx +5 -0
  93. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  94. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  95. package/themes/kiosk/src/components/OrderDetails/index.tsx +2 -2
  96. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  97. package/themes/kiosk/src/components/PaymentOptions/index.tsx +1 -1
  98. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  99. package/themes/kiosk/src/types/index.d.ts +2 -0
  100. package/themes/original/index.tsx +22 -0
  101. package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
  102. package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
  103. package/themes/original/src/components/AddressForm/index.tsx +136 -133
  104. package/themes/original/src/components/AddressList/index.tsx +1 -1
  105. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  106. package/themes/original/src/components/BusinessBasicInformation/index.tsx +302 -160
  107. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +6 -2
  108. package/themes/original/src/components/BusinessController/index.tsx +179 -96
  109. package/themes/original/src/components/BusinessController/styles.tsx +5 -0
  110. package/themes/original/src/components/BusinessItemAccordion/index.tsx +12 -9
  111. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -1
  112. package/themes/original/src/components/BusinessListingSearch/BusinessControllerSkeletons/index.tsx +57 -0
  113. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +59 -0
  114. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/styles.tsx +13 -0
  115. package/themes/original/src/components/BusinessListingSearch/index.tsx +106 -126
  116. package/themes/original/src/components/BusinessListingSearch/styles.tsx +18 -13
  117. package/themes/original/src/components/BusinessPreorder/index.tsx +1 -1
  118. package/themes/original/src/components/BusinessProductsCategories/index.tsx +2 -2
  119. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  120. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +87 -0
  121. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/styles.tsx +12 -0
  122. package/themes/original/src/components/BusinessProductsList/index.tsx +66 -73
  123. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  124. package/themes/original/src/components/BusinessProductsListing/index.tsx +290 -178
  125. package/themes/original/src/components/BusinessProductsListing/styles.tsx +18 -0
  126. package/themes/original/src/components/BusinessReviews/index.tsx +6 -1
  127. package/themes/original/src/components/BusinessTypeFilter/index.tsx +106 -38
  128. package/themes/original/src/components/BusinessTypeFilter/styles.tsx +2 -0
  129. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +561 -0
  130. package/themes/original/src/components/BusinessesListing/{styles.tsx → Layout/Appointment/styles.tsx} +24 -2
  131. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +673 -0
  132. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +137 -0
  133. package/themes/original/src/components/BusinessesListing/index.tsx +102 -464
  134. package/themes/original/src/components/Cart/index.tsx +82 -37
  135. package/themes/original/src/components/Cart/styles.tsx +4 -0
  136. package/themes/original/src/components/CartContent/index.tsx +22 -16
  137. package/themes/original/src/components/Checkout/index.tsx +107 -67
  138. package/themes/original/src/components/Checkout/styles.tsx +0 -1
  139. package/themes/original/src/components/DriverTips/index.tsx +11 -6
  140. package/themes/original/src/components/Favorite/index.tsx +92 -0
  141. package/themes/original/src/components/Favorite/styles.tsx +22 -0
  142. package/themes/original/src/components/FavoriteList/index.tsx +317 -0
  143. package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
  144. package/themes/original/src/components/GPSButton/index.tsx +25 -17
  145. package/themes/original/src/components/GoogleMap/index.tsx +21 -12
  146. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +8 -3
  147. package/themes/original/src/components/HelpGuide/index.tsx +8 -3
  148. package/themes/original/src/components/HelpOrder/index.tsx +8 -3
  149. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +18 -1
  150. package/themes/original/src/components/LoginForm/Otp/index.tsx +3 -2
  151. package/themes/original/src/components/LoginForm/index.tsx +86 -43
  152. package/themes/original/src/components/Messages/index.tsx +17 -17
  153. package/themes/original/src/components/MomentSelector/index.tsx +197 -0
  154. package/themes/original/src/components/MomentSelector/styles.tsx +6 -0
  155. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +243 -0
  156. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/styles.tsx +46 -0
  157. package/themes/original/src/components/MultiCheckout/index.tsx +304 -0
  158. package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
  159. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +372 -0
  160. package/themes/original/src/components/MultiOrdersDetails/index.tsx +262 -0
  161. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
  162. package/themes/original/src/components/MyOrders/index.tsx +132 -27
  163. package/themes/original/src/components/MyOrders/styles.tsx +8 -1
  164. package/themes/original/src/components/NavBar/index.tsx +11 -5
  165. package/themes/original/src/components/NotFoundSource/index.tsx +2 -1
  166. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +167 -0
  167. package/themes/original/src/components/OrderDetails/index.tsx +135 -56
  168. package/themes/original/src/components/OrderDetails/styles.tsx +5 -2
  169. package/themes/original/src/components/OrderItAgain/index.tsx +73 -0
  170. package/themes/original/src/components/OrderItAgain/styles.tsx +10 -0
  171. package/themes/original/src/components/OrderProgress/index.tsx +8 -2
  172. package/themes/original/src/components/OrderSummary/index.tsx +2 -35
  173. package/themes/original/src/components/OrderTypeSelector/index.tsx +84 -36
  174. package/themes/original/src/components/OrderTypeSelector/styles.tsx +19 -1
  175. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +140 -0
  176. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
  177. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +56 -0
  178. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
  179. package/themes/original/src/components/OrdersOption/index.tsx +143 -47
  180. package/themes/original/src/components/OrdersOption/styles.tsx +4 -1
  181. package/themes/original/src/components/PaymentOptionWallet/index.tsx +15 -23
  182. package/themes/original/src/components/PaymentOptions/index.tsx +57 -37
  183. package/themes/original/src/components/PhoneInputNumber/index.tsx +4 -10
  184. package/themes/original/src/components/PlaceSpot/index.tsx +243 -47
  185. package/themes/original/src/components/PlaceSpot/styles.tsx +0 -2
  186. package/themes/original/src/components/PreviousOrders/index.tsx +18 -147
  187. package/themes/original/src/components/ProductForm/index.tsx +697 -649
  188. package/themes/original/src/components/ProductForm/styles.tsx +9 -7
  189. package/themes/original/src/components/ProductItemAccordion/index.tsx +37 -24
  190. package/themes/original/src/components/ProductOption/index.tsx +1 -1
  191. package/themes/original/src/components/ProfessionalFilter/index.tsx +129 -0
  192. package/themes/original/src/components/ProfessionalFilter/styles.tsx +0 -0
  193. package/themes/original/src/components/ProfessionalProfile/index.tsx +309 -0
  194. package/themes/original/src/components/ProfessionalProfile/styles.tsx +46 -0
  195. package/themes/original/src/components/ReviewDriver/index.tsx +6 -6
  196. package/themes/original/src/components/ReviewOrder/index.tsx +18 -3
  197. package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
  198. package/themes/original/src/components/ReviewTrigger/index.tsx +118 -0
  199. package/themes/original/src/components/ReviewTrigger/styles.tsx +34 -0
  200. package/themes/original/src/components/SearchBar/index.tsx +13 -5
  201. package/themes/original/src/components/ServiceForm/index.tsx +608 -0
  202. package/themes/original/src/components/ServiceForm/styles.tsx +50 -0
  203. package/themes/original/src/components/SignupForm/index.tsx +307 -159
  204. package/themes/original/src/components/SingleOrderCard/index.tsx +316 -0
  205. package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
  206. package/themes/original/src/components/SingleProductCard/index.tsx +215 -95
  207. package/themes/original/src/components/SingleProductCard/styles.tsx +2 -2
  208. package/themes/original/src/components/SingleProductReview/index.tsx +30 -3
  209. package/themes/original/src/components/SingleProductReview/styles.tsx +12 -0
  210. package/themes/original/src/components/StripeElementsForm/index.tsx +25 -9
  211. package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
  212. package/themes/original/src/components/UpsellingProducts/index.tsx +7 -3
  213. package/themes/original/src/components/UserDetails/index.tsx +32 -18
  214. package/themes/original/src/components/UserFormDetails/index.tsx +107 -73
  215. package/themes/original/src/components/UserProfile/index.tsx +4 -0
  216. package/themes/original/src/components/UserProfileForm/index.tsx +15 -10
  217. package/themes/original/src/components/WalletTransactions/index.tsx +76 -0
  218. package/themes/original/src/components/WalletTransactions/styles.tsx +13 -0
  219. package/themes/original/src/components/Wallets/index.tsx +176 -162
  220. package/themes/original/src/components/Wallets/styles.tsx +10 -8
  221. package/themes/original/src/components/shared/OBottomPopup.tsx +47 -14
  222. package/themes/original/src/components/shared/OButton.tsx +10 -3
  223. package/themes/original/src/components/shared/OInput.tsx +3 -2
  224. package/themes/original/src/components/shared/OModal.tsx +4 -2
  225. package/themes/original/src/layouts/FloatingBottomContainer.tsx +5 -1
  226. package/themes/original/src/types/index.tsx +200 -47
  227. package/themes/original/src/utils/index.tsx +77 -0
  228. 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);
@@ -135,6 +151,17 @@ const SignupFormUI = (props: SignupParams) => {
135
151
  const recaptchaRef = useRef<any>({});
136
152
 
137
153
  const showInputPhoneNumber = (validationFields?.fields?.checkout?.cellphone?.enabled ?? false) || configs?.verification_phone_required?.value === '1'
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
+ }
138
165
 
139
166
  const handleRefs = (ref: any, code: string) => {
140
167
  switch (code) {
@@ -160,6 +187,13 @@ const SignupFormUI = (props: SignupParams) => {
160
187
  }
161
188
  };
162
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
+
163
197
  const handleFocusRef = (code: string) => {
164
198
  switch (code) {
165
199
  case 'name': {
@@ -203,13 +237,13 @@ const SignupFormUI = (props: SignupParams) => {
203
237
  navigation.navigate('Home');
204
238
  };
205
239
 
206
- const handleChangeTab = (val: string) => {
207
- setSignupTab(val);
208
- setPasswordSee(false);
209
- };
240
+ const handleSignUpTab = (tab: string) => {
241
+ setSignUpTab && setSignUpTab(tab)
242
+ clearErrors()
243
+ }
210
244
 
211
- const onSubmit = (values: any) => {
212
- if (phoneInputData.error) {
245
+ const onSubmit = (values?: any) => {
246
+ if (phoneInputData.error && signUpTab !== 'otpEmail') {
213
247
  showToast(ToastType.Error, phoneInputData.error);
214
248
  return;
215
249
  }
@@ -218,7 +252,8 @@ const SignupFormUI = (props: SignupParams) => {
218
252
  !phoneInputData.phone.cellphone &&
219
253
  ((validationFields?.fields?.checkout?.cellphone?.enabled &&
220
254
  validationFields?.fields?.checkout?.cellphone?.required) ||
221
- configs?.verification_phone_required?.value === '1')
255
+ configs?.verification_phone_required?.value === '1') &&
256
+ signUpTab !== 'otpEmail'
222
257
  ) {
223
258
  showToast(
224
259
  ToastType.Error,
@@ -229,26 +264,29 @@ const SignupFormUI = (props: SignupParams) => {
229
264
  );
230
265
  return;
231
266
  }
232
- if (signupTab === 'email' || !useSignupByCellphone) {
233
- handleButtonSignupClick &&
234
- handleButtonSignupClick({
235
- ...values,
236
- ...((phoneInputData.phone.cellphone !== null && phoneInputData.phone.country_phone_code !== null) && { ...phoneInputData.phone }),
237
- country_code: phoneInputData.phone.country_code
238
- });
239
- if (
240
- !formState.loading &&
241
- formState.result.result &&
242
- !formState.result.error
243
- ) {
244
- handleSuccessSignup && handleSuccessSignup(formState.result.result);
245
- }
246
- 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);
247
283
  }
248
- setFormValues(values);
249
- handleVerifyCodeClick(values);
250
284
  };
251
285
 
286
+ const handleSingUpOtp = (value: string) => {
287
+ setOtpState && setOtpState(value)
288
+ }
289
+
252
290
  const handleVerifyCodeClick = (values: any) => {
253
291
  const formData = values || formValues;
254
292
  handleSendVerifyCode &&
@@ -310,20 +348,44 @@ const SignupFormUI = (props: SignupParams) => {
310
348
 
311
349
  const onRecaptchaVerify = (token: any) => {
312
350
  setRecaptchaVerified(true)
313
- handleReCaptcha(token)
351
+ handleReCaptcha && handleReCaptcha({ code: token, version: recaptchaConfig?.version })
314
352
  }
315
353
 
316
354
  useEffect(() => {
317
355
  if (configs && Object.keys(configs).length > 0 && enableReCaptcha) {
318
- setRecaptchaConfig({
319
- siteKey: configs?.security_recaptcha_site_key?.value || null,
320
- baseUrl: configs?.security_recaptcha_base_url?.value || null
321
- })
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
+ }
322
374
  }
323
375
  }, [configs, enableReCaptcha])
324
376
 
325
377
  useEffect(() => {
326
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
+ }
327
389
  formState.result?.result &&
328
390
  showToast(ToastType.Error, formState.result?.result[0]);
329
391
  setIsLoadingVerifyModal(false);
@@ -334,15 +396,19 @@ const SignupFormUI = (props: SignupParams) => {
334
396
  if (Object.keys(errors).length > 0) {
335
397
  setIsLoadingVerifyModal(false);
336
398
  }
337
- }, [errors]);
399
+ }, [errors])
338
400
 
339
401
  useEffect(() => {
340
- register('cellphone', {
341
- required: isRequiredField('cellphone')
342
- ? t('VALIDATION_ERROR_MOBILE_PHONE_REQUIRED', 'The field Mobile phone is required').replace('_attribute_', t('CELLPHONE', 'Cellphone'))
343
- : null
344
- })
345
- }, [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])
346
412
 
347
413
  useEffect(() => {
348
414
  if (phoneInputData?.phone?.cellphone) setValue('cellphone', phoneInputData?.phone?.cellphone, '')
@@ -379,6 +445,16 @@ const SignupFormUI = (props: SignupParams) => {
379
445
  })
380
446
  }, [configs])
381
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
+
382
458
  return (
383
459
  <View>
384
460
  <NavBar
@@ -392,47 +468,92 @@ const SignupFormUI = (props: SignupParams) => {
392
468
  titleStyle={{ marginLeft: 0, marginRight: 0 }}
393
469
  />
394
470
  <FormSide>
395
- {useSignupByEmail &&
396
- useSignupByCellphone &&
397
- configs &&
398
- Object.keys(configs).length > 0 &&
399
- (configs?.twilio_service_enabled?.value === 'true' ||
400
- configs?.twilio_service_enabled?.value === '1') && (
401
- <SignupWith style={{ paddingBottom: 25 }}>
402
- <OTabs>
403
- {useSignupByEmail && (
404
- <Pressable onPress={() => handleChangeTab('email')}>
405
- <OTab>
406
- <OText
407
- size={18}
408
- color={
409
- signupTab === 'email'
410
- ? theme.colors.primary
411
- : theme.colors.disabled
412
- }>
413
- {t('SIGNUP_BY_EMAIL', 'Signup by Email')}
414
- </OText>
415
- </OTab>
416
- </Pressable>
417
- )}
418
- {useSignupByCellphone && (
419
- <Pressable onPress={() => handleChangeTab('cellphone')}>
420
- <OTab>
421
- <OText
422
- size={18}
423
- color={
424
- signupTab === 'cellphone'
425
- ? theme.colors.primary
426
- : theme.colors.disabled
427
- }>
428
- {t('SIGNUP_BY_PHONE', 'Signup by Phone')}
429
- </OText>
430
- </OTab>
431
- </Pressable>
432
- )}
433
- </OTabs>
434
- </SignupWith>
435
- )}
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
+ )}
436
557
  <FormInput>
437
558
  {!(useChekoutFileds && validationFields?.loading) ? (
438
559
  <>
@@ -442,7 +563,9 @@ const SignupFormUI = (props: SignupParams) => {
442
563
  (field: any, i: number) =>
443
564
  !notValidationFields.includes(field.code) &&
444
565
  showField &&
445
- showField(field.code) && (
566
+ showField(field.code) &&
567
+ (signUpTab === 'default' ||
568
+ (signUpTab === 'otpEmail' && field.code === 'email')) && (
446
569
  <React.Fragment key={field.id}>
447
570
  {errors?.[`${field.code}`] && (
448
571
  <OText
@@ -466,7 +589,7 @@ const SignupFormUI = (props: SignupParams) => {
466
589
  value={value}
467
590
  onChange={(val: any) =>
468
591
  field.code !== 'email'
469
- ? onChange(val)
592
+ ? (onChange(val))
470
593
  : handleChangeInputEmail(val, onChange)
471
594
  }
472
595
  autoCapitalize={
@@ -498,7 +621,7 @@ const SignupFormUI = (props: SignupParams) => {
498
621
  ),
499
622
  )}
500
623
 
501
- {!!showInputPhoneNumber && (
624
+ {(!!showInputPhoneNumber && (signUpTab === 'default' || signUpTab === 'otpCellphone')) && (
502
625
  <View style={{ marginBottom: 25 }}>
503
626
  <PhoneInputNumber
504
627
  data={phoneInputData}
@@ -512,7 +635,6 @@ const SignupFormUI = (props: SignupParams) => {
512
635
  }
513
636
  })}
514
637
  forwardRef={phoneRef}
515
- defaultCode={formState?.country_code ?? formState?.country_phone_code ?? null}
516
638
  changeCountry={(val: any) => setPhoneInputData({
517
639
  ...phoneInputData,
518
640
  phone: {
@@ -529,66 +651,79 @@ const SignupFormUI = (props: SignupParams) => {
529
651
  </View>
530
652
  )}
531
653
 
532
- {enableReCaptcha && (
654
+ {(enableReCaptcha && recaptchaConfig?.version) && (
533
655
  <>
534
- <TouchableOpacity
535
- onPress={handleOpenRecaptcha}
536
- style={{ marginHorizontal: 4, marginBottom: 10 }}
537
- >
538
- <RecaptchaButton>
539
- {recaptchaVerified ? (
540
- <MaterialCommunityIcons
541
- name="checkbox-marked"
542
- size={23}
543
- color={theme.colors.primary}
544
- />
545
- ) : (
546
- <MaterialCommunityIcons
547
- name="checkbox-blank-outline"
548
- size={23}
549
- color={theme.colors.disabled}
550
- />
551
- )}
552
- <OText size={14} mLeft={8}>{t('VERIFY_ReCAPTCHA', 'Verify reCAPTCHA')}</OText>
553
- </RecaptchaButton>
554
- </TouchableOpacity>
555
- <Recaptcha
556
- ref={recaptchaRef}
557
- siteKey={recaptchaConfig?.siteKey}
558
- baseUrl={recaptchaConfig?.baseUrl}
559
- onVerify={onRecaptchaVerify}
560
- onExpire={() => setRecaptchaVerified(false)}
561
- />
562
- </>
563
- )}
564
-
565
- <View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 20 }}>
566
- <Controller
567
- control={control}
568
- render={({ onChange, value }: any) => (
569
- <CheckBox
570
- value={value}
571
- onValueChange={newValue => {
572
- onChange(newValue)
573
- handleChangePromotions()
574
- }}
575
- boxType={'square'}
576
- tintColors={{
577
- true: theme.colors.primary,
578
- false: theme.colors.disabled
579
- }}
580
- tintColor={theme.colors.disabled}
581
- onCheckColor={theme.colors.primary}
582
- onTintColor={theme.colors.primary}
583
- 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}
584
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
+ </>
585
695
  )}
586
- name='promotions'
587
- defaultValue={false}
588
- />
589
- <OText style={{ fontSize: 14, paddingHorizontal: 5 }}>{t('RECEIVE_NEWS_EXCLUSIVE_PROMOTIONS', 'Receive newsletters and exclusive promotions')}</OText>
590
- </View>
591
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
+ )}
592
727
  {configs?.terms_and_conditions?.value === 'true' && (
593
728
  <>
594
729
  {errors?.termsAccept && (
@@ -640,7 +775,7 @@ const SignupFormUI = (props: SignupParams) => {
640
775
 
641
776
  )}
642
777
 
643
- {signupTab !== 'cellphone' && (
778
+ {signUpTab === 'default' && (
644
779
  <>
645
780
  {errors?.password && (
646
781
  <OText
@@ -712,9 +847,7 @@ const SignupFormUI = (props: SignupParams) => {
712
847
  <Spinner visible />
713
848
  )}
714
849
 
715
- {signupTab === 'cellphone' &&
716
- useSignupByEmail &&
717
- useSignupByCellphone ? (
850
+ {(signUpTab === 'otpEmail' || signUpTab === 'otpCellphone') ? (
718
851
  <OButton
719
852
  onClick={handleSubmit(onSubmit)}
720
853
  text={t('GET_VERIFY_CODE', 'Get Verify Code')}
@@ -779,7 +912,9 @@ const SignupFormUI = (props: SignupParams) => {
779
912
  <ButtonsWrapper>
780
913
  <SocialButtons>
781
914
  {(configs?.facebook_login?.value === 'true' || configs?.facebook_login?.value === '1') &&
782
- configs?.facebook_id?.value && (
915
+ configs?.facebook_id?.value &&
916
+ facebookLoginEnabled &&
917
+ (
783
918
  <FacebookLogin
784
919
  notificationState={notificationState}
785
920
  handleErrors={(err: any) => showToast(ToastType.Error, err)}
@@ -787,7 +922,7 @@ const SignupFormUI = (props: SignupParams) => {
787
922
  handleSuccessFacebookLogin={handleSuccessFacebook}
788
923
  />
789
924
  )}
790
- {(configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) && (
925
+ {(configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) && googleLoginEnabled && (
791
926
  <GoogleLogin
792
927
  notificationState={notificationState}
793
928
  webClientId={configs?.google_login_client_id?.value}
@@ -796,7 +931,7 @@ const SignupFormUI = (props: SignupParams) => {
796
931
  handleSuccessGoogleLogin={handleSuccessFacebook}
797
932
  />
798
933
  )}
799
- {(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 && (
800
935
  <AppleLogin
801
936
  notificationState={notificationState}
802
937
  handleErrors={(err: any) => showToast(ToastType.Error, err)}
@@ -810,27 +945,40 @@ const SignupFormUI = (props: SignupParams) => {
810
945
  )}
811
946
 
812
947
  </FormSide>
813
- <OModal open={isModalVisible} onClose={() => setIsModalVisible(false)}>
814
- <VerifyPhone
815
- phone={phoneInputData.phone}
816
- formValues={formValues}
817
- verifyPhoneState={verifyPhoneState}
818
- checkPhoneCodeState={checkPhoneCodeState}
819
- handleCheckPhoneCode={handleCheckPhoneCode}
820
- setCheckPhoneCodeState={setCheckPhoneCodeState}
821
- 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}
822
961
  />
823
962
  </OModal>
824
963
  <Spinner
825
964
  visible={formState.loading || validationFields.loading || isFBLoading}
826
965
  />
966
+ <Alert
967
+ open={alertState.open}
968
+ content={alertState.content}
969
+ title={alertState.title || ''}
970
+ onAccept={closeAlert}
971
+ onClose={closeAlert}
972
+ />
827
973
  </View>
828
974
  );
829
975
  };
830
976
 
831
977
  export const SignupForm = (props: any) => {
978
+ const _numOtpInputs = 6
832
979
  const signupProps = {
833
980
  ...props,
981
+ numOtpInputs: _numOtpInputs,
834
982
  isRecaptchaEnable: true,
835
983
  UIComponent: SignupFormUI,
836
984
  };