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

solution #1133

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

solution #1133

wants to merge 1 commit into from

Conversation

tonni004
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.

Great job on implementing the task requirements! 🎉 Your code meets the core functionality and constraints, and the overall structure is well-organized. While there are a few minor issues related to parameter handling and assumptions about data uniqueness, these don't significantly impact the core functionality. Consider addressing these in future iterations to enhance robustness and maintainability. Keep up the great work! 🚀

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

Comment on lines +23 to +25
<Route path="people" element={<PeoplePage />}>
<Route path=":slug" element={<PeoplePage />} />
</Route>

Choose a reason for hiding this comment

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

The nested route for PeoplePage is defined, but it might be worth checking if the PeoplePage component is designed to handle both the base path /people and the nested :slug path. If PeoplePage is not intended to handle both, consider creating a separate component for the nested route.

Comment on lines +13 to +17
const resetParams = {
query: null,
sex: null,
centuries: null,
};

Choose a reason for hiding this comment

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

The resetParams object sets query, sex, and centuries to null. However, when using URLSearchParams, setting a parameter to null does not remove it from the URL. Consider using params.delete('key') to remove parameters or set them to an empty string if you want to clear them.

Comment on lines +23 to +24
? { sort: null, order: null }
: { sort: value, order: 'desc' };

Choose a reason for hiding this comment

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

In the sortParams function, setting sort and order to null does not remove them from the URL. Consider using params.delete('key') to remove these parameters or set them to an empty string if you want to clear them. This will ensure the URL reflects the absence of sorting when the same field is clicked twice.

Comment on lines +24 to +25
const mother = people.find(mom => mom.name === person.motherName);
const father = people.find(dad => dad.name === person.fatherName);

Choose a reason for hiding this comment

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

The logic for finding a person's mother and father assumes that names are unique identifiers. If there are multiple people with the same name, this could lead to incorrect parent assignments. Consider using a unique identifier, such as an ID, to find parents accurately.

Comment on lines +7 to +8
sort: string | null;
order: string | null;

Choose a reason for hiding this comment

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

The sort and order parameters are typed as string | null, but they are defaulted to an empty string in the calling code. Ensure consistency by either allowing empty strings here or adjusting the calling code to use null.

Comment on lines +38 to +61
if (sort) {
filteredPeople.sort((currentPerson, nextPerson) => {
switch (sort) {
case 'name':
return order === 'desc'
? nextPerson.name.localeCompare(currentPerson.name)
: currentPerson.name.localeCompare(nextPerson.name);
case 'sex':
return order === 'desc'
? nextPerson.sex.localeCompare(currentPerson.sex)
: currentPerson.sex.localeCompare(nextPerson.sex);
case 'born':
return order === 'desc'
? nextPerson.born - currentPerson.born
: currentPerson.born - nextPerson.born;
case 'died':
return order === 'desc'
? nextPerson.died - currentPerson.died
: currentPerson.died - nextPerson.died;
default:
return 0;
}
});
}

Choose a reason for hiding this comment

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

The sorting logic assumes that all fields are present and comparable. Consider adding checks to ensure that fields like born and died are not undefined before performing arithmetic operations, to avoid potential runtime errors.

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