diff --git a/src/App.js b/src/App.js index 6a0bfd4..08cc2b9 100755 --- a/src/App.js +++ b/src/App.js @@ -27,8 +27,24 @@ class BooksApp extends React.Component { } onResultSelect = (e) => { - console.log("onResultSelect") - this.history.push('/'); + + const books = this.state.books + const id = e.target.name + const newShelf = e.target.value + const results = this.state.results + let newBook + + results.forEach((result) => { + if (result.id === id) { + newBook = result + newBook.shelf = newShelf + } + }); + + this.setState({ + books: [...newBook] + }) + } onSelectChange = (e) => {