|
@@ -1,4 +1,4 @@
|
|
|
-import React, { useRef, useState} from 'react';
|
|
|
+import React, {useRef, useState} from 'react';
|
|
|
import {connect} from 'react-redux';
|
|
|
import {NavLink, useHistory} from 'react-router-dom';
|
|
|
import {actionLogin} from '../../Actions/action_login';
|
|
@@ -28,40 +28,46 @@ const Login = ({onLogin = null, checkLogin = false, promiseLoginStatus, payloadL
|
|
|
const [login, setLogin] = useState('')
|
|
|
const [password, setPassword] = useState('')
|
|
|
|
|
|
+ const isLoginValid = () => {
|
|
|
+ if (!login || !password) return false
|
|
|
+ else return true
|
|
|
+ }
|
|
|
+
|
|
|
const RESOLVED = 'RESOLVED'
|
|
|
|
|
|
return (
|
|
|
- <div className='login-wrapper'>
|
|
|
- <input
|
|
|
- value={login}
|
|
|
- placeholder='Login'
|
|
|
- ref={loginRef}
|
|
|
- onChange={(e) => setLogin(e.target.value)}
|
|
|
- />
|
|
|
-
|
|
|
- <input
|
|
|
- value={password}
|
|
|
- placeholder='Password'
|
|
|
- ref={pasRef} onChange={(e) => setPassword(e.target.value)}
|
|
|
- type='password'
|
|
|
- />
|
|
|
-
|
|
|
- {/*<button onClick={() => onLogin(login, password)}>*/}
|
|
|
- {/* <b>Login</b>*/}
|
|
|
- {/*</button>*/}
|
|
|
-
|
|
|
- <Button
|
|
|
- name='Login2'
|
|
|
- isValid={true}
|
|
|
- callback={() => onLogin(login, password)}
|
|
|
- />
|
|
|
-
|
|
|
- <nav className='login-wrapper__link'>
|
|
|
- <NavLink to='/registration'>Registration</NavLink>
|
|
|
- </nav>
|
|
|
-
|
|
|
- {promiseLoginStatus === RESOLVED && payloadLogin === null && <LoginError/>}
|
|
|
- </div>
|
|
|
+ <>
|
|
|
+ <div className='login-wrapper'>
|
|
|
+ <input
|
|
|
+ value={login}
|
|
|
+ placeholder='Login'
|
|
|
+ ref={loginRef}
|
|
|
+ onChange={(e) => setLogin(e.target.value)}
|
|
|
+ />
|
|
|
+
|
|
|
+ <input
|
|
|
+ value={password}
|
|
|
+ placeholder='Password'
|
|
|
+ ref={pasRef} onChange={(e) => setPassword(e.target.value)}
|
|
|
+ type='password'
|
|
|
+ />
|
|
|
+
|
|
|
+ <Button
|
|
|
+ name='Login'
|
|
|
+ isValid={isLoginValid()}
|
|
|
+ callback={() => onLogin(login, password)}
|
|
|
+ />
|
|
|
+
|
|
|
+ <nav className='login-wrapper__link'>
|
|
|
+ <NavLink to='/registration'>Registration</NavLink>
|
|
|
+ </nav>
|
|
|
+
|
|
|
+ {promiseLoginStatus === RESOLVED && payloadLogin === null && <LoginError/>}
|
|
|
+ </div>
|
|
|
+
|
|
|
+ {/*/!*{(pending1 || pending2) && gif}*!/ for registration*/}
|
|
|
+
|
|
|
+ </>
|
|
|
)
|
|
|
}
|
|
|
|
|
@@ -69,7 +75,7 @@ const CLogin = connect((state) => ({
|
|
|
checkLogin: state.auth.isLogin,
|
|
|
promiseLoginStatus: state?.promise?.Login?.status,
|
|
|
payloadLogin: state?.promise?.Login?.payload?.data?.login,
|
|
|
- loginNetworkError: state?.networkError?.loginNetworkError
|
|
|
+ loginNetworkError: state?.errors?.loginNetworkError
|
|
|
}), {onLogin: actionLogin})(Login)
|
|
|
|
|
|
export default CLogin;
|