ordering-ui-react-native 0.15.67 → 0.15.68-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 (216) hide show
  1. package/package.json +7 -3
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/ActiveOrders/index.tsx +61 -63
  4. package/src/components/ActiveOrders/styles.tsx +1 -1
  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 +16 -8
  8. package/src/components/BusinessInformation/index.tsx +14 -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 +23 -2
  12. package/src/components/DriverTips/index.tsx +11 -6
  13. package/src/components/LanguageSelector/index.tsx +6 -2
  14. package/src/components/LoginForm/index.tsx +120 -30
  15. package/src/components/LoginForm/styles.tsx +6 -0
  16. package/src/components/OrderDetails/index.tsx +7 -21
  17. package/src/components/PaymentOptions/index.tsx +67 -50
  18. package/src/components/PaymentOptionsWebView/index.tsx +120 -121
  19. package/src/components/ReviewDriver/index.tsx +1 -1
  20. package/src/components/ReviewOrder/index.tsx +2 -1
  21. package/src/components/ReviewProducts/index.tsx +11 -0
  22. package/src/components/SignupForm/index.tsx +145 -61
  23. package/src/components/SingleProductCard/index.tsx +16 -4
  24. package/src/components/SingleProductReview/index.tsx +1 -1
  25. package/src/components/StripeMethodForm/index.tsx +22 -24
  26. package/src/components/UpsellingProducts/index.tsx +1 -1
  27. package/src/components/UserProfileForm/index.tsx +63 -6
  28. package/src/components/UserProfileForm/styles.tsx +8 -0
  29. package/src/components/VerifyPhone/styles.tsx +1 -2
  30. package/src/components/shared/OModal.tsx +1 -1
  31. package/src/hooks/useCountdownTimer.tsx +26 -0
  32. package/src/navigators/CheckoutNavigator.tsx +6 -0
  33. package/src/navigators/HomeNavigator.tsx +12 -0
  34. package/src/pages/BusinessesListing.tsx +7 -6
  35. package/src/pages/MultiCheckout.tsx +31 -0
  36. package/src/pages/MultiOrdersDetails.tsx +27 -0
  37. package/src/pages/OrderDetails.tsx +1 -1
  38. package/src/pages/ReviewDriver.tsx +2 -2
  39. package/src/pages/ReviewOrder.tsx +2 -2
  40. package/src/pages/Sessions.tsx +22 -0
  41. package/src/theme.json +0 -1
  42. package/src/types/index.tsx +18 -11
  43. package/src/utils/index.tsx +68 -2
  44. package/themes/business/index.tsx +4 -0
  45. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +103 -15
  46. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -0
  47. package/themes/business/src/components/Chat/index.tsx +42 -90
  48. package/themes/business/src/components/DriverMap/index.tsx +6 -5
  49. package/themes/business/src/components/DriverSchedule/index.tsx +71 -0
  50. package/themes/business/src/components/DriverSchedule/styles.tsx +6 -0
  51. package/themes/business/src/components/LoginForm/index.tsx +89 -2
  52. package/themes/business/src/components/LoginForm/styles.tsx +6 -0
  53. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  54. package/themes/business/src/components/NewOrderNotification/index.tsx +26 -13
  55. package/themes/business/src/components/OrderDetails/Business.tsx +2 -2
  56. package/themes/business/src/components/OrderDetails/Delivery.tsx +28 -11
  57. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +14 -7
  58. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +6 -0
  59. package/themes/business/src/components/OrdersListManager/index.tsx +1 -1
  60. package/themes/business/src/components/OrdersOption/index.tsx +8 -4
  61. package/themes/business/src/components/PreviousOrders/index.tsx +7 -7
  62. package/themes/business/src/components/ProductItemAccordion/index.tsx +2 -2
  63. package/themes/business/src/components/ScheduleBlocked/index.tsx +53 -0
  64. package/themes/business/src/components/UserFormDetails/index.tsx +5 -2
  65. package/themes/business/src/components/UserProfileForm/index.tsx +28 -4
  66. package/themes/business/src/components/shared/OModal.tsx +41 -38
  67. package/themes/business/src/types/index.tsx +8 -2
  68. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  69. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  70. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  71. package/themes/kiosk/src/components/BusinessMenu/index.tsx +39 -28
  72. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -3
  73. package/themes/kiosk/src/components/Cart/index.tsx +11 -12
  74. package/themes/kiosk/src/components/CartBottomSheet/index.tsx +9 -2
  75. package/themes/kiosk/src/components/CartContent/index.tsx +0 -11
  76. package/themes/kiosk/src/components/CartItem/index.tsx +4 -3
  77. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +107 -62
  78. package/themes/kiosk/src/components/Checkout/index.tsx +40 -22
  79. package/themes/kiosk/src/components/CustomerName/index.tsx +0 -6
  80. package/themes/kiosk/src/components/DrawerView/index.tsx +1 -0
  81. package/themes/kiosk/src/components/DrawerView/styles.tsx +2 -2
  82. package/themes/kiosk/src/components/NavBar/index.tsx +29 -20
  83. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  84. package/themes/kiosk/src/components/OrderDetails/index.tsx +32 -27
  85. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +9 -11
  86. package/themes/kiosk/src/components/PaymentOptions/index.tsx +56 -54
  87. package/themes/kiosk/src/components/ProductForm/index.tsx +7 -8
  88. package/themes/kiosk/src/components/ProductItemAccordion/index.tsx +2 -2
  89. package/themes/kiosk/src/components/ProductOption/index.tsx +1 -1
  90. package/themes/kiosk/src/components/ProductOptionSubOption/index.tsx +3 -1
  91. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +16 -5
  92. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  93. package/themes/kiosk/src/types/index.d.ts +1 -0
  94. package/themes/original/index.tsx +30 -8
  95. package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
  96. package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
  97. package/themes/original/src/components/AddressForm/index.tsx +7 -6
  98. package/themes/original/src/components/AddressList/index.tsx +30 -18
  99. package/themes/original/src/components/AppleLogin/index.tsx +6 -8
  100. package/themes/original/src/components/BusinessBasicInformation/index.tsx +304 -158
  101. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +6 -2
  102. package/themes/original/src/components/BusinessController/index.tsx +195 -96
  103. package/themes/original/src/components/BusinessController/styles.tsx +5 -0
  104. package/themes/original/src/components/BusinessItemAccordion/index.tsx +8 -5
  105. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -1
  106. package/themes/original/src/components/BusinessListingSearch/index.tsx +231 -63
  107. package/themes/original/src/components/BusinessListingSearch/styles.tsx +22 -2
  108. package/themes/original/src/components/BusinessPreorder/index.tsx +1 -1
  109. package/themes/original/src/components/BusinessProductsCategories/index.tsx +2 -2
  110. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  111. package/themes/original/src/components/BusinessProductsList/index.tsx +53 -52
  112. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  113. package/themes/original/src/components/BusinessProductsListing/index.tsx +318 -155
  114. package/themes/original/src/components/BusinessProductsListing/styles.tsx +32 -0
  115. package/themes/original/src/components/BusinessReviews/index.tsx +6 -1
  116. package/themes/original/src/components/BusinessTypeFilter/index.tsx +106 -39
  117. package/themes/original/src/components/BusinessTypeFilter/styles.tsx +2 -0
  118. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +560 -0
  119. package/themes/original/src/components/BusinessesListing/{styles.tsx → Layout/Appointment/styles.tsx} +24 -2
  120. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +679 -0
  121. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +137 -0
  122. package/themes/original/src/components/BusinessesListing/index.tsx +99 -458
  123. package/themes/original/src/components/Cart/index.tsx +61 -42
  124. package/themes/original/src/components/Checkout/index.tsx +90 -39
  125. package/themes/original/src/components/DriverTips/index.tsx +17 -12
  126. package/themes/original/src/components/Favorite/index.tsx +92 -0
  127. package/themes/original/src/components/Favorite/styles.tsx +22 -0
  128. package/themes/original/src/components/FavoriteList/index.tsx +298 -0
  129. package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
  130. package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
  131. package/themes/original/src/components/GPSButton/index.tsx +15 -8
  132. package/themes/original/src/components/GoogleMap/index.tsx +11 -11
  133. package/themes/original/src/components/Help/index.tsx +21 -4
  134. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +18 -1
  135. package/themes/original/src/components/LastOrders/index.tsx +12 -1
  136. package/themes/original/src/components/LoginForm/Otp/index.tsx +91 -0
  137. package/themes/original/src/components/LoginForm/Otp/styles.tsx +7 -0
  138. package/themes/original/src/components/LoginForm/index.tsx +332 -164
  139. package/themes/original/src/components/LoginForm/styles.tsx +1 -3
  140. package/themes/original/src/components/MessageListing/index.tsx +10 -1
  141. package/themes/original/src/components/Messages/index.tsx +1 -1
  142. package/themes/original/src/components/MomentSelector/index.tsx +197 -0
  143. package/themes/original/src/components/MomentSelector/styles.tsx +6 -0
  144. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +243 -0
  145. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/styles.tsx +46 -0
  146. package/themes/original/src/components/MultiCheckout/index.tsx +298 -0
  147. package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
  148. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +372 -0
  149. package/themes/original/src/components/MultiOrdersDetails/index.tsx +258 -0
  150. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
  151. package/themes/original/src/components/MyOrders/index.tsx +120 -32
  152. package/themes/original/src/components/MyOrders/styles.tsx +8 -1
  153. package/themes/original/src/components/NavBar/index.tsx +4 -4
  154. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +167 -0
  155. package/themes/original/src/components/OrderDetails/index.tsx +148 -63
  156. package/themes/original/src/components/OrderDetails/styles.tsx +1 -2
  157. package/themes/original/src/components/OrderSummary/index.tsx +6 -6
  158. package/themes/original/src/components/OrderTypeSelector/index.tsx +79 -35
  159. package/themes/original/src/components/OrderTypeSelector/styles.tsx +19 -1
  160. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +153 -0
  161. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
  162. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +53 -0
  163. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
  164. package/themes/original/src/components/OrdersOption/index.tsx +137 -38
  165. package/themes/original/src/components/OrdersOption/styles.tsx +4 -1
  166. package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
  167. package/themes/original/src/components/PaymentOptionWallet/index.tsx +17 -23
  168. package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
  169. package/themes/original/src/components/PaymentOptions/index.tsx +58 -37
  170. package/themes/original/src/components/PhoneInputNumber/index.tsx +5 -11
  171. package/themes/original/src/components/PreviousOrders/index.tsx +18 -147
  172. package/themes/original/src/components/ProductForm/index.tsx +718 -679
  173. package/themes/original/src/components/ProductForm/styles.tsx +6 -2
  174. package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
  175. package/themes/original/src/components/ProductOption/index.tsx +1 -1
  176. package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -12
  177. package/themes/original/src/components/ProfessionalFilter/index.tsx +128 -0
  178. package/themes/original/src/components/ProfessionalFilter/styles.tsx +0 -0
  179. package/themes/original/src/components/ProfessionalProfile/index.tsx +298 -0
  180. package/themes/original/src/components/ProfessionalProfile/styles.tsx +46 -0
  181. package/themes/original/src/components/Promotions/index.tsx +151 -133
  182. package/themes/original/src/components/Promotions/styles.tsx +3 -23
  183. package/themes/original/src/components/ReviewDriver/index.tsx +6 -6
  184. package/themes/original/src/components/ReviewOrder/index.tsx +1 -1
  185. package/themes/original/src/components/ReviewTrigger/index.tsx +118 -0
  186. package/themes/original/src/components/ReviewTrigger/styles.tsx +34 -0
  187. package/themes/original/src/components/SearchBar/index.tsx +13 -5
  188. package/themes/original/src/components/ServiceForm/index.tsx +579 -0
  189. package/themes/original/src/components/ServiceForm/styles.tsx +50 -0
  190. package/themes/original/src/components/Sessions/index.tsx +160 -0
  191. package/themes/original/src/components/Sessions/styles.tsx +15 -0
  192. package/themes/original/src/components/SignupForm/index.tsx +237 -126
  193. package/themes/original/src/components/SingleOrderCard/index.tsx +275 -0
  194. package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
  195. package/themes/original/src/components/SingleProductCard/index.tsx +215 -90
  196. package/themes/original/src/components/SingleProductCard/styles.tsx +2 -2
  197. package/themes/original/src/components/StripeElementsForm/index.tsx +16 -8
  198. package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
  199. package/themes/original/src/components/UpsellingProducts/index.tsx +86 -74
  200. package/themes/original/src/components/UserDetails/index.tsx +15 -81
  201. package/themes/original/src/components/UserFormDetails/index.tsx +98 -66
  202. package/themes/original/src/components/UserProfile/index.tsx +11 -2
  203. package/themes/original/src/components/UserProfileForm/index.tsx +33 -22
  204. package/themes/original/src/components/UserVerification/index.tsx +178 -192
  205. package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
  206. package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
  207. package/themes/original/src/components/Wallets/index.tsx +25 -12
  208. package/themes/original/src/components/shared/OBottomPopup.tsx +44 -13
  209. package/themes/original/src/components/shared/OButton.tsx +2 -0
  210. package/themes/original/src/components/shared/OInput.tsx +3 -2
  211. package/themes/original/src/components/shared/OModal.tsx +4 -2
  212. package/themes/original/src/layouts/FloatingBottomContainer.tsx +5 -1
  213. package/themes/original/src/types/index.tsx +187 -35
  214. package/themes/original/src/utils/index.tsx +94 -1
  215. package/themes/single-business/src/components/OrderTypeSelector/index.tsx +1 -1
  216. 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,15 +119,12 @@ 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: '',
