Commit eb0ff9cc authored by Цой Данил's avatar Цой Данил 💬

Rebuild authorize page. Now it has password that could be shown or hidden

parent e2fd31d3
This diff is collapsed.
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
"dependencies": { "dependencies": {
"@emotion/react": "^11.10.6", "@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.6", "@emotion/styled": "^11.10.6",
"@material/icon-button": "^14.0.0",
"@mui/icons-material": "^5.11.16",
"@mui/material": "^5.12.0", "@mui/material": "^5.12.0",
"@reduxjs/toolkit": "^1.9.3", "@reduxjs/toolkit": "^1.9.3",
"@types/axios": "^0.14.0", "@types/axios": "^0.14.0",
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
justify-content: center; justify-content: center;
align-items: center; align-items: center;
margin-top: 100px; margin-top: 100px;
color: black;
} }
.AuthorizeForm p { .AuthorizeForm p {
...@@ -18,12 +19,13 @@ ...@@ -18,12 +19,13 @@
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
padding: 20px; padding: 20px;
background: rgba(83, 26, 136, 0.659); background: rgb(255, 255, 255);
border-radius: 5px; border-radius: 5px;
} }
.login_input{ .login_input{
width: 80%; width: 80%;
color: white;
height: 40px; height: 40px;
padding: 5px; padding: 5px;
border-radius: 7px; border-radius: 7px;
...@@ -88,7 +90,7 @@ ...@@ -88,7 +90,7 @@
} }
.login_btn{ .login_btn{
margin: 0 auto; margin: 0 auto;
margin-top: 30px; margin-top: 10px;
width: 170px; width: 170px;
height: 50px; height: 50px;
} }
......
...@@ -7,6 +7,9 @@ import { shallowEqual, useSelector } from 'react-redux' ...@@ -7,6 +7,9 @@ import { shallowEqual, useSelector } from 'react-redux'
import Preloader from '../../components/UI/Preloader/Preloader' import Preloader from '../../components/UI/Preloader/Preloader'
import { createUser, hideMessage, loginUser } from '../../store/user/user.slice' import { createUser, hideMessage, loginUser } from '../../store/user/user.slice'
import Alert from '@mui/material/Alert'; import Alert from '@mui/material/Alert';
import Visibility from '@mui/icons-material/Visibility';
import VisibilityOff from '@mui/icons-material/VisibilityOff';
import { FormControl, FormControlLabel, IconButton, InputAdornment, InputLabel, OutlinedInput, Switch, TextField } from '@mui/material'
const AuthorizeForm: React.FunctionComponent = (): React.ReactElement => { const AuthorizeForm: React.FunctionComponent = (): React.ReactElement => {
const navigate = useNavigate() const navigate = useNavigate()
...@@ -23,6 +26,10 @@ const AuthorizeForm: React.FunctionComponent = (): React.ReactElement => { ...@@ -23,6 +26,10 @@ const AuthorizeForm: React.FunctionComponent = (): React.ReactElement => {
const [isLoginUser, setIsLoginUser] = useState<boolean>(true) const [isLoginUser, setIsLoginUser] = useState<boolean>(true)
const [showPassword, setShowPassword] = useState<boolean>(false);
const handleClickShowPassword = () => setShowPassword((show) => !show);
const inputHandler = (e: React.ChangeEvent<HTMLInputElement>): void => { const inputHandler = (e: React.ChangeEvent<HTMLInputElement>): void => {
setUserValues(prevState => { setUserValues(prevState => {
return {...prevState, [e.target.name]: e.target.value} return {...prevState, [e.target.name]: e.target.value}
...@@ -42,6 +49,10 @@ const AuthorizeForm: React.FunctionComponent = (): React.ReactElement => { ...@@ -42,6 +49,10 @@ const AuthorizeForm: React.FunctionComponent = (): React.ReactElement => {
} }
} }
const handleMouseDownPassword = (event: React.MouseEvent<HTMLButtonElement>) => {
event.preventDefault();
};
useEffect(() => { useEffect(() => {
checkButton() checkButton()
},[userValues]) },[userValues])
...@@ -77,35 +88,73 @@ const AuthorizeForm: React.FunctionComponent = (): React.ReactElement => { ...@@ -77,35 +88,73 @@ const AuthorizeForm: React.FunctionComponent = (): React.ReactElement => {
</Alert> : null </Alert> : null
} }
<p>{isLoginUser ? 'Login user' : 'Authorize user'}</p> <p>{isLoginUser ? 'Login user' : 'Authorize user'}</p>
<p>Username:</p> {/* <OutlinedInput
<input label="Username"
className={styles.login_input} name={'username'}
placeholder='username...'
autoComplete='off'
value={userValues.username}
onChange={inputHandler}
style={{
marginBottom: '20px'
}}
/> */}
<FormControl sx={{ m: 1, width: '80%' }} variant="outlined">
<InputLabel htmlFor="outlined-adornment-password">Username</InputLabel>
<OutlinedInput
id="outlined-adornment-password"
type={'text'}
label="Username"
name={'username'} name={'username'}
autoComplete='off' autoComplete='off'
value={userValues.username} value={userValues.username}
onChange={inputHandler} onChange={inputHandler}
style={{
marginBottom: '10px',
width: '100%'
}
}
/> />
<p>Password:</p> </FormControl>
<input
className={styles.login_input}
placeholder='password...' <FormControl sx={{ m: 1, width: '80%' }} variant="outlined">
<InputLabel htmlFor="outlined-adornment-password">Password</InputLabel>
<OutlinedInput
id="outlined-adornment-password"
type={showPassword ? 'text' : 'password'}
label="Password"
name={'password'} name={'password'}
type='password'
autoComplete='off' autoComplete='off'
value={userValues.password} value={userValues.password}
onChange={inputHandler} onChange={inputHandler}
style={{
marginBottom: '10px',
width: '100%'
}}
endAdornment={
<InputAdornment position="end">
<IconButton
aria-label="toggle password visibility"
onClick={handleClickShowPassword}
onMouseDown={handleMouseDownPassword}
edge="end"
>
{showPassword ? <VisibilityOff /> : <Visibility />}
</IconButton>
</InputAdornment>
}
/> />
<label style={{display: 'flex', alignItems: 'center'}}> </FormControl>
<input <FormControlLabel
className={styles.toggleCheckbox} control={<Switch
type="checkbox"
checked={isLoginUser} checked={isLoginUser}
onChange={toggleChangeHandler} onChange={toggleChangeHandler}
inputProps={{ 'aria-label': 'controlled' }}
/>}
label={<p style={{color: 'black'}}>Add new user</p>}
/> />
<div className={styles.toggleSwitch}></div>
<span className={styles.toggleLabel}>New user?</span>
</label>
<button <button
className={styles.login_btn} className={styles.login_btn}
disabled={buttonDisabled} disabled={buttonDisabled}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment