Untitled

mail@pastecode.io avatar
unknown
jsx
2 years ago
542 B
2
Indexable
Never
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");
    }
};