import React, { Component } from "react"; import { connect } from "react-redux"; import { Container, Form, Header, Message, Segment } from "semantic-ui-react"; import { clearAuthRequestError, clearAuthRequestSuccess, setFormPassword, setFormPasswordConfirmation, setFormOldPassword } from "../../actions/auth/reducer.actions"; import { sendChangePasswordRequest } from "../../actions/auth/saga.actions"; import Error from "../Shared/Error"; class Settings extends Component { constructor(props) { super(props); this.props.dispatch(clearAuthRequestError()); this.props.dispatch(clearAuthRequestSuccess()); } changePassword = event => { this.props.dispatch(setFormPassword(event.target.value)); }; changePasswordConfirmation = event => { this.props.dispatch(setFormPasswordConfirmation(event.target.value)); }; changeOldPassword = event => { this.props.dispatch(setFormOldPassword(event.target.value)); }; onSubmitChangePassword = event => { event.preventDefault(); const { dispatch, password, passwordConfirmation, oldPassword } = this.props; dispatch( sendChangePasswordRequest({ new_password1: password, new_password2: passwordConfirmation, old_password: oldPassword }) ); }; render() { const { isSendingAuthRequest, authRequestError, authRequestSuccess, password, passwordConfirmation, oldPassword } = this.props; return ( ); } } function mapStateToProps(state) { return { ...state.auth }; } const SettingsView = ({ isSendingAuthRequest, authRequestError, authRequestSuccess, password, passwordConfirmation, oldPassword, changePassword, changePasswordConfirmation, changeOldPassword, onSubmitChangePassword }) => ( Settings Change Password Old Password New Password Confirm New Password Password Successfully Changed! New password has been set. Change Password ); export default connect(mapStateToProps)(Settings);
New password has been set.