ordering-ui-react-native 0.17.50 → 0.17.51-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 (220) hide show
  1. package/package.json +8 -7
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessesListing/index.tsx +1 -1
  4. package/src/components/OrderCreating/index.tsx +1 -21
  5. package/src/components/PaymentOptionsWebView/index.tsx +29 -8
  6. package/src/components/PhoneInputNumber/index.tsx +6 -2
  7. package/src/components/StripeMethodForm/index.tsx +136 -102
  8. package/src/components/VerifyPhone/styles.tsx +1 -2
  9. package/src/components/shared/OToast.tsx +4 -4
  10. package/src/types/index.tsx +5 -0
  11. package/src/utils/index.tsx +7 -1
  12. package/themes/business/index.tsx +2 -0
  13. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +265 -240
  14. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -4
  15. package/themes/business/src/components/BusinessController/index.tsx +0 -1
  16. package/themes/business/src/components/Chat/index.tsx +125 -113
  17. package/themes/business/src/components/DriverMap/index.tsx +17 -6
  18. package/themes/business/src/components/DriverSchedule/index.tsx +29 -2
  19. package/themes/business/src/components/GoogleMap/index.tsx +58 -57
  20. package/themes/business/src/components/LoginForm/Otp/index.tsx +120 -0
  21. package/themes/business/src/components/LoginForm/Otp/styles.tsx +7 -0
  22. package/themes/business/src/components/LoginForm/index.tsx +238 -80
  23. package/themes/business/src/components/LoginForm/styles.tsx +10 -0
  24. package/themes/business/src/components/MapView/index.tsx +10 -10
  25. package/themes/business/src/components/NewOrderNotification/index.tsx +35 -21
  26. package/themes/business/src/components/OrderDetails/Delivery.tsx +31 -5
  27. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +93 -50
  28. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +59 -62
  29. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +195 -0
  30. package/themes/business/src/components/OrderDetailsLogistic/styles.tsx +5 -0
  31. package/themes/business/src/components/OrderMessage/index.tsx +18 -17
  32. package/themes/business/src/components/OrderSummary/index.tsx +113 -121
  33. package/themes/business/src/components/OrdersOption/index.tsx +32 -75
  34. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +249 -0
  35. package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +115 -0
  36. package/themes/business/src/components/PreviousOrders/index.tsx +445 -243
  37. package/themes/business/src/components/PreviousOrders/styles.tsx +31 -3
  38. package/themes/business/src/components/ProductItemAccordion/index.tsx +27 -3
  39. package/themes/business/src/components/ReviewCustomer/index.tsx +29 -14
  40. package/themes/business/src/components/StoresList/index.tsx +2 -2
  41. package/themes/business/src/components/UserProfileForm/index.tsx +11 -13
  42. package/themes/business/src/components/shared/OLink.tsx +33 -13
  43. package/themes/business/src/components/shared/OModal.tsx +16 -9
  44. package/themes/business/src/components/shared/OText.tsx +8 -2
  45. package/themes/business/src/types/index.tsx +32 -2
  46. package/themes/business/src/utils/index.tsx +44 -1
  47. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  48. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  49. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  50. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -1
  51. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  52. package/themes/kiosk/src/components/LoginForm/Otp/index.tsx +92 -0
  53. package/themes/kiosk/src/components/LoginForm/Otp/styles.tsx +7 -0
  54. package/themes/kiosk/src/components/LoginForm/index.tsx +480 -156
  55. package/themes/kiosk/src/components/LoginForm/styles.tsx +14 -1
  56. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  57. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  58. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  59. package/themes/kiosk/src/components/PhoneInputNumber/index.tsx +3 -2
  60. package/themes/kiosk/src/components/PhoneInputNumber/styles.tsx +1 -3
  61. package/themes/kiosk/src/components/ProductForm/index.tsx +1 -14
  62. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  63. package/themes/kiosk/src/components/shared/OModal.tsx +14 -11
  64. package/themes/kiosk/src/layouts/Container.tsx +7 -1
  65. package/themes/kiosk/src/types/index.d.ts +13 -0
  66. package/themes/kiosk/src/utils/index.tsx +15 -0
  67. package/themes/original/index.tsx +4 -0
  68. package/themes/original/src/components/AddressDetails/index.tsx +29 -11
  69. package/themes/original/src/components/AddressForm/index.tsx +79 -44
  70. package/themes/original/src/components/AddressList/index.tsx +27 -22
  71. package/themes/original/src/components/AddressList/styles.tsx +4 -2
  72. package/themes/original/src/components/AnalyticsSegment/index.tsx +193 -10
  73. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  74. package/themes/original/src/components/AppleLogin/styles.tsx +3 -1
  75. package/themes/original/src/components/BusinessBasicInformation/index.tsx +160 -91
  76. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +9 -7
  77. package/themes/original/src/components/BusinessController/index.tsx +122 -68
  78. package/themes/original/src/components/BusinessController/styles.tsx +23 -4
  79. package/themes/original/src/components/BusinessFeaturedController/index.tsx +21 -54
  80. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +8 -0
  81. package/themes/original/src/components/BusinessInformation/index.tsx +110 -108
  82. package/themes/original/src/components/BusinessItemAccordion/index.tsx +23 -22
  83. package/themes/original/src/components/BusinessListingSearch/index.tsx +352 -326
  84. package/themes/original/src/components/BusinessPreorder/index.tsx +103 -19
  85. package/themes/original/src/components/BusinessProductsCategories/index.tsx +1 -2
  86. package/themes/original/src/components/BusinessProductsList/index.tsx +23 -14
  87. package/themes/original/src/components/BusinessProductsList/styles.tsx +8 -3
  88. package/themes/original/src/components/BusinessProductsListing/UpsellingRedirect.tsx +1 -1
  89. package/themes/original/src/components/BusinessProductsListing/index.tsx +668 -514
  90. package/themes/original/src/components/BusinessProductsListing/styles.tsx +2 -2
  91. package/themes/original/src/components/BusinessReviews/index.tsx +3 -1
  92. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +1 -1
  93. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +95 -80
  94. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -11
  95. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  96. package/themes/original/src/components/Cart/index.tsx +100 -67
  97. package/themes/original/src/components/CartContent/index.tsx +115 -19
  98. package/themes/original/src/components/CartContent/styles.tsx +17 -7
  99. package/themes/original/src/components/Checkout/index.tsx +367 -174
  100. package/themes/original/src/components/Checkout/styles.tsx +4 -2
  101. package/themes/original/src/components/CitiesControl/index.tsx +89 -0
  102. package/themes/original/src/components/CitiesControl/styles.tsx +17 -0
  103. package/themes/original/src/components/CouponControl/index.tsx +10 -3
  104. package/themes/original/src/components/DriverTips/index.tsx +52 -34
  105. package/themes/original/src/components/FacebookLogin/styles.tsx +3 -1
  106. package/themes/original/src/components/Favorite/index.tsx +8 -9
  107. package/themes/original/src/components/Favorite/styles.tsx +1 -1
  108. package/themes/original/src/components/FavoriteList/index.tsx +51 -80
  109. package/themes/original/src/components/FloatingButton/index.tsx +1 -2
  110. package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
  111. package/themes/original/src/components/GPSButton/index.tsx +6 -4
  112. package/themes/original/src/components/GPSButton/styles.ts +3 -3
  113. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +96 -0
  114. package/themes/original/src/components/GiftCard/GiftCardUI/styles.tsx +5 -0
  115. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +100 -0
  116. package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +8 -0
  117. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +191 -0
  118. package/themes/original/src/components/GiftCard/RedeemGiftCard/styles.tsx +8 -0
  119. package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +165 -0
  120. package/themes/original/src/components/GiftCard/SendGiftCard/styles.tsx +9 -0
  121. package/themes/original/src/components/GoogleLogin/styles.tsx +1 -1
  122. package/themes/original/src/components/GoogleMap/index.tsx +15 -4
  123. package/themes/original/src/components/Help/index.tsx +8 -8
  124. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +10 -31
  125. package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +5 -3
  126. package/themes/original/src/components/HelpGuide/index.tsx +6 -6
  127. package/themes/original/src/components/HelpGuide/styles.tsx +6 -0
  128. package/themes/original/src/components/HelpOrder/index.tsx +6 -15
  129. package/themes/original/src/components/HelpOrder/styles.tsx +8 -1
  130. package/themes/original/src/components/Home/index.tsx +13 -4
  131. package/themes/original/src/components/LastOrder/index.tsx +1 -34
  132. package/themes/original/src/components/LoginForm/Otp/index.tsx +55 -13
  133. package/themes/original/src/components/LoginForm/Otp/styles.tsx +0 -1
  134. package/themes/original/src/components/LoginForm/index.tsx +64 -26
  135. package/themes/original/src/components/LottieAnimation/index.tsx +89 -55
  136. package/themes/original/src/components/MessageListing/index.tsx +16 -42
  137. package/themes/original/src/components/Messages/index.tsx +32 -10
  138. package/themes/original/src/components/MomentOption/index.tsx +195 -88
  139. package/themes/original/src/components/MultiCart/index.tsx +50 -0
  140. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +151 -49
  141. package/themes/original/src/components/MultiCheckout/index.tsx +308 -88
  142. package/themes/original/src/components/MultiCheckout/styles.tsx +3 -1
  143. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +37 -224
  144. package/themes/original/src/components/MultiOrdersDetails/index.tsx +68 -21
  145. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +1 -1
  146. package/themes/original/src/components/MyOrders/index.tsx +77 -52
  147. package/themes/original/src/components/NavBar/index.tsx +18 -18
  148. package/themes/original/src/components/NotFoundSource/index.tsx +14 -10
  149. package/themes/original/src/components/Notifications/index.tsx +46 -50
  150. package/themes/original/src/components/Notifications/styles.tsx +6 -3
  151. package/themes/original/src/components/OrderDetails/OrderEta.tsx +76 -0
  152. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +15 -3
  153. package/themes/original/src/components/OrderDetails/index.tsx +190 -358
  154. package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
  155. package/themes/original/src/components/OrderItAgain/index.tsx +3 -1
  156. package/themes/original/src/components/OrderProgress/index.tsx +93 -114
  157. package/themes/original/src/components/OrderProgress/styles.tsx +5 -0
  158. package/themes/original/src/components/OrderSummary/index.tsx +85 -57
  159. package/themes/original/src/components/OrderTypeSelector/index.tsx +1 -1
  160. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +24 -19
  161. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +14 -14
  162. package/themes/original/src/components/OrdersOption/index.tsx +76 -66
  163. package/themes/original/src/components/OrdersOption/styles.tsx +1 -1
  164. package/themes/original/src/components/PageBanner/index.tsx +107 -40
  165. package/themes/original/src/components/PageBanner/styles.tsx +4 -1
  166. package/themes/original/src/components/PaymentOptionCard/index.tsx +180 -0
  167. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +1 -1
  168. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  169. package/themes/original/src/components/PaymentOptions/index.tsx +64 -7
  170. package/themes/original/src/components/PhoneInputNumber/index.tsx +3 -3
  171. package/themes/original/src/components/PlaceSpot/index.tsx +12 -6
  172. package/themes/original/src/components/ProductForm/index.tsx +114 -36
  173. package/themes/original/src/components/ProductForm/styles.tsx +5 -7
  174. package/themes/original/src/components/ProductItemAccordion/index.tsx +22 -19
  175. package/themes/original/src/components/ProductOptionSubOption/index.tsx +24 -14
  176. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +3 -4
  177. package/themes/original/src/components/ProfessionalFilter/SingleProfessionalCard/index.tsx +108 -0
  178. package/themes/original/src/components/ProfessionalFilter/index.tsx +20 -50
  179. package/themes/original/src/components/ProfessionalProfile/index.tsx +36 -7
  180. package/themes/original/src/components/Promotions/index.tsx +234 -220
  181. package/themes/original/src/components/Promotions/styles.tsx +10 -3
  182. package/themes/original/src/components/ReviewDriver/index.tsx +3 -3
  183. package/themes/original/src/components/ReviewOrder/index.tsx +26 -9
  184. package/themes/original/src/components/ReviewOrder/styles.tsx +7 -0
  185. package/themes/original/src/components/ReviewProducts/index.tsx +23 -11
  186. package/themes/original/src/components/ReviewTrigger/index.tsx +27 -9
  187. package/themes/original/src/components/ReviewTrigger/styles.tsx +8 -1
  188. package/themes/original/src/components/ScheduleAccordion/index.tsx +68 -0
  189. package/themes/original/src/components/ScheduleAccordion/styles.tsx +14 -0
  190. package/themes/original/src/components/ServiceForm/index.tsx +66 -17
  191. package/themes/original/src/components/Sessions/index.tsx +11 -8
  192. package/themes/original/src/components/Sessions/styles.tsx +5 -0
  193. package/themes/original/src/components/SignupForm/index.tsx +43 -20
  194. package/themes/original/src/components/SingleOrderCard/index.tsx +130 -52
  195. package/themes/original/src/components/SingleOrderCard/styles.tsx +11 -2
  196. package/themes/original/src/components/SingleProductCard/index.tsx +72 -34
  197. package/themes/original/src/components/SingleProductCard/styles.tsx +22 -4
  198. package/themes/original/src/components/SingleProductReview/styles.tsx +1 -1
  199. package/themes/original/src/components/StripeCardsList/index.tsx +13 -3
  200. package/themes/original/src/components/StripeElementsForm/index.tsx +67 -34
  201. package/themes/original/src/components/UpsellingProducts/index.tsx +238 -224
  202. package/themes/original/src/components/UpsellingProducts/styles.tsx +12 -1
  203. package/themes/original/src/components/UserDetails/index.tsx +8 -4
  204. package/themes/original/src/components/UserFormDetails/index.tsx +76 -7
  205. package/themes/original/src/components/UserFormDetails/styles.tsx +1 -1
  206. package/themes/original/src/components/UserProfile/index.tsx +88 -79
  207. package/themes/original/src/components/UserProfileForm/index.tsx +27 -29
  208. package/themes/original/src/components/UserProfileForm/styles.tsx +7 -0
  209. package/themes/original/src/components/WalletTransactionItem/index.tsx +2 -2
  210. package/themes/original/src/components/WalletTransactions/index.tsx +3 -3
  211. package/themes/original/src/components/Wallets/index.tsx +67 -24
  212. package/themes/original/src/components/Wallets/styles.tsx +3 -4
  213. package/themes/original/src/components/shared/HeaderTitle.tsx +8 -3
  214. package/themes/original/src/components/shared/OButton.tsx +6 -2
  215. package/themes/original/src/components/shared/OInput.tsx +16 -2
  216. package/themes/original/src/components/shared/OModal.tsx +3 -3
  217. package/themes/original/src/layouts/Container.tsx +1 -1
  218. package/themes/original/src/types/index.tsx +40 -11
  219. package/themes/original/src/utils/index.tsx +375 -58
  220. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useState, useRef } from 'react';
