-
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
table_advansed #639
table_advansed #639
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.
src/components/PeopleFilters.tsx
Outdated
|
||
const sex = searchParams.get('sex'); | ||
const centuries = searchParams.getAll('centuries'); | ||
const query = searchParams.get('query') || ''; |
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.
suggest to make enum for all possible searchParams
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.
i cannot find PeopleTable component in github
src/components/PeoplePage.tsx
Outdated
case 'name': | ||
{ | ||
prepared.sort((a, b) => a.name.localeCompare(b.name)); | ||
break; | ||
} | ||
|
||
case 'sex': | ||
{ | ||
prepared.sort((a, b) => a.sex.localeCompare(b.sex)); | ||
break; | ||
} |
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.
case 'name': | |
{ | |
prepared.sort((a, b) => a.name.localeCompare(b.name)); | |
break; | |
} | |
case 'sex': | |
{ | |
prepared.sort((a, b) => a.sex.localeCompare(b.sex)); | |
break; | |
} | |
case 'name': | |
case 'sex': | |
{ | |
prepared.sort((a, b) => a[sort].localeCompare(b[sort])); | |
break; | |
} |
you can group some cases
src/components/PeoplePage.tsx
Outdated
case 'born': { | ||
prepared.sort((a, b) => a.born - b.born); | ||
break; | ||
} | ||
|
||
case 'died': { | ||
prepared.sort((a, b) => a.died - b.died); | ||
break; | ||
} | ||
|
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.
same here
src/components/PeoplePage.tsx
Outdated
setLoading(true); | ||
getPeople() | ||
.then(peopleOnServer) | ||
.then(preparedPeople => setPeople(preparedPeople)) |
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.
.then(preparedPeople => setPeople(preparedPeople)) | |
.then(setPeople) |
we can simplify it
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.
https://maksymkos.github.io/react_people-table-advanced/