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

made solution #1245

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

made solution #1245

wants to merge 2 commits into from

Conversation

futdevelop
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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


Thank you for your hard work on this project! 😊 While your code is well-structured and meets many of the task requirements, there are a few critical issues that need to be addressed before we can approve the pull request:

  1. Error Handling: The use of .catch() for error handling in promises does not align with the checklist's recommendation to use try {..} catch blocks. This is important for consistency and readability.

  2. Type Safety: The use of any for the data parameter in the fetchClient.ts utility undermines TypeScript's type safety. Consider using a more specific type or a generic type parameter to enforce type safety.

  3. PropTypes: The absence of propTypes for type-checking props in your components is a significant oversight. This is crucial for ensuring that components receive the correct props and can prevent potential bugs.

  4. Display Logic: The logic for displaying the 'No posts yet' message needs adjustment to ensure it only appears when appropriate, specifically after the fetch request is completed.

Addressing these issues will greatly enhance the functionality and maintainability of your code. Keep up the great work, and I'm confident you'll nail it with these improvements! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review button in the Reviewers tab.

src/App.tsx Outdated
</div>
)}

{/* // ! Доробити щоб no posts не з'являлось перед запитом */}

Choose a reason for hiding this comment

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

The comment indicates that the 'No posts yet' message should not appear before the fetch request is completed. To address this, you might want to adjust the condition on line 62 to ensure that the message only appears when !isLoading && posts.length === 0. This way, the message will only show when there are no posts after loading is complete.

</a>
{users.map((user: User, i) => (
<a
href={`#user-${i}`}

Choose a reason for hiding this comment

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

The href attribute in the <a> tag is not necessary for the dropdown functionality and could cause unwanted page jumps. Consider removing it or using href="#" to prevent default behavior if you want to maintain the anchor tag structure.

type RequestMethod = 'GET' | 'POST' | 'PATCH' | 'DELETE';

function request<T>(
url: string,
method: RequestMethod = 'GET',
data: any = null, // we can send any data to the server
data: any = null,

Choose a reason for hiding this comment

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

The data parameter is typed as any, which can undermine the benefits of TypeScript's type safety. Consider using a more specific type or a generic type parameter to enforce type safety for the data being passed to the request function.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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


Thank you for your hard work on this project! 😊 While your implementation is mostly correct, there are a few critical issues that need to be addressed before we can approve the pull request:

  1. Conditional Rendering Issue: The 'No posts yet' message is displayed prematurely, before the posts are fetched. This affects the user experience and needs to be fixed by adding a condition to check if the fetch has been attempted.

  2. Key Generation: Using indices for key generation in the UserSelector component is not recommended as it can lead to issues with component identity. Please update this to use a more stable key.

These issues impact the functionality and user experience, so it's important to address them. Once these are fixed, your code will be in great shape! Keep up the good work, and I'm looking forward to seeing the improvements. 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review button in the Reviewers tab.

src/App.tsx Outdated
Comment on lines 61 to 68
{/* // ! Доробити щоб no posts не з'являлось перед запитом */}
{posts && posts.length > 0 ? (
<PostsList />
) : (
<div className="notification is-warning" data-cy="NoPostsYet">
No posts yet
</div>
)}

Choose a reason for hiding this comment

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

The comment indicates an intention to prevent the 'No posts yet' message from appearing before the fetch request is completed. Currently, the logic does not account for this, as the message will display if posts is an empty array, even before the fetch completes. Consider adding a condition to check if the fetch has been attempted, such as using a state variable to track if the fetch is in progress or completed.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Great job on implementing the solution! 🎉 While the core functionality is mostly correct, there are a couple of critical issues that need attention to enhance the user experience and maintainability of the code:

  1. Conditional Rendering Issue: The 'No posts yet' message is displayed prematurely. Ensure that this message is only shown after the fetch operation is complete and no posts are returned. Consider using a state variable to track whether the fetch has been initiated.

  2. Key Generation: In the UserSelector component, avoid using indices for key generation in the users.map function. Instead, use a unique and stable key, such as user.id, to prevent issues with component identity when the list changes.

These improvements are crucial for meeting the task requirements and ensuring a smooth user experience. Keep up the good work, and make sure to address these points in future iterations to avoid similar issues. Your effort and progress are commendable, and these adjustments will help you grow as a developer. Keep learning and improving! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

Comment on lines +62 to +68
{posts && posts.length > 0 ? (
<PostsList />
) : (
<div className="notification is-warning" data-cy="NoPostsYet">
No posts yet
</div>
)}

Choose a reason for hiding this comment

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

The 'No posts yet' message is displayed even before the posts are fetched. This can be misleading to users. Consider adding a condition to check if the fetch has been attempted before displaying this message. You can use a state variable to track whether the fetch has been initiated.

Comment on lines +55 to +63
{users.map((user: User, i) => (
<a
href={`#user-${i}`}
className="dropdown-item"
onClick={() => onSelect(user.id)}
>
{user.name}
</a>
))}

Choose a reason for hiding this comment

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

Using the index i as a key for list items can lead to issues with component identity, especially if the list changes. Instead, use a unique identifier from the user object, such as user.id, as the key to ensure stable component behavior.

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.

2 participants