Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
InvestCustomer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Giang Tran
InvestCustomer
Commits
88248ed1
Commit
88248ed1
authored
May 31, 2021
by
Giang Tran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug re send otp
parent
25b6772d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
16 deletions
+79
-16
OTPWallet.js
src/Screens/Action/Wallet/OTPWallet.js
+35
-5
ConfirmOTP.js
src/Screens/Authen/ConfirmOTP.js
+20
-4
RegisterOTP.js
src/Screens/Authen/RegisterOTP.js
+20
-6
CountDown.js
src/components/CountDown.js
+4
-1
No files found.
src/Screens/Action/Wallet/OTPWallet.js
View file @
88248ed1
...
@@ -18,7 +18,11 @@ import {
...
@@ -18,7 +18,11 @@ import {
}
from
'react-native-confirmation-code-field'
;
}
from
'react-native-confirmation-code-field'
;
import
{
getFontXD
,
HEIGHTXD
,
WIDTHXD
}
from
'../../../Config/Functions'
;
import
{
getFontXD
,
HEIGHTXD
,
WIDTHXD
}
from
'../../../Config/Functions'
;
import
R
from
'.././../../assets/R'
;
import
R
from
'.././../../assets/R'
;
import
{
verifyOTPApi
,
registorApi
}
from
'../../../apis/Functions/users'
;
import
{
verifyOTPApi
,
registorApi
,
getOTPApi
,
}
from
'../../../apis/Functions/users'
;
import
{
useNavigation
}
from
'@react-navigation/native'
;
import
{
useNavigation
}
from
'@react-navigation/native'
;
import
I18n
from
'../../../helper/i18/i18n'
;
import
I18n
from
'../../../helper/i18/i18n'
;
import
AppText
from
'../../../components/AppText'
;
import
AppText
from
'../../../components/AppText'
;
...
@@ -34,6 +38,8 @@ const CELL_COUNT = 4;
...
@@ -34,6 +38,8 @@ const CELL_COUNT = 4;
const
ConfirmOTP
=
(
propsa
)
=>
{
const
ConfirmOTP
=
(
propsa
)
=>
{
const
[
value
,
setValue
]
=
useState
(
''
);
const
[
value
,
setValue
]
=
useState
(
''
);
const
[
isReset
,
setReset
]
=
useState
(
false
);
const
navigate
=
useNavigation
();
const
navigate
=
useNavigation
();
const
ref
=
useBlurOnFulfill
({
value
,
cellCount
:
CELL_COUNT
});
const
ref
=
useBlurOnFulfill
({
value
,
cellCount
:
CELL_COUNT
});
...
@@ -107,6 +113,32 @@ const ConfirmOTP = (propsa) => {
...
@@ -107,6 +113,32 @@ const ConfirmOTP = (propsa) => {
propsa
.
hideLoading
();
propsa
.
hideLoading
();
}
}
};
};
const
getOTP
=
async
()
=>
{
let
res
;
propsa
.
showLoading
();
if
(
propsa
.
route
.
params
.
type
==
'DEPOSIT'
)
{
res
=
await
getOTPApi
({
platform
:
Platform
.
OS
,
otp_by
:
propsa
.
user
.
email
,
type
:
'CUSTOMER_REQUEST_DEPOSIT'
,
});
}
else
{
res
=
await
getOTPApi
({
platform
:
Platform
.
OS
,
otp_by
:
propsa
.
user
.
email
,
type
:
'REQUEST_WITHDRAW'
,
});
}
propsa
.
hideLoading
();
if
(
res
.
data
.
code
==
200
)
{
setReset
(
!
isReset
);
showAlert
(
TYPE
.
SUCCESS
,
I18n
.
t
(
'Notification'
),
res
.
data
.
message
);
}
else
{
showAlert
(
TYPE
.
ERROR
,
I18n
.
t
(
'Notification'
),
res
.
data
.
message
);
}
};
return
(
return
(
<
View
style
=
{{
flex
:
1
}}
>
<
View
style
=
{{
flex
:
1
}}
>
<
HeaderBack
title
=
{
'VerifyOTP'
}
/
>
<
HeaderBack
title
=
{
'VerifyOTP'
}
/
>
...
@@ -142,14 +174,12 @@ const ConfirmOTP = (propsa) => {
...
@@ -142,14 +174,12 @@ const ConfirmOTP = (propsa) => {
<
TouchableOpacity
onPress
=
{
confirm
}
style
=
{
styles
.
btn
}
>
<
TouchableOpacity
onPress
=
{
confirm
}
style
=
{
styles
.
btn
}
>
<
AppText
i18nKey
=
{
'Continue'
}
style
=
{
styles
.
txtBtn
}
/
>
<
AppText
i18nKey
=
{
'Continue'
}
style
=
{
styles
.
txtBtn
}
/
>
<
/TouchableOpacity
>
<
/TouchableOpacity
>
<
TouchableOpacity
<
TouchableOpacity
style
=
{
styles
.
wrapFooter
}
onPress
=
{
getOTP
}
>
style
=
{
styles
.
wrapFooter
}
onPress
=
{()
=>
navigate
.
goBack
()}
>
<
Text
style
=
{
styles
.
txtNote
}
>
{
I18n
.
t
(
'OTPValidFiveMinute'
)}
<
/Text
>
<
Text
style
=
{
styles
.
txtNote
}
>
{
I18n
.
t
(
'OTPValidFiveMinute'
)}
<
/Text
>
<
AppText
i18nKey
=
{
'Re_send'
}
style
=
{
styles
.
txtSend
}
/
>
<
AppText
i18nKey
=
{
'Re_send'
}
style
=
{
styles
.
txtSend
}
/
>
<
/TouchableOpacity
>
<
/TouchableOpacity
>
<
CountDown
/>
<
CountDown
isReset
=
{
isReset
}
/
>
<
/View
>
<
/View
>
<
/View
>
<
/View
>
);
);
...
...
src/Screens/Authen/ConfirmOTP.js
View file @
88248ed1
...
@@ -28,11 +28,13 @@ import {showLoading, hideLoading} from '../../actions/loadingAction';
...
@@ -28,11 +28,13 @@ import {showLoading, hideLoading} from '../../actions/loadingAction';
import
{
connect
}
from
'react-redux'
;
import
{
connect
}
from
'react-redux'
;
import
{
showAlert
,
TYPE
}
from
'../../components/DropdownAlert'
;
import
{
showAlert
,
TYPE
}
from
'../../components/DropdownAlert'
;
import
CountDown
from
'../../components/CountDown'
;
import
CountDown
from
'../../components/CountDown'
;
import
{
getOTPApi
}
from
'../../apis/Functions/users'
;
const
CELL_COUNT
=
4
;
const
CELL_COUNT
=
4
;
const
ConfirmOTP
=
(
propsa
)
=>
{
const
ConfirmOTP
=
(
propsa
)
=>
{
const
[
value
,
setValue
]
=
useState
(
''
);
const
[
value
,
setValue
]
=
useState
(
''
);
const
[
isReset
,
setReset
]
=
useState
(
false
);
const
navigate
=
useNavigation
();
const
navigate
=
useNavigation
();
...
@@ -42,6 +44,22 @@ const ConfirmOTP = (propsa) => {
...
@@ -42,6 +44,22 @@ const ConfirmOTP = (propsa) => {
setValue
,
setValue
,
});
});
const
getOTP
=
async
()
=>
{
propsa
.
showLoading
();
const
res
=
await
getOTPApi
({
platform
:
Platform
.
OS
,
otp_by
:
propsa
.
route
.
params
.
email
,
type
:
'FORGOT_PASSWORD'
,
});
propsa
.
hideLoading
();
if
(
res
.
data
.
code
==
200
)
{
setReset
(
!
isReset
);
showAlert
(
TYPE
.
SUCCESS
,
I18n
.
t
(
'Notification'
),
res
.
data
.
message
);
}
else
{
showAlert
(
TYPE
.
ERROR
,
I18n
.
t
(
'Notification'
),
res
.
data
.
message
);
}
};
const
confirm
=
async
()
=>
{
const
confirm
=
async
()
=>
{
if
(
!
value
)
{
if
(
!
value
)
{
showAlert
(
TYPE
.
WARN
,
I18n
.
t
(
'Notification'
),
I18n
.
t
(
'EnterOTPRequest'
));
showAlert
(
TYPE
.
WARN
,
I18n
.
t
(
'Notification'
),
I18n
.
t
(
'EnterOTPRequest'
));
...
@@ -106,13 +124,11 @@ const ConfirmOTP = (propsa) => {
...
@@ -106,13 +124,11 @@ const ConfirmOTP = (propsa) => {
<
TouchableOpacity
onPress
=
{
confirm
}
style
=
{
styles
.
btn
}
>
<
TouchableOpacity
onPress
=
{
confirm
}
style
=
{
styles
.
btn
}
>
<
AppText
i18nKey
=
{
'Continue'
}
style
=
{
styles
.
txtBtn
}
/
>
<
AppText
i18nKey
=
{
'Continue'
}
style
=
{
styles
.
txtBtn
}
/
>
<
/TouchableOpacity
>
<
/TouchableOpacity
>
<
TouchableOpacity
<
TouchableOpacity
style
=
{
styles
.
wrapFooter
}
onPress
=
{
getOTP
}
>
style
=
{
styles
.
wrapFooter
}
onPress
=
{()
=>
navigate
.
goBack
()}
>
<
Text
style
=
{
styles
.
txtNote
}
>
{
I18n
.
t
(
'OTPValidFiveMinute'
)}
<
/Text
>
<
Text
style
=
{
styles
.
txtNote
}
>
{
I18n
.
t
(
'OTPValidFiveMinute'
)}
<
/Text
>
<
AppText
i18nKey
=
{
'Re_send'
}
style
=
{
styles
.
txtSend
}
/
>
<
AppText
i18nKey
=
{
'Re_send'
}
style
=
{
styles
.
txtSend
}
/
>
<
/TouchableOpacity
>
<
/TouchableOpacity
>
<
CountDown
/>
<
CountDown
isReset
=
{
isReset
}
/
>
<
/View
>
<
/View
>
<
/View
>
<
/View
>
);
);
...
...
src/Screens/Authen/RegisterOTP.js
View file @
88248ed1
...
@@ -19,7 +19,7 @@ import {
...
@@ -19,7 +19,7 @@ import {
import
{
getFontXD
,
HEIGHTXD
,
WIDTHXD
}
from
'../../Config/Functions'
;
import
{
getFontXD
,
HEIGHTXD
,
WIDTHXD
}
from
'../../Config/Functions'
;
import
R
from
'../../assets/R'
;
import
R
from
'../../assets/R'
;
import
{
NEWPASSWORD
}
from
'../../routers/ScreenNames'
;
import
{
NEWPASSWORD
}
from
'../../routers/ScreenNames'
;
import
{
verifyOTPApi
,
registorApi
}
from
'../../apis/Functions/users'
;
import
{
verifyOTPApi
,
registorApi
,
getOTPApi
}
from
'../../apis/Functions/users'
;
import
{
useNavigation
}
from
'@react-navigation/native'
;
import
{
useNavigation
}
from
'@react-navigation/native'
;
import
I18n
from
'../../helper/i18/i18n'
;
import
I18n
from
'../../helper/i18/i18n'
;
import
AppText
from
'../../components/AppText'
;
import
AppText
from
'../../components/AppText'
;
...
@@ -33,7 +33,7 @@ const CELL_COUNT = 4;
...
@@ -33,7 +33,7 @@ const CELL_COUNT = 4;
const
ConfirmOTP
=
(
propsa
)
=>
{
const
ConfirmOTP
=
(
propsa
)
=>
{
const
[
value
,
setValue
]
=
useState
(
''
);
const
[
value
,
setValue
]
=
useState
(
''
);
const
[
isReset
,
setReset
]
=
useState
(
false
);
const
navigate
=
useNavigation
();
const
navigate
=
useNavigation
();
const
ref
=
useBlurOnFulfill
({
value
,
cellCount
:
CELL_COUNT
});
const
ref
=
useBlurOnFulfill
({
value
,
cellCount
:
CELL_COUNT
});
...
@@ -103,6 +103,22 @@ const ConfirmOTP = (propsa) => {
...
@@ -103,6 +103,22 @@ const ConfirmOTP = (propsa) => {
}
}
};
};
const
getOTP
=
async
()
=>
{
propsa
.
showLoading
();
const
res
=
await
getOTPApi
({
platform
:
Platform
.
OS
,
otp_by
:
propsa
.
route
.
params
.
email
,
type
:
'CUSTOMER_VERIFY'
,
});
propsa
.
hideLoading
();
if
(
res
.
data
.
code
==
200
)
{
setReset
(
!
isReset
);
showAlert
(
TYPE
.
SUCCESS
,
I18n
.
t
(
'Notification'
),
res
.
data
.
message
);
}
else
{
showAlert
(
TYPE
.
ERROR
,
I18n
.
t
(
'Notification'
),
res
.
data
.
message
);
}
};
return
(
return
(
<
View
style
=
{{
flex
:
1
}}
>
<
View
style
=
{{
flex
:
1
}}
>
<
HeaderBack
title
=
{
'VerifyOTP'
}
/
>
<
HeaderBack
title
=
{
'VerifyOTP'
}
/
>
...
@@ -138,13 +154,11 @@ const ConfirmOTP = (propsa) => {
...
@@ -138,13 +154,11 @@ const ConfirmOTP = (propsa) => {
<
TouchableOpacity
onPress
=
{
confirm
}
style
=
{
styles
.
btn
}
>
<
TouchableOpacity
onPress
=
{
confirm
}
style
=
{
styles
.
btn
}
>
<
AppText
i18nKey
=
{
'Continue'
}
style
=
{
styles
.
txtBtn
}
/
>
<
AppText
i18nKey
=
{
'Continue'
}
style
=
{
styles
.
txtBtn
}
/
>
<
/TouchableOpacity
>
<
/TouchableOpacity
>
<
TouchableOpacity
<
TouchableOpacity
style
=
{
styles
.
wrapFooter
}
onPress
=
{
getOTP
}
>
style
=
{
styles
.
wrapFooter
}
onPress
=
{()
=>
navigate
.
goBack
()}
>
<
Text
style
=
{
styles
.
txtNote
}
>
{
I18n
.
t
(
'OTPValidFiveMinute'
)}
<
/Text
>
<
Text
style
=
{
styles
.
txtNote
}
>
{
I18n
.
t
(
'OTPValidFiveMinute'
)}
<
/Text
>
<
AppText
i18nKey
=
{
'Re_send'
}
style
=
{
styles
.
txtSend
}
/
>
<
AppText
i18nKey
=
{
'Re_send'
}
style
=
{
styles
.
txtSend
}
/
>
<
/TouchableOpacity
>
<
/TouchableOpacity
>
<
CountDown
/>
<
CountDown
isReset
=
{
isReset
}
/
>
<
/View
>
<
/View
>
<
/View
>
<
/View
>
);
);
...
...
src/components/CountDown.js
View file @
88248ed1
...
@@ -8,12 +8,15 @@ const CountDown = (props) => {
...
@@ -8,12 +8,15 @@ const CountDown = (props) => {
const
[
count
,
setCount
]
=
useState
(
300
);
const
[
count
,
setCount
]
=
useState
(
300
);
useEffect
(()
=>
{
useEffect
(()
=>
{
setCount
(
300
);
},
[
props
.
isReset
]);
useEffect
(()
=>
{
if
(
count
==
0
)
if
(
count
==
0
)
showAlert
(
TYPE
.
ERROR
,
I18n
.
t
(
'Notification'
),
I18n
.
t
(
'Overtime'
));
showAlert
(
TYPE
.
ERROR
,
I18n
.
t
(
'Notification'
),
I18n
.
t
(
'Overtime'
));
},
[
count
]);
},
[
count
]);
useEffect
(()
=>
{
useEffect
(()
=>
{
clearTimeout
();
if
(
count
>
0
)
{
if
(
count
>
0
)
{
const
timer
=
setTimeout
(()
=>
{
const
timer
=
setTimeout
(()
=>
{
setCount
(
count
-
1
);
setCount
(
count
-
1
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment