Adding a notification after saving

This commit is contained in:
okbel
2018-04-24 13:39:13 -03:00
parent eaf0df9573
commit 37919a11ab
3 changed files with 27 additions and 7 deletions
@@ -9,6 +9,7 @@ import isEqual from 'lodash/isEqual';
import { t } from 'plugin-api/beta/client/services';
import Form from './Form';
import InputField from './InputField';
import { getErrorMessages } from 'coral-framework/utils';
const initialState = {
editing: false,
@@ -106,10 +107,18 @@ class ChangePassword extends React.Component {
onSave = async () => {
const { oldPassword, newPassword } = this.state.formData;
await this.props.changePassword({
oldPassword,
newPassword,
});
try {
await this.props.changePassword({
oldPassword,
newPassword,
});
this.props.notify(
'success',
t('talk-plugin-auth.change_password.changed_password_msg')
);
} catch (err) {
this.props.notify('error', getErrorMessages(err));
}
this.clearForm();
this.disableEditing();
@@ -208,7 +217,8 @@ class ChangePassword extends React.Component {
}
ChangePassword.propTypes = {
changePassword: PropTypes.func,
changePassword: PropTypes.func.isRequired,
notify: PropTypes.func.isRequired,
};
export default ChangePassword;
@@ -1,4 +1,12 @@
import { withChangePassword } from 'plugin-api/beta/client/hocs';
import { compose } from 'react-apollo';
import { bindActionCreators } from 'redux';
import { connect } from 'plugin-api/beta/client/hocs';
import ChangePassword from '../components/ChangePassword';
import { notify } from 'coral-framework/actions/notification';
import { withChangePassword } from 'plugin-api/beta/client/hocs';
export default withChangePassword(ChangePassword);
const mapDispatchToProps = dispatch => bindActionCreators({ notify }, dispatch);
export default compose(connect(null, mapDispatchToProps), withChangePassword)(
ChangePassword
);
@@ -139,6 +139,7 @@ en:
save: "Save"
cancel: "Cancel"
edit: "Edit"
changed_password_msg: "Changed Password - Your password has been successfully changed"
de:
talk-plugin-auth:
login:
@@ -238,6 +239,7 @@ es:
save: "Guardar"
cancel: "Cancelar"
edit: "Editar"
changed_password_msg: "Contraseña Actualizada - Tu contraseña ha sido exitosamente actualizada"
fr:
talk-plugin-auth:
login: