Skip to content

Commit

Permalink
update filters
Browse files Browse the repository at this point in the history
  • Loading branch information
VovaStelmashchuk committed Sep 1, 2024
1 parent 5bae9da commit 0c9a75a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion database/filetrs.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,17 @@ async function buildFutureCounter(inputFilters, filterKey, collectionName) {

const futureFilter = { ...filters, [filterKey]: theFilterValue };

const futureSelectedFilterCount = Object.keys(futureFilter).reduce((acc, key) => acc + futureFilter[key].length, 0);
const isAddToIndex = futureSelectedFilterCount < 3;

const count = await getCocktailCountByFilter(futureFilter);

return {
id: filterValue.id,
query: filterToPath(futureFilter),
count: count,
isActive: isInclude,
isAddToIndex: isAddToIndex,
};
}));

Expand All @@ -154,6 +158,9 @@ async function getCocktailFilterState(filters, skip, limit, sortType) {
buildFutureCounter(filters, 'tags', 'tags')
]);

const selectedFilterCount = Object.keys(filters).reduce((acc, key) => acc + filters[key].length, 0);
const isAddToIndex = selectedFilterCount < 3;

return {
totalCount,
cocktails,
Expand All @@ -164,7 +171,8 @@ async function getCocktailFilterState(filters, skip, limit, sortType) {
3: toolsFuture,
4: goodsFuture,
5: tagsFuture,
}
},
isAddToIndex: isAddToIndex,
}
}

Expand Down

0 comments on commit 0c9a75a

Please sign in to comment.