|
@@ -1,11 +1,11 @@
|
|
|
-import React, { useEffect, useRef, useState } from 'react';
|
|
|
-import { connect } from 'react-redux';
|
|
|
-import { NavLink, useHistory } from 'react-router-dom';
|
|
|
-import { actionLogin } from '../../Actions/action_login';
|
|
|
+import React, {useEffect, useRef, useState} from 'react';
|
|
|
+import {connect} from 'react-redux';
|
|
|
+import {NavLink, useHistory} from 'react-router-dom';
|
|
|
+import {actionLogin} from '../../Actions/action_login';
|
|
|
import LoginError from '../../Components/LoginError/LoginError';
|
|
|
import './Login.css';
|
|
|
|
|
|
-const Login = ({ onLogin = null, checkLogin = false, promiseLoginStatus, payloadLogin, loginNetworkError }) => { //деструктуризация объекта
|
|
|
+const Login = ({onLogin = null, checkLogin = false, promiseLoginStatus, payloadLogin, loginNetworkError}) => { //деструктуризация объекта
|
|
|
|
|
|
let history = useHistory();
|
|
|
|
|
@@ -16,7 +16,7 @@ const Login = ({ onLogin = null, checkLogin = false, promiseLoginStatus, payload
|
|
|
if (localStorage.authToken) {
|
|
|
history.push('/profile')
|
|
|
}
|
|
|
- if(loginNetworkError) {
|
|
|
+ if (loginNetworkError) {
|
|
|
history.push('/404')
|
|
|
}
|
|
|
|
|
@@ -34,18 +34,29 @@ const Login = ({ onLogin = null, checkLogin = false, promiseLoginStatus, payload
|
|
|
|
|
|
return (
|
|
|
<div className='login-wrapper'>
|
|
|
- <input value={login} placeholder="Login" ref={loginRef} onChange={(e) => setLogin(e.target.value)}></input>
|
|
|
+ <input
|
|
|
+ value={login}
|
|
|
+ placeholder="Login"
|
|
|
+ ref={loginRef}
|
|
|
+ onChange={(e) => setLogin(e.target.value)}
|
|
|
+ />
|
|
|
{/* зачем нужен value? */}
|
|
|
{/* <input placeholder="Login" ref={loginRef} onChange={(e) => setLogin(e.target.value)}></input> */}
|
|
|
- <input value={password} placeholder="Password" ref={pasRef} onChange={(e) => setPassword(e.target.value)} type="password"></input>
|
|
|
+ <input
|
|
|
+ value={password}
|
|
|
+ placeholder="Password"
|
|
|
+ ref={pasRef} onChange={(e) => setPassword(e.target.value)} type="password"
|
|
|
+ />
|
|
|
|
|
|
- <button onClick={() => onLogin(login, password)}>Login</button>
|
|
|
+ <button onClick={() => onLogin(login, password)}>
|
|
|
+ <b>Login</b>
|
|
|
+ </button>
|
|
|
|
|
|
<nav>
|
|
|
- <NavLink to="/registration" >Registration</NavLink>
|
|
|
+ <NavLink to="/registration">Registration</NavLink>
|
|
|
</nav>
|
|
|
|
|
|
- {promiseLoginStatus ==='RESOLVED' && payloadLogin === null && <LoginError />}
|
|
|
+ {promiseLoginStatus === 'RESOLVED' && payloadLogin === null && <LoginError/>}
|
|
|
</div>
|
|
|
)
|
|
|
}
|
|
@@ -55,6 +66,6 @@ const CLogin = connect((state) => ({
|
|
|
promiseLoginStatus: state?.promise?.Login?.status,
|
|
|
payloadLogin: state?.promise?.Login?.payload?.data?.login,
|
|
|
loginNetworkError: state?.networkError?.loginNetworkError
|
|
|
-}), { onLogin: actionLogin })(Login)
|
|
|
+}), {onLogin: actionLogin})(Login)
|
|
|
|
|
|
export default CLogin;
|