-
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
implemented the ability to filter and sort people in the table #495
base: master
Are you sure you want to change the base?
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.
Good job 🔥, but reverse sorting is not working
Left comments
src/components/Navbar.tsx
Outdated
const getLinkClass = ({ isActive }: { isActive: boolean }) => classNames( | ||
'navbar-item', | ||
{ 'has-background-grey-lighter': isActive }, | ||
); |
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 can move this to utils
src/utils/constants.tsx
Outdated
export const SEARCH_FILTER = { | ||
All: null, | ||
Male: 'm', | ||
Female: 'f', |
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.
This search filter reffers only to sex, you can be more specific with name of constant
src/components/PeopleTable.tsx
Outdated
case 'died': | ||
return a[sort] - b[sort]; | ||
default: | ||
return 1; |
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.
Maybe it would be better to return 0, so the array stays unchanged in default case
src/components/PeopleTable.tsx
Outdated
</td> | ||
</tr> | ||
if (currentColumnTitle === sort && !order) { | ||
return { sort: null, order: 'desc' }; |
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.
Why do you delete sort option after second click, the reverse sorting is not working
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.
By mistake, it was supposed to be just 'sort'🙈 Thanks!
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.
Good job, but there is quite a bit of work to be done.
src/components/PeopleFilters.tsx
Outdated
|
||
const newQuery = e.target.value; | ||
|
||
if (newQuery === '') { |
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 (newQuery === '') { | |
if (!newQuery) { |
src/components/PeopleFilters.tsx
Outdated
<a className="is-active" href="#/people">All</a> | ||
<a className="" href="#/people?sex=m">Male</a> | ||
<a className="" href="#/people?sex=f">Female</a> | ||
{Object.keys(SEX_FILTER).map( |
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.
Use Object.entries
src/components/PeopleFilters.tsx
Outdated
}} | ||
data-cy="century" | ||
className={classNames( | ||
'button mr-1', |
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.
'button mr-1', | |
'button', 'mr-1', |
src/utils/constants.tsx
Outdated
Female: 'f', | ||
}; | ||
|
||
export const NO_PARENT_NAME = '-'; |
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.
export const NO_PARENT_NAME = '-'; | |
export const NOT_SET_VALUE = '-'; |
src/utils/constants.tsx
Outdated
Female: 'f', | ||
}; | ||
|
||
export const NO_PARENT_NAME = '-'; |
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.
export const NO_PARENT_NAME = '-'; | |
export const EMPTY_VALUE = '-'; |
src/utils/getPreparedPeople.tsx
Outdated
const findPersonByName = (personName: string | null) => { | ||
return people.find(({ name }) => name === personName); | ||
}; |
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 can move this to utils
src/utils/getPreparedPeople.tsx
Outdated
|| person.fatherName?.toLowerCase().includes(query) | ||
); | ||
|
||
const bornCentury = (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 "magic values" (100)
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