1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- import React, { useState } from 'react';
- import LockOutlinedIcon from '@mui/icons-material/LockOutlined';
- import Button from '@mui/material/Button';
- import { Container, CssBaseline, TextField, Avatar, Typography, FormControlLabel, Checkbox, Grid, Link } from '@mui/material';
- import { Box } from '@mui/system';
- const LoginForm = ({ onLogin }) => {
- const [login, setLogin] = useState('');
- const [password, setPassword] = useState('');
- const isButtonActive = login?.length > 3 && password?.length > 3;
- return (
- <Container component="main" maxWidth="xs">
- <CssBaseline />
- <Box
- sx={{
- marginTop: 8,
- display: 'flex',
- flexDirection: 'column',
- alignItems: 'center',
- }}
- >
- <Avatar sx={{ m: 1, bgcolor: 'secondary.main' }}>
- <LockOutlinedIcon />
- </Avatar>
- <Typography component="h1" variant="h5">
- Sign in
- </Typography>
- <TextField
- fullWidth
- margin="normal"
- autoFocus
- required
- id="login-input"
- label="Login"
- size="small"
- defaultValue=""
- onChange={e => setLogin(e.target.value)}
- />
- <TextField
- fullWidth
- margin="normal"
- required
- id="password-input"
- label="Password"
- type="password"
- size="small"
- defaultValue=""
- onChange={e => setPassword(e.target.value)}
- />
- <FormControlLabel
- control={<Checkbox value="remember" color="primary" />}
- label="Remember me"
- />
- <Button
- variant="contained"
- sx={{ mt: 3, mb: 2 }}
- fullWidth
- type="submit"
- disabled={!isButtonActive}
- onClick={() => { onLogin({ login, password }) }}>
- Login...
- </Button>
- <Grid container>
- <Grid item xs>
- <Link href="#" variant='body2'>
- Forgot password?
- </Link>
- </Grid>
- <Grid item>
- <Link href="#" variant='body2'>
- {"Don't have an account? Sign Up"}
- </Link>
- </Grid>
- </Grid>
- </Box>
- </Container>
- )
- }
- export { LoginForm };
|