-
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
Develop #1520
base: master
Are you sure you want to change the base?
Develop #1520
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/TodoItem.tsx
Outdated
return; | ||
} | ||
|
||
// Якщо заголовок порожній, спробувати видалити туду |
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.
Remove all comments
// Якщо заголовок порожній, спробувати видалити туду |
src/components/TodoItem.tsx
Outdated
onDoubleClick={() => { | ||
setIsEditingMode(true); | ||
setEditedTitle(todo.title); | ||
}} |
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 this logic to the helper function and use it here
src/components/Footer.tsx
Outdated
return ( | ||
<footer className="todoapp__footer" data-cy="Footer"> | ||
<span className="todo-count" data-cy="TodosCounter"> | ||
{`${activeCount} item${activeCount === 1 ? '' : 's'} left`} |
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 this logic to the helper variable and use it here
src/App.tsx
Outdated
onRemoveTodo={() => {}} | ||
onToggleTodoCompletion={() => {}} |
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.
Do you need these empty props?
src/App.tsx
Outdated
todo={tempTodo} | ||
onRemoveTodo={() => {}} | ||
onToggleTodoCompletion={() => {}} | ||
onUpdateTodoTitle={async (todo: Todo) => todo.title} |
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.
onUpdateTodoTitle={async (todo: Todo) => todo.title} | |
onUpdateTodoTitle={(todo: Todo) => todo.title} |
src/components/Footer.tsx
Outdated
<a | ||
href="#/" | ||
className={cn('filter__link', { | ||
selected: filter === Filter.all, | ||
})} | ||
data-cy="FilterLinkAll" | ||
onClick={() => setFilter(Filter.all)} | ||
> | ||
All | ||
</a> | ||
|
||
<a | ||
href="#/active" | ||
className={cn('filter__link', { | ||
selected: filter === Filter.active, | ||
})} | ||
data-cy="FilterLinkActive" | ||
onClick={() => setFilter(Filter.active)} | ||
> | ||
Active | ||
</a> | ||
|
||
<a | ||
href="#/completed" | ||
className={cn('filter__link', { | ||
selected: filter === Filter.completed, | ||
})} | ||
data-cy="FilterLinkCompleted" | ||
onClick={() => setFilter(Filter.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 created enum)
and render these options with map()
method
src/App.tsx
Outdated
<section className="todoapp__main" data-cy="TodoList"> | ||
{filteredTodos.map(todo => ( | ||
<TodoItem | ||
todo={todo} | ||
key={todo.id} | ||
onRemoveTodo={handleDeleteTodo} | ||
onToggleTodoCompletion={handleTodoStatusChange} | ||
onUpdateTodoTitle={handleRenameTodo} | ||
isLoading={isLoading.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.
Move this logic to the separate TodoList
component
@volodymyr-soltys97, Thank you very much for all the recommendations! The code has been rewritten. |
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