No need to handle errors here

This commit is contained in:
Belen Curcio
2017-09-11 11:02:02 -03:00
parent 908b3c20b4
commit 65085fea65
2 changed files with 10 additions and 34 deletions
@@ -1,28 +1,16 @@
import React from 'react';
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';
import isNil from 'lodash/isNil';
class ApproveCommentActionContainer extends React.Component {
approveComment = async () => {
approveComment = () => {
const {setCommentStatus, comment} = this.props;
try {
const result = await setCommentStatus({
commentId: comment.id,
status: 'ACCEPTED'
});
if (!isNil(result.data.setCommentStatus)) {
throw result.data.setCommentStatus.errors;
}
} catch (err) {
notify('error', getErrorMessages(err));
}
setCommentStatus({
commentId: comment.id,
status: 'ACCEPTED'
});
}
render() {
@@ -1,28 +1,16 @@
import React from 'react';
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';
import isNil from 'lodash/isNil';
class RejectCommentActionContainer extends React.Component {
rejectComment = async () => {
rejectComment = () => {
const {setCommentStatus, comment} = this.props;
try {
const result = await setCommentStatus({
commentId: comment.id,
status: 'REJECTED'
});
if (!isNil(result.data.setCommentStatus)) {
throw result.data.setCommentStatus.errors;
}
} catch (err) {
notify('error', getErrorMessages(err));
}
setCommentStatus({
commentId: comment.id,
status: 'REJECTED'
});
}
render() {