mirror of
https://github.com/optim-enterprises-bv/OptimCloud-gw-ui.git
synced 2025-11-01 18:57:46 +00:00
Added enter key listener on login page
This commit is contained in:
@@ -23,6 +23,12 @@ const Login = () => {
|
|||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const [userId, setUsername] = useState('');
|
const [userId, setUsername] = useState('');
|
||||||
const [password, setPassword] = useState('');
|
const [password, setPassword] = useState('');
|
||||||
|
|
||||||
|
const onKeyDown = (event) => {
|
||||||
|
if(event.code === 'Enter' && formValidation()){
|
||||||
|
SignIn({ userId, password });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const SignIn = (credentials) => {
|
const SignIn = (credentials) => {
|
||||||
axiosInstance.post('/oauth2', credentials)
|
axiosInstance.post('/oauth2', credentials)
|
||||||
@@ -33,7 +39,7 @@ const Login = () => {
|
|||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.log(error.response);
|
console.log(error.response);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
const formValidation = () => {
|
const formValidation = () => {
|
||||||
if (userId.trim() === '' || password.trim() === ''){
|
if (userId.trim() === '' || password.trim() === ''){
|
||||||
@@ -50,7 +56,7 @@ const Login = () => {
|
|||||||
<CCardGroup>
|
<CCardGroup>
|
||||||
<CCard className="p-4">
|
<CCard className="p-4">
|
||||||
<CCardBody>
|
<CCardBody>
|
||||||
<CForm>
|
<CForm onKeyDown = { onKeyDown }>
|
||||||
<h1>Login</h1>
|
<h1>Login</h1>
|
||||||
<p className="text-muted">Sign In to your account</p>
|
<p className="text-muted">Sign In to your account</p>
|
||||||
<CInputGroup className="mb-3">
|
<CInputGroup className="mb-3">
|
||||||
|
|||||||
Reference in New Issue
Block a user