blob: 1735d8e5e4850b376400a3e04ed800806727aa41 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
import React, { useState } from 'react';
import Box from '@mui/material/Box';
import TextField from '@mui/material/TextField';
import Button from '@mui/material/Button';
import {Stack} from '@mui/system';
export default function Login({ login }) {
const [user, setUser] = useState('');
const [password, setPassword] = useState('');
const [loginFailed, setLoginFailed] = useState(false);
const getApiKey = () => {
login(user, password)
.then(ok => {
setLoginFailed(!ok);
}
)
.catch(console.error);
};
return (
<Box
component="form"
sx={{
'& > :not(style)': { m: 1 },
flexGrow: 1,
}}
noValidate
autoComplete="off"
>
<Stack spacing={1} maxWidth='20em'>
<h2>Repeated Surveyer</h2>
<h3>Login</h3>
<TextField
label='Email Address'
type='text'
value={user}
onChange={e => setUser(e.target.value.trim())}
/>
<TextField
label='Password'
type='password'
value={password}
onChange={e => setPassword(e.target.value)}
/>
<Button onClick={() => getApiKey()}>Login</Button>
{loginFailed && <b>Login Failed</b>}
</Stack>
</Box>
);
}
|