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

Deleted not needed comments + rewrote titles in authorize form to match the idea

parent 5e15b7bd
......@@ -61,7 +61,7 @@ const Header: React.FunctionComponent = (): React.ReactElement => {
<button className={styles.Header_button} onClick={logoutHandler}>Logout</button>
</div> :
<div>
<button className={styles.Header_button} onClick={()=>{navigateToPage('authorize')}}>Login</button>
<button className={styles.Header_button} onClick={()=>{navigateToPage('authorize')}}>Authorize</button>
</div>
}
</div>
......
......@@ -24,7 +24,7 @@ const AuthorizeForm: React.FunctionComponent = (): React.ReactElement => {
const [buttonDisabled, setButtonDisabled] = useState<boolean>(true)
const [isLoginUser, setIsLoginUser] = useState<boolean>(true)
const [addNewUser, setAddNewUser] = useState<boolean>(true)
const [showPassword, setShowPassword] = useState<boolean>(false);
......@@ -37,12 +37,12 @@ const AuthorizeForm: React.FunctionComponent = (): React.ReactElement => {
}
const toggleChangeHandler = () => {
setIsLoginUser(!isLoginUser)
setAddNewUser(!addNewUser)
}
const submitHandler = async (e: FormEvent) => {
e.preventDefault()
if (isLoginUser){
if (addNewUser){
await dispatch(createUser(userValues))
} else{
await dispatch(loginUser(userValues))
......@@ -87,18 +87,7 @@ const AuthorizeForm: React.FunctionComponent = (): React.ReactElement => {
{messageUser}
</Alert> : null
}
<p>{isLoginUser ? 'Login user' : 'Authorize user'}</p>
{/* <OutlinedInput
label="Username"
name={'username'}
autoComplete='off'
value={userValues.username}
onChange={inputHandler}
style={{
marginBottom: '20px'
}}
/> */}
<p>{addNewUser ? 'Register user' : 'Log in user'}</p>
<FormControl sx={{ m: 1, width: '80%' }} variant="outlined">
<InputLabel htmlFor="outlined-adornment-password">Username</InputLabel>
......@@ -118,7 +107,6 @@ const AuthorizeForm: React.FunctionComponent = (): React.ReactElement => {
/>
</FormControl>
<FormControl sx={{ m: 1, width: '80%' }} variant="outlined">
<InputLabel htmlFor="outlined-adornment-password">Password</InputLabel>
<OutlinedInput
......@@ -149,7 +137,7 @@ const AuthorizeForm: React.FunctionComponent = (): React.ReactElement => {
</FormControl>
<FormControlLabel
control={<Switch
checked={isLoginUser}
checked={addNewUser}
onChange={toggleChangeHandler}
inputProps={{ 'aria-label': 'controlled' }}
/>}
......@@ -158,7 +146,7 @@ const AuthorizeForm: React.FunctionComponent = (): React.ReactElement => {
<button
className={styles.login_btn}
disabled={buttonDisabled}
>Authorize</button>
>{addNewUser ? 'Register' : 'Log in'}</button>
</form>
</div>
)
......
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