mirror of
https://github.com/astuto/astuto.git
synced 2025-12-15 19:27:52 +01:00
Add basic version of Comments component
This commit is contained in:
41
app/javascript/components/Comments/CommentsP.tsx
Normal file
41
app/javascript/components/Comments/CommentsP.tsx
Normal 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;
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user