follow along
This commit is contained in:
parent
6691671c86
commit
70992d6cb0
2 changed files with 12 additions and 6 deletions
|
|
@ -42,9 +42,15 @@ 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
|
||||||
setNotes(notes.map((note) => (note.id === id ? response.data : note)));
|
.update(id, changedNote)
|
||||||
});
|
.then((response) => {
|
||||||
|
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));
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ const update = (id, newObject) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
getAll: getAll,
|
getAll,
|
||||||
create: create,
|
create,
|
||||||
update: update,
|
update,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue