Untitled
unknown
jsx
3 years ago
542 B
9
Indexable
const moveNote = async (e, direction) => {
e.preventDefault();
const todoToUpdate = todos.find((todo) => todo.id === e.target.id);
const count = direction == 'right' ? 1 : -1
const updatedTodo = { ...todoToUpdate, status: todoToUpdate.status + count };
try {
const response = await todoService.update(updatedTodo.id, updatedTodo)
setTodos(prev => [...prev, updatedTodo]);
showToast("👍 Success");
} catch(err) {
console.log("error", error);
showToast("👎 Failed");
}
};Editor is loading...