ordering-ui-react-native 0.16.75 → 0.16.76-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.
- package/package.json +6 -5
- package/src/DeliveryApp.tsx +43 -1
- package/src/components/ActiveOrders/styles.tsx +8 -14
- package/src/components/BusinessInformation/index.tsx +19 -4
- package/src/components/BusinessInformation/styles.tsx +2 -2
- package/src/components/BusinessProductsList/index.tsx +10 -10
- package/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/LanguageSelector/index.tsx +21 -16
- package/src/components/Messages/index.tsx +2 -2
- package/src/components/OrderCreating/index.tsx +2 -2
- package/src/components/OrdersOption/index.tsx +54 -56
- package/src/components/PaymentOptions/index.tsx +298 -347
- package/src/components/PaymentOptionsWebView/index.tsx +119 -120
- package/src/components/SingleProductReview/index.tsx +7 -4
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/components/shared/OToast.tsx +4 -4
- package/src/types/@fatnlazycat/react-native-recaptcha-v3/index.d.ts +1 -0
- package/src/utils/index.tsx +2 -1
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +260 -238
- package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -4
- package/themes/business/src/components/BusinessController/index.tsx +2 -2
- package/themes/business/src/components/Chat/index.tsx +31 -31
- package/themes/business/src/components/DriverMap/index.tsx +7 -5
- package/themes/business/src/components/LoginForm/Otp/index.tsx +120 -0
- package/themes/business/src/components/LoginForm/Otp/styles.tsx +7 -0
- package/themes/business/src/components/LoginForm/index.tsx +332 -140
- package/themes/business/src/components/LoginForm/styles.tsx +10 -0
- package/themes/business/src/components/MapView/index.tsx +14 -3
- package/themes/business/src/components/MessagesOption/index.tsx +11 -1
- package/themes/business/src/components/NewOrderNotification/index.tsx +31 -41
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +70 -43
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +3 -3
- package/themes/business/src/components/OrdersOption/index.tsx +63 -73
- package/themes/business/src/components/OrdersOption/styles.tsx +5 -1
- package/themes/business/src/components/OrdersOptionBusiness/index.tsx +15 -1
- package/themes/business/src/components/OrdersOptionCity/index.tsx +15 -1
- package/themes/business/src/components/OrdersOptionDate/index.tsx +19 -6
- package/themes/business/src/components/OrdersOptionDelivery/index.tsx +15 -1
- package/themes/business/src/components/OrdersOptionDriver/index.tsx +15 -1
- package/themes/business/src/components/OrdersOptionPaymethod/index.tsx +15 -1
- package/themes/business/src/components/OrdersOptionStatus/index.tsx +10 -1
- package/themes/business/src/components/PreviousMessages/index.tsx +17 -18
- package/themes/business/src/components/PreviousOrders/OrderItem.tsx +250 -0
- package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +115 -0
- package/themes/business/src/components/PreviousOrders/index.tsx +440 -245
- package/themes/business/src/components/PreviousOrders/styles.tsx +31 -3
- package/themes/business/src/components/ProductItemAccordion/index.tsx +24 -5
- package/themes/business/src/components/ReviewCustomer/index.tsx +39 -15
- package/themes/business/src/components/shared/ODropDown.tsx +42 -8
- package/themes/business/src/components/shared/ODropDownCalendar.tsx +36 -7
- package/themes/business/src/components/shared/OLink.tsx +33 -13
- package/themes/business/src/components/shared/OText.tsx +8 -2
- package/themes/business/src/types/index.tsx +29 -3
- package/themes/business/src/utils/index.tsx +26 -0
- package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
- package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -1
- package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
- package/themes/kiosk/src/components/LoginForm/Otp/index.tsx +92 -0
- package/themes/kiosk/src/components/LoginForm/Otp/styles.tsx +7 -0
- package/themes/kiosk/src/components/LoginForm/index.tsx +545 -112
- package/themes/kiosk/src/components/LoginForm/styles.tsx +18 -0
- package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
- package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
- package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
- package/themes/kiosk/src/components/PhoneInputNumber/index.tsx +1 -0
- package/themes/kiosk/src/components/PhoneInputNumber/styles.tsx +1 -3
- package/themes/kiosk/src/components/ProductForm/index.tsx +1 -14
- package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
- package/themes/kiosk/src/components/shared/OModal.tsx +14 -11
- package/themes/kiosk/src/layouts/Container.tsx +7 -1
- package/themes/kiosk/src/types/index.d.ts +15 -0
- package/themes/kiosk/src/utils/index.tsx +15 -0
- package/themes/original/index.tsx +8 -0
- package/themes/original/src/components/AddressDetails/index.tsx +10 -8
- package/themes/original/src/components/AddressForm/index.tsx +155 -139
- package/themes/original/src/components/AddressList/index.tsx +18 -18
- package/themes/original/src/components/AddressList/styles.tsx +4 -2
- package/themes/original/src/components/AppleLogin/index.tsx +4 -4
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +47 -22
- package/themes/original/src/components/BusinessController/index.tsx +101 -70
- package/themes/original/src/components/BusinessController/styles.tsx +14 -9
- package/themes/original/src/components/BusinessInformation/index.tsx +10 -31
- package/themes/original/src/components/BusinessItemAccordion/index.tsx +12 -6
- package/themes/original/src/components/BusinessListingSearch/BusinessControllerSkeletons/index.tsx +57 -0
- package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +59 -0
- package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/styles.tsx +13 -0
- package/themes/original/src/components/BusinessListingSearch/index.tsx +104 -155
- package/themes/original/src/components/BusinessListingSearch/styles.tsx +10 -12
- package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +87 -0
- package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/styles.tsx +12 -0
- package/themes/original/src/components/BusinessProductsList/index.tsx +26 -52
- package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
- package/themes/original/src/components/BusinessProductsListing/index.tsx +563 -493
- package/themes/original/src/components/BusinessProductsListing/styles.tsx +13 -12
- package/themes/original/src/components/BusinessTypeFilter/index.tsx +3 -2
- package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +2 -1
- package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +116 -81
- package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -9
- package/themes/original/src/components/BusinessesListing/index.tsx +7 -6
- package/themes/original/src/components/Cart/index.tsx +75 -40
- package/themes/original/src/components/CartContent/index.tsx +80 -18
- package/themes/original/src/components/CartContent/styles.tsx +11 -1
- package/themes/original/src/components/Checkout/index.tsx +102 -108
- package/themes/original/src/components/Checkout/styles.tsx +4 -3
- package/themes/original/src/components/CitiesControl/index.tsx +89 -0
- package/themes/original/src/components/CitiesControl/styles.tsx +17 -0
- package/themes/original/src/components/DriverTips/index.tsx +47 -37
- package/themes/original/src/components/DriverTips/styles.tsx +2 -1
- package/themes/original/src/components/Favorite/index.tsx +7 -4
- package/themes/original/src/components/Favorite/styles.tsx +1 -1
- package/themes/original/src/components/FavoriteList/index.tsx +70 -80
- package/themes/original/src/components/FloatingButton/index.tsx +1 -2
- package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
- package/themes/original/src/components/GPSButton/index.tsx +20 -19
- package/themes/original/src/components/GPSButton/styles.ts +3 -3
- package/themes/original/src/components/GoogleMap/index.tsx +10 -1
- package/themes/original/src/components/Help/index.tsx +8 -8
- package/themes/original/src/components/HelpAccountAndPayment/index.tsx +14 -20
- package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +6 -0
- package/themes/original/src/components/HelpGuide/index.tsx +13 -12
- package/themes/original/src/components/HelpGuide/styles.tsx +6 -0
- package/themes/original/src/components/HelpOrder/index.tsx +12 -20
- package/themes/original/src/components/HelpOrder/styles.tsx +8 -1
- package/themes/original/src/components/LanguageSelector/index.tsx +19 -14
- package/themes/original/src/components/LastOrder/index.tsx +1 -34
- package/themes/original/src/components/LoginForm/Otp/index.tsx +89 -73
- package/themes/original/src/components/LoginForm/Otp/styles.tsx +0 -1
- package/themes/original/src/components/LoginForm/index.tsx +98 -41
- package/themes/original/src/components/LottieAnimation/index.tsx +78 -0
- package/themes/original/src/components/MessageListing/index.tsx +7 -40
- package/themes/original/src/components/Messages/index.tsx +42 -26
- package/themes/original/src/components/MomentOption/index.tsx +23 -14
- package/themes/original/src/components/MultiCart/index.tsx +50 -0
- package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +92 -93
- package/themes/original/src/components/MultiCheckout/index.tsx +158 -77
- package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +37 -224
- package/themes/original/src/components/MultiOrdersDetails/index.tsx +85 -34
- package/themes/original/src/components/MultiOrdersDetails/styles.tsx +1 -1
- package/themes/original/src/components/MyOrders/index.tsx +66 -17
- package/themes/original/src/components/NavBar/index.tsx +7 -6
- package/themes/original/src/components/NetworkError/index.tsx +5 -3
- package/themes/original/src/components/NotFoundSource/index.tsx +2 -1
- package/themes/original/src/components/Notifications/index.tsx +144 -0
- package/themes/original/src/components/Notifications/styles.tsx +20 -0
- package/themes/original/src/components/OrderDetails/index.tsx +108 -218
- package/themes/original/src/components/OrderDetails/styles.tsx +10 -1
- package/themes/original/src/components/OrderItAgain/index.tsx +46 -43
- package/themes/original/src/components/OrderProgress/index.tsx +81 -105
- package/themes/original/src/components/OrderProgress/styles.tsx +5 -0
- package/themes/original/src/components/OrderSummary/index.tsx +2 -2
- package/themes/original/src/components/OrderTypeSelector/index.tsx +13 -6
- package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +93 -97
- package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +3 -0
- package/themes/original/src/components/OrdersOption/index.tsx +86 -92
- package/themes/original/src/components/PageBanner/index.tsx +146 -0
- package/themes/original/src/components/PageBanner/styles.tsx +11 -0
- package/themes/original/src/components/PaymentOptionStripe/styles.tsx +1 -1
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
- package/themes/original/src/components/PaymentOptions/index.tsx +1 -1
- package/themes/original/src/components/PhoneInputNumber/index.tsx +1 -1
- package/themes/original/src/components/PlaceSpot/index.tsx +16 -6
- package/themes/original/src/components/PreviousOrders/index.tsx +3 -2
- package/themes/original/src/components/ProductForm/index.tsx +240 -254
- package/themes/original/src/components/ProductForm/styles.tsx +5 -8
- package/themes/original/src/components/ProductItemAccordion/index.tsx +199 -128
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -10
- package/themes/original/src/components/ProductOptionSubOption/styles.tsx +1 -2
- package/themes/original/src/components/ProfessionalFilter/SingleProfessionalCard/index.tsx +108 -0
- package/themes/original/src/components/ProfessionalFilter/index.tsx +20 -49
- package/themes/original/src/components/ProfessionalProfile/index.tsx +20 -9
- package/themes/original/src/components/Promotions/index.tsx +234 -220
- package/themes/original/src/components/Promotions/styles.tsx +7 -2
- package/themes/original/src/components/ReviewDriver/index.tsx +3 -3
- package/themes/original/src/components/ReviewOrder/index.tsx +43 -11
- package/themes/original/src/components/ReviewOrder/styles.tsx +7 -0
- package/themes/original/src/components/ReviewProducts/index.tsx +8 -5
- package/themes/original/src/components/ReviewTrigger/index.tsx +27 -9
- package/themes/original/src/components/ReviewTrigger/styles.tsx +8 -1
- package/themes/original/src/components/ScheduleAccordion/index.tsx +68 -0
- package/themes/original/src/components/ScheduleAccordion/styles.tsx +14 -0
- package/themes/original/src/components/ServiceForm/index.tsx +360 -265
- package/themes/original/src/components/Sessions/index.tsx +11 -8
- package/themes/original/src/components/Sessions/styles.tsx +5 -0
- package/themes/original/src/components/SignupForm/index.tsx +150 -100
- package/themes/original/src/components/SingleOrderCard/index.tsx +125 -56
- package/themes/original/src/components/SingleOrderCard/styles.tsx +10 -8
- package/themes/original/src/components/SingleProductCard/index.tsx +116 -79
- package/themes/original/src/components/SingleProductCard/styles.tsx +14 -13
- package/themes/original/src/components/SingleProductReview/index.tsx +38 -5
- package/themes/original/src/components/SingleProductReview/styles.tsx +12 -0
- package/themes/original/src/components/StripeCardsList/index.tsx +1 -1
- package/themes/original/src/components/StripeElementsForm/index.tsx +3 -0
- package/themes/original/src/components/UpsellingProducts/index.tsx +244 -215
- package/themes/original/src/components/UpsellingProducts/styles.tsx +12 -1
- package/themes/original/src/components/UserDetails/index.tsx +5 -3
- package/themes/original/src/components/UserFormDetails/index.tsx +50 -54
- package/themes/original/src/components/UserProfile/index.tsx +58 -35
- package/themes/original/src/components/UserProfile/styles.ts +17 -0
- package/themes/original/src/components/UserProfileForm/index.tsx +21 -28
- package/themes/original/src/components/UserProfileForm/styles.tsx +7 -0
- package/themes/original/src/components/WalletTransactions/index.tsx +76 -0
- package/themes/original/src/components/WalletTransactions/styles.tsx +13 -0
- package/themes/original/src/components/Wallets/index.tsx +177 -164
- package/themes/original/src/components/Wallets/styles.tsx +12 -8
- package/themes/original/src/components/shared/CardAnimation.tsx +47 -0
- package/themes/original/src/components/shared/HeaderTitle.tsx +8 -3
- package/themes/original/src/components/shared/OBottomPopup.tsx +6 -4
- package/themes/original/src/components/shared/OButton.tsx +9 -4
- package/themes/original/src/components/shared/OIcon.tsx +8 -1
- package/themes/original/src/components/shared/OInput.tsx +10 -1
- package/themes/original/src/layouts/Container.tsx +13 -9
- package/themes/original/src/types/index.tsx +42 -7
- package/themes/original/src/utils/index.tsx +322 -58
- 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
|
-
|
|
56
|
-
|
|
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
|
-
|
|
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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
131
|
+
const onRecaptchaVerify = (token: any) => {
|
|
132
|
+
setRecaptchaVerified(true)
|
|
133
|
+
handleReCaptcha({ code: token, version: recaptchaConfig?.version })
|
|
134
|
+
}
|
|
116
135
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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?.
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
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
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
{
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
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
|
|
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
|
+
`;
|