-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
add working version #813
base: master
Are you sure you want to change the base?
add working version #813
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.
Looks good to me👍
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 great 🔥
Just get rid of comments and take a look at suggestions.
src/App.tsx
Outdated
<div | ||
data-cy="ErrorNotification" | ||
className={cn( | ||
'notification is-danger is-light has-text-weight-normal', { | ||
hidden: !errorMessage, | ||
}, | ||
)} | ||
> | ||
<button | ||
data-cy="HideErrorButton" | ||
type="button" | ||
className="delete" | ||
onClick={() => setErrorMessage('')} | ||
/> | ||
{/* show only one message at a time */} | ||
{errorMessage} | ||
{/* Unable to load todos | ||
<br /> | ||
Title should not be empty | ||
<br /> | ||
Unable to add a todo | ||
<br /> | ||
Unable to delete a todo | ||
<br /> | ||
Unable to update a todo */} | ||
</div> |
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.
Remove comments, create a separate ErrorNotification
component, and move related logic and useEffect
to it
src/components/TodoFilter.tsx
Outdated
const setFilterHref = (filter: TodosFilter) => { | ||
switch (filter) { | ||
case TodosFilter.Active: | ||
return '#/active'; | ||
|
||
case TodosFilter.Completed: | ||
return '#/completed'; | ||
|
||
case TodosFilter.All: | ||
default: | ||
return '#/'; | ||
} | ||
}; | ||
|
||
const setFilterDataCy = (filter: TodosFilter) => { | ||
switch (filter) { | ||
case TodosFilter.Active: | ||
return 'FilterLinkActive'; |
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.
You do the same checks so you can return an object and one function is enough in this case.
case TodosFilter.Active:
return {
href: '#/active',
dataCy: 'FilterLinkActive',
};
src/components/TodoFilter.tsx
Outdated
|
||
return ( | ||
<footer className="todoapp__footer" data-cy="Footer"> | ||
{/* Hide the footer if there are no todos */} |
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.
Remove all comments
src/components/TodoForm.tsx
Outdated
.catch(() => { | ||
|
||
}) |
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 catch
block is empty? Notify a user in case of error
DEMO LINK