summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortanhengyeow <E0032242@u.nus.edu>2020-06-19 00:17:45 +0800
committertanhengyeow <E0032242@u.nus.edu>2020-06-19 00:17:45 +0800
commitb6c1f45066da01cb28bbdd8e2d81c1c2bb8ed872 (patch)
tree1ed52f8568215b2f3b1f66ee5aa359a9baed783e
parenta29532e27ab525381c751b2ffa7458451b2b87d2 (diff)
downloadlibeufin-b6c1f45066da01cb28bbdd8e2d81c1c2bb8ed872.tar.gz
libeufin-b6c1f45066da01cb28bbdd8e2d81c1c2bb8ed872.tar.bz2
libeufin-b6c1f45066da01cb28bbdd8e2d81c1c2bb8ed872.zip
Enable 'enter' keystroke support for login page
-rw-r--r--frontend/src/components/login/Index.tsx25
1 files changed, 18 insertions, 7 deletions
diff --git a/frontend/src/components/login/Index.tsx b/frontend/src/components/login/Index.tsx
index e73e234a..15f2b507 100644
--- a/frontend/src/components/login/Index.tsx
+++ b/frontend/src/components/login/Index.tsx
@@ -20,6 +20,21 @@ const Login = ({ loginConnect }: Props) => {
wrapperCol: { span: 32 },
};
+ const login = () => {
+ loginConnect(nexusURL, username, password)
+ .then(() => {
+ setAuthenticationFailure(false);
+ })
+ .catch((err) => setAuthenticationFailure(true));
+ };
+
+ const enterPressed = (event) => {
+ let code = event.keyCode || event.which;
+ if (code === 13) {
+ login();
+ }
+ };
+
return (
<div className="login">
{authenticationFailure ? (
@@ -43,25 +58,21 @@ const Login = ({ loginConnect }: Props) => {
<Input
placeholder="Username"
onChange={(e) => setUsername(e.target.value)}
+ onKeyPress={(e) => enterPressed(e)}
/>
</Form.Item>
<Form.Item>
<Input.Password
placeholder="Password"
onChange={(e) => setPassword(e.target.value)}
+ onKeyPress={(e) => enterPressed(e)}
/>
</Form.Item>
<div className="button">
<Button
type="primary"
icon={<LoginOutlined />}
- onClick={() =>
- loginConnect(nexusURL, username, password)
- .then(() => {
- setAuthenticationFailure(false);
- })
- .catch((err) => setAuthenticationFailure(true))
- }
+ onClick={() => login()}
>
Login
</Button>