Skip to content

Commit

Permalink
NoCommentMessege moved in separate component, changed render logic
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksiy-uchaev committed Jan 20, 2024
1 parent 53f93ce commit 0896702
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
10 changes: 10 additions & 0 deletions src/components/Comments/NoteEmpty.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const NoteEmpty: React.FC = () => {
return (
<p
className="title is-4"
data-cy="NoCommentsMessage"
>
No comments yet
</p>
);
};
17 changes: 2 additions & 15 deletions src/components/Comments/PostDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { useContext } from 'react';
import classNames from 'classnames';
import { MainContext } from '../MainContext';
import { CommentsList } from './CommentsList';
import { Loader } from '../Notices/Loader/Loader';
Expand All @@ -8,11 +7,11 @@ import { Notification } from '../Notices/Notification';
import { Error } from '../../types/Message';
import { NewCommentForm } from '../Form/NewCommentForm';
import { AddButton } from './AddButton';
import { NoteEmpty } from './NoteEmpty';

export const PostDetails: React.FC = () => {
const {
isForm,
comments,
loadType,
currentPost,
notification,
Expand All @@ -35,19 +34,7 @@ export const PostDetails: React.FC = () => {

{notification === Error.getComments
? <Notification />
: (
<p
className={classNames('title is-4',
{ 'is-active': comments.length },
{
'is-hidden': !comments.length
|| loadType === Load.Comments,
})}
data-cy="NoCommentsMessage"
>
No comments yet
</p>
)}
: loadType === Load.None && <NoteEmpty />}

<CommentsList />
<AddButton />
Expand Down

0 comments on commit 0896702

Please sign in to comment.