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

add task solution #1134

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

Conversation

DariaFesiun
Copy link

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! Your implementation is quite comprehensive and meets many of the task requirements. However, there are a few critical issues that need to be addressed before we can approve the pull request:

  1. Sorting Logic: The sortParams function has a logical error. It should toggle between ascending and descending order when the current sort value matches the column. Currently, it sets the order to 'desc', which might not toggle correctly. Please revise this logic to ensure proper toggling between 'asc' and 'desc'.

  2. noPeople Condition: The condition currently checks if people.length === 0, which may not accurately reflect the filtered results. It would be more accurate to check filteredAndSortedPeople.length to ensure the message corresponds to the filtered data.

  3. Sorting Logic Clarity: While using comparison * -1 works for reversing order, it's more idiomatic in JavaScript to use -comparison. This change would enhance the readability and maintainability of your code.

Once these issues are addressed, your code will be in great shape! Keep up the excellent 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.

Comment on lines +26 to +28
return sort === value
? { sort, order: 'desc' }
: { sort: value, order: null };

Choose a reason for hiding this comment

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

The logic in sortParams seems incorrect. When the current sort value matches the column, it should toggle between ascending and descending order. The current logic sets the order to 'desc' when the sort matches, which might not toggle correctly. Consider revising this logic to handle toggling between 'asc' and 'desc' properly.

const [searchParams] = useSearchParams();

const hasError = !isLoading && error;
const noPeople = !isLoading && people.length === 0;

Choose a reason for hiding this comment

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

The noPeople condition checks if people.length === 0, which might not be accurate if the filtering results in an empty list. Consider checking filteredAndSortedPeople.length instead to ensure the message reflects the filtered results.

Comment on lines 58 to 59

return order === 'desc' ? comparison * -1 : comparison;

Choose a reason for hiding this comment

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

The sorting logic uses comparison * -1 to reverse the order for descending. While this works, it might be clearer to use -comparison for negating the comparison result, which is more idiomatic in JavaScript.

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.

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: 7]

If the issue is within your control, please address it.
The next review attempt will automatically launch in 1 hour.
If you believe this is an error or need assistance, please contact the support team.

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 addressing the issues previously mentioned! 🎉 Your code now meets the task requirements and constraints as specified. Here are some key points to consider for further improvement:

  • Sorting Logic: The sortParams function has been updated to correctly toggle between ascending and descending order based on the current sort value. This enhancement ensures the sorting logic works as expected.

  • 'No People' Message Condition: The condition for displaying the "no people" message has been updated to check filteredAndSortedPeople.length, ensuring that the message accurately reflects the filtered data.

  • Sorting Logic Clarity: The use of -comparison in getFilteredPeople to reverse the order is idiomatic and enhances readability.

Your code is well-structured and ready for use. Keep up the good work and continue learning from these improvements. Remember, addressing critical issues in the future will help you avoid similar problems and enhance your coding skills. 🚀

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

Comment on lines +26 to +28
return sort === value
? { sort, order: 'desc' }
: { sort: value, order: null };

Choose a reason for hiding this comment

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

The sortParams function currently sets the order to 'desc' when the sort value matches. To toggle between 'asc' and 'desc', consider checking the current order and toggling it accordingly. This will ensure the sorting logic works as expected.

Comment on lines +74 to +76
{!isLoading && people.length === 0 && (
<p data-cy="noPeopleMessage">There are no people on the server</p>
)}

Choose a reason for hiding this comment

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

The condition for displaying the 'no people' message should check filteredAndSortedPeople.length instead of people.length to ensure the message corresponds to the filtered data.

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