added logic to compare search results to books on shelves in order to set correct shelf for search result books

This commit is contained in:
Ken Jannette
2018-04-21 14:39:34 -04:00
parent 3663827967
commit 6dca84899f

View File

@@ -12,8 +12,17 @@ class SearchPage extends Component {
} }
onSearch = (query) => { onSearch = (query) => {
const books = this.props.books
// console.log(books)
if (query.length > 3) { if (query.length > 3) {
search(query).then((results) => { search(query).then((results) => {
for (result in results) {
for (book in books) {
if (result === book) {
result.shelf = book.shelf
}
}
}
this.setState({ results }); this.setState({ results });
}) })
} }