|
@@ -1,15 +1,25 @@
|
|
|
-import React from 'react';
|
|
|
+import React, { useRef, useState } from 'react';
|
|
|
+import { connect } from 'react-redux';
|
|
|
import { NavLink } from 'react-router-dom';
|
|
|
import { actionLogin } from '../../Actions/action_login';
|
|
|
import './Login.css';
|
|
|
|
|
|
-const Login = () => {
|
|
|
+const Login = ({onLogin=null}) => {
|
|
|
+
|
|
|
+ const loginRef = useRef(null)
|
|
|
+ const pasRef = useRef(null)
|
|
|
+
|
|
|
+ const [login, setLogin] = useState("")
|
|
|
+ const [password, setPassword] = useState("")
|
|
|
+
|
|
|
return (
|
|
|
<div className='login-wrapper'>
|
|
|
- <input placeholder="Login"></input>
|
|
|
- <input placeholder="Password"></input>
|
|
|
+ <input value={login} 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>
|
|
|
|
|
|
- <button onClick={actionLogin}>Login</button>
|
|
|
+ <button onClick={() => onLogin(login, password)}>Login</button>
|
|
|
|
|
|
<nav>
|
|
|
<NavLink to="/registration" >Registration</NavLink>
|
|
@@ -18,4 +28,6 @@ const Login = () => {
|
|
|
)
|
|
|
}
|
|
|
|
|
|
-export default Login;
|
|
|
+const CLogin = connect(null, {onLogin: actionLogin})(Login)
|
|
|
+
|
|
|
+export default CLogin;
|