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

Develop #1579

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

Develop #1579

wants to merge 7 commits into from

Conversation

Andrew77788
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 improve your code

  1. It is bad practice to write all logic in one component, you need to separate the logic into different components, for example Header, Footer, TodoItem, TodoList

  2. The edit mode looks strange, you need to fix styles

image
  1. Empty todo should be deleted
image

src/App.tsx Outdated
setChangeTodoId(todoItem.id);
};

const ClearCompleted = () => {

Choose a reason for hiding this comment

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

Suggested change
const ClearCompleted = () => {
const clearCompleted = () => {

Copy link
Author

Choose a reason for hiding this comment

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

The edit mode looks strange, you need to fix styles - не знаю як це зробити, підскажіть будь-ласка, витратив купу часу і так і не зрозумів, чому стилі не спрацьовують

src/App.tsx Outdated
<header className="todoapp__header">
<button
type="button"
// className="todoapp__toggle-all active"

Choose a reason for hiding this comment

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

Remove all comments

Suggested change
// className="todoapp__toggle-all active"

src/App.tsx Outdated
<button
type="button"
// className="todoapp__toggle-all active"
className={`todoapp__toggle-all ${allCompleted ? 'active' : ''}`}

Choose a reason for hiding this comment

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

Use the classnames library for add classes with condition, fix it everywhere

Copy link

@anastasiiavorobiova anastasiiavorobiova 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!

  • Check styles here
  • A user shouldn't be able to delete the todo in the edit mode by clicking on the cross icon
Screenshot 2025-01-04 at 14 43 15

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.

Almost done!
Let's make your code better

src/App.tsx Outdated
Comment on lines 44 to 46
.then(todosList => {
setTodos(todosList);
})

Choose a reason for hiding this comment

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

Suggested change
.then(todosList => {
setTodos(todosList);
})
.then(setTodos)

return (
<div
data-cy="ErrorNotification"
className={`notification is-danger is-light has-text-weight-normal ${errorMessage ? '' : 'hidden'}`}

Choose a reason for hiding this comment

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

Use the classnames library for add classes with condition, fix it everywhere

return (
<footer className="todoapp__footer" data-cy="Footer">
<span className="todo-count" data-cy="TodosCounter">
{todos.filter(tod => !tod.completed).length} items left

Choose a reason for hiding this comment

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

Move this logic from jsx to the helper variable and use it here

Comment on lines 33 to 61
<a
href="#/"
className={classNames('filter__link', {
selected: filter === FilterType.All,
})}
data-cy="FilterLinkAll"
onClick={() => setFilter(FilterType.All)}
>
All
</a>

<a
href="#/active"
className={classNames('filter__link', {
selected: filter === FilterType.Active,
})}
data-cy="FilterLinkActive"
onClick={() => setFilter(FilterType.Active)}
>
Active
</a>

<a
href="#/completed"
className={classNames('filter__link', {
selected: filter === FilterType.Completed,
})}
data-cy="FilterLinkCompleted"
onClick={() => setFilter(FilterType.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 created enum) and render these options with map() method

}) => {
const inputRef = useRef<HTMLInputElement | null>(null);
const allCompleted = todos.every(tod => tod.completed);
const ToggleAllButton = () => {

Choose a reason for hiding this comment

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

Suggested change
const ToggleAllButton = () => {
const toggleAllButton = () => {

Copy link

@maxim2310 maxim2310 left a comment

Choose a reason for hiding this comment

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

Good work! Make sure to pass all the tests before getting approval
image

Comment on lines 82 to 87
{isLoadingIds.includes(todoItem.id) && (
<div data-cy="TodoLoader" className="modal overlay is-active">
<div className="modal-background has-background-white-ter" />
<div className="loader" />
</div>
)}

Choose a reason for hiding this comment

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

Suggested change
{isLoadingIds.includes(todoItem.id) && (
<div data-cy="TodoLoader" className="modal overlay is-active">
<div className="modal-background has-background-white-ter" />
<div className="loader" />
</div>
)}
<div
data-cy="TodoLoader"
className={cn('modal overlay', { 'is-active': isLoadingIds.includes(todoItem.id)})}
>
<div className="modal-background has-background-white-ter" />
<div className="loader" />
</div>

Comment on lines 57 to 60




Choose a reason for hiding this comment

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

remove empty spaces

Suggested change

@Andrew77788 Andrew77788 requested a review from maxim2310 January 6, 2025 09:21
Copy link

@etojeDenys etojeDenys 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

Comment on lines +18 to +19
const [todo, setTodo] = useState<string>('');
const [errorMessage, setErrorMessage] = useState<string>('');

Choose a reason for hiding this comment

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

it's redundant to specify types for primitives

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.

5 participants