Containers

This commit is contained in:
Belen Curcio
2017-09-11 15:02:01 -03:00
parent 06c45faeb0
commit 51f6c0738d
2 changed files with 51 additions and 15 deletions
@@ -1,16 +1,24 @@
import React from 'react';
import {withSetCommentStatus} from 'plugin-api/beta/client/hocs';
import {compose} from 'react-apollo';
import {bindActionCreators} from 'redux';
import {getErrorMessages} from 'plugin-api/beta/client/utils';
import {notify} from 'plugin-api/beta/client/actions/notification';
import ApproveCommentAction from '../components/ApproveCommentAction';
import {connect, withSetCommentStatus} from 'plugin-api/beta/client/hocs';
class ApproveCommentActionContainer extends React.Component {
approveComment = () => {
const {setCommentStatus, comment} = this.props;
setCommentStatus({
commentId: comment.id,
status: 'ACCEPTED'
});
try {
setCommentStatus({
commentId: comment.id,
status: 'ACCEPTED'
});
} catch (err) {
notify('error', getErrorMessages(err));
}
}
render() {
@@ -18,4 +26,14 @@ class ApproveCommentActionContainer extends React.Component {
}
}
export default withSetCommentStatus(ApproveCommentActionContainer);
const mapDispatchToProps = (dispatch) =>
bindActionCreators({
notify,
}, dispatch);
const enhance = compose(
connect(null, mapDispatchToProps),
withSetCommentStatus
);
export default enhance(ApproveCommentActionContainer);
@@ -1,16 +1,24 @@
import React from 'react';
import {withSetCommentStatus} from 'plugin-api/beta/client/hocs';
import {compose} from 'react-apollo';
import {bindActionCreators} from 'redux';
import {getErrorMessages} from 'plugin-api/beta/client/utils';
import {notify} from 'plugin-api/beta/client/actions/notification';
import RejectCommentAction from '../components/RejectCommentAction';
import {connect, withSetCommentStatus} from 'plugin-api/beta/client/hocs';
class RejectCommentActionContainer extends React.Component {
rejectComment = () => {
approveComment = () => {
const {setCommentStatus, comment} = this.props;
setCommentStatus({
commentId: comment.id,
status: 'REJECTED'
});
try {
setCommentStatus({
commentId: comment.id,
status: 'REJECTED'
});
} catch (err) {
notify('error', getErrorMessages(err));
}
}
render() {
@@ -18,4 +26,14 @@ class RejectCommentActionContainer extends React.Component {
}
}
export default withSetCommentStatus(RejectCommentActionContainer);
const mapDispatchToProps = (dispatch) =>
bindActionCreators({
notify,
}, dispatch);
const enhance = compose(
connect(null, mapDispatchToProps),
withSetCommentStatus
);
export default enhance(RejectCommentActionContainer);