-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 #487
add task solution #487
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.
Nice work, but the demo link doesn't work
src/components/PersonLink.tsx
Outdated
> | ||
{motherName} | ||
</Link> | ||
) : (motherName || '-')} |
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.
const NOT_SET_VALUE = '-';
...
) : (motherName || NOT_SET_VALUE)}
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.
Not fixed 😢
src/pages/PeoplePage.tsx
Outdated
father: peopleFormServer | ||
.find(father => father.name === person.fatherName), | ||
mother: peopleFormServer | ||
.find(mother => mother.name === person.motherName), |
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.
father: peopleFormServer | |
.find(father => father.name === person.fatherName), | |
mother: peopleFormServer | |
.find(mother => mother.name === person.motherName), | |
father: peopleFormServer | |
.find(({ name })=> name === person.fatherName), | |
mother: peopleFormServer | |
.find(({ name }) => name === person.motherName), |
src/utils/getFilteredPeople.tsx
Outdated
person => person.name.toLowerCase().includes(normalizedQuery) | ||
|| person.fatherName?.toLowerCase().includes(normalizedQuery) | ||
|| person.motherName?.toLowerCase().includes(normalizedQuery), |
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.
You use a similar action three times - this can be taken as a helper function
src/utils/getFilteredPeople.tsx
Outdated
}: FilterParams): Person[] => { | ||
let filteredPeople = [...people]; | ||
|
||
if (query.trim() !== '') { |
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.
if (query.trim() !== '') { | |
if (!!query.trim()) { |
src/utils/getFilteredPeople.tsx
Outdated
); | ||
} | ||
|
||
if (centuries.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.
if (centuries.length > 0) { | |
if (!!centuries.length) { |
src/utils/getFilteredPeople.tsx
Outdated
|
||
if (centuries.length > 0) { | ||
filteredPeople = filteredPeople.filter((person) => { | ||
return centuries.includes(Math.ceil(person.born / 100).toString()); |
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.
Avoid using "magiv values" (100 is magic value)
src/utils/getFilteredPeople.tsx
Outdated
sort, | ||
order, | ||
}: FilterParams): Person[] => { | ||
let filteredPeople = [...people]; |
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 filter
array method returns a copy of the array, so you don't need to do it manually
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.
src/components/PersonLink.tsx
Outdated
> | ||
{motherName} | ||
</Link> | ||
) : (motherName || '-')} |
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.
Not fixed 😢
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.
Well done 👍
DEMO LINK