comissions-app-ui/views/form-layouts/FormLayoutsAlignment.tsx
2024-02-18 01:44:48 -05:00

112 lines
3.9 KiB
TypeScript

// ** React Imports
import { ChangeEvent, MouseEvent, useState } from 'react'
// ** MUI Imports
import Card from '@mui/material/Card'
import Grid from '@mui/material/Grid'
import Button from '@mui/material/Button'
import Checkbox from '@mui/material/Checkbox'
import { styled } from '@mui/material/styles'
import TextField from '@mui/material/TextField'
import CardHeader from '@mui/material/CardHeader'
import Typography from '@mui/material/Typography'
import InputLabel from '@mui/material/InputLabel'
import IconButton from '@mui/material/IconButton'
import CardContent from '@mui/material/CardContent'
import FormControl from '@mui/material/FormControl'
import OutlinedInput from '@mui/material/OutlinedInput'
import InputAdornment from '@mui/material/InputAdornment'
import FormControlLabel from '@mui/material/FormControlLabel'
// ** Icons Imports
import EyeOutline from 'mdi-material-ui/EyeOutline'
import EyeOffOutline from 'mdi-material-ui/EyeOffOutline'
interface State {
password: string
showPassword: boolean
}
// Styled component for the form
const Form = styled('form')(({ theme }) => ({
maxWidth: 400,
padding: theme.spacing(12),
borderRadius: theme.shape.borderRadius,
border: `1px solid ${theme.palette.divider}`
}))
const FormLayoutsAlignment = () => {
// ** State
const [values, setValues] = useState<State>({
password: '',
showPassword: false
})
// Handle Password
const handleChange = (prop: keyof State) => (event: ChangeEvent<HTMLInputElement>) => {
setValues({ ...values, [prop]: event.target.value })
}
const handleClickShowPassword = () => {
setValues({ ...values, showPassword: !values.showPassword })
}
const handleMouseDownPassword = (event: MouseEvent<HTMLButtonElement>) => {
event.preventDefault()
}
return (
<Card>
<CardHeader title='Form Alignment' titleTypographyProps={{ variant: 'h6' }} />
<CardContent sx={{ minHeight: 500, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<Form onSubmit={e => e.preventDefault()}>
<Grid container spacing={5}>
<Grid item xs={12}>
<Typography variant='h5'>Sign In</Typography>
</Grid>
<Grid item xs={12}>
<TextField fullWidth label='Username' placeholder='carterLeonard' />
</Grid>
<Grid item xs={12}>
<FormControl fullWidth>
<InputLabel htmlFor='form-layouts-alignment-password'>Password</InputLabel>
<OutlinedInput
label='Password'
value={values.password}
onChange={handleChange('password')}
id='form-layouts-alignment-password'
type={values.showPassword ? 'text' : 'password'}
endAdornment={
<InputAdornment position='end'>
<IconButton
edge='end'
onClick={handleClickShowPassword}
onMouseDown={handleMouseDownPassword}
aria-label='toggle password visibility'
>
{values.showPassword ? <EyeOutline /> : <EyeOffOutline />}
</IconButton>
</InputAdornment>
}
/>
</FormControl>
</Grid>
<Grid item xs={12}>
<FormControlLabel
label='Remember me'
control={<Checkbox name='form-layouts-alignment-checkbox' />}
sx={{ '& .MuiButtonBase-root': { paddingTop: 0, paddingBottom: 0 } }}
/>
</Grid>
<Grid item xs={12}>
<Button size='large' type='submit' variant='contained' sx={{ width: '100%' }}>
Login
</Button>
</Grid>
</Grid>
</Form>
</CardContent>
</Card>
)
}
export default FormLayoutsAlignment