diff options
Diffstat (limited to 'src/pages/Login')
| -rw-r--r-- | src/pages/Login/index.js | 52 | 
1 files changed, 52 insertions, 0 deletions
| diff --git a/src/pages/Login/index.js b/src/pages/Login/index.js new file mode 100644 index 0000000..1735d8e --- /dev/null +++ b/src/pages/Login/index.js @@ -0,0 +1,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> +  ); +} + | 
