The getNewBookDetails method will simply retrieve values for the different fields in the new book creation form (in a specific book collection) and will create a Book object corresponding to those values.
Let's add the code for it.
First, add the method and some defensive checks:
getNewBookDetails(collectionIdentifier: string): { error?: string, book?: Book } { if (!collectionIdentifier) { // we throw this one because it means that there is a bug! throw new Error("The collection identifier must be provided!"); } // required const newBookForm = document.getElementById(`newBook-$ {collectionIdentifier}`) as HTMLFormElement; if (!newBookForm) { throw new Error(`Could not find ...