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