Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react'
- import { connect } from 'react-redux'
- import { reduxForm } from 'redux-form'
- import { catchForm } from 'core/Form'
- import { requestPasswordReset } from './actions'
- export class RequestResetPasswordComponent extends React.Component {
- constructor(props) {
- super(props)
- this.state = {
- finished: false,
- }
- }
- render() {
- const { error, handleSubmit, onSubmit } = this.props
- const { finished } = this.state
- return (
- <div>
- { !finished &&
- <form onSubmit={handleSubmit(onSubmit)}>
- </form>
- }
- { finished &&
- <p>Done</p>
- }
- </div>
- )
- }
- }
- let mapStateToProps = (state) => {
- return {
- }
- }
- let mapDispatchToProps = (dispatch, ownProps) => {
- return {
- onSubmit: (data) => {
- return requestPasswordReset(data, dispatch)
- .catch(catchForm)
- .then(ownProps.setFinished)
- },
- }
- }
- const RequestResetPassword = connect(mapStateToProps, mapDispatchToProps)(RequestResetPasswordComponent)
- RequestResetPassword.defaultProps = {
- setFinished: () => {
- this.setState({ finished: true });
- }
- }
- export default reduxForm({
- form: 'forgot-password',
- })(RequestResetPassword)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement