Notify errors

This commit is contained in:
Belen Curcio
2017-09-12 14:08:19 -03:00
parent 297b905163
commit 0e7d74559f
2 changed files with 47 additions and 13 deletions
@@ -1,16 +1,25 @@
import React from 'react';
import {bindActionCreators} from 'redux';
import {connect} from 'plugin-api/beta/client/hocs';
import {getErrorMessages} from 'plugin-api/beta/client/utils';
import {withSetCommentStatus} from 'plugin-api/beta/client/hocs';
import {notify} from 'plugin-api/beta/client/actions/notification';
import ApproveCommentAction from '../components/ApproveCommentAction';
class ApproveCommentActionContainer extends React.Component {
approveComment = () => {
const {setCommentStatus, comment, hideTooltip} = this.props;
approveComment = async () => {
const {setCommentStatus, comment, hideTooltip, notify} = this.props;
setCommentStatus({
commentId: comment.id,
status: 'ACCEPTED'
});
try {
await setCommentStatus({
commentId: comment.id,
status: 'ACCEPTED'
});
}
catch(err) {
notify('error', getErrorMessages(err));
}
hideTooltip();
}
@@ -20,4 +29,12 @@ class ApproveCommentActionContainer extends React.Component {
}
}
export default withSetCommentStatus(ApproveCommentActionContainer);
const mapDispatchToProps = (dispatch) =>
bindActionCreators({
notify
}, dispatch);
export default compose(
withSetCommentStatus,
connect(null, mapDispatchToProps)
)(ApproveCommentActionContainer);
@@ -1,16 +1,25 @@
import React from 'react';
import {bindActionCreators} from 'redux';
import {connect} from 'plugin-api/beta/client/hocs';
import {getErrorMessages} from 'plugin-api/beta/client/utils'
import {withSetCommentStatus} from 'plugin-api/beta/client/hocs';
import {notify} from 'plugin-api/beta/client/actions/notification';
import RejectCommentAction from '../components/RejectCommentAction';
class RejectCommentActionContainer extends React.Component {
rejectComment = () => {
const {setCommentStatus, comment, hideTooltip} = this.props;
const {setCommentStatus, comment, hideTooltip, notify} = this.props;
setCommentStatus({
commentId: comment.id,
status: 'REJECTED'
});
try {
await setCommentStatus({
commentId: comment.id,
status: 'REJECTED'
});
}
catch(err) {
notify('error', getErrorMessages(err));
}
hideTooltip();
}
@@ -20,4 +29,12 @@ class RejectCommentActionContainer extends React.Component {
}
}
export default withSetCommentStatus(RejectCommentActionContainer);
const mapDispatchToProps = (dispatch) =>
bindActionCreators({
notify
}, dispatch);
export default compose(
withSetCommentStatus,
connect(null, mapDispatchToProps)
)(RejectCommentActionContainer);