ordering-ui-react-native 0.15.56 → 0.15.58-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 (186) hide show
  1. package/package.json +5 -3
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/AddressForm/index.tsx +18 -2
  4. package/src/components/BusinessController/index.tsx +16 -8
  5. package/src/components/BusinessTypeFilter/index.tsx +3 -1
  6. package/src/components/BusinessesListing/index.tsx +1 -1
  7. package/src/components/Checkout/index.tsx +23 -2
  8. package/src/components/DriverTips/index.tsx +11 -6
  9. package/src/components/LanguageSelector/index.tsx +7 -2
  10. package/src/components/LoginForm/index.tsx +120 -30
  11. package/src/components/LoginForm/styles.tsx +6 -0
  12. package/src/components/OrderDetails/index.tsx +7 -21
  13. package/src/components/PaymentOptions/index.tsx +67 -50
  14. package/src/components/PaymentOptionsWebView/index.tsx +123 -124
  15. package/src/components/SignupForm/index.tsx +145 -61
  16. package/src/components/SingleProductCard/index.tsx +16 -4
  17. package/src/components/StripeMethodForm/index.tsx +1 -2
  18. package/src/components/UpsellingProducts/index.tsx +1 -1
  19. package/src/components/UserProfileForm/index.tsx +63 -6
  20. package/src/components/UserProfileForm/styles.tsx +8 -0
  21. package/src/components/VerifyPhone/styles.tsx +1 -2
  22. package/src/components/shared/OModal.tsx +1 -1
  23. package/src/hooks/useCountdownTimer.tsx +26 -0
  24. package/src/navigators/CheckoutNavigator.tsx +6 -0
  25. package/src/navigators/HomeNavigator.tsx +12 -0
  26. package/src/pages/BusinessesListing.tsx +1 -1
  27. package/src/pages/MultiCheckout.tsx +31 -0
  28. package/src/pages/MultiOrdersDetails.tsx +27 -0
  29. package/src/pages/Sessions.tsx +22 -0
  30. package/src/theme.json +0 -1
  31. package/src/types/index.tsx +18 -11
  32. package/src/utils/index.tsx +68 -1
  33. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +103 -15
  34. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -0
  35. package/themes/business/src/components/Chat/index.tsx +42 -90
  36. package/themes/business/src/components/DriverMap/index.tsx +6 -5
  37. package/themes/business/src/components/LoginForm/index.tsx +89 -2
  38. package/themes/business/src/components/LoginForm/styles.tsx +6 -0
  39. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  40. package/themes/business/src/components/NewOrderNotification/index.tsx +79 -105
  41. package/themes/business/src/components/OrderDetails/Business.tsx +2 -2
  42. package/themes/business/src/components/OrderDetails/Delivery.tsx +28 -11
  43. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +41 -7
  44. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +6 -0
  45. package/themes/business/src/components/OrdersListManager/index.tsx +1 -1
  46. package/themes/business/src/components/OrdersOption/index.tsx +5 -2
  47. package/themes/business/src/components/PreviousOrders/index.tsx +2 -2
  48. package/themes/business/src/components/ProductItemAccordion/index.tsx +2 -2
  49. package/themes/business/src/components/UserFormDetails/index.tsx +5 -2
  50. package/themes/business/src/components/UserProfileForm/index.tsx +2 -0
  51. package/themes/business/src/components/shared/OModal.tsx +1 -1
  52. package/themes/business/src/types/index.tsx +6 -1
  53. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  54. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  55. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  56. package/themes/kiosk/src/components/BusinessMenu/index.tsx +39 -28
  57. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -3
  58. package/themes/kiosk/src/components/Cart/index.tsx +11 -12
  59. package/themes/kiosk/src/components/CartBottomSheet/index.tsx +9 -2
  60. package/themes/kiosk/src/components/CartContent/index.tsx +0 -11
  61. package/themes/kiosk/src/components/CartItem/index.tsx +4 -3
  62. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +107 -62
  63. package/themes/kiosk/src/components/Checkout/index.tsx +40 -22
  64. package/themes/kiosk/src/components/CustomerName/index.tsx +0 -6
  65. package/themes/kiosk/src/components/DrawerView/index.tsx +1 -0
  66. package/themes/kiosk/src/components/DrawerView/styles.tsx +2 -2
  67. package/themes/kiosk/src/components/NavBar/index.tsx +29 -20
  68. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  69. package/themes/kiosk/src/components/OrderDetails/index.tsx +32 -27
  70. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +9 -11
  71. package/themes/kiosk/src/components/PaymentOptions/index.tsx +56 -54
  72. package/themes/kiosk/src/components/ProductForm/index.tsx +7 -8
  73. package/themes/kiosk/src/components/ProductItemAccordion/index.tsx +2 -2
  74. package/themes/kiosk/src/components/ProductOption/index.tsx +1 -1
  75. package/themes/kiosk/src/components/ProductOptionSubOption/index.tsx +3 -1
  76. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +16 -5
  77. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  78. package/themes/kiosk/src/types/index.d.ts +1 -0
  79. package/themes/original/index.tsx +169 -4
  80. package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
  81. package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
  82. package/themes/original/src/components/AddressForm/index.tsx +7 -6
  83. package/themes/original/src/components/AddressList/index.tsx +30 -18
  84. package/themes/original/src/components/AppleLogin/index.tsx +9 -13
  85. package/themes/original/src/components/BusinessBasicInformation/index.tsx +136 -45
  86. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +4 -0
  87. package/themes/original/src/components/BusinessController/index.tsx +48 -11
  88. package/themes/original/src/components/BusinessController/styles.tsx +27 -0
  89. package/themes/original/src/components/BusinessFeaturedController/index.tsx +20 -1
  90. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +23 -0
  91. package/themes/original/src/components/BusinessItemAccordion/index.tsx +8 -5
  92. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -1
  93. package/themes/original/src/components/BusinessListingSearch/index.tsx +196 -58
  94. package/themes/original/src/components/BusinessListingSearch/styles.tsx +22 -2
  95. package/themes/original/src/components/BusinessPreorder/index.tsx +1 -1
  96. package/themes/original/src/components/BusinessProductsCategories/index.tsx +2 -2
  97. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  98. package/themes/original/src/components/BusinessProductsList/index.tsx +119 -35
  99. package/themes/original/src/components/BusinessProductsList/styles.tsx +12 -4
  100. package/themes/original/src/components/BusinessProductsListing/index.tsx +109 -21
  101. package/themes/original/src/components/BusinessProductsListing/styles.tsx +22 -0
  102. package/themes/original/src/components/BusinessReviews/index.tsx +6 -1
  103. package/themes/original/src/components/BusinessTypeFilter/index.tsx +1 -2
  104. package/themes/original/src/components/BusinessesListing/index.tsx +127 -66
  105. package/themes/original/src/components/BusinessesListing/styles.tsx +11 -3
  106. package/themes/original/src/components/Cart/index.tsx +60 -41
  107. package/themes/original/src/components/Checkout/index.tsx +48 -32
  108. package/themes/original/src/components/DriverTips/index.tsx +17 -12
  109. package/themes/original/src/components/Favorite/index.tsx +92 -0
  110. package/themes/original/src/components/Favorite/styles.tsx +22 -0
  111. package/themes/original/src/components/FavoriteList/index.tsx +298 -0
  112. package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
  113. package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
  114. package/themes/original/src/components/GPSButton/index.tsx +15 -8
  115. package/themes/original/src/components/GoogleMap/index.tsx +11 -11
  116. package/themes/original/src/components/Help/index.tsx +21 -4
  117. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +18 -1
  118. package/themes/original/src/components/Home/index.tsx +1 -1
  119. package/themes/original/src/components/LastOrders/index.tsx +12 -1
  120. package/themes/original/src/components/LoginForm/Otp/index.tsx +91 -0
  121. package/themes/original/src/components/LoginForm/Otp/styles.tsx +7 -0
  122. package/themes/original/src/components/LoginForm/index.tsx +332 -164
  123. package/themes/original/src/components/LoginForm/styles.tsx +1 -3
  124. package/themes/original/src/components/MessageListing/index.tsx +10 -1
  125. package/themes/original/src/components/Messages/index.tsx +1 -1
  126. package/themes/original/src/components/MomentOption/index.tsx +10 -1
  127. package/themes/original/src/components/MomentOption/styles.tsx +1 -1
  128. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +243 -0
  129. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/styles.tsx +46 -0
  130. package/themes/original/src/components/MultiCheckout/index.tsx +298 -0
  131. package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
  132. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +372 -0
  133. package/themes/original/src/components/MultiOrdersDetails/index.tsx +258 -0
  134. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
  135. package/themes/original/src/components/MyOrders/index.tsx +120 -32
  136. package/themes/original/src/components/MyOrders/styles.tsx +8 -1
  137. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +167 -0
  138. package/themes/original/src/components/OrderDetails/index.tsx +135 -49
  139. package/themes/original/src/components/OrderDetails/styles.tsx +1 -2
  140. package/themes/original/src/components/OrderSummary/index.tsx +2 -2
  141. package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -2
  142. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +153 -0
  143. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
  144. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +53 -0
  145. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
  146. package/themes/original/src/components/OrdersOption/index.tsx +130 -38
  147. package/themes/original/src/components/OrdersOption/styles.tsx +4 -1
  148. package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
  149. package/themes/original/src/components/PaymentOptionWallet/index.tsx +17 -23
  150. package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
  151. package/themes/original/src/components/PaymentOptions/index.tsx +57 -36
  152. package/themes/original/src/components/PhoneInputNumber/index.tsx +1 -1
  153. package/themes/original/src/components/PreviousOrders/index.tsx +18 -147
  154. package/themes/original/src/components/ProductForm/index.tsx +70 -62
  155. package/themes/original/src/components/ProductForm/styles.tsx +0 -1
  156. package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
  157. package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -12
  158. package/themes/original/src/components/Promotions/index.tsx +151 -133
  159. package/themes/original/src/components/Promotions/styles.tsx +3 -23
  160. package/themes/original/src/components/SearchBar/index.tsx +10 -4
  161. package/themes/original/src/components/Sessions/index.tsx +160 -0
  162. package/themes/original/src/components/Sessions/styles.tsx +15 -0
  163. package/themes/original/src/components/SignupForm/index.tsx +269 -130
  164. package/themes/original/src/components/SingleOrderCard/index.tsx +282 -0
  165. package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
  166. package/themes/original/src/components/SingleProductCard/index.tsx +59 -17
  167. package/themes/original/src/components/StripeElementsForm/index.tsx +16 -8
  168. package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
  169. package/themes/original/src/components/UpsellingProducts/index.tsx +86 -74
  170. package/themes/original/src/components/UserDetails/index.tsx +5 -96
  171. package/themes/original/src/components/UserFormDetails/index.tsx +34 -24
  172. package/themes/original/src/components/UserProfile/index.tsx +53 -6
  173. package/themes/original/src/components/UserProfileForm/index.tsx +20 -18
  174. package/themes/original/src/components/UserVerification/index.tsx +178 -192
  175. package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
  176. package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
  177. package/themes/original/src/components/Wallets/index.tsx +76 -9
  178. package/themes/original/src/components/Wallets/styles.tsx +21 -0
  179. package/themes/original/src/components/shared/OModal.tsx +4 -2
  180. package/themes/original/src/config/constants.tsx +6 -6
  181. package/themes/original/src/types/index.tsx +192 -33
  182. package/themes/original/src/utils/index.tsx +85 -2
  183. package/themes/single-business/src/components/AddressList/index.tsx +1 -1
  184. package/themes/single-business/src/components/OrderTypeSelector/index.tsx +1 -1
  185. package/themes/single-business/src/components/UserProfile/index.tsx +1 -1
  186. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -18,10 +18,12 @@ import {
18
18
  } from 'ordering-components/native';
