Add basic version of Comments component

This commit is contained in:
riggraz
2019-09-17 11:33:18 +02:00
parent d05202a2d7
commit b40ddfd543
17 changed files with 389 additions and 10 deletions

View File

@@ -0,0 +1,41 @@
import * as React from 'react';
import IComment from '../../interfaces/IComment';
interface Props {
postId: number;
comments: Array<IComment>;
areLoading: boolean;
error: string;
page: number;
haveMore: boolean;
requestComments(postId: number, page?: number);
}
class CommentsP extends React.Component<Props> {
componentDidMount() {
this.props.requestComments(this.props.postId);
}
render() {
const {
comments,
areLoading,
error,
page,
haveMore,
} = this.props;
return (
<div>
{comments.map((comment, i) => (
<div key={i}>{comment.body}</div>
))}
</div>
);
}
}
export default CommentsP;

View File

@@ -5,6 +5,7 @@ import IPostStatus from '../../interfaces/IPostStatus';
import PostStatusSelect from './PostStatusSelect';
import PostStatusLabel from '../shared/PostStatusLabel';
import Comments from '../../containers/Comments';
interface Props {
postId: number;
@@ -15,6 +16,7 @@ interface Props {
authenticityToken: string;
requestPost(postId: number): void;
requestComments(postId: number, page?: number): void;
changePostStatus(
postId: number,
newPostStatusId: number,
@@ -57,6 +59,8 @@ class PostP extends React.Component<Props> {
}
<p>{post.description}</p>
<Comments postId={this.props.postId} />
</div>
);
}