|
@@ -26,7 +26,7 @@ const ButtonLogout = ({onLogout, isLoggedIn}) =>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-const PasswordConfirm = ({state, login, isLoggedIn, onLogin = null }) => {
|
|
|
|
|
|
+const PasswordConfirm = ({state, login, isLoggedIn, onLogin = null, }) => {
|
|
const [pass1, setPass1] = useState("");
|
|
const [pass1, setPass1] = useState("");
|
|
const [pass2, setPass2] = useState("");
|
|
const [pass2, setPass2] = useState("");
|
|
const history = useHistory();
|
|
const history = useHistory();
|
|
@@ -42,7 +42,14 @@ const PasswordConfirm = ({state, login, isLoggedIn, onLogin = null }) => {
|
|
onChange={(e) => {
|
|
onChange={(e) => {
|
|
setPass1(e.target.value);
|
|
setPass1(e.target.value);
|
|
}}
|
|
}}
|
|
- onKeyDown = {(e) => e.keyCode == 13 && onLogin(pass1, pass2)}
|
|
|
|
|
|
+ onKeyDown = {(e) => {
|
|
|
|
+ if (e.keyCode == 13) {
|
|
|
|
+ onLogin(pass1, pass2)
|
|
|
|
+ if(!login){
|
|
|
|
+ history.push("/loginError")
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }}
|
|
/>
|
|
/>
|
|
<input
|
|
<input
|
|
type="password"
|
|
type="password"
|
|
@@ -50,11 +57,24 @@ const PasswordConfirm = ({state, login, isLoggedIn, onLogin = null }) => {
|
|
onChange={(e) => {
|
|
onChange={(e) => {
|
|
setPass2(e.target.value);
|
|
setPass2(e.target.value);
|
|
}}
|
|
}}
|
|
- onKeyDown = {(e) => e.keyCode == 13 && onLogin(pass1, pass2)}
|
|
|
|
|
|
+ onKeyDown = {(e) => {
|
|
|
|
+ if (e.keyCode == 13) {
|
|
|
|
+ onLogin(pass1, pass2)
|
|
|
|
+ if(!login){
|
|
|
|
+ history.push("/loginError")
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }}
|
|
/>
|
|
/>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div>
|
|
- <button disabled = {isLoggedIn} onClick={() => onLogin(pass1, pass2)}>Login</button>
|
|
|
|
|
|
+ <button disabled = {isLoggedIn} onClick={() => {
|
|
|
|
+ onLogin(pass1, pass2)
|
|
|
|
+ if(!login){
|
|
|
|
+ history.push("/loginError")
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }>Login</button>
|
|
<CButtonLogout />
|
|
<CButtonLogout />
|
|
</div>
|
|
</div>
|
|
|
|
|
|
@@ -145,21 +165,13 @@ const CFormReg = connect((state) => ({
|
|
const CFormLogin = connect((s) => ({state: s, isLoggedIn: s.auth.payload, login: s.auth.payload && s.auth.payload.sub.login}), {
|
|
const CFormLogin = connect((s) => ({state: s, isLoggedIn: s.auth.payload, login: s.auth.payload && s.auth.payload.sub.login}), {
|
|
onLogin:actionLogin})(PasswordConfirm);
|
|
onLogin:actionLogin})(PasswordConfirm);
|
|
|
|
|
|
-// const LoginError = () => {
|
|
|
|
-// const history = useHistory();
|
|
|
|
-// return(
|
|
|
|
-// <>
|
|
|
|
-// <div>Упс, щось пішло не так. Можливо це ім'я вже зайнято. Спробуйте ще.</div>
|
|
|
|
-// <button onClick = {() => history.push("/login")}>Перейти на сторінку регістрації</button>
|
|
|
|
-// </>
|
|
|
|
-// )}
|
|
|
|
|
|
|
|
const LoginForm = ({}) => {
|
|
const LoginForm = ({}) => {
|
|
|
|
|
|
return(
|
|
return(
|
|
<>
|
|
<>
|
|
<div className = "loginWrapper">
|
|
<div className = "loginWrapper">
|
|
- <h2>Будь ласка, увійдіть в свій аккаунд</h2>
|
|
|
|
|
|
+ <h2>Будь ласка, увійдіть в свій аккаунт</h2>
|
|
<div className = "loginForm">
|
|
<div className = "loginForm">
|
|
|
|
|
|
{/* <CDashboardLink/> */}
|
|
{/* <CDashboardLink/> */}
|