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

Develop #631

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

Develop #631

wants to merge 5 commits into from

Conversation

kseniia-chepur
Copy link

Copy link

@lerastarynets lerastarynets left a comment

Choose a reason for hiding this comment

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

Pls see the checklist on how sorting should work and fix your project becuase now it doesn't work

<PeopleFilters />
</div>

{!isLoading && !hasError && !!people.length

Choose a reason for hiding this comment

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

pls consider moving long ternaries to separate consts with consistent names

Comment on lines 9 to 12
const [searchParams, setSearchParams] = useSearchParams();
const query = searchParams.get('query') || '';
const sex = searchParams.get('sex') || null;
const centuryParams = searchParams.getAll('centuries') || [];

Choose a reason for hiding this comment

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

let's make a code little bit cleaner

Suggested change
const [searchParams, setSearchParams] = useSearchParams();
const query = searchParams.get('query') || '';
const sex = searchParams.get('sex') || null;
const centuryParams = searchParams.getAll('centuries') || [];
const [searchParams, setSearchParams] = useSearchParams();
const query = searchParams.get('query') || '';
const sex = searchParams.get('sex') || null;
const centuryParams = searchParams.getAll('centuries') || [];

</SearchLink>
<SearchLink
params={{ sex: 'm' }}
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.

m is a 'magic word'
Consider will be better if you create a enum for magic words and use it everywhere

Comment on lines 14 to 20
const [people, setPeople] = useState<Person[]>([]);
const [isLoading, setIsLoading] = useState(false);
const [hasError, setHasError] = useState(false);
const [searchParams] = useSearchParams();
const query = searchParams.get('query') || '';
const sex = searchParams.get('sex') || null;
const centuryParams = searchParams.getAll('centuries') || [];

Choose a reason for hiding this comment

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

Suggested change
const [people, setPeople] = useState<Person[]>([]);
const [isLoading, setIsLoading] = useState(false);
const [hasError, setHasError] = useState(false);
const [searchParams] = useSearchParams();
const query = searchParams.get('query') || '';
const sex = searchParams.get('sex') || null;
const centuryParams = searchParams.getAll('centuries') || [];
const [people, setPeople] = useState<Person[]>([]);
const [isLoading, setIsLoading] = useState(false);
const [hasError, setHasError] = useState(false);
const [searchParams] = useSearchParams();
const query = searchParams.get('query') || '';
const sex = searchParams.get('sex') || null;
const centuryParams = searchParams.getAll('centuries') || [];

setHasError(false);

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

Choose a reason for hiding this comment

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

Suggested change
.then(peopleData => setPeople(peopleData))
.then(setPeople)

Comment on lines 79 to 83
{!!people.length && !!filteredPeople.length && (

<PeopleTable people={filteredPeople} />

)}

Choose a reason for hiding this comment

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

Suggested change
{!!people.length && !!filteredPeople.length && (
<PeopleTable people={filteredPeople} />
)}
{!!people.length && !!filteredPeople.length && (
<PeopleTable people={filteredPeople} />
)}

Comment on lines 23 to 30
filteredPeople
= filteredPeople.filter(person => person.name.toLowerCase()
.includes(query))
|| filteredPeople.filter(person => person.motherName?.toLowerCase()
.includes(normalizedQuery))
|| filteredPeople.filter(person => person.fatherName?.toLowerCase()
.includes(normalizedQuery));
}

Choose a reason for hiding this comment

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

let's make a code readable

Suggested change
filteredPeople
= filteredPeople.filter(person => person.name.toLowerCase()
.includes(query))
|| filteredPeople.filter(person => person.motherName?.toLowerCase()
.includes(normalizedQuery))
|| filteredPeople.filter(person => person.fatherName?.toLowerCase()
.includes(normalizedQuery));
}
filteredPeople
= filteredPeople.filter(person => {
return person.name.toLowerCase().includes(query);
})
|| filteredPeople.filter(person => {
return person.motherName?.toLowerCase().includes(normalizedQuery);
})
|| filteredPeople.filter(person => {
return person.fatherName?.toLowerCase().includes(normalizedQuery)
});
}

Copy link

@loralevitska loralevitska 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.

4 participants