make root filter work with children's books
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
David 2023-10-14 17:08:55 -04:00
parent c30052bac7
commit 43c3a25758

View File

@ -100,10 +100,11 @@ function apiResponseParsing(book) {
function search(books, searchBy, includeChildrensBooks) { function search(books, searchBy, includeChildrensBooks) {
searchBy = searchCleaner(searchBy); searchBy = searchCleaner(searchBy);
if (searchBy !== "") {
books = books.filter( books = books.filter(
({ title, authors, genre, publisher, series, year, childrens }) => { ({ title, authors, genre, publisher, series, year, childrens }) => {
var inSearch = Object.values({ var inSearch = true;
if (searchBy !== "") {
inSearch = Object.values({
title, title,
authors: authors.join(" "), authors: authors.join(" "),
genre, genre,
@ -111,13 +112,13 @@ function search(books, searchBy, includeChildrensBooks) {
series, series,
year, year,
}).find((field) => searchCleaner(field).indexOf(searchBy) !== -1); }).find((field) => searchCleaner(field).indexOf(searchBy) !== -1);
}
if (!includeChildrensBooks) { if (!includeChildrensBooks) {
return inSearch && !childrens; return inSearch && !childrens;
} }
return inSearch; return inSearch;
} }
); );
}
return books; return books;
} }