@@ -122,9 +134,12 @@ const SignupFormUI = (props: SignupParams) => {
122
134
  country_code: null
123
135
  },
124
136
  });
137
+ const [alertState, setAlertState] = useState({ open: false, title: '', content: [] })
125
138
  const [recaptchaConfig, setRecaptchaConfig] = useState<any>({})
126
139
  const [recaptchaVerified, setRecaptchaVerified] = useState(false)
140
+ const [tabLayouts, setTabLayouts] = useState<any>({})
127
141
 
142
+ const tabsRef = useRef<any>(null)
128
143
  const nameRef = useRef<any>(null);
129
144
  const lastnameRef = useRef<any>(null);
130
145
  const middleNameRef = useRef<any>(null);
@@ -135,6 +150,17 @@ const SignupFormUI = (props: SignupParams) => {
135
150
  const recaptchaRef = useRef<any>({});
136
151
 
137
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
+ }
138
164
 
139
165
  const handleRefs = (ref: any, code: string) => {
140
166
  switch (code) {
@@ -160,6 +186,13 @@ const SignupFormUI = (props: SignupParams) => {
160
186
  }
161
187
  };
162
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
+
163
196
  const handleFocusRef = (code: string) => {
164
197
  switch (code) {
165
198
  case 'name': {
@@ -203,13 +236,13 @@ const SignupFormUI = (props: SignupParams) => {
203
236
  navigation.navigate('Home');
204
237
  };
205
238
 
206
- const handleChangeTab = (val: string) => {
207
- setSignupTab(val);
208
- setPasswordSee(false);
209
- };
239
+ const handleSignUpTab = (tab: string) => {
240
+ setSignUpTab && setSignUpTab(tab)
241
+ clearErrors()
242
+ }
210
243
 
211
- const onSubmit = (values: any) => {
212
- if (phoneInputData.error) {
244
+ const onSubmit = (values?: any) => {
245
+ if (phoneInputData.error && signUpTab !== 'otpEmail') {
213
246
  showToast(ToastType.Error, phoneInputData.error);
214
247
  return;
215
248
  }
@@ -218,7 +251,8 @@ const SignupFormUI = (props: SignupParams) => {
218
251
  !phoneInputData.phone.cellphone &&
219
252
  ((validationFields?.fields?.checkout?.cellphone?.enabled &&
220
253
  validationFields?.fields?.checkout?.cellphone?.required) ||
221
- configs?.verification_phone_required?.value === '1')
254
+ configs?.verification_phone_required?.value === '1') &&
255
+ signUpTab !== 'otpEmail'
222
256
  ) {
223
257
  showToast(
224
258
  ToastType.Error,
@@ -229,26 +263,29 @@ const SignupFormUI = (props: SignupParams) => {
229
263
  );
230
264
  return;
231
265
  }
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;
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);
247
282
  }
248
- setFormValues(values);
249
- handleVerifyCodeClick(values);
250
283
  };
251
284
 
285
+ const handleSingUpOtp = (value: string) => {
286
+ setOtpState && setOtpState(value)
287
+ }
288
+
252
289
  const handleVerifyCodeClick = (values: any) => {
253
290
  const formData = values || formValues;
254
291
  handleSendVerifyCode &&
@@ -310,7 +347,7 @@ const SignupFormUI = (props: SignupParams) => {
310
347
 
311
348
  const onRecaptchaVerify = (token: any) => {
312
349
  setRecaptchaVerified(true)
313
- handleReCaptcha(token)
350
+ handleReCaptcha && handleReCaptcha(token)
314
351
  }
315
352
 
316
353
  useEffect(() => {
@@ -334,15 +371,19 @@ const SignupFormUI = (props: SignupParams) => {
334
371
  if (Object.keys(errors).length > 0) {
335
372
  setIsLoadingVerifyModal(false);
336
373
  }
337
- }, [errors]);
374
+ }, [errors])
338
375
 
339
376
  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])
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])
346
387
 
347
388
  useEffect(() => {
348
389
  if (phoneInputData?.phone?.cellphone) setValue('cellphone', phoneInputData?.phone?.cellphone, '')
@@ -379,6 +420,16 @@ const SignupFormUI = (props: SignupParams) => {
379
420
  })
380
421
  }, [configs])
