-
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
Todo App #1571
base: master
Are you sure you want to change the base?
Todo App #1571
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 solution a bit more!
<button | ||
className={classNames('filter__link', { | ||
selected: filter === 'all', | ||
})} | ||
data-cy="FilterLinkAll" | ||
onClick={() => setFilter(Filter.All)} | ||
> | ||
All | ||
</button> | ||
|
||
<button | ||
className={classNames('filter__link', { | ||
selected: filter === 'active', | ||
})} | ||
data-cy="FilterLinkActive" | ||
onClick={() => setFilter(Filter.Active)} | ||
> | ||
Active | ||
</button> | ||
|
||
<button | ||
className={classNames('filter__link', { | ||
selected: filter === 'completed', | ||
})} | ||
data-cy="FilterLinkCompleted" | ||
onClick={() => setFilter(Filter.Completed)} | ||
> | ||
Completed | ||
</button> |
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 show these elements using .map()
export const USER_ID = 2171; | ||
|
||
export const getTodos = () => { | ||
return client.get<Todo[]>(`/todos?userId=${USER_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.
move /todos
into const and reuse
activeTodos.forEach(todo => { | ||
onUpdateTodo({ ...todo, completed: true }); | ||
}); | ||
setIsToogleAll(true); | ||
} else { | ||
todos.forEach(todo => { | ||
onUpdateTodo({ ...todo, completed: false }); | ||
}); | ||
setIsToogleAll(false); |
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.
seems very similar can let's write one time and just change true or false depends on unCompletedTodos counter
DEMO LINK