feat: added "cookbook" filter to recipe pagination to serve frontend (#1609)

* added cookbook filter to recipe pagination

* fixed wrong filter var

* restored cookbook sorting

* reverted unnecessary var change
This commit is contained in:
Michael Genson
2022-09-10 11:59:30 -05:00
committed by GitHub
parent d26cb570ba
commit 2007bcfe28
5 changed files with 80 additions and 9 deletions

View File

@@ -11,8 +11,17 @@ export const useLazyRecipes = function () {
const recipes = ref<Recipe[]>([]);
async function fetchMore(page: number, perPage: number, orderBy: string | null = null, orderDirection = "desc", category: string | null = null, tag: string | null = null, tool: string | null = null) {
const { data } = await api.recipes.getAll(page, perPage, { orderBy, orderDirection, "categories": category, "tags": tag, "tools": tool });
async function fetchMore(
page: number,
perPage: number,
orderBy: string | null = null,
orderDirection = "desc",
cookbook: string | null = null,
category: string | null = null,
tag: string | null = null,
tool: string | null = null
) {
const { data } = await api.recipes.getAll(page, perPage, { orderBy, orderDirection, cookbook, "categories": category, "tags": tag, "tools": tool });
return data ? data.items : [];
}