-
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
task solution #610
base: master
Are you sure you want to change the base?
task solution #610
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! :)
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 try🔥
let visiblePeople = [...people]; | ||
|
||
if (sex) { | ||
visiblePeople = visiblePeople.filter(person => person.sex === sex); | ||
} | ||
|
||
if (centuries.length) { | ||
visiblePeople = visiblePeople | ||
.filter(person => centuries | ||
.includes(Math.ceil(person.born / 100).toString())); | ||
} | ||
|
||
if (query) { | ||
visiblePeople = visiblePeople.filter(person => ( | ||
person.name.toLowerCase().includes(query) | ||
|| person.motherName?.toLowerCase().includes(query) | ||
|| person.fatherName?.toLowerCase().includes(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.
Let's put filtration into separate function and store it in separate file
<SearchLink | ||
params={{ sex: null }} | ||
className={cn({ 'is-active': !sex })} | ||
> | ||
All | ||
</SearchLink> | ||
<SearchLink | ||
params={{ sex: 'm' }} | ||
className={cn({ 'is-active': sex === 'm' })} | ||
> | ||
Male | ||
</SearchLink> | ||
<SearchLink | ||
params={{ sex: 'f' }} | ||
className={cn({ 'is-active': sex === 'f' })} | ||
> | ||
Female | ||
</SearchLink> |
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.
Let'a render as a list
className="button is-link is-outlined is-fullwidth" | ||
href="#/people" | ||
params={{ sex: null, query: null, centuries: 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.
Let's find a way to reset ALL filters together (not setting null to each of them separately)
DEMO LINK