2
- import { StyleSheet, View } from 'react-native';
2
+ import { StyleSheet, View, ScrollView, Dimensions, Pressable } from 'react-native';
3
3
  import { useForm, Controller } from 'react-hook-form';
4
4
  import { useTheme } from 'styled-components/native';
5
5
  import { TouchableOpacity } from 'react-native-gesture-handler';
@@ -17,15 +17,20 @@ import {
17
17
  } from 'ordering-components/native';
18
18
 
19
19
  import {
20
+ LoginWith,
21
+ TabsContainer,
20
22
  WelcomeTextContainer,
21
23
  LogoWrapper,
22
- RecaptchaButton
24
+ RecaptchaButton,
23
25
  } from './styles';
24
26
 
25
- import { OText, OButton, OInput, OIcon } from '../shared';
27
+ import { OText, OButton, OInput, OIcon, OModal } from '../shared';
26
28
  import { LoginParams } from '../../types';
27
29
  import { LANDSCAPE, PORTRAIT, useDeviceOrientation } from '../../../../../src/hooks/DeviceOrientation';
28
30
  import { _setStoreData } from '../../../../../src/providers/StoreUtil'
31
+ import { Otp } from './Otp'
32
+ import Alert from '../../../../../src/providers/AlertProvider'
33
+ import { PhoneInputNumber } from '../PhoneInputNumber'
29
34
 
