Skip to content

Commit

Permalink
improved code
Browse files Browse the repository at this point in the history
  • Loading branch information
Bonum-taurus committed Aug 31, 2023
1 parent 8bdff58 commit e134d85
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
2 changes: 0 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export const App: React.FC = () => {
const [comments, setComments] = useState<Comment[]>([]);
const [currentPostId, setCurrentPostId] = useState(0);
const [showSpinnerComments, setShowSpinnerComments] = useState(false);
// const [isNotComments, setIsNotComments] = useState(false);
const [isErrorComments, setIsErrorComments] = useState(false);
const [openForm, setOpenForm] = useState(false);

Expand Down Expand Up @@ -162,7 +161,6 @@ export const App: React.FC = () => {
comments={comments}
currentPost={currentPost}
showSpinner={showSpinnerComments}
// isNotComments={isNotComments}
isErrorComments={isErrorComments}
openForm={openForm}
setOpenForm={setOpenForm}
Expand Down
16 changes: 8 additions & 8 deletions src/components/PostDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ type Props = {
comments: Comment[],
currentPost: Post,
showSpinner: boolean,
// isNotComments: boolean,
isErrorComments: boolean,
openForm: boolean,
setOpenForm: (value: boolean) => void,
Expand All @@ -22,7 +21,6 @@ export const PostDetails: React.FC<Props> = ({
currentPost,
comments,
showSpinner,
// isNotComments,
isErrorComments,
openForm,
setOpenForm,
Expand Down Expand Up @@ -69,18 +67,20 @@ export const PostDetails: React.FC<Props> = ({
&& <p className="title is-4">Comments:</p>}

{!isErrorComments && comments.map(
comment => (
({
id, email, name, body,
}) => (
<article
key={comment.id}
key={id}
className="message is-small"
data-cy="Comment"
>
<div className="message-header">
<a href={`mailto:${comment.email}`} data-cy="CommentAuthor">
{comment.name}
<a href={`mailto:${email}`} data-cy="CommentAuthor">
{name}
</a>
<button
onClick={() => hendleDeleteComment(comment.id)}
onClick={() => hendleDeleteComment(id)}
data-cy="CommentDelete"
type="button"
className="delete is-small"
Expand All @@ -91,7 +91,7 @@ export const PostDetails: React.FC<Props> = ({
</div>

<div className="message-body" data-cy="CommentBody">
{comment.body}
{body}
</div>
</article>
),
Expand Down

0 comments on commit e134d85

Please sign in to comment.