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 task solution #1515

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

add task solution #1515

wants to merge 2 commits into from

Conversation

marichkamt
Copy link

Copy link

@volodymyr-soltys97 volodymyr-soltys97 left a 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

data-cy="HideErrorButton"
type="button"
className="delete"
onClick={() => clearErrorMessage()}

Choose a reason for hiding this comment

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

Suggested change
onClick={() => clearErrorMessage()}
onClick={clearErrorMessage}

Comment on lines 15 to 45
<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}

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

className="todoapp__clear-completed"
data-cy="ClearCompletedButton"
disabled={completedTodos.length === 0}
onClick={() => onCompleteDelete()}

Choose a reason for hiding this comment

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

Suggested change
onClick={() => onCompleteDelete()}
onClick={onCompleteDelete}

loadingTodosIds,
setLoadingTodosIds,
}) => {
const { title, completed } = todo;

Choose a reason for hiding this comment

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

Suggested change
const { title, completed } = todo;
const { title, completed, id } = todo;

};

const handleChangeCheckbox = () => {
setLoadingTodosIds([...loadingTodosIds, todo.id]);

Choose a reason for hiding this comment

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

Suggested change
setLoadingTodosIds([...loadingTodosIds, todo.id]);
setLoadingTodosIds([...loadingTodosIds, id]);

Comment on lines 40 to 41
updtTodo(todo.id, changeValue).finally(() =>
setLoadingTodosIds(loadingTodosIds.filter(ids => ids !== todo.id)),

Choose a reason for hiding this comment

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

Suggested change
updtTodo(todo.id, changeValue).finally(() =>
setLoadingTodosIds(loadingTodosIds.filter(ids => ids !== todo.id)),
updtTodo(id, changeValue).finally(() =>
setLoadingTodosIds(loadingTodosIds.filter(ids => ids !== id)),

);
};

const isTodoLoading = loadingTodosIds.includes(todo.id);

Choose a reason for hiding this comment

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

Suggested change
const isTodoLoading = loadingTodosIds.includes(todo.id);
const isTodoLoading = loadingTodosIds.includes(id);

type="button"
className="todo__remove"
data-cy="TodoDelete"
onClick={() => handleDeleteTodo(todo.id)}

Choose a reason for hiding this comment

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

Suggested change
onClick={() => handleDeleteTodo(todo.id)}
onClick={() => handleDeleteTodo(id)}

Copy link

@volodymyr-soltys97 volodymyr-soltys97 left a comment

Choose a reason for hiding this comment

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

Great work! 🔥

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