mirror of
https://github.com/wassname/talk.git
synced 2026-09-11 12:51:33 +08:00
Notify errors
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user