Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. import React from 'react'
  2. import { connect } from 'react-redux'
  3.  
  4. import { reduxForm } from 'redux-form'
  5. import { catchForm } from 'core/Form'
  6.  
  7. import { requestPasswordReset } from './actions'
  8.  
  9. export class RequestResetPasswordComponent extends React.Component {
  10.  
  11. constructor(props) {
  12. super(props)
  13. this.state = {
  14. finished: false,
  15. }
  16. }
  17.  
  18. render() {
  19. const { error, handleSubmit, onSubmit } = this.props
  20. const { finished } = this.state
  21. return (
  22. <div>
  23. { !finished &&
  24. <form onSubmit={handleSubmit(onSubmit)}>
  25. </form>
  26. }
  27.  
  28. { finished &&
  29. <p>Done</p>
  30. }
  31. </div>
  32. )
  33. }
  34.  
  35. }
  36.  
  37. let mapStateToProps = (state) => {
  38. return {
  39. }
  40. }
  41.  
  42. let mapDispatchToProps = (dispatch, ownProps) => {
  43. return {
  44. onSubmit: (data) => {
  45. return requestPasswordReset(data, dispatch)
  46. .catch(catchForm)
  47. .then(ownProps.setFinished)
  48. },
  49. }
  50. }
  51.  
  52. const RequestResetPassword = connect(mapStateToProps, mapDispatchToProps)(RequestResetPasswordComponent)
  53.  
  54. RequestResetPassword.defaultProps = {
  55. setFinished: () => {
  56. this.setState({ finished: true });
  57. }
  58. }
  59.  
  60. export default reduxForm({
  61. form: 'forgot-password',
  62. })(RequestResetPassword)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement