-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSigninForm.js
More file actions
54 lines (42 loc) · 1.15 KB
/
SigninForm.js
File metadata and controls
54 lines (42 loc) · 1.15 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
/* tslint:disable:no-empty */
import FormControl from '../../shared/FormControl';
import PropTypes from 'prop-types';
import React, { PureComponent } from 'react';
import './SignInForm.scss';
export class SignInForm extends PureComponent {
state = {
email: '',
password: '',
}
static propTypes = {
action: PropTypes.string.isRequired,
submit: PropTypes.func.isRequired,
}
handleSubmit = event => {
event.preventDefault();
this.props.submit(this.state)
.catch(() => {});
}
handleChange = ({ target }) => {
this.setState({ [target.email]: target.value });
}
render() {
const { action } = this.props;
const { email, password } = this.state;
return (
<form onSubmit={this.handleSubmit}>
<FormControl label="email">
<input className="form-boxes" name="email" value={email}
onChange={this.handleChange}/>
</FormControl>
<FormControl label="password">
<input className="form-boxes" name="password" value={password} type="password"
onChange={this.handleChange}/>
</FormControl>
<FormControl>
<button className="form-boxes">{action}</button>
</FormControl>
</form>
);
}
}