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) {
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;
}