-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
base: master
Are you sure you want to change the base?
add task solution #1134
Conversation
There was a problem hiding this 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:
-
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'. -
noPeople
Condition: The condition currently checks ifpeople.length === 0
, which may not accurately reflect the filtered results. It would be more accurate to checkfilteredAndSortedPeople.length
to ensure the message corresponds to the filtered data. -
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.
return sort === value | ||
? { sort, order: 'desc' } | ||
: { sort: value, order: null }; |
There was a problem hiding this comment.
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.
src/pages/PeoplePage.tsx
Outdated
const [searchParams] = useSearchParams(); | ||
|
||
const hasError = !isLoading && error; | ||
const noPeople = !isLoading && people.length === 0; |
There was a problem hiding this comment.
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.
src/utils/getFilteredPeople.ts
Outdated
|
||
return order === 'desc' ? comparison * -1 : comparison; |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
There was a problem hiding this 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
ingetFilteredPeople
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! ✨
return sort === value | ||
? { sort, order: 'desc' } | ||
: { sort: value, order: null }; |
There was a problem hiding this comment.
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.
{!isLoading && people.length === 0 && ( | ||
<p data-cy="noPeopleMessage">There are no people on the server</p> | ||
)} |
There was a problem hiding this comment.
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.
DEMO LINK