-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
base: master
Are you sure you want to change the base?
Develop #1154
Conversation
There was a problem hiding this 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} />} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<Route path="home" element={<Navigate to="/" replace={true} />} /> | |
<Route path="home" element={<Navigate to="/" replace />} /> |
just one small update
src/components/PeopleFilters.tsx
Outdated
const sexValues = { | ||
all: 'All', | ||
m: 'Male', | ||
f: 'Female', | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not enum
?
src/components/PersonRow.tsx
Outdated
search: searchParams.toString(), | ||
}} | ||
className={classNames({ | ||
'has-text-danger': person.sex === 'f', |
There was a problem hiding this comment.
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
src/components/PersonRow.tsx
Outdated
<td>{person.born}</td> | ||
<td>{person.died}</td> | ||
<td> | ||
<ParentLink person={person} parent={'mother'} /> |
There was a problem hiding this comment.
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
src/hooks/usePeople.ts
Outdated
const [isPeopleError, setIsPeopleError] = useState(false); | ||
|
||
const loadPeople = useCallback(async () => { | ||
setIsPeopleLoading(true); |
There was a problem hiding this comment.
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
src/pages/PeoplePage.tsx
Outdated
let status = 'loading'; | ||
|
||
if (isPeopleError) { | ||
status = 'error'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move to enum
src/utils/sortHelper.ts
Outdated
.filter(person => person.name.toLowerCase().includes(query.toLowerCase())) | ||
.filter(person => !sex || person.sex === sex) | ||
.filter( | ||
person => | ||
!centuries.length || centuries.includes(getPersonCentury(person)), | ||
) |
There was a problem hiding this comment.
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
There was a problem hiding this 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🔥
DEMO LINK