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

implemented the ability to filter and sort people in the table #495

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

OlhaMomot
Copy link

Copy link

@ivannaromanovych ivannaromanovych left a 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

Comment on lines 4 to 7
const getLinkClass = ({ isActive }: { isActive: boolean }) => classNames(
'navbar-item',
{ 'has-background-grey-lighter': isActive },
);

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

Comment on lines 25 to 28
export const SEARCH_FILTER = {
All: null,
Male: 'm',
Female: 'f',

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

case 'died':
return a[sort] - b[sort];
default:
return 1;

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

</td>
</tr>
if (currentColumnTitle === sort && !order) {
return { sort: null, order: 'desc' };

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

Copy link
Author

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!

Copy link

@roman-mirzoian roman-mirzoian left a 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.


const newQuery = e.target.value;

if (newQuery === '') {

Choose a reason for hiding this comment

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

Suggested change
if (newQuery === '') {
if (!newQuery) {

<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(

Choose a reason for hiding this comment

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

Use Object.entries

}}
data-cy="century"
className={classNames(
'button mr-1',

Choose a reason for hiding this comment

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

Suggested change
'button mr-1',
'button', 'mr-1',

Female: 'f',
};

export const NO_PARENT_NAME = '-';

Choose a reason for hiding this comment

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

Suggested change
export const NO_PARENT_NAME = '-';
export const NOT_SET_VALUE = '-';

Female: 'f',
};

export const NO_PARENT_NAME = '-';

Choose a reason for hiding this comment

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

Suggested change
export const NO_PARENT_NAME = '-';
export const EMPTY_VALUE = '-';

Comment on lines 11 to 13
const findPersonByName = (personName: string | null) => {
return people.find(({ name }) => name === personName);
};

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

|| person.fatherName?.toLowerCase().includes(query)
);

const bornCentury = (Math.ceil(person.born / 100)).toString();

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)

Copy link

@roman-mirzoian roman-mirzoian left a comment

Choose a reason for hiding this comment

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

Well done 👍

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.

3 participants