Skip to content

Commit

Permalink
See changes.md for a list of revisions.
Browse files Browse the repository at this point in the history
  • Loading branch information
xnodeoncode committed Sep 28, 2024
1 parent 941a202 commit e38336e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
Binary file added v4/favicon.ico
Binary file not shown.
15 changes: 4 additions & 11 deletions v4/src/components/BookForm/BookForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,17 @@ export function BookForm({

function saveBook(e) {
if (selectedBook.id) {
updateBooks(
books.map((b) => {
if (b.id === selectedBook.id) {
return selectedBook;
}
return b;
})
);
updateBook({});
e.preventDefault();
const bookIndex = books.findIndex((b) => b.id === selectedBook.id);
books[bookIndex] = book;
updateBooks([...books]);
return;
}
book.id = new Date().getTime();
console.log(book);
updateBook({ ...book });

updateBooks([...books, book]);
book = {};
clearForm(e);
e.preventDefault();
}

Expand Down

0 comments on commit e38336e

Please sign in to comment.