ordering-ui-react-native 0.16.74 → 0.16.75-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 +155 -139
  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 +104 -155
  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 +26 -52
  96. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  97. package/themes/original/src/components/BusinessProductsListing/index.tsx +562 -493
  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 +82 -69
  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 +102 -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 +23 -14
  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 +66 -17
  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 +93 -97
  157. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +3 -0
  158. package/themes/original/src/components/OrdersOption/index.tsx +86 -92
  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 +16 -6
  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 +360 -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 +150 -100
  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 +116 -79
  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 +50 -54
  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 +41 -6
  215. package/themes/original/src/utils/index.tsx +322 -58
  216. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -9,6 +9,7 @@ import {
9
9
  } from 'react-native';
10
10
  import { useForm, Controller } from 'react-hook-form';
11
11
  import Recaptcha from 'react-native-recaptcha-that-works'
12
+ import ReCaptcha from '@fatnlazycat/react-native-recaptcha-v3'
12
13
  import { TouchableOpacity } from 'react-native-gesture-handler';
13
14
  import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
14
15
  import {
@@ -27,7 +28,9 @@ import {
27
28
  TabsContainer,
28
29
  OrSeparator,
29
30
  LineSeparator,
30
- RecaptchaButton
31
+ RecaptchaButton,
32
+ TabBtn,
33
+ OTab
31
34
  } from './styles';
32
35
  import { _setStoreData } from '../../providers/StoreUtil'
33
36
  import { OText, OButton, OInput, OIconButton, OModal } from '../shared';
@@ -35,6 +38,9 @@ import { PhoneInputNumber } from '../PhoneInputNumber';
35
38
  import { VerifyPhone } from '../VerifyPhone';
36
39
  import { LoginParams } from '../../types';
37
40
 
41
+ import { Otp } from './Otp'
42
+ import Alert from '../../../../../src/providers/AlertProvider'
43
+
38
44
  const LoginFormUI = (props: LoginParams) => {
39
45
  const {
40
46
  navigation,
@@ -52,8 +58,15 @@ const LoginFormUI = (props: LoginParams) => {
52
58
  allowedLevels,
53
59
  useRootPoint,
54
60
  notificationState,
55
- handleReCaptcha,
56
- enableReCaptcha
61
+ handleReCaptcha,
62
+ enableReCaptcha,
63
+
64
+ useLoginOtp,
65
+ otpType,
66
+ setOtpType,
67
+ generateOtpCode,
68
+ useLoginOtpEmail,
69
+ useLoginOtpCellphone,
57
70
  } = props;
58
71
 
59
72
  const [ordering, { setOrdering }] = useApi();
@@ -67,7 +80,7 @@ const LoginFormUI = (props: LoginParams) => {
67
80
  const inputRef = useRef<any>(null);
68
81
  const inputMailRef = useRef<any>(null);
69
82
 
70
- const [projectName, setProjectName] = useState({name: '', isFocued: false});
83
+ const [projectName, setProjectName] = useState({ name: '', isFocued: false });
71
84
  const [passwordSee, setPasswordSee] = useState(false);
72
85
  const [isLoadingVerifyModal, setIsLoadingVerifyModal] = useState(false);
73
86
  const [isModalVisible, setIsModalVisible] = useState(false);
@@ -92,36 +105,56 @@ const LoginFormUI = (props: LoginParams) => {
92
105
  const [formValues, setFormValues] = useState(null);
93
106
 
94
107
  const [recaptchaConfig, setRecaptchaConfig] = useState<any>({})
95
- const [recaptchaVerified, setRecaptchaVerified] = useState(false)
108
+ const [recaptchaVerified, setRecaptchaVerified] = useState(false)
96
109
 
97
110
  const recaptchaRef = useRef<any>({});
98
111
 
112
+ const [willVerifyOtpState, setWillVerifyOtpState] = useState(false)
113
+ const [alertState, setAlertState] = useState({ open: false, title: '', content: [] })
114
+ const isOtpEmail = loginTab === 'otp' && otpType === 'email'
115
+ const isOtpCellphone = loginTab === 'otp' && otpType === 'cellphone'
116
+
117
+
99
118
  const handleOpenRecaptcha = () => {
100
- setRecaptchaVerified(false)
101
- if (!recaptchaConfig?.siteKey) {
102
- showToast(ToastType.Error, t('NO_RECAPTCHA_SITE_KEY', 'The config doesn\'t have recaptcha site key'));
103
- return
104
- }
105
- if (!recaptchaConfig?.baseUrl) {
106
- showToast(ToastType.Error, t('NO_RECAPTCHA_BASE_URL', 'The config doesn\'t have recaptcha base url'));
107
- return
108
- }
109
- recaptchaRef.current.open()
110
- }
119
+ setRecaptchaVerified(false)
120
+ if (!recaptchaConfig?.siteKey) {
121
+ showToast(ToastType.Error, t('NO_RECAPTCHA_SITE_KEY', 'The config doesn\'t have recaptcha site key'));
122
+ return
123
+ }
124
+ if (!recaptchaConfig?.baseUrl) {
125
+ showToast(ToastType.Error, t('NO_RECAPTCHA_BASE_URL', 'The config doesn\'t have recaptcha base url'));
126
+ return
127
+ }
128
+ recaptchaRef.current.open()
129
+ }
111
130
 
112
- const onRecaptchaVerify = (token: any) => {
113
- setRecaptchaVerified(true)
114
- handleReCaptcha(token)
115
- }
131
+ const onRecaptchaVerify = (token: any) => {
132
+ setRecaptchaVerified(true)
133
+ handleReCaptcha({ code: token, version: recaptchaConfig?.version })
134
+ }
116
135
 
117
- useEffect(() => {
118
- if (configs && Object.keys(configs).length > 0 && enableReCaptcha) {
119
- setRecaptchaConfig({
120
- siteKey: configs?.security_recaptcha_site_key?.value || null,
121
- baseUrl: configs?.security_recaptcha_base_url?.value || null
122
- })
123
- }
124
- }, [configs, enableReCaptcha])
136
+ useEffect(() => {
137
+ if (configs && Object.keys(configs).length > 0 && enableReCaptcha) {
138
+ if (configs?.security_recaptcha_type?.value === 'v3' &&
139
+ configs?.security_recaptcha_score_v3?.value > 0 &&
140
+ configs?.security_recaptcha_site_key_v3?.value
141
+ ) {
142
+ setRecaptchaConfig({
143
+ version: 'v3',
144
+ siteKey: configs?.security_recaptcha_site_key_v3?.value || null,
145
+ baseUrl: configs?.security_recaptcha_base_url?.value || null
146
+ })
147
+ return
148
+ }
149
+ if (configs?.security_recaptcha_site_key?.value) {
150
+ setRecaptchaConfig({
151
+ version: 'v2',
152
+ siteKey: configs?.security_recaptcha_site_key?.value || null,
153
+ baseUrl: configs?.security_recaptcha_base_url?.value || null
154
+ })
155
+ }
156
+ }
157
+ }, [configs, enableReCaptcha])
125
158
 
126
159
  useEffect(() => {
127
160
  const projectInputInterval = setInterval(() => {
@@ -164,6 +197,7 @@ const LoginFormUI = (props: LoginParams) => {
164
197
  'An error occurred while trying to pay by PayPal',
165
198
  ERROR_ADD_PRODUCT_VERY_FAR_FOR_DELIVERY:
166
199
  'Error adding product, very far for delivery',
200
+ ERROR_AUTH_DRIVER_LOGIN_VALIDATION: 'Error auth driver login validation'
167
201
  };
168
202
 
169
203
  return keyList[key] ? t(key, keyList[key]) : t(key);
@@ -193,6 +227,31 @@ const LoginFormUI = (props: LoginParams) => {
193
227
  handleSubmit(onSubmit)();
194
228
  };
195
229
 
230
+ const mainLogin = (values) => {
231
+ if (loginTab === 'otp') {
232
+ if (phoneInputData.error && (loginTab !== 'otp' || (otpType === 'cellphone' && loginTab === 'otp'))) {
233
+ showToast(ToastType.Error, t('INVALID_PHONE_NUMBER', 'Invalid phone number'));
234
+ return
235
+ }
236
+ if (loginTab === 'otp') {
237
+ generateOtpCode({
238
+ ...values,
239
+ ...phoneInputData.phone
240
+ })
241
+ }
242
+ setWillVerifyOtpState(true)
243
+ } else {
244
+ if (phoneInputData.error) {
245
+ showToast(ToastType.Error, phoneInputData.error);
246
+ return;
247
+ }
248
+ handleButtonLoginClick({
249
+ ...values,
250
+ ...phoneInputData.phone,
251
+ });
252
+ }
253
+ }
254
+
196
255
  const onSubmit = (values: any) => {
197
256
  Keyboard.dismiss();
198
257
 
@@ -211,13 +270,26 @@ const LoginFormUI = (props: LoginParams) => {
211
270
  setSubmitted(true)
212
271
  return
213
272
  }
214
-
215
- handleButtonLoginClick({
216
- ...values,
217
- ...phoneInputData.phone
218
- });
273
+ mainLogin(values)
219
274
  };
220
275
 
276
+ const handleChangeOtpType = (type: string) => {
277
+ handleChangeTab('otp', type)
278
+ setOtpType(type)
279
+ }
280
+
281
+ const handleLoginOtp = (code: string) => {
282
+ handleButtonLoginClick({ code })
283
+ }
284
+
285
+ const closeAlert = () => {
286
+ setAlertState({
287
+ open: false,
288
+ title: '',
289
+ content: []
290
+ })
291
+ }
292
+
221
293
  const handleVerifyCodeClick = () => {
222
294
  if (phoneInputData.error) {
223
295
  showToast(ToastType.Error, phoneInputData.error);
@@ -245,27 +317,28 @@ const LoginFormUI = (props: LoginParams) => {
245
317
 
246
318
  useEffect(() => {
247
319
  if (!formState?.loading && formState?.result?.error) {
248
- formState?.result?.result &&
249
- showToast(
250
- ToastType.Error,
251
- loginTab === 'email' && typeof formState.result?.result === 'string'
252
- ? getTraduction(formState.result?.result)
253
- : loginTab === 'email' &&
254
- typeof formState.result?.result !== 'string'
255
- ? getTraduction(formState.result?.result[0])
256
- : loginTab === 'cellphone' &&
257
- typeof formState.result?.result === 'string'
258
- ? getTraduction(formState.result?.result).replace(
259
- t('USER', 'user').toLowerCase(),
260
- t('PHONE_NUMER', 'Phone number'),
261
- )
262
- : getTraduction(formState.result?.result[0]).replace(
263
- t('USER', 'user').toLowerCase(),
264
- t('PHONE_NUMER', 'Phone number'),
265
- ),
266
- );
320
+ if (formState.result?.result?.[0] === 'ERROR_AUTH_VERIFICATION_CODE') {
321
+ setRecaptchaVerified(false)
322
+ setSubmitted(false)
323
+ setRecaptchaConfig({
324
+ version: 'v2',
325
+ siteKey: configs?.security_recaptcha_site_key?.value || null,
326
+ baseUrl: configs?.security_recaptcha_base_url?.value || null
327
+ })
328
+ showToast(ToastType.Info, t('TRY_AGAIN', 'Please try again'))
329
+ return
330
+ }
331
+ formState.result?.result && showToast(
332
+ ToastType.Error,
333
+ typeof formState.result?.result === 'string'
334
+ ? formState.result?.result
335
+ : formState.result?.result[0]
336
+ )
267
337
  setSubmitted(false)
268
338
  }
339
+ if (!formState?.loading && !formState?.result?.error) {
340
+ setWillVerifyOtpState(false)
341
+ }
269
342
  }, [formState]);
270
343
 
271
344
  useEffect(() => {
@@ -333,9 +406,20 @@ const LoginFormUI = (props: LoginParams) => {
333
406
  if (values?.project_name) {
334
407
  delete values.project_name
335
408
  }
336
- handleButtonLoginClick({ ...values })
409
+ mainLogin(values)
410
+ setSubmitted(false)
337
411
  }, [ordering, submitted])
338
412
 
413
+ useEffect(() => {
414
+ if (checkPhoneCodeState?.result?.error) {
415
+ setAlertState({
416
+ open: true,
417
+ content: t(checkPhoneCodeState?.result?.error, checkPhoneCodeState?.result?.error),
418
+ title: ''
419
+ })
420
+ }
421
+ }, [checkPhoneCodeState])
422
+
339
423
  Dimensions.addEventListener('change', ({ window: { width, height } }) => {
340
424
  setWindowWidth(
341
425
  parseInt(parseFloat(String(Dimensions.get('window').width)).toFixed(0)),
@@ -418,6 +502,25 @@ const LoginFormUI = (props: LoginParams) => {
418
502
  fontWeight: 'normal',
419
503
  fontSize: 16,
420
504
  },
505
+
506
+ borderStyleBase: {
507
+ width: 30,
508
+ height: 45
509
+ },
510
+ borderStyleHighLighted: {
511
+ borderColor: "#03DAC6",
512
+ },
513
+ underlineStyleBase: {
514
+ width: 45,
515
+ height: 60,
516
+ borderWidth: 1,
517
+ fontSize: 16
518
+ },
519
+ underlineStyleHighLighted: {
520
+ borderColor: theme.colors.primary,
521
+ color: theme.colors.primary,
522
+ fontSize: 16
523
+ },
421
524
  });
422
525
 
423
526
  return (
@@ -434,7 +537,7 @@ const LoginFormUI = (props: LoginParams) => {
434
537
  <OText style={styles.title}>{t('LOGIN', 'Login')}</OText>
435
538
  </View>
436
539
 
437
- {(useLoginByEmail || useLoginByCellphone) && (
540
+ {(Number(useLoginByEmail) + Number(useLoginByCellphone) + Number(useLoginOtpEmail) + Number(useLoginOtpCellphone) > 1) && (
438
541
  <LoginWith>
439
542
  <ScrollView
440
543
  ref={scrollRefTab}
@@ -495,12 +598,63 @@ const LoginFormUI = (props: LoginParams) => {
495
598
  }}></View>
496
599
  </Pressable>
497
600
  )}
601
+
602
+ {useLoginOtpEmail && (
603
+ <Pressable
604
+ style={styles.btnTab}
605
+ onPress={() => handleChangeOtpType('email')}>
606
+ <OText
607
+ style={styles.btnTabText}
608
+ color={
609
+ isOtpEmail
610
+ ? theme.colors.textNormal
611
+ : theme.colors.disabled
612
+ }
613
+ weight={isOtpEmail ? 'bold' : 'normal'}>
614
+ {t('BY_OTP_EMAIL', 'By Otp Email')}
615
+ </OText>
616
+ <View
617
+ style={{
618
+ width: '100%',
619
+ borderBottomColor:
620
+ isOtpEmail
621
+ ? theme.colors.textGray
622
+ : theme.colors.tabBar,
623
+ borderBottomWidth: 2,
624
+ }} />
625
+ </Pressable>
626
+ )}
627
+ {useLoginOtpCellphone && (
628
+ <Pressable
629
+ style={styles.btnTab}
630
+ onPress={() => handleChangeOtpType('cellphone')}>
631
+ <OText
632
+ style={styles.btnTabText}
633
+ color={
634
+ isOtpCellphone
635
+ ? theme.colors.textNormal
636
+ : theme.colors.disabled
637
+ }
638
+ weight={isOtpCellphone ? 'bold' : 'normal'}>
639
+ {t('BY_OTP_PHONE', 'By Otp Phone')}
640
+ </OText>
641
+ <View
642
+ style={{
643
+ width: '100%',
644
+ borderBottomColor:
645
+ isOtpCellphone
646
+ ? theme.colors.textGray
647
+ : theme.colors.tabBar,
648
+ borderBottomWidth: 2,
649
+ }} />
650
+ </Pressable>
651
+ )}
498
652
  </TabsContainer>
499
653
  </ScrollView>
500
654
  </LoginWith>
501
655
  )}
502
656
 
503
- {(useLoginByCellphone || useLoginByEmail) && (
657
+ {(useLoginByCellphone || useLoginByEmail || useLoginOtp) && (
504
658
  <FormInput>
505
659
  {useRootPoint && (
506
660
  <Controller
@@ -516,7 +670,7 @@ const LoginFormUI = (props: LoginParams) => {
516
670
  icon={theme.images.general.project}
517
671
  iconColor={theme.colors.arrowColor}
518
672
  onChange={(e: any) => {
519
- setProjectName({name: e?.target?.value, isFocued: true})
673
+ setProjectName({ name: e?.target?.value, isFocued: true })
520
674
  onChange(e?.target?.value);
521
675
  setSubmitted(false);
522
676
  }}
@@ -534,7 +688,7 @@ const LoginFormUI = (props: LoginParams) => {
534
688
  />
535
689
  )}
536
690
 
537
- {useLoginByEmail && loginTab === 'email' && (
691
+ {((useLoginByEmail && loginTab === 'email') || (loginTab === 'otp' && otpType === 'email')) && (
538
692
  <Controller
539
693
  control={control}
540
694
  render={({ onChange, value }: any) => (
@@ -545,7 +699,7 @@ const LoginFormUI = (props: LoginParams) => {
545
699
  icon={theme.images.logos.emailInputIcon}
546
700
  iconColor={theme.colors.arrowColor}
547
701
  onChange={(e: any) => {
548
- setProjectName({...projectName, isFocued: false})
702
+ setProjectName({ ...projectName, isFocued: false })
549
703
  handleChangeInputEmail(e, onChange);
550
704
  }}
551
705
  selectionColor={theme.colors.primary}
@@ -579,7 +733,7 @@ const LoginFormUI = (props: LoginParams) => {
579
733
  />
580
734
  )}
581
735
 
582
- {useLoginByCellphone && loginTab === 'cellphone' && (
736
+ {((useLoginByCellphone && loginTab === 'cellphone') || (loginTab === 'otp' && otpType === 'cellphone')) && (
583
737
  <View style={{ marginBottom: 20 }}>
584
738
  <PhoneInputNumber
585
739
  data={phoneInputData}
@@ -594,54 +748,56 @@ const LoginFormUI = (props: LoginParams) => {
594
748
  </View>
595
749
  )}
596
750
 
597
- <Controller
598
- control={control}
599
- render={({ onChange, value }: any) => (
600
- <OInput
601
- isSecured={!passwordSee ? true : false}
602
- placeholder={t('PASSWORD', 'Password')}
603
- placeholderTextColor={theme.colors.arrowColor}
604
- style={styles.input}
605
- icon={theme.images.logos.passwordInputIcon}
606
- iconColor={theme.colors.arrowColor}
607
- iconCustomRight={
608
- !passwordSee ? (
609
- <MaterialCommunityIcons
610
- name="eye-outline"
611
- size={24}
612
- color={theme.colors.arrowColor}
613
- onPress={() => setPasswordSee(!passwordSee)}
614
- />
615
- ) : (
616
- <MaterialCommunityIcons
617
- name="eye-off-outline"
618
- size={24}
619
- color={theme.colors.arrowColor}
620
- onPress={() => setPasswordSee(!passwordSee)}
621
- />
622
- )
623
- }
624
- selectionColor={theme.colors.primary}
625
- color={theme.colors.textGray}
626
- value={value}
627
- forwardRef={inputRef}
628
- onChange={(val: any) => onChange(val)}
629
- returnKeyType="done"
630
- onSubmitEditing={() => handleLogin()}
631
- blurOnSubmit
632
- />
633
- )}
634
- name="password"
635
- rules={{
636
- required: t(
637
- 'VALIDATION_ERROR_PASSWORD_REQUIRED',
638
- 'The field Password is required',
639
- ).replace('_attribute_', t('PASSWORD', 'Password')),
640
- }}
641
- defaultValue=""
642
- />
751
+ {loginTab !== 'otp' && (
752
+ <Controller
753
+ control={control}
754
+ render={({ onChange, value }: any) => (
755
+ <OInput
756
+ isSecured={!passwordSee ? true : false}
757
+ placeholder={t('PASSWORD', 'Password')}
758
+ placeholderTextColor={theme.colors.arrowColor}
759
+ style={styles.input}
760
+ icon={theme.images.logos.passwordInputIcon}
761
+ iconColor={theme.colors.arrowColor}
762
+ iconCustomRight={
763
+ !passwordSee ? (
764
+ <MaterialCommunityIcons
765
+ name="eye-outline"
766
+ size={24}
767
+ color={theme.colors.arrowColor}
768
+ onPress={() => setPasswordSee(!passwordSee)}
769
+ />
770
+ ) : (
771
+ <MaterialCommunityIcons
772
+ name="eye-off-outline"
773
+ size={24}
774
+ color={theme.colors.arrowColor}
775
+ onPress={() => setPasswordSee(!passwordSee)}
776
+ />
777
+ )
778
+ }
779
+ selectionColor={theme.colors.primary}
780
+ color={theme.colors.textGray}
781
+ value={value}
782
+ forwardRef={inputRef}
783
+ onChange={(val: any) => onChange(val)}
784
+ returnKeyType="done"
785
+ onSubmitEditing={() => handleLogin()}
786
+ blurOnSubmit
787
+ />
788
+ )}
789
+ name="password"
790
+ rules={{
791
+ required: t(
792
+ 'VALIDATION_ERROR_PASSWORD_REQUIRED',
793
+ 'The field Password is required',
794
+ ).replace('_attribute_', t('PASSWORD', 'Password')),
795
+ }}
796
+ defaultValue=""
797
+ />
798
+ )}
643
799
 
644
- {onNavigationRedirect && (
800
+ {onNavigationRedirect && loginTab !== 'otp' && (
645
801
  <Pressable
646
802
  style={{ marginRight: 'auto', marginBottom: 20 }}
647
803
  onPress={() => onNavigationRedirect('Forgot')}>
@@ -650,43 +806,53 @@ const LoginFormUI = (props: LoginParams) => {
650
806
  </OText>
651
807
  </Pressable>
652
808
  )}
653
-
654
- {enableReCaptcha && (
809
+ {(enableReCaptcha && recaptchaConfig?.version) && (
655
810
  <>
656
- <TouchableOpacity
657
- style={{ marginBottom: 15 }}
658
- onPress={handleOpenRecaptcha}
659
- >
660
- <RecaptchaButton>
661
- {recaptchaVerified ? (
662
- <MaterialCommunityIcons
663
- name="checkbox-marked"
664
- size={26}
665
- color={theme.colors.primary}
666
- />
667
- ) : (
668
- <MaterialCommunityIcons
669
- name="checkbox-blank-outline"
670
- size={26}
671
- color={theme.colors.mediumGray}
672
- />
673
- )}
674
- <OText size={14} mLeft={8}>{t('VERIFY_ReCAPTCHA', 'Verify reCAPTCHA')}</OText>
675
- </RecaptchaButton>
676
- </TouchableOpacity>
677
- <Recaptcha
678
- ref={recaptchaRef}
679
- siteKey={recaptchaConfig?.siteKey}
680
- baseUrl={recaptchaConfig?.baseUrl}
681
- onVerify={onRecaptchaVerify}
682
- onExpire={() => setRecaptchaVerified(false)}
683
- />
811
+ {recaptchaConfig?.version === 'v3' ? (
812
+ <ReCaptcha
813
+ url={recaptchaConfig?.baseUrl}
814
+ siteKey={recaptchaConfig?.siteKey}
815
+ containerStyle={{ height: 40 }}
816
+ onExecute={onRecaptchaVerify}
817
+ reCaptchaType={1}
818
+ />
819
+ ) : (
820
+ <>
821
+ <TouchableOpacity
822
+ style={{ marginBottom: 15 }}
823
+ onPress={handleOpenRecaptcha}
824
+ >
825
+ <RecaptchaButton>
826
+ {recaptchaVerified ? (
827
+ <MaterialCommunityIcons
828
+ name="checkbox-marked"
829
+ size={26}
830
+ color={theme.colors.primary}
831
+ />
832
+ ) : (
833
+ <MaterialCommunityIcons
834
+ name="checkbox-blank-outline"
835
+ size={26}
836
+ color={theme.colors.mediumGray}
837
+ />
838
+ )}
839
+ <OText size={14} mLeft={8}>{t('VERIFY_ReCAPTCHA', 'Verify reCAPTCHA')}</OText>
840
+ </RecaptchaButton>
841
+ </TouchableOpacity>
842
+ <Recaptcha
843
+ ref={recaptchaRef}
844
+ siteKey={recaptchaConfig?.siteKey}
845
+ baseUrl={recaptchaConfig?.baseUrl}
846
+ onVerify={onRecaptchaVerify}
847
+ onExpire={() => setRecaptchaVerified(false)}
848
+ />
849
+ </>)
850
+ }
684
851
  </>
685
- )}
686
-
852
+ )}
687
853
  <OButton
688
854
  onClick={handleLogin}
689
- text={t('LOGIN', 'Login')}
855
+ text={loginTab !== 'otp' ? t('LOGIN', 'Login') : t('GET_VERIFY_CODE', 'Get verify code')}
690
856
  bgColor={theme.colors.primary}
691
857
  borderColor={theme.colors.primary}
692
858
  textStyle={styles.btnText}
@@ -726,7 +892,10 @@ const LoginFormUI = (props: LoginParams) => {
726
892
  </>
727
893
  )}
728
894
 
729
- <OModal open={isModalVisible} onClose={() => setIsModalVisible(false)}>
895
+ <OModal
896
+ open={isModalVisible}
897
+ onClose={() => setIsModalVisible(false)}
898
+ >
730
899
  <VerifyPhone
731
900
  phone={phoneInputData.phone}
732
901
  verifyPhoneState={verifyPhoneState}
@@ -736,6 +905,29 @@ const LoginFormUI = (props: LoginParams) => {
736
905
  handleVerifyCodeClick={handleVerifyCodeClick}
737
906
  />
738
907
  </OModal>
908
+ <OModal
909
+ open={willVerifyOtpState}
910
+ onClose={() => setWillVerifyOtpState(false)}
911
+ entireModal
912
+ hideIcons
913
+ title={t('ENTER_VERIFICATION_CODE', 'Enter verification code')}
914
+ >
915
+ <Otp
916
+ willVerifyOtpState={willVerifyOtpState}
917
+ setWillVerifyOtpState={setWillVerifyOtpState}
918
+ handleLoginOtp={handleLoginOtp}
919
+ onSubmit={handleLogin}
920
+ setAlertState={setAlertState}
921
+ formState={formState}
922
+ />
923
+ </OModal>
924
+ <Alert
925
+ open={alertState.open}
926
+ content={alertState.content}
927
+ title={alertState.title || ''}
928
+ onAccept={closeAlert}
929
+ onClose={closeAlert}
930
+ />
739
931
  </View>
740
932
  );
741
933
  };
@@ -52,3 +52,13 @@ export const RecaptchaButton = styled.View`
52
52
  align-items: center;
53
53
  margin-bottom: 10px;
54
54
  `
55
+ export const OTab = styled.View`
56
+ padding-bottom: 10px;
57
+ border-bottom-width: 1px;
58
+ margin-end: 14px;
59
+ `;
60
+
61
+ export const TabBtn = styled.TouchableOpacity`
62
+ min-height: 30px;
63
+ height: 30px;
64
+ `;