-
Notifications
You must be signed in to change notification settings - Fork 102
Expand file tree
/
Copy pathLogin.js
More file actions
88 lines (81 loc) · 2.6 KB
/
Login.js
File metadata and controls
88 lines (81 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import React, { Component } from "react";
// import { Route, Link } from "react-router-dom";
class Login extends Component {
constructor() {
super();
this.state = {
email: "",
password: ""
};
}
canBeSubmitted() {
const { password } = this.state;
if (password.length > 4) {
return true;
}
return false;
}
handleOnChange = evt => {
this.setState({ [evt.target.name]: evt.target.value, emailError: false });
};
//debe de ir en un action
handleLoginSubmit = evt => {
evt.preventDefault();
const { email, password } = this.state;
this.props.loginUser(email,password,this.props.closeModal);
};
render() {
let { error } = this.props.user;
return (
<div className="login-form">
<div className="row">
<div className="col-6 mx-auto mt-5">
<h1>Login Form </h1>
<div className="col-12">
<form onSubmit={this.handleLoginSubmit}>
<div className="form-group">
<label htmlFor="exampleInputEmail1">Email address</label>
<input
type="email"
className={`form-control ${error ? "is-invalid" : ""}`}
id="exampleInputEmail1"
aria-describedby="emailHelp"
placeholder="10seconds@gmail.com"
name="email"
onChange={this.handleOnChange}
/>
<small id="emailHelp" className="form-text">
We'll never share your email with anyone else.
</small>
</div>
<div className="form-group">
<label htmlFor="exampleInputPassword1">Password</label>
<input
type="password"
className="form-control"
id="exampleInputPassword1"
placeholder="Password"
name="password"
onChange={this.handleOnChange}
/>
<small id="emailHelp" className="form-text">
Minimum password length should be greater than 4.
</small>
</div>
<button
type="submit"
className="btn btn-primary"
disabled={!this.canBeSubmitted()}
onClick={this.handleLoginSubmit}
>
Submit
</button>
</form>
</div>
</div>
</div>
</div>
);
}
}
export default Login;