381
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
+
382
433
  return (
383
434
  <View>
384
435
  <NavBar
@@ -392,47 +443,92 @@ const SignupFormUI = (props: SignupParams) => {
392
443
  titleStyle={{ marginLeft: 0, marginRight: 0 }}
393
444
  />
394
445
  <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
- )}
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
+ )}
436
532
  <FormInput>
437
533
  {!(useChekoutFileds && validationFields?.loading) ? (
438
534
  <>
@@ -442,7 +538,9 @@ const SignupFormUI = (props: SignupParams) => {
442
538
  (field: any, i: number) =>
443
539
  !notValidationFields.includes(field.code) &&
444
540
  showField &&
445
- showField(field.code) && (
541
+ showField(field.code) &&
542
+ (signUpTab === 'default' ||
543
+ (signUpTab === 'otpEmail' && field.code === 'email')) && (
446
544
  <React.Fragment key={field.id}>
447
545
  {errors?.[`${field.code}`] && (
448
546
  <OText
@@ -466,7 +564,7 @@ const SignupFormUI = (props: SignupParams) => {
466
564
  value={value}
467
565
  onChange={(val: any) =>
468
566
  field.code !== 'email'
469
- ? onChange(val)
567
+ ? (onChange(val))
470
568
  : handleChangeInputEmail(val, onChange)
471
569
  }
472
570
  autoCapitalize={
@@ -498,7 +596,7 @@ const SignupFormUI = (props: SignupParams) => {
498
596
  ),
499
597
  )}
500
598
 
501
- {!!showInputPhoneNumber && (
599
+ {(!!showInputPhoneNumber && (signUpTab === 'default' || signUpTab === 'otpCellphone')) && (
502
600
  <View style={{ marginBottom: 25 }}>
503
601
  <PhoneInputNumber
504
602
  data={phoneInputData}
@@ -561,34 +659,34 @@ const SignupFormUI = (props: SignupParams) => {
561
659
  />
562
660
  </>
563
661
  )}
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}
584
- />
585
- )}
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
-
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
+ )}
592
690
  {configs?.terms_and_conditions?.value === 'true' && (
593
691
  <>
594
692
  {errors?.termsAccept && (
@@ -640,7 +738,7 @@ const SignupFormUI = (props: SignupParams) => {
640
738
 
641
739
  )}
642
740
 
643
- {signupTab !== 'cellphone' && (
741
+ {signUpTab === 'default' && (
644
742
  <>
645
743
  {errors?.password && (
646
744
  <OText
@@ -712,9 +810,7 @@ const SignupFormUI = (props: SignupParams) => {
712
810
  <Spinner visible />
713
811
  )}
714
812
 
715
- {signupTab === 'cellphone' &&
716
- useSignupByEmail &&
717
- useSignupByCellphone ? (
813
+ {(signUpTab === 'otpEmail' || signUpTab === 'otpCellphone') ? (
718
814
  <OButton
719
815
  onClick={handleSubmit(onSubmit)}
720
816
  text={t('GET_VERIFY_CODE', 'Get Verify Code')}
@@ -779,7 +875,9 @@ const SignupFormUI = (props: SignupParams) => {
779
875
  <ButtonsWrapper>
780
876
  <SocialButtons>
781
877
  {(configs?.facebook_login?.value === 'true' || configs?.facebook_login?.value === '1') &&
782
- configs?.facebook_id?.value && (
878
+ configs?.facebook_id?.value &&
879
+ facebookLoginEnabled &&
880
+ (
783
881
  <FacebookLogin
784
882
  notificationState={notificationState}
785
883
  handleErrors={(err: any) => showToast(ToastType.Error, err)}
@@ -787,7 +885,7 @@ const SignupFormUI = (props: SignupParams) => {
787
885
  handleSuccessFacebookLogin={handleSuccessFacebook}
788
886
  />
789
887
  )}
790
- {(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 && (
791
889
  <GoogleLogin
792
890
  notificationState={notificationState}
793
891
  webClientId={configs?.google_login_client_id?.value}
@@ -796,7 +894,7 @@ const SignupFormUI = (props: SignupParams) => {
796
894
  handleSuccessGoogleLogin={handleSuccessFacebook}
797
895
  />
798
896
  )}
799
- {(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 && (
800
898
  <AppleLogin
801
899
  notificationState={notificationState}
802
900
  handleErrors={(err: any) => showToast(ToastType.Error, err)}
@@ -810,27 +908,40 @@ const SignupFormUI = (props: SignupParams) => {
810
908
  )}
811
909
 
812
910
  </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}
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}
822
924
  />
823
925
  </OModal>
824
926
  <Spinner
825
927
  visible={formState.loading || validationFields.loading || isFBLoading}
826
928
  />
929
+ <Alert
930
+ open={alertState.open}
931
+ content={alertState.content}
932
+ title={alertState.title || ''}
933
+ onAccept={closeAlert}
934
+ onClose={closeAlert}
935
+ />
827
936
  </View>
828
937
  );
829
938
  };
830
939
 
831
940
  export const SignupForm = (props: any) => {
941
+ const _numOtpInputs = 6
832
942
  const signupProps = {
833
943
  ...props,
944
+ numOtpInputs: _numOtpInputs,
834
945
  isRecaptchaEnable: true,
835
946
  UIComponent: SignupFormUI,
836
947
  };