Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #1153

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Develop #1153

wants to merge 3 commits into from

Conversation

yaros-dev
Copy link

Copy link

@volodymyr-soltys97 volodymyr-soltys97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job 👍
Let's make your code better

src/App.tsx Outdated
setIsLoading(true);
setPostLoadingFail(false);
getPosts(selectedUser.id)
.then(data => setPosts(data))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.then(data => setPosts(data))
.then(setPosts)

src/App.tsx Outdated
}, [selectedUser]);

const showPostTost =
posts.length === 0 && !isLoading && selectedUser && !postLoadingFail;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
posts.length === 0 && !isLoading && selectedUser && !postLoadingFail;
!posts.length && !isLoading && selectedUser && !postLoadingFail;

src/App.tsx Outdated

<PostsList />
{posts.length > 0 && !isLoading && (

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{posts.length > 0 && !isLoading && (
{!!posts.length && !isLoading && (

</button>
</div>
deleteComment(commentId).catch(() => {
// Опционально: можно добавить обработку ошибок для восстановления удалённого комментария

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment must be on English

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I`m use chatgpt because i want to better understand how writing nice code and logic. However i know than it bad practice. maybe)

>
<div className="message-header">
<a href={`mailto:${comment.email}`} data-cy="CommentAuthor">
{comment.name}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use destructuring for comment

delete button
</button>
</div>
{!isLoading && !isError && comments.length === 0 && (

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{!isLoading && !isError && comments.length === 0 && (
{!isLoading && !isError && !comments.length && (

Comment on lines 64 to 68
onClick={() => {
setSelectedUserState(user);
setDropdownOpen(false);
setSelectedUser(user);
}}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this logic from jsx to the helper function and use it here

Copy link

@anastasiiavorobiova anastasiiavorobiova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants