Files
astuto/app/javascript/containers/Comments.tsx

47 lines
1.2 KiB
TypeScript
Raw Normal View History

import { connect } from 'react-redux';
import { requestComments } from '../actions/requestComments';
import {
toggleCommentReply,
setCommentReplyBody,
} from '../actions/handleCommentReplies';
2019-09-18 13:40:00 +02:00
import { submitComment } from '../actions/submitComment';
import { State } from '../reducers/rootReducer';
import CommentsP from '../components/Comments/CommentsP';
const mapStateToProps = (state: State) => ({
comments: state.currentPost.comments.items,
replyForms: state.currentPost.comments.replyForms,
areLoading: state.currentPost.comments.areLoading,
error: state.currentPost.comments.error,
});
const mapDispatchToProps = (dispatch) => ({
2019-09-17 15:03:25 +02:00
requestComments(postId: number) {
dispatch(requestComments(postId));
},
toggleCommentReply(commentId: number) {
dispatch(toggleCommentReply(commentId));
},
setCommentReplyBody(commentId: number, body: string) {
dispatch(setCommentReplyBody(commentId, body));
},
2019-09-18 13:40:00 +02:00
submitComment(
postId: number,
body: string,
parentId: number,
authenticityToken: string,
) {
dispatch(submitComment(postId, body, parentId, authenticityToken));
},
});
export default connect(
mapStateToProps,
mapDispatchToProps,
)(CommentsP);