ordering-ui-react-native 0.15.92 → 0.15.93-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 (233) 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 +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 +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 +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/SingleProductCard/index.tsx +16 -4
  27. package/src/components/SingleProductReview/index.tsx +1 -1
  28. package/src/components/StripeElementsForm/index.tsx +25 -16
  29. package/src/components/StripeMethodForm/index.tsx +22 -24
  30. package/src/components/UpsellingProducts/index.tsx +1 -1
  31. package/src/components/UserProfileForm/index.tsx +63 -6
  32. package/src/components/UserProfileForm/styles.tsx +8 -0
  33. package/src/components/VerifyPhone/styles.tsx +1 -2
  34. package/src/components/shared/OBottomPopup.tsx +6 -2
  35. package/src/components/shared/OModal.tsx +1 -1
  36. package/src/index.tsx +2 -0
  37. package/src/navigators/CheckoutNavigator.tsx +6 -0
  38. package/src/navigators/HomeNavigator.tsx +6 -0
  39. package/src/pages/BusinessesListing.tsx +7 -6
  40. package/src/pages/MultiCheckout.tsx +31 -0
  41. package/src/pages/MultiOrdersDetails.tsx +27 -0
  42. package/src/pages/OrderDetails.tsx +1 -1
  43. package/src/pages/ReviewDriver.tsx +2 -2
  44. package/src/pages/ReviewOrder.tsx +2 -2
  45. package/src/theme.json +0 -1
  46. package/src/types/index.tsx +18 -11
  47. package/src/utils/index.tsx +1 -2
  48. package/themes/business/index.tsx +4 -0
  49. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +1 -1
  50. package/themes/business/src/components/Chat/index.tsx +14 -6
  51. package/themes/business/src/components/DriverMap/index.tsx +6 -5
  52. package/themes/business/src/components/DriverSchedule/index.tsx +71 -0
  53. package/themes/business/src/components/DriverSchedule/styles.tsx +6 -0
  54. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  55. package/themes/business/src/components/MapView/index.tsx +1 -1
  56. package/themes/business/src/components/MessagesOption/index.tsx +11 -1
  57. package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
  58. package/themes/business/src/components/OrderDetails/Delivery.tsx +6 -4
  59. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +25 -18
  60. package/themes/business/src/components/OrdersListManager/index.tsx +10 -3
  61. package/themes/business/src/components/OrdersOption/index.tsx +65 -21
  62. package/themes/business/src/components/OrdersOption/styles.tsx +5 -1
  63. package/themes/business/src/components/OrdersOptionBusiness/index.tsx +15 -1
  64. package/themes/business/src/components/OrdersOptionCity/index.tsx +15 -1
  65. package/themes/business/src/components/OrdersOptionDate/index.tsx +19 -6
  66. package/themes/business/src/components/OrdersOptionDelivery/index.tsx +15 -1
  67. package/themes/business/src/components/OrdersOptionDriver/index.tsx +15 -1
  68. package/themes/business/src/components/OrdersOptionPaymethod/index.tsx +15 -1
  69. package/themes/business/src/components/OrdersOptionStatus/index.tsx +10 -1
  70. package/themes/business/src/components/PreviousMessages/index.tsx +1 -0
  71. package/themes/business/src/components/PreviousOrders/index.tsx +7 -7
  72. package/themes/business/src/components/ProductItemAccordion/index.tsx +5 -4
  73. package/themes/business/src/components/ReviewCustomer/index.tsx +1 -1
  74. package/themes/business/src/components/ScheduleBlocked/index.tsx +53 -0
  75. package/themes/business/src/components/UserFormDetails/index.tsx +5 -2
  76. package/themes/business/src/components/UserProfileForm/index.tsx +28 -4
  77. package/themes/business/src/components/shared/ODropDown.tsx +42 -8
  78. package/themes/business/src/components/shared/ODropDownCalendar.tsx +36 -7
  79. package/themes/business/src/components/shared/OModal.tsx +41 -38
  80. package/themes/business/src/types/index.tsx +14 -9
  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 +25 -26
  85. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -3
  86. package/themes/kiosk/src/components/Cart/index.tsx +10 -11
  87. package/themes/kiosk/src/components/CartBottomSheet/index.tsx +9 -2
  88. package/themes/kiosk/src/components/CartContent/index.tsx +0 -11
  89. package/themes/kiosk/src/components/CartItem/index.tsx +4 -3
  90. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +107 -62
  91. package/themes/kiosk/src/components/Checkout/index.tsx +40 -22
  92. package/themes/kiosk/src/components/CustomerName/index.tsx +0 -6
  93. package/themes/kiosk/src/components/DrawerView/index.tsx +1 -0
  94. package/themes/kiosk/src/components/DrawerView/styles.tsx +2 -2
  95. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  96. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  97. package/themes/kiosk/src/components/OrderDetails/index.tsx +2 -2
  98. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +9 -11
  99. package/themes/kiosk/src/components/PaymentOptions/index.tsx +55 -53
  100. package/themes/kiosk/src/components/ProductForm/index.tsx +6 -7
  101. package/themes/kiosk/src/components/ProductOptionSubOption/index.tsx +3 -1
  102. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +16 -5
  103. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  104. package/themes/kiosk/src/types/index.d.ts +1 -0
  105. package/themes/original/index.tsx +22 -0
  106. package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
  107. package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
  108. package/themes/original/src/components/AddressForm/index.tsx +137 -134
  109. package/themes/original/src/components/AddressList/index.tsx +2 -2
  110. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  111. package/themes/original/src/components/BusinessBasicInformation/index.tsx +302 -160
  112. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +6 -2
  113. package/themes/original/src/components/BusinessController/index.tsx +179 -96
  114. package/themes/original/src/components/BusinessController/styles.tsx +5 -0
  115. package/themes/original/src/components/BusinessItemAccordion/index.tsx +11 -8
  116. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -1
  117. package/themes/original/src/components/BusinessListingSearch/BusinessControllerSkeletons/index.tsx +57 -0
  118. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +59 -0
  119. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/styles.tsx +13 -0
  120. package/themes/original/src/components/BusinessListingSearch/index.tsx +106 -126
  121. package/themes/original/src/components/BusinessListingSearch/styles.tsx +18 -13
  122. package/themes/original/src/components/BusinessPreorder/index.tsx +1 -1
  123. package/themes/original/src/components/BusinessProductsCategories/index.tsx +2 -2
  124. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  125. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +87 -0
  126. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/styles.tsx +12 -0
  127. package/themes/original/src/components/BusinessProductsList/index.tsx +66 -73
  128. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  129. package/themes/original/src/components/BusinessProductsListing/index.tsx +296 -178
  130. package/themes/original/src/components/BusinessProductsListing/styles.tsx +18 -0
  131. package/themes/original/src/components/BusinessReviews/index.tsx +6 -1
  132. package/themes/original/src/components/BusinessTypeFilter/index.tsx +106 -38
  133. package/themes/original/src/components/BusinessTypeFilter/styles.tsx +2 -0
  134. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +561 -0
  135. package/themes/original/src/components/BusinessesListing/{styles.tsx → Layout/Appointment/styles.tsx} +24 -2
  136. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +673 -0
  137. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +137 -0
  138. package/themes/original/src/components/BusinessesListing/index.tsx +102 -464
  139. package/themes/original/src/components/Cart/index.tsx +82 -37
  140. package/themes/original/src/components/Cart/styles.tsx +4 -0
  141. package/themes/original/src/components/CartContent/index.tsx +22 -16
  142. package/themes/original/src/components/Checkout/index.tsx +107 -67
  143. package/themes/original/src/components/Checkout/styles.tsx +0 -1
  144. package/themes/original/src/components/DriverTips/index.tsx +17 -12
  145. package/themes/original/src/components/Favorite/index.tsx +92 -0
  146. package/themes/original/src/components/Favorite/styles.tsx +22 -0
  147. package/themes/original/src/components/FavoriteList/index.tsx +298 -0
  148. package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
  149. package/themes/original/src/components/GPSButton/index.tsx +25 -17
  150. package/themes/original/src/components/GoogleMap/index.tsx +21 -12
  151. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +8 -3
  152. package/themes/original/src/components/HelpGuide/index.tsx +8 -3
  153. package/themes/original/src/components/HelpOrder/index.tsx +8 -3
  154. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +18 -1
  155. package/themes/original/src/components/LoginForm/Otp/index.tsx +3 -2
  156. package/themes/original/src/components/LoginForm/index.tsx +16 -10
  157. package/themes/original/src/components/Messages/index.tsx +17 -17
  158. package/themes/original/src/components/MomentSelector/index.tsx +197 -0
  159. package/themes/original/src/components/MomentSelector/styles.tsx +6 -0
  160. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +243 -0
  161. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/styles.tsx +46 -0
  162. package/themes/original/src/components/MultiCheckout/index.tsx +304 -0
  163. package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
  164. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +372 -0
  165. package/themes/original/src/components/MultiOrdersDetails/index.tsx +262 -0
  166. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
  167. package/themes/original/src/components/MyOrders/index.tsx +132 -27
  168. package/themes/original/src/components/MyOrders/styles.tsx +8 -1
  169. package/themes/original/src/components/NavBar/index.tsx +11 -5
  170. package/themes/original/src/components/NotFoundSource/index.tsx +2 -1
  171. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +167 -0
  172. package/themes/original/src/components/OrderDetails/index.tsx +138 -58
  173. package/themes/original/src/components/OrderDetails/styles.tsx +5 -2
  174. package/themes/original/src/components/OrderItAgain/index.tsx +73 -0
  175. package/themes/original/src/components/OrderItAgain/styles.tsx +10 -0
  176. package/themes/original/src/components/OrderProgress/index.tsx +8 -2
  177. package/themes/original/src/components/OrderSummary/index.tsx +2 -35
  178. package/themes/original/src/components/OrderTypeSelector/index.tsx +84 -36
  179. package/themes/original/src/components/OrderTypeSelector/styles.tsx +19 -1
  180. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +140 -0
  181. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
  182. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +53 -0
  183. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
  184. package/themes/original/src/components/OrdersOption/index.tsx +138 -46
  185. package/themes/original/src/components/OrdersOption/styles.tsx +4 -1
  186. package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
  187. package/themes/original/src/components/PaymentOptionWallet/index.tsx +15 -23
  188. package/themes/original/src/components/PaymentOptions/index.tsx +57 -37
  189. package/themes/original/src/components/PhoneInputNumber/index.tsx +4 -10
  190. package/themes/original/src/components/PlaceSpot/index.tsx +243 -47
  191. package/themes/original/src/components/PlaceSpot/styles.tsx +0 -2
  192. package/themes/original/src/components/PreviousOrders/index.tsx +18 -147
  193. package/themes/original/src/components/ProductForm/index.tsx +694 -647
  194. package/themes/original/src/components/ProductForm/styles.tsx +9 -7
  195. package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
  196. package/themes/original/src/components/ProductOption/index.tsx +1 -1
  197. package/themes/original/src/components/ProfessionalFilter/index.tsx +128 -0
  198. package/themes/original/src/components/ProfessionalFilter/styles.tsx +0 -0
  199. package/themes/original/src/components/ProfessionalProfile/index.tsx +298 -0
  200. package/themes/original/src/components/ProfessionalProfile/styles.tsx +46 -0
  201. package/themes/original/src/components/Promotions/index.tsx +4 -4
  202. package/themes/original/src/components/ReviewDriver/index.tsx +6 -6
  203. package/themes/original/src/components/ReviewOrder/index.tsx +1 -1
  204. package/themes/original/src/components/ReviewTrigger/index.tsx +118 -0
  205. package/themes/original/src/components/ReviewTrigger/styles.tsx +34 -0
  206. package/themes/original/src/components/SearchBar/index.tsx +13 -5
  207. package/themes/original/src/components/ServiceForm/index.tsx +579 -0
  208. package/themes/original/src/components/ServiceForm/styles.tsx +50 -0
  209. package/themes/original/src/components/SignupForm/index.tsx +237 -127
  210. package/themes/original/src/components/SingleOrderCard/index.tsx +316 -0
  211. package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
  212. package/themes/original/src/components/SingleProductCard/index.tsx +204 -95
  213. package/themes/original/src/components/SingleProductCard/styles.tsx +2 -2
  214. package/themes/original/src/components/StripeElementsForm/index.tsx +25 -9
  215. package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
  216. package/themes/original/src/components/UpsellingProducts/index.tsx +7 -3
  217. package/themes/original/src/components/UserDetails/index.tsx +32 -18
  218. package/themes/original/src/components/UserFormDetails/index.tsx +108 -74
  219. package/themes/original/src/components/UserProfile/index.tsx +4 -0
  220. package/themes/original/src/components/UserProfileForm/index.tsx +15 -10
  221. package/themes/original/src/components/UserVerification/index.tsx +178 -192
  222. package/themes/original/src/components/WalletTransactions/index.tsx +76 -0
  223. package/themes/original/src/components/WalletTransactions/styles.tsx +13 -0
  224. package/themes/original/src/components/Wallets/index.tsx +176 -162
  225. package/themes/original/src/components/Wallets/styles.tsx +10 -8
  226. package/themes/original/src/components/shared/OBottomPopup.tsx +47 -14
  227. package/themes/original/src/components/shared/OButton.tsx +10 -3
  228. package/themes/original/src/components/shared/OInput.tsx +3 -2
  229. package/themes/original/src/components/shared/OModal.tsx +4 -2
  230. package/themes/original/src/layouts/FloatingBottomContainer.tsx +5 -1
  231. package/themes/original/src/types/index.tsx +197 -47
  232. package/themes/original/src/utils/index.tsx +77 -0
  233. 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}
