-
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
solution 0.01 one test failed #1532
base: master
Are you sure you want to change the base?
Conversation
i can't understand failed test,
|
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.
on completed all click and toggle all click you need to update all todos immediately
Screen.Recording.2024-12-12.at.22.06.49.mov
src/App.tsx
Outdated
const allTodosComplited = useMemo(() => { | ||
return todos.every(item => item.completed); | ||
}, [todos]); | ||
|
||
useEffect(() => { | ||
if (allTodosComplited) { | ||
setActive(true); | ||
} else { | ||
setActive(false); | ||
} | ||
}, [allTodosComplited, active]); |
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.
const allTodosComplited = useMemo(() => { | |
return todos.every(item => item.completed); | |
}, [todos]); | |
useEffect(() => { | |
if (allTodosComplited) { | |
setActive(true); | |
} else { | |
setActive(false); | |
} | |
}, [allTodosComplited, active]); | |
const allTodosComplited = useMemo(() => { | |
return todos.every(item => item.completed); | |
}, [todos]); |
it looks redundant, you can just use allTodosComplited var
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.
const countNotCompletedItem = useCallback(() => { | ||
const filtered = todos.filter(todo => !todo.completed); | ||
|
||
return filtered.length; | ||
}, [todos]); | ||
|
||
const notCompletedItem = countNotCompletedItem(); |
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.
const countNotCompletedItem = useCallback(() => { | |
const filtered = todos.filter(todo => !todo.completed); | |
return filtered.length; | |
}, [todos]); | |
const notCompletedItem = countNotCompletedItem(); | |
const notCompletedItem = useMemo(() => { | |
const filtered = todos.filter(todo => !todo.completed); | |
return filtered.length; | |
}, [todos]); |
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.
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.
a192aa6
to
56d0477
Compare
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! Almost done
src/App.tsx
Outdated
|
||
setTodosForModify(content); | ||
|
||
await Promise.allSettled(content.map(todo => updateTodos([todo]))); |
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.
await Promise.allSettled(content.map(todo => updateTodos([todo]))); | |
await Promise.allSettled(content.map(todo => updateTodos([todo]))).then(here you should filter just successfully removed todos); |
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.
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.
Looks good
DEMO LINK
Toggling a todo status
Toggle the
completed
status onTodoStatus
change:Unable to update a todo
notification in case of API error.Add the ability to toggle the completed status of all the todos with the
toggleAll
checkbox:toggleAll
button should haveactive
class only if all the todos are completed;toggleAll
click changes its status to the opposite one, and sets this new status to all the todos;Renaming a todo
Implement the ability to edit a todo title on double click:
Enter
);onBlur
);Esс
keykeyup
event;x
button does it;Unable to update a todo
in case of API error;