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

made people-table-advanced #597

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

Conversation

sintax1s
Copy link

if (!century) {
return getSearchWith(searchParams, {
centuries: [],
});

Choose a reason for hiding this comment

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

as I understand if we want to remove params, we should pass value = null

const toggleAllReset = () => {
return getSearchWith(
searchParams, { query: null, centuries: [], sex: null },
);

Choose a reason for hiding this comment

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

same here

All
</Link>
<Link
className={cn({ 'is-active': sex === 'm' })}

Choose a reason for hiding this comment

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

we can also use SearchLink

Choose a reason for hiding this comment

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

For sure. Also render as a list (using map). Fix everywhere

case 'sex':
filteredPeople = filteredPeople.sort((person1, person2) => {
return (order === 'desc')
? person2[sort].localeCompare(person1[sort])

Choose a reason for hiding this comment

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

it looks like you repeat yourself

Copy link

@OlhaKoziuk OlhaKoziuk left a comment

Choose a reason for hiding this comment

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

Awesome! Just a few suggestions

Copy link

@superpooperxxx superpooperxxx left a comment

Choose a reason for hiding this comment

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

The functionality works. Let's improve code😉

setIsLoading(true);

getPeople()
.then((peopleFromServer) => setPeople(peopleFromServer))

Choose a reason for hiding this comment

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

.then(setPeople)

.finally(() => setIsLoading(false));
}, []);

const getFilteredPeople = () => {

Choose a reason for hiding this comment

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

Let's move this function to separate file and receive people and filters as a parameters

Comment on lines 14 to 19
const [searchParams] = useSearchParams();
const centuries = searchParams.getAll('centuries') || [];
const sex = searchParams.get('sex') || 'All';
const query = searchParams.get('query') || '';
const sort = searchParams.get('sort') || '';
const order = searchParams.get('order') || '';

Choose a reason for hiding this comment

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

You don't need it here

All
</Link>
<Link
className={cn({ 'is-active': sex === 'm' })}

Choose a reason for hiding this comment

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

For sure. Also render as a list (using map). Fix everywhere

Copy link

@StasSokolov StasSokolov left a comment

Choose a reason for hiding this comment

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

Overall looks good to me, only one minor comment, i'm approving it🔥

);
}

if (sex !== 'All') {

Choose a reason for hiding this comment

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

not critical but All is used in many places your code, will be better create enum for sort fields

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.

4 participants