LoginForm.js 884 B

123456789101112131415161718192021222324252627282930313233
  1. import React from 'react'
  2. import { Field, reduxForm } from 'redux-form';
  3. import './login.scss';
  4. let LoginForm = props => {
  5. const { handleSubmit, postLoginSubmit, history } = props;
  6. const submit = value => {
  7. postLoginSubmit(value);
  8. history.push('/profile');
  9. };
  10. return (
  11. <form className="form" onSubmit={handleSubmit(submit)}>
  12. <div>
  13. <label htmlFor="email">E-mail</label>
  14. <Field name="email" component="input" type="text" id="email" />
  15. </div>
  16. <div>
  17. <label htmlFor="password">Password</label>
  18. <Field name="password" component="input" type="text" id="password" />
  19. </div>
  20. <button type="submit">Sign in</button>
  21. </form>
  22. )
  23. };
  24. LoginForm = reduxForm({
  25. form: 'login'
  26. })(LoginForm)
  27. export default LoginForm