diff --git a/src/AC/index.js b/src/AC/index.js
index dda2dd6..235100d 100644
--- a/src/AC/index.js
+++ b/src/AC/index.js
@@ -1,4 +1,4 @@
-import {INCREMENT, DELETE_ARTICLE, CHANGE_DATE_RANGE, CHANGE_SELECTION} from '../constants'
+import {INCREMENT, DELETE_ARTICLE, CHANGE_DATE_RANGE, CHANGE_SELECTION, ADD_COMMENT} from '../constants'
export function increment() {
return {
@@ -26,3 +26,10 @@ export function changeSelection(selected) {
payload: { selected }
}
}
+
+export function addComment(comment, user, articleId) {
+ return {
+ type: ADD_COMMENT,
+ payload: { comment, user, articleId }
+ }
+}
diff --git a/src/components/article/index.js b/src/components/article/index.js
index 96261d8..32fe613 100644
--- a/src/components/article/index.js
+++ b/src/components/article/index.js
@@ -4,6 +4,8 @@ import CSSTransition from 'react-addons-css-transition-group'
import { connect } from 'react-redux'
import CommentList from '../comment-list'
import { deleteArticle } from '../../AC'
+import { articleListSelector } from '../../selectors'
+
import './style.css'
class Article extends PureComponent {
@@ -58,7 +60,7 @@ function getBody(article) {
return (
)
}
@@ -73,4 +75,10 @@ Article.propTypes = {
onButtonClick: PropTypes.func
}
-export default connect(null, { deleteArticle })(Article)
\ No newline at end of file
+export default connect(/*state => {
+ console.log('---', 'article connect')
+ console.log(this.props)
+ return {
+ article: articleListSelector(state)
+ }
+}*/null, { deleteArticle })(Article)
diff --git a/src/components/comment-list/index.js b/src/components/comment-list/index.js
index 91c4f08..7845b82 100644
--- a/src/components/comment-list/index.js
+++ b/src/components/comment-list/index.js
@@ -3,13 +3,15 @@ import PropTypes from 'prop-types'
import CSSTransition from 'react-addons-css-transition-group'
import Comment from '../comment'
import toggleOpen from '../../decorators/toggleOpen'
+import { connect } from 'react-redux'
+import { addComment } from '../../AC'
import './style.css'
class CommentList extends Component {
static defaultProps = {
comments: []
}
-
+addComment
static propTypes = {
comments: PropTypes.array.isRequired,
//from toggleOpen decorator
@@ -51,6 +53,7 @@ class CommentList extends Component {
getComments() {
return (
+
{
this.props.comments.map(id =>
@@ -59,9 +62,17 @@ class CommentList extends Component {
)
}
+
+
)
}
+ handleAdd = () => {
+ const { addComment, comment, user, articleId } = this.props
+ addComment('comment', 'user', articleId)
+ }
}
-export default toggleOpen(CommentList)
\ No newline at end of file
+export default connect(null, { addComment })(toggleOpen(CommentList))
diff --git a/src/components/filters/select.js b/src/components/filters/select.js
index 1a91857..139056e 100644
--- a/src/components/filters/select.js
+++ b/src/components/filters/select.js
@@ -8,18 +8,20 @@ import 'react-select/dist/react-select.css'
class SelectFilter extends Component {
static propTypes = {
- articles: PropTypes.array.isRequired
+ articles: PropTypes.object.isRequired
};
handleChange = selected => this.props.changeSelection(selected.map(option => option.value))
render() {
const { articles, selected } = this.props
- const options = articles.map(article => ({
- label: article.title,
- value: article.id
- }))
-
+ const options = [];
+ for(var id in articles) {
+ options.push({
+ label: articles[id].title,
+ value: id
+ })
+ }
return