-
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 task solution #1515
base: master
Are you sure you want to change the base?
add task solution #1515
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.
Good job 👍
Let's make your code better
src/components/ErrorNotification.tsx
Outdated
data-cy="HideErrorButton" | ||
type="button" | ||
className="delete" | ||
onClick={() => clearErrorMessage()} |
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.
onClick={() => clearErrorMessage()} | |
onClick={clearErrorMessage} |
src/components/TodoFilter.tsx
Outdated
<a | ||
href="#/" | ||
className={classNames('filter__link', { | ||
selected: filterSelected === FilteredTodos.all, | ||
})} | ||
onClick={() => setFilterSelected(FilteredTodos.all)} | ||
data-cy="FilterLinkAll" | ||
> | ||
{FilteredTodos.all} | ||
</a> | ||
|
||
<a | ||
href="#/" | ||
className={classNames('filter__link', { | ||
selected: filterSelected === FilteredTodos.active, | ||
})} | ||
onClick={() => setFilterSelected(FilteredTodos.active)} | ||
data-cy="FilterLinkActive" | ||
> | ||
{FilteredTodos.active} | ||
</a> | ||
|
||
<a | ||
href="#/" | ||
className={classNames('filter__link', { | ||
selected: filterSelected === FilteredTodos.completed, | ||
})} | ||
onClick={() => setFilterSelected(FilteredTodos.completed)} | ||
data-cy="FilterLinkCompleted" | ||
> | ||
{FilteredTodos.completed} |
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.
Use Object.values(your enum)
and render these options with map()
method
src/components/TodoFooter.tsx
Outdated
className="todoapp__clear-completed" | ||
data-cy="ClearCompletedButton" | ||
disabled={completedTodos.length === 0} | ||
onClick={() => onCompleteDelete()} |
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.
onClick={() => onCompleteDelete()} | |
onClick={onCompleteDelete} |
src/components/TodoItem.tsx
Outdated
loadingTodosIds, | ||
setLoadingTodosIds, | ||
}) => { | ||
const { title, completed } = todo; |
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.
const { title, completed } = todo; | |
const { title, completed, id } = todo; |
src/components/TodoItem.tsx
Outdated
}; | ||
|
||
const handleChangeCheckbox = () => { | ||
setLoadingTodosIds([...loadingTodosIds, todo.id]); |
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.
setLoadingTodosIds([...loadingTodosIds, todo.id]); | |
setLoadingTodosIds([...loadingTodosIds, id]); |
src/components/TodoItem.tsx
Outdated
updtTodo(todo.id, changeValue).finally(() => | ||
setLoadingTodosIds(loadingTodosIds.filter(ids => ids !== todo.id)), |
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.
updtTodo(todo.id, changeValue).finally(() => | |
setLoadingTodosIds(loadingTodosIds.filter(ids => ids !== todo.id)), | |
updtTodo(id, changeValue).finally(() => | |
setLoadingTodosIds(loadingTodosIds.filter(ids => ids !== id)), |
src/components/TodoItem.tsx
Outdated
); | ||
}; | ||
|
||
const isTodoLoading = loadingTodosIds.includes(todo.id); |
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.
const isTodoLoading = loadingTodosIds.includes(todo.id); | |
const isTodoLoading = loadingTodosIds.includes(id); |
src/components/TodoItem.tsx
Outdated
type="button" | ||
className="todo__remove" | ||
data-cy="TodoDelete" | ||
onClick={() => handleDeleteTodo(todo.id)} |
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.
onClick={() => handleDeleteTodo(todo.id)} | |
onClick={() => handleDeleteTodo(id)} |
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.
Great work! 🔥
DEMO LINK