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