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

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

Develop #1154

wants to merge 7 commits into from

Conversation

Krykunov
Copy link

Copy link

@StasSokolov1 StasSokolov1 left a comment

Choose a reason for hiding this comment

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

Almost done, let's improve your code a bit more!

src/Root.tsx Outdated
<Route path=":slug" element={<PeoplePage />} />
</Route>
<Route path="*" element={<h1 className="title">Page not found</h1>} />
<Route path="home" element={<Navigate to="/" replace={true} />} />

Choose a reason for hiding this comment

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

Suggested change
<Route path="home" element={<Navigate to="/" replace={true} />} />
<Route path="home" element={<Navigate to="/" replace />} />

just one small update

Comment on lines 12 to 16
const sexValues = {
all: 'All',
m: 'Male',
f: 'Female',
};

Choose a reason for hiding this comment

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

why not enum?

search: searchParams.toString(),
}}
className={classNames({
'has-text-danger': person.sex === 'f',

Choose a reason for hiding this comment

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

what is f? let's create enum with these values f, m

<td>{person.born}</td>
<td>{person.died}</td>
<td>
<ParentLink person={person} parent={'mother'} />

Choose a reason for hiding this comment

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

for mother and father we can also create enum

const [isPeopleError, setIsPeopleError] = useState(false);

const loadPeople = useCallback(async () => {
setIsPeopleLoading(true);

Choose a reason for hiding this comment

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

let's set initial value for isPeopleLoading true so we can remove this line

let status = 'loading';

if (isPeopleError) {
status = 'error';

Choose a reason for hiding this comment

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

please move to enum

Comment on lines 11 to 16
.filter(person => person.name.toLowerCase().includes(query.toLowerCase()))
.filter(person => !sex || person.sex === sex)
.filter(
person =>
!centuries.length || centuries.includes(getPersonCentury(person)),
)

Choose a reason for hiding this comment

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

do we really need three filters? let's combine all these rules into one

Copy link

@StasSokolov1 StasSokolov1 left a comment

Choose a reason for hiding this comment

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

Looks much more better, I'm approving it🔥

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.

2 participants