This commit is contained in:
Belen Curcio
2017-04-11 13:46:27 -03:00
parent aeaa9ae80f
commit 536b2ed371
4 changed files with 28 additions and 16 deletions
@@ -1,15 +1,20 @@
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.addCommentHooks({
postSubmit: {
addTag: (data) => {
console.log('This is a hook after posting')
const {comment} = data.createComment;
this.props.addCommentTag({
id: comment.id,
tag: 'OFF_TOPIC',
});
}
}
})
@@ -23,9 +28,6 @@ class OffTopicCheckbox extends React.Component {
}
render() {
return (
<div className={styles.offTopic}>
<label>
@@ -37,4 +39,4 @@ class OffTopicCheckbox extends React.Component {
}
}
export default OffTopicCheckbox;
export default compose(addCommentTag)(OffTopicCheckbox);
@@ -1,8 +1,18 @@
import React from 'react';
import styles from './styles.css';
const isOffTopic = (tags) => {
return !!tags.filter(tag => tag.name === 'OFF_TOPIC').length
}
export default (props) => (
<span className={styles.tag}>
Off-topic
<span>
{
isOffTopic(props.comment.tags) ? (
<span className={styles.tag}>
Off-topic
</span>
) : null
}
</span>
);