mirror of
https://github.com/wassname/talk.git
synced 2026-07-01 05:59:50 +08:00
39 lines
932 B
JavaScript
39 lines
932 B
JavaScript
import React from 'react';
|
|
import styles from './styles.css';
|
|
import {addCommentTag} from 'coral-framework/graphql/mutations';
|
|
import {compose} from 'react-apollo';
|
|
|
|
class OffTopicCheckbox extends React.Component {
|
|
|
|
handleChange = (e) => {
|
|
if (e.target.checked) {
|
|
this.props.registerHook({
|
|
postSubmit: {
|
|
addTag: (data) => {
|
|
const {comment} = data.createComment;
|
|
this.props.addCommentTag({
|
|
id: comment.id,
|
|
tag: 'OFF_TOPIC',
|
|
});
|
|
}
|
|
}
|
|
})
|
|
} else {
|
|
this.props.unregisterHook('postSubmit', 'addTag');
|
|
}
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<div className={styles.offTopic}>
|
|
<label className={styles.offTopicLabel}>
|
|
<input type="checkbox" onChange={this.handleChange}/>
|
|
Off-Topic
|
|
</label>
|
|
</div>
|
|
)
|
|
}
|
|
}
|
|
|
|
export default compose(addCommentTag)(OffTopicCheckbox);
|