30
35
  const LoginFormUI = (props: LoginParams) => {
31
36
  const {
@@ -34,7 +39,16 @@ const LoginFormUI = (props: LoginParams) => {
34
39
  handleButtonLoginClick,
35
40
  useRootPoint,
36
41
  handleReCaptcha,
37
- enableReCaptcha
42
+ enableReCaptcha,
43
+ checkPhoneCodeState,
44
+ useLoginByCellphone,
45
+ useLoginByEmail,
46
+ loginTab,
47
+ otpType,
48
+ setOtpType,
49
+ generateOtpCode,
50
+ useLoginOtpEmail,
51
+ useLoginOtpCellphone,
38
52
  } = props;
39
53
 
40
54
  const theme = useTheme()
@@ -45,17 +59,63 @@ const LoginFormUI = (props: LoginParams) => {
45
59
  const [recaptchaConfig, setRecaptchaConfig] = useState<any>({})
46
60
  const [recaptchaVerified, setRecaptchaVerified] = useState(false)
47
61
  const recaptchaRef = useRef<any>({});
48
- const { control, handleSubmit, formState: { errors } } = useForm();
62
+ const { control, handleSubmit, formState: { errors }, clearErrors } = useForm();
49
63
  const [orientationState] = useDeviceOrientation();
50
64
 
51
65
  const [formsStateValues, setFormsStateValues] = useState<any>({ isSubmitted: false })
52
66
 
67
+ const scrollRefTab = useRef() as React.MutableRefObject<ScrollView>;
68
+ const inputRef = useRef<any>(null);
69
+ const [windowWidth, setWindowWidth] = useState(
70
+ parseInt(parseFloat(String(Dimensions.get('window').width)).toFixed(0)),
71
+ );
72
+ const [projectName, setProjectName] = useState('');
73
+ const [isLoadingVerifyModal, setIsLoadingVerifyModal] = useState(false);
74
+ const [willVerifyOtpState, setWillVerifyOtpState] = useState(false)
75
+ const [alertState, setAlertState] = useState({ open: false, title: '', content: [] })
76
+ const [phoneInputData, setPhoneInputData] = useState({
77
+ error: '',
78
+ phone: {
79
+ country_phone_code: null,
80
+ cellphone: null,
81
+ },
82
+ });
83
+
84
+ const isOtpEmail = loginTab === 'otp' && otpType === 'email'
85
+ const isOtpCellphone = loginTab === 'otp' && otpType === 'cellphone'
86
+
87
+ const mainLogin = (values) => {
88
+ if (loginTab === 'otp') {
89
+ if (phoneInputData.error && (loginTab !== 'otp' || (otpType === 'cellphone' && loginTab === 'otp'))) {
90
+ showToast(ToastType.Error, t('INVALID_PHONE_NUMBER', 'Invalid phone number'));
91
+ return
92
+ }
93
+ if (loginTab === 'otp') {
94
+ generateOtpCode({
95
+ ...values,
96
+ ...phoneInputData.phone
97
+ })
98
+ }
99
+ setWillVerifyOtpState(true)
100
+ } else {
101
+ if (phoneInputData.error) {
102
+ showToast(ToastType.Error, phoneInputData.error);
103
+ return;
104
+ }
105
+ handleButtonLoginClick({
106
+ ...values,
107
+ ...phoneInputData.phone,
108
+ });
109
+ }
110
+ }
111
+
53
112
  const onSubmit = (values: any) => {
113
+ if (phoneInputData.error) {
114
+ showToast(ToastType.Error, phoneInputData.error);
115
+ return;
116
+ }
117
+
54
118
  if (values?.project_name) {
55
- setOrdering({
56
- ...ordering,
57
- project: values?.project_name
58
- })
59
119
  _setStoreData('project_name', values?.project_name)
60
120
  setFormsStateValues({
61
121
  ...formsStateValues,
@@ -65,7 +125,7 @@ const LoginFormUI = (props: LoginParams) => {
65
125
  return
66
126
  }
67
127
 
68
- handleButtonLoginClick(values);
128
+ mainLogin(values)
69
129
  };
70
130
 
71
131
  const handleChangeInputEmail = (value: string, onChange: any) => {
@@ -110,10 +170,52 @@ const LoginFormUI = (props: LoginParams) => {
110
170
  },
111
171
  forgotStyle: {
112
172
  textAlign: 'center',
113
- fontWeight: 'bold',
173
+ fontWeight: '600',
114
174
  color: theme.colors.skyBlue,
115
175
  marginTop: orientationState?.dimensions?.height * 0.03,
116
- }
176
+ },
177
+ btn: {
178
+ borderRadius: 7.6,
179
+ height: 44,
180
+ },
181
+ btnTab: {
182
+ flex: 1,
183
+ minWidth: 88,
184
+ alignItems: 'center',
185
+ },
186
+ btnTabText: {
187
+ fontFamily: 'Poppins',
188
+ fontStyle: 'normal',
189
+ fontSize: 16,
190
+ marginBottom: 10,
191
+ paddingLeft: 8,
192
+ paddingRight: 8,
193
+ },
194
+ btnFlag: {
195
+ width: 79,
196
+ borderWidth: 1,
197
+ borderRadius: 7.6,
198
+ marginRight: 9,
199
+ borderColor: theme.colors.inputSignup,
200
+ },
201
+ borderStyleBase: {
202
+ width: 30,
203
+ height: 45
204
+ },
205
+ borderStyleHighLighted: {
206
+ borderColor: "#03DAC6",
207
+ },
208
+ underlineStyleBase: {
209
+ width: 45,
210
+ height: 60,
211
+ borderWidth: 1,
212
+ fontSize: 16
213
+ },
214
+ underlineStyleHighLighted: {
215
+ borderColor: theme.colors.primary,
216
+ color: theme.colors.primary,
217
+ fontSize: 16
218
+ },
117
219
  });
118
220
 
119
221
  useEffect(() => {
@@ -151,7 +253,11 @@ const LoginFormUI = (props: LoginParams) => {
151
253
  if (values?.project_name) {
152
254
  delete values.project_name
153
255
  }
154
- handleButtonLoginClick({ ...values })
256
+ mainLogin(values)
257
+ setFormsStateValues({
258
+ ...formsStateValues,
259
+ isSubmitted: false,
260
+ })
155
261
  }, [ordering, formsStateValues.isSubmitted])
156
262
 
157
263
 
@@ -190,149 +296,66 @@ const LoginFormUI = (props: LoginParams) => {
190
296
  }
191
297
  }, [configs, enableReCaptcha])
192
298
 
299
+ const handleChangeTab = (val: string) => {
300
+ setPhoneInputData({ ...phoneInputData, error: '' });
301
+ clearErrors([val]);
302
+ props.handleChangeTab(val);
303
+
304
+ if (loginTab === 'email') {
305
+ scrollRefTab.current?.scrollToEnd({ animated: true });
306
+ }
307
+
308
+ if (loginTab === 'cellphone') {
309
+ scrollRefTab.current?.scrollTo({ animated: true });
310
+ }
311
+ };
312
+
313
+ const handleChangeOtpType = (type: string) => {
314
+ handleChangeTab('otp', type)
315
+ setOtpType(type)
316
+ }
317
+
318
+ const handleLoginOtp = (code: string) => {
319
+ handleButtonLoginClick({ code })
320
+ setWillVerifyOtpState(false)
321
+ }
322
+
323
+ const closeAlert = () => {
324
+ setAlertState({
325
+ open: false,
326
+ title: '',
327
+ content: []
328
+ })
329
+ }
330
+
331
+ useEffect(() => {
332
+ if (checkPhoneCodeState?.result?.error) {
333
+ setAlertState({
334
+ open: true,
335
+ content: t(checkPhoneCodeState?.result?.error, checkPhoneCodeState?.result?.error),
336
+ title: ''
337
+ })
338
+ }
339
+ }, [checkPhoneCodeState])
340
+
341
+ useEffect(() => {
342
+ const projectInputTimeout = setTimeout(() => {
343
+ if (projectName && useRootPoint) {
344
+ setOrdering({
345
+ ...ordering,
346
+ project: projectName
347
+ })
348
+ }
349
+ }, 1500)
350
+ return () => clearTimeout(projectInputTimeout);
351
+ }, [projectName])
352
+
193
353
  const logo = (
194
354
  <LogoWrapper>
195
355
  <OIcon src={theme.images.logos.logotype} style={styles.logo} />
196
356
  </LogoWrapper>
197
357
  );
198
358
 
199
- const InputControllers = (
200
- <>
201
- {useRootPoint && (
202
- <Controller
203
- control={control}
204
- name='project_name'
205
- rules={{ required: t(`VALIDATION_ERROR_PROJECT_NAME_REQUIRED`, 'The field project name is required') }}
206
- defaultValue=""
207
- render={({ onChange, value }: any) => (
208
- <OInput
209
- name='project_name'
210
- placeholder={t('PROJECT_NAME', 'Project Name')}
211
- style={styles.inputStyle}
212
- value={value}
213
- autoCapitalize='none'
214
- autoCorrect={false}
215
- inputStyle={{ textAlign: 'center' }}
216
- onChange={(e: any) => {
217
- onChange(e?.target?.value);
218
- setFormsStateValues({
219
- ...formsStateValues,
220
- isSubmitted: false,
221
- })
222
- }}
223
- />
224
- )}
225
- />
226
- )}
227
-
228
- <Controller
229
- control={control}
230
- render={({ onChange, value }: any) => (
231
- <OInput
232
- placeholder={t('USER', 'User')}
233
- style={styles.inputStyle}
234
- value={value}
235
- autoCapitalize="none"
236
- autoCorrect={false}
237
- type="email-address"
238
- inputStyle={{ textAlign: 'center' }}
239
- onChange={(e: any) => {
240
- handleChangeInputEmail(e, onChange);
241
- }}
242
- />
243
- )}
244
- name="email"
245
- rules={{
246
- required: t(
247
- 'VALIDATION_ERROR_EMAIL_REQUIRED',
248
- 'The field Email is required',
249
- ).replace('_attribute_', t('EMAIL', 'Email')),
250
- pattern: {
251
- value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
252
- message: t(
253
- 'INVALID_ERROR_EMAIL',
254
- 'Invalid email address',
255
- ).replace('_attribute_', t('EMAIL', 'Email')),
256
- },
257
- }}
258
- defaultValue=""
259
- />
260
-
261
- <Controller
262
- control={control}
263
- render={({ onChange, value }: any) => (
264
- <OInput
265
- isSecured={true}
266
- placeholder={t('PASSWORD', 'Password')}
267
- style={styles.inputStyle}
268
- value={value}
269
- onChange={(val: any) => onChange(val)}
270
- inputStyle={{ textAlign: 'center' }}
271
- />
272
- )}
273
- name="password"
274
- rules={{
275
- required: t(
276
- 'VALIDATION_ERROR_PASSWORD_REQUIRED',
277
- 'The field Password is required',
278
- ).replace('_attribute_', t('PASSWORD', 'Password')),
279
- }}
280
- defaultValue=""
281
- />
282
- {(recaptchaConfig?.version) && (
283
- <>
284
- {recaptchaConfig?.version === 'v3' ? (
285
- <ReCaptcha
286
- url={recaptchaConfig?.baseUrl}
287
- siteKey={recaptchaConfig?.siteKey}
288
- containerStyle={{ height: 40 }}
289
- onExecute={onRecaptchaVerify}
290
- reCaptchaType={1}
291
- />
292
- ) : (
293
- <>
294
- <TouchableOpacity
295
- onPress={handleOpenRecaptcha}
296
- >
297
- <RecaptchaButton>
298
- {recaptchaVerified ? (
299
- <MaterialCommunityIcons
300
- name="checkbox-marked"
301
- size={26}
302
- color={theme.colors.primary}
303
- />
304
- ) : (
305
- <MaterialCommunityIcons
306
- name="checkbox-blank-outline"
307
- size={26}
308
- color={theme.colors.mediumGray}
309
- />
310
- )}
311
- <OText size={14} mLeft={8}>{t('VERIFY_ReCAPTCHA', 'Verify reCAPTCHA')}</OText>
312
- </RecaptchaButton>
313
- </TouchableOpacity>
314
- <Recaptcha
315
- ref={recaptchaRef}
316
- siteKey={recaptchaConfig?.siteKey}
317
- baseUrl={recaptchaConfig?.baseUrl}
318
- onVerify={onRecaptchaVerify}
319
- onExpire={() => setRecaptchaVerified(false)}
320
- />
321
- </>)
322
- }
323
- </>
324
- )}
325
- <OButton
326
- onClick={handleSubmit(onSubmit)}
327
- text={loginButtonText}
328
- imgRightSrc={null}
329
- isLoading={formState.loading}
330
- style={{ borderRadius: 0 }}
331
- textStyle={{ fontSize: 24 }}
332
- />
333
- </>
334
- );
335
-
336
359
  const welcome = (
337
360
  <WelcomeTextContainer>
338
361
  <OText
@@ -357,12 +380,14 @@ const LoginFormUI = (props: LoginParams) => {
357
380
  );
358
381
 
359
382
  const note = (
360
- <OText size={24} mBottom={18}>
361
- {t('IF_NOT_HAVE_ACCOUNT', 'If you don\'t have and account, please contact Ordering')}&nbsp;
362
- <OText size={24} mBottom={18} color={theme.colors.skyBlue}>
363
- {t('SUPPORT_DEPARTMENT', 'support department')}
383
+ useRootPoint && (
384
+ <OText size={24} mBottom={18}>
385
+ {t('IF_NOT_HAVE_ACCOUNT', 'If you don\'t have and account, please contact Ordering')}&nbsp;
386
+ <OText size={24} mBottom={18} color={theme.colors.skyBlue}>
387
+ {t('SUPPORT_DEPARTMENT', 'support department')}
388
+ </OText>
364
389
  </OText>
365
- </OText>
390
+ )
366
391
  )
367
392
 
368
393
  return (
@@ -416,8 +441,286 @@ const LoginFormUI = (props: LoginParams) => {
416
441
  {logo}
417
442
  </View>
418
443
  )}
419
- {InputControllers}
444
+
445
+ {(Number(useLoginByEmail) + Number(useLoginOtpEmail) + Number(useLoginOtpCellphone) > 1) && (
446
+ <LoginWith>
447
+ <ScrollView
448
+ ref={scrollRefTab}
449
+ showsVerticalScrollIndicator={false}
450
+ showsHorizontalScrollIndicator={false}
451
+ horizontal
452
+ style={{
453
+ width: orientationState?.orientation === LANDSCAPE ? orientationState?.dimensions?.width * 0.4 : windowWidth - 42
454
+ }}
455
+ >
456
+ <TabsContainer
457
+ width={orientationState?.orientation === LANDSCAPE ? orientationState?.dimensions?.width * 0.4 : windowWidth - 42}
458
+ >
459
+ {useLoginByEmail && (
460
+ <Pressable
461
+ style={styles.btnTab}
462
+ onPress={() => handleChangeTab('email')}>
463
+ <OText
464
+ style={styles.btnTabText}
465
+ color={
466
+ loginTab === 'email'
467
+ ? theme.colors.black
468
+ : theme.colors.lightGray
469
+ }
470
+ weight={loginTab === 'email' ? '600' : 'normal'}>
471
+ {t('BY_EMAIL', 'by Email')}
472
+ </OText>
473
+
474
+ <View
475
+ style={{
476
+ width: '100%',
477
+ borderBottomColor:
478
+ loginTab === 'email'
479
+ ? theme.colors.black
480
+ : theme.colors.border,
481
+ borderBottomWidth: 2,
482
+ }}></View>
483
+ </Pressable>
484
+ )}
485
+
486
+ {useLoginByCellphone && (
487
+ <Pressable
488
+ style={styles.btnTab}
489
+ onPress={() => handleChangeTab('cellphone')}>
490
+ <OText
491
+ style={styles.btnTabText}
492
+ color={
493
+ loginTab === 'cellphone'
494
+ ? theme.colors.black
495
+ : theme.colors.lightGray
496
+ }
497
+ weight={loginTab === 'cellphone' ? '600' : 'normal'}>
498
+ {t('BY_PHONE', 'by Phone')}
499
+ </OText>
500
+
501
+ <View
502
+ style={{
503
+ width: '100%',
504
+ borderBottomColor:
505
+ loginTab === 'cellphone'
506
+ ? theme.colors.black
507
+ : theme.colors.border,
508
+ borderBottomWidth: 2,
509
+ }}></View>
510
+ </Pressable>
511
+ )}
512
+
513
+ {useLoginOtpEmail && (
514
+ <Pressable
515
+ style={styles.btnTab}
516
+ onPress={() => handleChangeOtpType('email')}>
517
+ <OText
518
+ style={styles.btnTabText}
519
+ color={
520
+ isOtpEmail
521
+ ? theme.colors.black
522
+ : theme.colors.lightGray
523
+ }
524
+ weight={isOtpEmail ? '600' : 'normal'}>
525
+ {t('BY_OTP_EMAIL', 'By Otp Email')}
526
+ </OText>
527
+ <View
528
+ style={{
529
+ width: '100%',
530
+ borderBottomColor:
531
+ isOtpEmail
532
+ ? theme.colors.black
533
+ : theme.colors.border,
534
+ borderBottomWidth: 2,
535
+ }} />
536
+ </Pressable>
537
+ )}
538
+ {useLoginOtpCellphone && (
539
+ <Pressable
540
+ style={styles.btnTab}
541
+ onPress={() => handleChangeOtpType('cellphone')}>
542
+ <OText
543
+ style={styles.btnTabText}
544
+ color={
545
+ isOtpCellphone
546
+ ? theme.colors.black
547
+ : theme.colors.lightGray
548
+ }
549
+ weight={isOtpCellphone ? '600' : 'normal'}>
550
+ {t('BY_OTP_PHONE', 'By Otp Phone')}
551
+ </OText>
552
+ <View
553
+ style={{
554
+ width: '100%',
555
+ borderBottomColor:
556
+ isOtpCellphone
557
+ ? theme.colors.black
558
+ : theme.colors.border,
559
+ borderBottomWidth: 2,
560
+ }} />
561
+ </Pressable>
562
+ )}
563
+ </TabsContainer>
564
+ </ScrollView>
565
+ </LoginWith>
566
+ )}
567
+
568
+ {useRootPoint && (
569
+ <Controller
570
+ control={control}
571
+ name='project_name'
572
+ rules={{ required: t(`VALIDATION_ERROR_PROJECT_NAME_REQUIRED`, 'The field project name is required') }}
573
+ defaultValue=""
574
+ render={({ onChange, value }: any) => (
575
+ <OInput
576
+ name='project_name'
577
+ placeholder={t('PROJECT_NAME', 'Project Name')}
578
+ style={styles.inputStyle}
579
+ value={value}
580
+ autoCapitalize='none'
581
+ autoCorrect={false}
582
+ inputStyle={{ textAlign: 'center' }}
583
+ onChange={(e: any) => {
584
+ setProjectName(e?.target?.value)
585
+ onChange(e?.target?.value);
586
+ setFormsStateValues({
587
+ ...formsStateValues,
588
+ isSubmitted: false,
589
+ })
590
+ }}
591
+ />
592
+ )}
593
+ />
594
+ )}
595
+
596
+ {((useLoginByEmail && loginTab === 'email') || (loginTab === 'otp' && otpType === 'email')) && (
597
+ <Controller
598
+ control={control}
599
+ render={({ onChange, value }: any) => (
600
+ <OInput
601
+ placeholder={t('USER', 'User')}
602
+ style={styles.inputStyle}
603
+ value={value}
604
+ autoCapitalize="none"
605
+ autoCorrect={false}
606
+ type="email-address"
607
+ inputStyle={{ textAlign: 'center' }}
608
+ onChange={(e: any) => {
609
+ handleChangeInputEmail(e, onChange);
610
+ }}
611
+ />
612
+ )}
613
+ name="email"
614
+ rules={{
615
+ required: t(
616
+ 'VALIDATION_ERROR_EMAIL_REQUIRED',
617
+ 'The field Email is required',
618
+ ).replace('_attribute_', t('EMAIL', 'Email')),
619
+ pattern: {
620
+ value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
621
+ message: t(
622
+ 'INVALID_ERROR_EMAIL',
623
+ 'Invalid email address',
624
+ ).replace('_attribute_', t('EMAIL', 'Email')),
625
+ },
626
+ }}
627
+ defaultValue=""
628
+ />
629
+ )}
630
+
631
+ {((useLoginByCellphone && loginTab === 'cellphone') || (loginTab === 'otp' && otpType === 'cellphone')) && (
632
+ <View style={{ marginBottom: 20 }}>
633
+ <PhoneInputNumber
634
+ data={phoneInputData}
635
+ handleData={(val: any) => setPhoneInputData(val)}
636
+ onSubmitEditing={() => null}
637
+ textInputProps={{
638
+ returnKeyType: 'next',
639
+ onSubmitEditing: () => inputRef?.current?.focus?.(),
640
+ }}
641
+ />
642
+ </View>
643
+ )}
644
+
645
+ {loginTab !== 'otp' && (
646
+ <Controller
647
+ control={control}
648
+ render={({ onChange, value }: any) => (
649
+ <OInput
650
+ isSecured={true}
651
+ placeholder={t('PASSWORD', 'Password')}
652
+ style={styles.inputStyle}
653
+ value={value}
654
+ onChange={(val: any) => onChange(val)}
655
+ inputStyle={{ textAlign: 'center' }}
656
+ />
657
+ )}
658
+ name="password"
659
+ rules={{
660
+ required: t(
661
+ 'VALIDATION_ERROR_PASSWORD_REQUIRED',
662
+ 'The field Password is required',
663
+ ).replace('_attribute_', t('PASSWORD', 'Password')),
664
+ }}
665
+ defaultValue=""
666
+ forwardRef={inputRef}
667
+ />
668
+ )}
669
+
670
+ {(recaptchaConfig?.version) && (
671
+ <>
672
+ {recaptchaConfig?.version === 'v3' ? (
673
+ <ReCaptcha
674
+ url={recaptchaConfig?.baseUrl}
675
+ siteKey={recaptchaConfig?.siteKey}
676
+ containerStyle={{ height: 40 }}
677
+ onExecute={onRecaptchaVerify}
678
+ reCaptchaType={1}
679
+ />
680
+ ) : (
681
+ <>
682
+ <TouchableOpacity
683
+ onPress={handleOpenRecaptcha}
684
+ >
685
+ <RecaptchaButton>
686
+ {recaptchaVerified ? (
687
+ <MaterialCommunityIcons
688
+ name="checkbox-marked"
689
+ size={26}
690
+ color={theme.colors.primary}
691
+ />
692
+ ) : (
693
+ <MaterialCommunityIcons
694
+ name="checkbox-blank-outline"
695
+ size={26}
696
+ color={theme.colors.mediumGray}
697
+ />
698
+ )}
699
+ <OText size={14} mLeft={8}>{t('VERIFY_ReCAPTCHA', 'Verify reCAPTCHA')}</OText>
700
+ </RecaptchaButton>
701
+ </TouchableOpacity>
702
+ <Recaptcha
703
+ ref={recaptchaRef}
704
+ siteKey={recaptchaConfig?.siteKey}
705
+ baseUrl={recaptchaConfig?.baseUrl}
706
+ onVerify={onRecaptchaVerify}
707
+ onExpire={() => setRecaptchaVerified(false)}
708
+ />
709
+ </>)
710
+ }
711
+ </>
712
+ )}
713
+
714
+ <OButton
715
+ onClick={handleSubmit(onSubmit)}
716
+ text={loginTab !== 'otp' ? loginButtonText : t('GET_VERIFY_CODE', 'Get verify code')}
717
+ imgRightSrc={null}
718
+ isLoading={formState.loading}
719
+ style={{ borderRadius: 0 }}
720
+ textStyle={{ fontSize: 24 }}
721
+ />
420
722
  </View>
723
+
421
724
  {orientationState?.orientation === PORTRAIT && (
422
725
  <View style={{
423
726
  flexGrow: 1,
@@ -428,6 +731,27 @@ const LoginFormUI = (props: LoginParams) => {
428
731
  </View>
429
732
  )}
430
733
  </View>
734
+ <OModal
735
+ open={willVerifyOtpState}
736
+ onClose={() => setWillVerifyOtpState(false)}
737
+ entireModal
738
+ title={t('ENTER_VERIFICATION_CODE', 'Enter verification code')}
739
+ >
740
+ <Otp
741
+ willVerifyOtpState={willVerifyOtpState}
742
+ setWillVerifyOtpState={setWillVerifyOtpState}
743
+ handleLoginOtp={handleLoginOtp}
744
+ onSubmit={onSubmit}
745
+ setAlertState={setAlertState}
746
+ />
747
+ </OModal>
748
+ <Alert
749
+ open={alertState.open}
750
+ content={alertState.content}
751
+ title={alertState.title || ''}
752
+ onAccept={closeAlert}
753
+ onClose={closeAlert}
754
+ />
431
755
  </View>
432
756
  );
433
757
  };