Untitled
unknown
jsx
3 years ago
678 B
8
Indexable
const moveNote = (event, right = false) => {
event.preventDefault();
const targetId = +event.target.id;
const todoToUpdate = todos.find((todo) => todo.id === targetId);
const newStatus = null;
right ? todoToUpdate.status + 1 : todoToUpdate.status - 1;
const updatedTodo = { ...todoToUpdate, status: newStatus };
todoService
.update(updatedTodo.id, updatedTodo)
.then((response) => {
setTodos([...todos].map((todo) => (todo.id !== updatedTodo.id ? todo : updatedTodo)));
showToast("👍 Success");
})
.catch((error) => {
console.log("error", error);
showToast("👎 Failed");
});
};
Editor is loading...