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