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 #609

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

Develop #609

wants to merge 5 commits into from

Conversation

denzzlle171
Copy link

Copy link

@dolphinnq dolphinnq 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!

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

const getVisiblePeople = () => {

Choose a reason for hiding this comment

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

Better move this function outside the component and just call it here with your arguments.

setIsLoad(true);
getPeople()
.then((peopleFromServer) => setPeople(peopleFromServer))
.catch(() => {

Choose a reason for hiding this comment

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

Try to catch an error here, maybe it will fix some of your failed tests


export const PeoplePage = () => {
const [people, setPeople] = useState<Person[] | null>(null);
const [isLoad, setIsLoad] = useState<boolean>(false);

Choose a reason for hiding this comment

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

It is better to make isLoad true by default. Now there's no need to set it true in line 23

</p>
)}
{people && <PeopleTable people={getVisiblePeople()} />}
{!isLoad && !error && !people && (

Choose a reason for hiding this comment

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

no people appears before page is loaded for a moment. Create a variable for this and try to change your people condition.
image

Copy link
Author

Choose a reason for hiding this comment

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

Maybe I've already fixed it with lowder, because I don't see this problem now

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.

Almost there🔥


useEffect(() => {
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)

Comment on lines 51 to 58
people={getVisiblePeople(
people,
sex,
query,
centuries,
sort,
order,
)}

Choose a reason for hiding this comment

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

  1. For better readability store in separate variable
  2. Just pass the whole searchParams object

Comment on lines 28 to 47
<SearchLink
className={classnames({ 'is-active': !sex })}
params={{ sex: null }}
>
All
</SearchLink>

<SearchLink
className={classnames({ 'is-active': sex === 'm' })}
params={{ sex: 'm' }}
>
Male
</SearchLink>

<SearchLink
className={classnames({ 'is-active': sex === 'f' })}
params={{ sex: 'f' }}
>
Female
</SearchLink>

Choose a reason for hiding this comment

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

Render as list

className="button is-link is-outlined is-fullwidth"
href="#/people"
params={{ centuries: null, query: null, sex: null }}

Choose a reason for hiding this comment

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

Find a better way to reset all by just 1 line of code. If you had 20 filters, would you set null to all of them?

Copy link
Author

Choose a reason for hiding this comment

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

all the other options I can think of
will either just increase the amount of code or reset the sorting as well.

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.

🔥

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