Fully working offtopic

This commit is contained in:
Belen Curcio
2017-05-17 11:19:06 -03:00
parent 9dc0693530
commit b2f1707f17
6 changed files with 29 additions and 5 deletions
@@ -1,13 +1,23 @@
import React from 'react';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {addTag, removeTag} from 'coral-plugin-commentbox/actions';
import {addTag, removeTag, clearTags} from 'coral-plugin-commentbox/actions';
import styles from './styles.css';
class OffTopicCheckbox extends React.Component {
label = 'OFF_TOPIC';
componentDidMount() {
this.clearTagsHook = this.props.registerHook('postSubmit', (data) => {
this.props.clearTags();
});
}
componentWillUnmount() {
this.props.unregisterHook(this.clearTagsHook);
}
handleChange = (e) => {
if (e.target.checked) {
this.props.addTag(this.label)
@@ -33,6 +43,6 @@ class OffTopicCheckbox extends React.Component {
const mapStateToProps = ({commentBox}) => ({commentBox});
const mapDispatchToProps = dispatch =>
bindActionCreators({addTag, removeTag}, dispatch);
bindActionCreators({addTag, removeTag, clearTags}, dispatch);
export default connect(mapStateToProps, mapDispatchToProps)(OffTopicCheckbox);