RegistrationForm.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import React from 'react'
  2. import { Field, reduxForm } from 'redux-form';
  3. import './registrationForm.scss';
  4. import { customInput } from "../customFields/customInput/customInput";
  5. import { validationForms } from "../../utils/validationForms";
  6. let RegistrationForm = props => {
  7. const { handleSubmit, postCheckInSubmit, message } = props;
  8. const submit = value => {
  9. //console.log(value);
  10. postCheckInSubmit(value);
  11. if(message !== 'User was successfully register'){
  12. //console.log(message);
  13. props.history.push('/login');
  14. }
  15. };
  16. return (
  17. <form className="form" onSubmit={handleSubmit(submit)}>
  18. <div className="form-item">
  19. <Field name="name" component={customInput} type="text" id="name" label="Full name" />
  20. </div>
  21. <div className="reg-radio form-item">
  22. <div className="radio-label">
  23. <Field name="sex" component="input" type="radio" id="male" value="male" hidden/>
  24. <label htmlFor="male">male</label>
  25. </div>
  26. <div className="radio-label">
  27. <Field name="sex" component="input" type="radio" id="female" value="female" hidden/>
  28. <label htmlFor="female">female</label>
  29. </div>
  30. <div className="required-field">!Required field</div>
  31. </div>
  32. <div className="form-item">
  33. <Field name="phone" component={customInput} type="phone" id="phone" label="Phone" />
  34. </div>
  35. <div className="form-item">
  36. <Field name="email" component={customInput} type="email" id="email" label="E-mail" />
  37. </div>
  38. <div className="form-item password">
  39. <Field name="password" component={customInput} type="password" id="password" label="Password" />
  40. </div>
  41. <div className="form-item password">
  42. <Field name="confirmPassword" component={customInput} type="password" id="confirmPassword" label="Confirm Password" />
  43. </div>
  44. <div className="btn-group">
  45. <button type="submit" className="btn">Check in</button>
  46. </div>
  47. </form>
  48. )
  49. };
  50. RegistrationForm = reduxForm({
  51. form: 'registration',
  52. validate: validationForms
  53. })(RegistrationForm)
  54. export default RegistrationForm