Add comment replies toggle and body to state

This commit is contained in:
riggraz
2019-09-17 19:09:38 +02:00
parent 0c0c6d4e30
commit ecfdc54100
8 changed files with 191 additions and 4 deletions

View File

@@ -1,6 +1,10 @@
import { connect } from 'react-redux';
import { requestComments } from '../actions/requestComments';
import {
toggleCommentReply,
setCommentReplyBody,
} from '../actions/handleCommentReplies';
import { State } from '../reducers/rootReducer';
@@ -8,6 +12,7 @@ import CommentsP from '../components/Comments/CommentsP';
const mapStateToProps = (state: State) => ({
comments: state.currentPost.comments.items,
replies: state.currentPost.comments.replies,
areLoading: state.currentPost.comments.areLoading,
error: state.currentPost.comments.error,
});
@@ -16,6 +21,14 @@ const mapDispatchToProps = (dispatch) => ({
requestComments(postId: number) {
dispatch(requestComments(postId));
},
toggleCommentReply(commentId: number) {
dispatch(toggleCommentReply(commentId));
},
setCommentReplyBody(commentId: number, body: string) {
dispatch(setCommentReplyBody(commentId, body));
},
});
export default connect(