Skip to content

Commit

Permalink
fixed comment list
Browse files Browse the repository at this point in the history
  • Loading branch information
daniil-trusov committed Mar 4, 2025
1 parent ff182dd commit 4c4b381
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
18 changes: 7 additions & 11 deletions src/components/CommentList/CommentList.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import './CommentList.scss';
import { CommentInfo } from '../CommentInfo/index';

export const CommentList = ({ comments }) => {
return comments.length === 0 ? (
<b data-cy="NoCommentsMessage">No comments yet</b>
) : (
<div className="CommentList">
{comments.map(comment => (
<CommentInfo comment={comment} key={comment.id} />
))}
</div>
);
};
export const CommentList = ({ comments }) => (
<div className="CommentList">
{comments.map(comment => (
<CommentInfo comment={comment} key={comment.id} />
))}
</div>
);
10 changes: 9 additions & 1 deletion src/components/PostInfo/PostInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ export const PostInfo = ({ post }) => {
</div>

<p className="PostInfo__body">{body}</p>
<CommentList comments={comments} />

{comments.length === 0 ? (
<>
<hr />
<b data-cy="NoCommentsMessage">No comments yet</b>
</>
) : (
<CommentList comments={comments} />
)}
</div>
);
};

0 comments on commit 4c4b381

Please sign in to comment.