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

This commit is contained in:
David 2023-10-14 17:08:55 -04:00
parent c30052bac7
commit 43c3a25758
1 changed files with 11 additions and 10 deletions

View File

@ -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;
}