mirror of
https://github.com/wassname/talk.git
synced 2026-07-03 09:12:07 +08:00
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
import React from 'react';
|
|
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 = async () => {
|
|
const { setCommentStatus, comment, hideMenu, notify } = this.props;
|
|
|
|
try {
|
|
await setCommentStatus({
|
|
commentId: comment.id,
|
|
status: 'REJECTED',
|
|
});
|
|
} catch (err) {
|
|
notify('error', getErrorMessages(err));
|
|
}
|
|
|
|
hideMenu();
|
|
};
|
|
|
|
render() {
|
|
return <RejectCommentAction rejectComment={this.rejectComment} />;
|
|
}
|
|
}
|
|
|
|
const mapDispatchToProps = dispatch =>
|
|
bindActionCreators(
|
|
{
|
|
notify,
|
|
},
|
|
dispatch
|
|
);
|
|
|
|
const enhance = compose(
|
|
connect(null, mapDispatchToProps),
|
|
withSetCommentStatus
|
|
);
|
|
|
|
export default enhance(RejectCommentActionContainer);
|