follow along

This commit is contained in:
counterweight 2025-05-26 00:04:01 +02:00
parent 6691671c86
commit 70992d6cb0
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
2 changed files with 12 additions and 6 deletions

View file

@ -42,8 +42,14 @@ const App = ({ startingNotes = [] }) => {
const note = notes.find((n) => n.id === id); const note = notes.find((n) => n.id === id);
const changedNote = { ...note, important: !note.important }; const changedNote = { ...note, important: !note.important };
noteService.update(id, changedNote).then((response) => { noteService
.update(id, changedNote)
.then((response) => {
setNotes(notes.map((note) => (note.id === id ? response.data : note))); setNotes(notes.map((note) => (note.id === id ? response.data : note)));
})
.catch((error) => {
alert(`The note '${note.content}' was already deleted from server.`);
setNotes(notes.filter((n) => n.id !== id));
}); });
}; };

View file

@ -14,7 +14,7 @@ const update = (id, newObject) => {
}; };
export default { export default {
getAll: getAll, getAll,
create: create, create,
update: update, update,
}; };