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

Todo App #1571

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

SemenVodolazskij
Copy link

Copy link

@StasSokolov1 StasSokolov1 left a 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!

Comment on lines +229 to +257
<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>

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}`);

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

Comment on lines +152 to +160
activeTodos.forEach(todo => {
onUpdateTodo({ ...todo, completed: true });
});
setIsToogleAll(true);
} else {
todos.forEach(todo => {
onUpdateTodo({ ...todo, completed: false });
});
setIsToogleAll(false);

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

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.

2 participants