19
19
  import { useTheme } from 'styled-components/native';
20
20
  import { FormSide, FormInput, SocialButtons } from './styles';
21
+ import { Otp } from '../LoginForm/Otp'
21
22
 
22
23
  import {
23
24
  ButtonsWrapper,
24
25
  LoginWith as SignupWith,
26
+ TabBtn,
25
27
  OTab,
26
28
  OTabs,
27
29
  RecaptchaButton
@@ -30,7 +32,9 @@ import {
30
32
  import NavBar from '../NavBar';
31
33
  import { VerifyPhone } from '../VerifyPhone';
32
34
 
33
- import { OText, OButton, OInput, OModal } from '../shared';
35
+ import Alert from '../../../../../src/providers/AlertProvider'
36
+ import { OText, OButton, OInput } from '../shared';
37
+ import { OModal } from '../../../../../src/components/shared';
34
38
  import { SignupParams } from '../../types';
35
39
  import { sortInputFields } from '../../utils';
36
40
  import { GoogleLogin } from '../GoogleLogin';
@@ -67,7 +71,18 @@ const SignupFormUI = (props: SignupParams) => {
67
71
  notificationState,
68
72
  handleChangePromotions,
69
73
  enableReCaptcha,
70
- handleReCaptcha
74
+ handleReCaptcha,
75
+ generateOtpCode,
76
+ numOtpInputs,
77
+ setWillVerifyOtpState,
78
+ handleChangeInput,
79
+ willVerifyOtpState,
80
+ setOtpState,
81
+ setSignUpTab,
82
+ signUpTab,
83
+ useSignUpFullDetails,
84
+ useSignUpOtpEmail,
85
+ useSignUpOtpCellphone
71
86
  } = props;
72
87
 
73
88
  const theme = useTheme();
@@ -104,26 +119,27 @@ const SignupFormUI = (props: SignupParams) => {
104
119
  const [, t] = useLanguage();
105
120
  const [, { login }] = useSession();
106
121
  const [{ configs }] = useConfig();
107
- const { control, handleSubmit, errors, register, setValue } = useForm();
122
+ const { control, handleSubmit, clearErrors, errors, register, unregister, setValue } = useForm();
108
123
 
109
124
  const [passwordSee, setPasswordSee] = useState(false);
110
125
  const [formValues, setFormValues] = useState(null);
111
126
  const [isModalVisible, setIsModalVisible] = useState(false);
112
127
  const [isLoadingVerifyModal, setIsLoadingVerifyModal] = useState(false);
113
- const [signupTab, setSignupTab] = useState(
114
- useSignupByCellphone && !useSignupByEmail ? 'cellphone' : 'email',
115
- );
116
128
  const [isFBLoading, setIsFBLoading] = useState(false);
117
129
  const [phoneInputData, setPhoneInputData] = useState({
118
130
  error: '',
119
131
  phone: {
120
132
  country_phone_code: null,
121
133
  cellphone: null,
134
+ country_code: null
122
135
  },
123
136
  });
137
+ const [alertState, setAlertState] = useState({ open: false, title: '', content: [] })
124
138
  const [recaptchaConfig, setRecaptchaConfig] = useState<any>({})
125
139
  const [recaptchaVerified, setRecaptchaVerified] = useState(false)
140
+ const [tabLayouts, setTabLayouts] = useState<any>({})
126
141
 
142
+ const tabsRef = useRef<any>(null)
127
143
  const nameRef = useRef<any>(null);
128
144
  const lastnameRef = useRef<any>(null);
129
145
  const middleNameRef = useRef<any>(null);
@@ -133,7 +149,18 @@ const SignupFormUI = (props: SignupParams) => {
133
149
  const passwordRef = useRef<any>(null);
134
150
  const recaptchaRef = useRef<any>({});
135
151
 
136
- const showInputPhoneNumber = (validationFields?.fields?.checkout?.cellphone?.enabled ?? false) || configs?.verification_phone_required?.value === '1'
152
+ const showInputPhoneNumber = (validationFields?.fields?.checkout?.cellphone?.enabled ?? false) || configs?.verification_phone_required?.value === '1'
153
+ const googleLoginEnabled = configs?.google_login_enabled?.value === '1' || !configs?.google_login_enabled?.enabled
154
+ const facebookLoginEnabled = configs?.facebook_login_enabled?.value === '1' || !configs?.facebook_login_enabled?.enabled
155
+ const appleLoginEnabled = configs?.apple_login_enabled?.value === '1' || !configs?.apple_login_enabled?.enabled
156
+
157
+ const closeAlert = () => {
158
+ setAlertState({
159
+ open: false,
160
+ title: '',
161
+ content: []
162
+ })
163
+ }
137
164
 
138
165
  const handleRefs = (ref: any, code: string) => {
139
166
  switch (code) {
@@ -159,6 +186,13 @@ const SignupFormUI = (props: SignupParams) => {
159
186
  }
160
187
  };
161
188
 
189
+ const handleOnLayout = (event: any, opc: string) => {
190
+ const _tabLayouts = { ...tabLayouts }
191
+ const categoryKey = opc
192
+ _tabLayouts[categoryKey] = event.nativeEvent.layout
193
+ setTabLayouts(_tabLayouts)
194
+ }
195
+
162
196
  const handleFocusRef = (code: string) => {
163
197
  switch (code) {
164
198
  case 'name': {
@@ -202,13 +236,13 @@ const SignupFormUI = (props: SignupParams) => {
202
236
  navigation.navigate('Home');
203
237
  };
204
238
 
205
- const handleChangeTab = (val: string) => {
206
- setSignupTab(val);
207
- setPasswordSee(false);
208
- };
239
+ const handleSignUpTab = (tab: string) => {
240
+ setSignUpTab && setSignUpTab(tab)
241
+ clearErrors()
242
+ }
209
243
 
210
- const onSubmit = (values: any) => {
211
- if (phoneInputData.error) {
244
+ const onSubmit = (values?: any) => {
245
+ if (phoneInputData.error && signUpTab !== 'otpEmail') {
212
246
  showToast(ToastType.Error, phoneInputData.error);
213
247
  return;
214
248
  }
@@ -216,8 +250,9 @@ const SignupFormUI = (props: SignupParams) => {
216
250
  !phoneInputData.phone.country_phone_code &&
217
251
  !phoneInputData.phone.cellphone &&
218
252
  ((validationFields?.fields?.checkout?.cellphone?.enabled &&
219
- validationFields?.fields?.checkout?.cellphone?.required) ||
220
- configs?.verification_phone_required?.value === '1')
253
+ validationFields?.fields?.checkout?.cellphone?.required) ||
254
+ configs?.verification_phone_required?.value === '1') &&
255
+ signUpTab !== 'otpEmail'
221
256
  ) {
222
257
  showToast(
223
258
  ToastType.Error,
@@ -228,25 +263,29 @@ const SignupFormUI = (props: SignupParams) => {
228
263
  );
229
264
  return;
230
265
  }
231
- if (signupTab === 'email' || !useSignupByCellphone) {
232
- handleButtonSignupClick &&
233
- handleButtonSignupClick({
234
- ...values,
235
- ...((phoneInputData.phone.cellphone !== null && phoneInputData.phone.country_phone_code !== null) && {...phoneInputData.phone}),
236
- });
237
- if (
238
- !formState.loading &&
239
- formState.result.result &&
240
- !formState.result.error
241
- ) {
242
- handleSuccessSignup && handleSuccessSignup(formState.result.result);
243
- }
244
- return;
266
+ if (signUpTab === 'otpEmail' || signUpTab === 'otpCellphone') {
267
+ generateOtpCode && generateOtpCode({
268
+ ...values,
269
+ ...((phoneInputData.phone.cellphone !== null && phoneInputData.phone.country_phone_code !== null) && { ...phoneInputData.phone }),
270
+ country_code: phoneInputData.phone.country_code
271
+ })
272
+ return
273
+ }
274
+ handleButtonSignupClick &&
275
+ handleButtonSignupClick({
276
+ ...values,
277
+ ...((phoneInputData.phone.cellphone !== null && phoneInputData.phone.country_phone_code !== null) && { ...phoneInputData.phone }),
278
+ country_code: phoneInputData.phone.country_code
279
+ });
280
+ if (!formState.loading && formState.result.result && !formState.result.error) {
281
+ handleSuccessSignup && handleSuccessSignup(formState.result.result);
245
282
  }
246
- setFormValues(values);
247
- handleVerifyCodeClick(values);
248
283
  };
249
284
 
285
+ const handleSingUpOtp = (value: string) => {
286
+ setOtpState && setOtpState(value)
287
+ }
288
+
250
289
  const handleVerifyCodeClick = (values: any) => {
251
290
  const formData = values || formValues;
252
291
  handleSendVerifyCode &&
@@ -295,7 +334,7 @@ const SignupFormUI = (props: SignupParams) => {
295
334
 
296
335
  const handleOpenRecaptcha = () => {
297
336
  setRecaptchaVerified(false)
298
- if (!recaptchaConfig?.siteKey) {
337
+ if (!recaptchaConfig?.siteKey) {
299
338
  showToast(ToastType.Error, t('NO_RECAPTCHA_SITE_KEY', 'The config doesn\'t have recaptcha site key'));
300
339
  return
301
340
  }
@@ -304,11 +343,11 @@ const SignupFormUI = (props: SignupParams) => {
304
343
  return
305
344
  }
306
345
  recaptchaRef.current.open()
307
- }
346
+ }
308
347
 
309
348
  const onRecaptchaVerify = (token: any) => {
310
349
  setRecaptchaVerified(true)
311
- handleReCaptcha(token)
350
+ handleReCaptcha && handleReCaptcha(token)
312
351
  }
313
352
 
314
353
  useEffect(() => {
@@ -332,15 +371,19 @@ const SignupFormUI = (props: SignupParams) => {
332
371
  if (Object.keys(errors).length > 0) {
333
372
  setIsLoadingVerifyModal(false);
334
373
  }
335
- }, [errors]);
374
+ }, [errors])
336
375
 
337
376
  useEffect(() => {
338
- register('cellphone', {
339
- required: isRequiredField('cellphone')
340
- ? t('VALIDATION_ERROR_MOBILE_PHONE_REQUIRED', 'The field Mobile phone is required').replace('_attribute_', t('CELLPHONE', 'Cellphone'))
341
- : null
342
- })
343
- }, [register])
377
+ if (signUpTab === 'default' || signUpTab === 'otpCellphone') {
378
+ register('cellphone', {
379
+ required: isRequiredField('cellphone')
380
+ ? t('VALIDATION_ERROR_MOBILE_PHONE_REQUIRED', 'The field Mobile phone is required').replace('_attribute_', t('CELLPHONE', 'Cellphone'))
381
+ : null
382
+ })
383
+ } else {
384
+ unregister('cellphone')
385
+ }
386
+ }, [signUpTab])
344
387
 
345
388
  useEffect(() => {
346
389
  if (phoneInputData?.phone?.cellphone) setValue('cellphone', phoneInputData?.phone?.cellphone, '')
@@ -367,6 +410,26 @@ const SignupFormUI = (props: SignupParams) => {
367
410
  }
368
411
  }, [verifyPhoneState]);
369
412
 
413
+ useEffect(() => {
414
+ setPhoneInputData({
415
+ ...phoneInputData,
416
+ phone: {
417
+ ...phoneInputData.phone,
418
+ country_code: configs?.default_country_code?.value
419
+ }
420
+ })
421
+ }, [configs])
422
+
423
+ useEffect(() => {
424
+ if (checkPhoneCodeState?.result?.error) {
425
+ setAlertState({
426
+ open: true,
427
+ title: (typeof checkPhoneCodeState?.result?.result === 'string' ? checkPhoneCodeState?.result?.result : checkPhoneCodeState?.result?.result[0].toString()) || t('ERROR', 'Error'),
428
+ content: []
429
+ })
430
+ }
431
+ }, [checkPhoneCodeState])
432
+
370
433
  return (
371
434
  <View>
372
435
  <NavBar
@@ -380,47 +443,92 @@ const SignupFormUI = (props: SignupParams) => {
380
443
  titleStyle={{ marginLeft: 0, marginRight: 0 }}
381
444
  />
382
445
  <FormSide>
383
- {useSignupByEmail &&
384
- useSignupByCellphone &&
385
- configs &&
386
- Object.keys(configs).length > 0 &&
387
- (configs?.twilio_service_enabled?.value === 'true' ||
388
- configs?.twilio_service_enabled?.value === '1') && (
389
- <SignupWith style={{ paddingBottom: 25 }}>
390
- <OTabs>
391
- {useSignupByEmail && (
392
- <Pressable onPress={() => handleChangeTab('email')}>
393
- <OTab>
394
- <OText
395
- size={18}
396
- color={
397
- signupTab === 'email'
398
- ? theme.colors.primary
399
- : theme.colors.disabled
400
- }>
401
- {t('SIGNUP_BY_EMAIL', 'Signup by Email')}
402
- </OText>
403
- </OTab>
404
- </Pressable>
405
- )}
406
- {useSignupByCellphone && (
407
- <Pressable onPress={() => handleChangeTab('cellphone')}>
408
- <OTab>
409
- <OText
410
- size={18}
411
- color={
412
- signupTab === 'cellphone'
413
- ? theme.colors.primary
414
- : theme.colors.disabled
415
- }>
416
- {t('SIGNUP_BY_PHONE', 'Signup by Phone')}
417
- </OText>
418
- </OTab>
419
- </Pressable>
420
- )}
421
- </OTabs>
422
- </SignupWith>
423
- )}
446
+ {((Number(useSignUpFullDetails) + Number(useSignUpOtpEmail) + Number(useSignUpOtpCellphone)) > 1) && (
447
+ <SignupWith>
448
+ <OTabs
449
+ horizontal
450
+ showsHorizontalScrollIndicator={false}
451
+ ref={tabsRef}
452
+ >
453
+ {useSignUpFullDetails && (
454
+ <TabBtn
455
+ onPress={() => handleSignUpTab('default')}
456
+ onLayout={(event: any) => handleOnLayout(event, 'default')}
457
+ >
458
+ <OTab
459
+ style={{
460
+ borderBottomColor:
461
+ signUpTab === 'default'
462
+ ? theme.colors.textNormal
463
+ : theme.colors.border,
464
+ }}>
465
+ <OText
466
+ size={14}
467
+ color={
468
+ signUpTab === 'default'
469
+ ? theme.colors.textNormal
470
+ : theme.colors.disabled
471
+ }
472
+ weight={signUpTab === 'default' ? 'bold' : 'normal'}>
473
+ {t('DEFAULT', 'Default')}
474
+ </OText>
475
+ </OTab>
476
+ </TabBtn>
477
+ )}
478
+ {useSignUpOtpEmail && (
479
+ <TabBtn
480
+ onPress={() => handleSignUpTab('otpEmail')}
481
+ onLayout={(event: any) => handleOnLayout(event, 'otpEmail')}
482
+ >
483
+ <OTab
484
+ style={{
485
+ borderBottomColor:
486
+ signUpTab === 'otpEmail'
487
+ ? theme.colors.textNormal
488
+ : theme.colors.border,
489
+ }}>
490
+ <OText
491
+ size={14}
492
+ color={
493
+ signUpTab === 'otpEmail'
494
+ ? theme.colors.textNormal
495
+ : theme.colors.disabled
496
+ }
497
+ weight={signUpTab === 'otpEmail' ? 'bold' : 'normal'}>
498
+ {t('BY_OTP_EMAIL', 'by Otp Email')}
499
+ </OText>
500
+ </OTab>
501
+ </TabBtn>
502
+
503
+ )}
504
+ {useSignUpOtpCellphone && (
505
+ <TabBtn
506
+ onPress={() => handleSignUpTab('otpCellphone')}
507
+ onLayout={(event: any) => handleOnLayout(event, 'otpCellphone')}
508
+ >
509
+ <OTab
510
+ style={{
511
+ borderBottomColor:
512
+ signUpTab === 'otpCellphone'
513
+ ? theme.colors.textNormal
514
+ : theme.colors.border,
515
+ }}>
516
+ <OText
517
+ size={14}
518
+ color={
519
+ signUpTab === 'otpCellphone'
520
+ ? theme.colors.textNormal
521
+ : theme.colors.disabled
522
+ }
523
+ weight={signUpTab === 'otpCellphone' ? 'bold' : 'normal'}>
524
+ {t('BY_OTP_CELLPHONE', 'by Otp Cellphone')}
525
+ </OText>
526
+ </OTab>
527
+ </TabBtn>
528
+ )}
529
+ </OTabs>
530
+ </SignupWith>
531
+ )}
424
532
  <FormInput>
425
533
  {!(useChekoutFileds && validationFields?.loading) ? (
426
534
  <>
@@ -430,7 +538,9 @@ const SignupFormUI = (props: SignupParams) => {
430
538
  (field: any, i: number) =>
431
539
  !notValidationFields.includes(field.code) &&
432
540
  showField &&
433
- showField(field.code) && (
541
+ showField(field.code) &&
542
+ (signUpTab === 'default' ||
543
+ (signUpTab === 'otpEmail' && field.code === 'email')) && (
434
544
  <React.Fragment key={field.id}>
435
545
  {errors?.[`${field.code}`] && (
436
546
  <OText
@@ -454,7 +564,7 @@ const SignupFormUI = (props: SignupParams) => {
454
564
  value={value}
455
565
  onChange={(val: any) =>
456
566
  field.code !== 'email'
457
- ? onChange(val)
567
+ ? (onChange(val))
458
568
  : handleChangeInputEmail(val, onChange)
459
569
  }
460
570
  autoCapitalize={
@@ -486,12 +596,28 @@ const SignupFormUI = (props: SignupParams) => {
486
596
  ),
487
597
  )}
488
598
 
489
- {!!showInputPhoneNumber && (
599
+ {(!!showInputPhoneNumber && (signUpTab === 'default' || signUpTab === 'otpCellphone')) && (
490
600
  <View style={{ marginBottom: 25 }}>
491
601
  <PhoneInputNumber
492
602
  data={phoneInputData}
493
- handleData={(val: any) => setPhoneInputData(val)}
603
+ handleData={(val: any) => setPhoneInputData({
604
+ ...phoneInputData,
605
+ ...val,
606
+ phone: {
607
+ ...phoneInputData.phone,
608
+ ...val.phone,
609
+ country_code: phoneInputData.phone.country_code
610
+ }
611
+ })}
494
612
  forwardRef={phoneRef}
613
+ defaultCode={formState?.country_code ?? formState?.country_phone_code ?? null}
614
+ changeCountry={(val: any) => setPhoneInputData({
615
+ ...phoneInputData,
616
+ phone: {
617
+ ...phoneInputData.phone,
618
+ country_code: val.cca2
619
+ }
620
+ })}
495
621
  textInputProps={{
496
622
  returnKeyType: 'next',
497
623
  onSubmitEditing: () => passwordRef?.current?.focus?.(),
@@ -533,34 +659,34 @@ const SignupFormUI = (props: SignupParams) => {
533
659
  />
534
660
  </>
535
661
  )}
536
-
537
- <View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 20 }}>
538
- <Controller
539
- control={control}
540
- render={({ onChange, value }: any) => (
541
- <CheckBox
542
- value={value}
543
- onValueChange={newValue => {
544
- onChange(newValue)
545
- handleChangePromotions()
546
- }}
547
- boxType={'square'}
548
- tintColors={{
549
- true: theme.colors.primary,
550
- false: theme.colors.disabled
551
- }}
552
- tintColor={theme.colors.disabled}
553
- onCheckColor={theme.colors.primary}
554
- onTintColor={theme.colors.primary}
555
- style={Platform.OS === 'ios' && style.checkBoxStyle}
556
- />
557
- )}
558
- name='promotions'
559
- defaultValue={false}
560
- />
561
- <OText style={{ fontSize: 14, paddingHorizontal: 5 }}>{t('RECEIVE_NEWS_EXCLUSIVE_PROMOTIONS', 'Receive newsletters and exclusive promotions')}</OText>
562
- </View>
563
-
662
+ {(signUpTab === 'default') && (
663
+ <View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 20 }}>
664
+ <Controller
665
+ control={control}
666
+ render={({ onChange, value }: any) => (
667
+ <CheckBox
668
+ value={value}
669
+ onValueChange={newValue => {
670
+ onChange(newValue)
671
+ handleChangePromotions()
672
+ }}
673
+ boxType={'square'}
674
+ tintColors={{
675
+ true: theme.colors.primary,
676
+ false: theme.colors.disabled
677
+ }}
678
+ tintColor={theme.colors.disabled}
679
+ onCheckColor={theme.colors.primary}
680
+ onTintColor={theme.colors.primary}
681
+ style={Platform.OS === 'ios' && style.checkBoxStyle}
682
+ />
683
+ )}
684
+ name='promotions'
685
+ defaultValue={false}
686
+ />
687
+ <OText style={{ fontSize: 14, paddingHorizontal: 5 }}>{t('RECEIVE_NEWS_EXCLUSIVE_PROMOTIONS', 'Receive newsletters and exclusive promotions')}</OText>
688
+ </View>
689
+ )}
564
690
  {configs?.terms_and_conditions?.value === 'true' && (
565
691
  <>
566
692
  {errors?.termsAccept && (
@@ -612,7 +738,7 @@ const SignupFormUI = (props: SignupParams) => {
612
738
 
613
739
  )}
614
740
 
615
- {signupTab !== 'cellphone' && (
741
+ {signUpTab === 'default' && (
616
742
  <>
617
743
  {errors?.password && (
618
744
  <OText
@@ -684,9 +810,7 @@ const SignupFormUI = (props: SignupParams) => {
684
810
  <Spinner visible />
685
811
  )}
686
812
 
687
- {signupTab === 'cellphone' &&
688
- useSignupByEmail &&
689
- useSignupByCellphone ? (
813
+ {(signUpTab === 'otpEmail' || signUpTab === 'otpCellphone') ? (
690
814
  <OButton
691
815
  onClick={handleSubmit(onSubmit)}
692
816
  text={t('GET_VERIFY_CODE', 'Get Verify Code')}
@@ -751,7 +875,9 @@ const SignupFormUI = (props: SignupParams) => {
751
875
  <ButtonsWrapper>
752
876
  <SocialButtons>
753
877
  {(configs?.facebook_login?.value === 'true' || configs?.facebook_login?.value === '1') &&
754
- configs?.facebook_id?.value && (
878
+ configs?.facebook_id?.value &&
879
+ facebookLoginEnabled &&
880
+ (
755
881
  <FacebookLogin
756
882
  notificationState={notificationState}
757
883
  handleErrors={(err: any) => showToast(ToastType.Error, err)}
@@ -759,7 +885,7 @@ const SignupFormUI = (props: SignupParams) => {
759
885
  handleSuccessFacebookLogin={handleSuccessFacebook}
760
886
  />
761
887
  )}
762
- {(configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) && (
888
+ {(configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) && googleLoginEnabled && (
763
889
  <GoogleLogin
764
890
  notificationState={notificationState}
765
891
  webClientId={configs?.google_login_client_id?.value}
@@ -768,7 +894,7 @@ const SignupFormUI = (props: SignupParams) => {
768
894
  handleSuccessGoogleLogin={handleSuccessFacebook}
769
895
  />
770
896
  )}
771
- {(configs?.apple_login_client_id?.value !== '' && configs?.apple_login_client_id?.value !== null) && (
897
+ {(configs?.apple_login_client_id?.value !== '' && configs?.apple_login_client_id?.value !== null) && appleLoginEnabled && (
772
898
  <AppleLogin
773
899
  notificationState={notificationState}
774
900
  handleErrors={(err: any) => showToast(ToastType.Error, err)}
@@ -782,27 +908,40 @@ const SignupFormUI = (props: SignupParams) => {
782
908
  )}
783
909
 
784
910
  </FormSide>
785
- <OModal open={isModalVisible} onClose={() => setIsModalVisible(false)}>
786
- <VerifyPhone
787
- phone={phoneInputData.phone}
788
- formValues={formValues}
789
- verifyPhoneState={verifyPhoneState}
790
- checkPhoneCodeState={checkPhoneCodeState}
791
- handleCheckPhoneCode={handleCheckPhoneCode}
792
- setCheckPhoneCodeState={setCheckPhoneCodeState}
793
- handleVerifyCodeClick={onSubmit}
911
+ <OModal
912
+ open={willVerifyOtpState}
913
+ onClose={() => setWillVerifyOtpState && setWillVerifyOtpState(false)}
914
+ entireModal
915
+ title={t('ENTER_VERIFICATION_CODE', 'Enter verification code')}
916
+ >
917
+ <Otp
918
+ pinCount={numOtpInputs || 6}
919
+ willVerifyOtpState={willVerifyOtpState || false}
920
+ setWillVerifyOtpState={() => setWillVerifyOtpState && setWillVerifyOtpState(false)}
921
+ handleLoginOtp={handleSingUpOtp}
922
+ onSubmit={onSubmit}
923
+ setAlertState={setAlertState}
794
924
  />
795
925
  </OModal>
796
926
  <Spinner
797
927
  visible={formState.loading || validationFields.loading || isFBLoading}
798
928
  />
929
+ <Alert
930
+ open={alertState.open}
931
+ content={alertState.content}
932
+ title={alertState.title || ''}
933
+ onAccept={closeAlert}
934
+ onClose={closeAlert}
935
+ />
799
936
  </View>
800
937
  );
801
938
  };
802
939
 
803
940
  export const SignupForm = (props: any) => {
941
+ const _numOtpInputs = 6
804
942
  const signupProps = {
805
943
  ...props,
944
+ numOtpInputs: _numOtpInputs,
806
945
  isRecaptchaEnable: true,
807
946
  UIComponent: SignupFormUI,
808
947
  };