From 43c3a257589f69f6eb6b7335340c0bf0923ec4d8 Mon Sep 17 00:00:00 2001 From: David Ashby Date: Sat, 14 Oct 2023 17:08:55 -0400 Subject: [PATCH] make root filter work with children's books --- frontend/files/app.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/frontend/files/app.js b/frontend/files/app.js index 2a53e87..78e598a 100644 --- a/frontend/files/app.js +++ b/frontend/files/app.js @@ -100,10 +100,11 @@ function apiResponseParsing(book) { function search(books, searchBy, includeChildrensBooks) { searchBy = searchCleaner(searchBy); - if (searchBy !== "") { - books = books.filter( - ({ title, authors, genre, publisher, series, year, childrens }) => { - var inSearch = Object.values({ + books = books.filter( + ({ title, authors, genre, publisher, series, year, childrens }) => { + var inSearch = true; + if (searchBy !== "") { + inSearch = Object.values({ title, authors: authors.join(" "), genre, @@ -111,13 +112,13 @@ function search(books, searchBy, includeChildrensBooks) { series, year, }).find((field) => searchCleaner(field).indexOf(searchBy) !== -1); - if (!includeChildrensBooks) { - return inSearch && !childrens; - } - return inSearch; } - ); - } + if (!includeChildrensBooks) { + return inSearch && !childrens; + } + return inSearch; + } + ); return books; }