|
@@ -1,29 +1,41 @@
|
|
|
import React from 'react';
|
|
|
import { reduxForm, Field } from 'redux-form';
|
|
|
-import { connect } from 'react-redux'
|
|
|
+import { connect } from 'react-redux';
|
|
|
+import { bindActionCreators } from 'redux';
|
|
|
+
|
|
|
import validate from './validate';
|
|
|
import formInput from './../../../common/formInput';
|
|
|
|
|
|
class Form extends React.Component {
|
|
|
|
|
|
- submit(values) {
|
|
|
- const { } = this.props;
|
|
|
- console.log('Submit', values);
|
|
|
- // TODO: request
|
|
|
+ submit = ({ email, password }) => {
|
|
|
+ const { signIn } = this.props;
|
|
|
+ signIn({
|
|
|
+ email,
|
|
|
+ password
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
- const { handleSubmit } = this.props;
|
|
|
+ const { handleSubmit, error } = this.props;
|
|
|
|
|
|
return (
|
|
|
- <form className="text-center">
|
|
|
+ <form className="text-center" onSubmit={handleSubmit(this.submit)}>
|
|
|
+ {
|
|
|
+ error
|
|
|
+ ?
|
|
|
+ <p className="text-af text-uppercase">{error}</p>
|
|
|
+ :
|
|
|
+ null
|
|
|
+ }
|
|
|
+
|
|
|
<div className="form-group">
|
|
|
- <label>Email address</label>
|
|
|
+ <label className="text-uppercase">Email address</label>
|
|
|
<Field type="email" name='email' className="form-control" placeholder="name@example.com" component={formInput} />
|
|
|
</div>
|
|
|
|
|
|
<div className="form-group">
|
|
|
- <label>Password</label>
|
|
|
+ <label className="text-uppercase">Password</label>
|
|
|
<Field type="password" name='password' className="form-control" placeholder="example123" component={formInput} />
|
|
|
</div>
|
|
|
|
|
@@ -33,11 +45,7 @@ class Form extends React.Component {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-const mapStateToProps = state => ({
|
|
|
- user: state.user
|
|
|
-})
|
|
|
-
|
|
|
-export default connect(mapStateToProps, null)(reduxForm({
|
|
|
+export default reduxForm({
|
|
|
form: "SignIn",
|
|
|
validate
|
|
|
-})(Form))
|
|
|
+})(Form)
|