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

add working version #813

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

Conversation

dpidlutska
Copy link

@dpidlutska dpidlutska commented Sep 27, 2023

Copy link

@Yevheniia-Sid Yevheniia-Sid left a 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👍

Copy link

@BudnikOleksii BudnikOleksii left a 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
Comment on lines 69 to 94
<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>

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

Comment on lines 6 to 23
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';

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',
      };


return (
<footer className="todoapp__footer" data-cy="Footer">
{/* Hide the footer if there are no todos */}

Choose a reason for hiding this comment

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

Remove all comments

Comment on lines 56 to 58
.catch(() => {

})

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

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