@@ -512,7 +610,6 @@ const SignupFormUI = (props: SignupParams) => {
512
610
  }
513
611
  })}
514
612
  forwardRef={phoneRef}
515
- defaultCode={formState?.country_code ?? formState?.country_phone_code ?? null}
516
613
  changeCountry={(val: any) => setPhoneInputData({
517
614
  ...phoneInputData,
518
615
  phone: {
@@ -561,34 +658,34 @@ const SignupFormUI = (props: SignupParams) => {
561
658
  />
562
659
  </>
563
660
  )}
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
-
661
+ {(signUpTab === 'default') && (
662
+ <View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 20 }}>
663
+ <Controller
664
+ control={control}
665
+ render={({ onChange, value }: any) => (
666
+ <CheckBox
667
+ value={value}
668
+ onValueChange={newValue => {
669
+ onChange(newValue)
670
+ handleChangePromotions()
671
+ }}
672
+ boxType={'square'}
673
+ tintColors={{
674
+ true: theme.colors.primary,
675
+ false: theme.colors.disabled
676
+ }}
677
+ tintColor={theme.colors.disabled}
678
+ onCheckColor={theme.colors.primary}
679
+ onTintColor={theme.colors.primary}
680
+ style={Platform.OS === 'ios' && style.checkBoxStyle}
681
+ />
682
+ )}
683
+ name='promotions'
684
+ defaultValue={false}
685
+ />
686
+ <OText style={{ fontSize: 14, paddingHorizontal: 5 }}>{t('RECEIVE_NEWS_EXCLUSIVE_PROMOTIONS', 'Receive newsletters and exclusive promotions')}</OText>
687
+ </View>
688
+ )}
592
689
  {configs?.terms_and_conditions?.value === 'true' && (
593
690
  <>
594
691
  {errors?.termsAccept && (
@@ -640,7 +737,7 @@ const SignupFormUI = (props: SignupParams) => {
640
737
 
641
738
  )}
642
739
 
643
- {signupTab !== 'cellphone' && (
740
+ {signUpTab === 'default' && (
644
741
  <>
645
742
  {errors?.password && (
646
743
  <OText
@@ -712,9 +809,7 @@ const SignupFormUI = (props: SignupParams) => {
712
809
  <Spinner visible />
713
810
  )}
714
811
 
715
- {signupTab === 'cellphone' &&
716
- useSignupByEmail &&
717
- useSignupByCellphone ? (
812
+ {(signUpTab === 'otpEmail' || signUpTab === 'otpCellphone') ? (
718
813
  <OButton
719
814
  onClick={handleSubmit(onSubmit)}
720
815
  text={t('GET_VERIFY_CODE', 'Get Verify Code')}
@@ -779,7 +874,9 @@ const SignupFormUI = (props: SignupParams) => {
779
874
  <ButtonsWrapper>
780
875
  <SocialButtons>
781
876
  {(configs?.facebook_login?.value === 'true' || configs?.facebook_login?.value === '1') &&
782
- configs?.facebook_id?.value && (
877
+ configs?.facebook_id?.value &&
878
+ facebookLoginEnabled &&
879
+ (
783
880
  <FacebookLogin
784
881
  notificationState={notificationState}
785
882
  handleErrors={(err: any) => showToast(ToastType.Error, err)}
@@ -787,7 +884,7 @@ const SignupFormUI = (props: SignupParams) => {
787
884
  handleSuccessFacebookLogin={handleSuccessFacebook}
788
885
  />
789
886
  )}
790
- {(configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) && (
887
+ {(configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) && googleLoginEnabled && (
791
888
  <GoogleLogin
792
889
  notificationState={notificationState}
793
890
  webClientId={configs?.google_login_client_id?.value}
@@ -796,7 +893,7 @@ const SignupFormUI = (props: SignupParams) => {
796
893
  handleSuccessGoogleLogin={handleSuccessFacebook}
797
894
  />
798
895
  )}
799
- {(configs?.apple_login_client_id?.value !== '' && configs?.apple_login_client_id?.value !== null) && (
896
+ {(configs?.apple_login_client_id?.value !== '' && configs?.apple_login_client_id?.value !== null) && appleLoginEnabled && (
800
897
  <AppleLogin
801
898
  notificationState={notificationState}
802
899
  handleErrors={(err: any) => showToast(ToastType.Error, err)}
@@ -810,27 +907,40 @@ const SignupFormUI = (props: SignupParams) => {
810
907
  )}
811
908
 
812
909
  </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}
910
+ <OModal
911
+ open={willVerifyOtpState}
912
+ onClose={() => setWillVerifyOtpState && setWillVerifyOtpState(false)}
913
+ entireModal
914
+ title={t('ENTER_VERIFICATION_CODE', 'Enter verification code')}
915
+ >
916
+ <Otp
917
+ pinCount={numOtpInputs || 6}
918
+ willVerifyOtpState={willVerifyOtpState || false}
919
+ setWillVerifyOtpState={() => setWillVerifyOtpState && setWillVerifyOtpState(false)}
920
+ handleLoginOtp={handleSingUpOtp}
921
+ onSubmit={onSubmit}
922
+ setAlertState={setAlertState}
822
923
  />
823
924
  </OModal>
824
925
  <Spinner
825
926
  visible={formState.loading || validationFields.loading || isFBLoading}
826
927
  />
928
+ <Alert
929
+ open={alertState.open}
930
+ content={alertState.content}
931
+ title={alertState.title || ''}
932
+ onAccept={closeAlert}
933
+ onClose={closeAlert}
934
+ />
827
935
  </View>
828
936
  );
829
937
  };
830
938
 
831
939
  export const SignupForm = (props: any) => {
940
+ const _numOtpInputs = 6
832
941
  const signupProps = {
833
942
  ...props,
943
+ numOtpInputs: _numOtpInputs,
834
944
  isRecaptchaEnable: true,
835
945
  UIComponent: SignupFormUI,
836
946
  };