-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathSignInForm.js
More file actions
35 lines (31 loc) · 1.05 KB
/
SignInForm.js
File metadata and controls
35 lines (31 loc) · 1.05 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
import React, { Component } from 'react'
import {connect} from 'react-redux'
import {reduxForm, Field} from 'redux-form'
import ErrorField from '../common/ErrorField'
import Loader from '../common/Loader'
import {loadingSelector, errorSelector} from '../../ducks/auth'
class SignInForm extends Component {
static propTypes = {
};
render() {
const {loading, authError} = this.props
return (
<div>
<h3>Sign In</h3>
<form onSubmit={this.props.handleSubmit}>
<Field name='email' component={ErrorField}/>
<Field name='password' component={ErrorField} type='password'/>
{authError && <h2 style={{color: 'red'}}>{authError}</h2>}
{loading && <Loader />}
<input type='submit' />
</form>
</div>
)
}
}
export default connect(state => ({
loading: loadingSelector(state),
authError: errorSelector(state)
}))(reduxForm({
form: 'auth'
})(SignInForm))