From 747e66704faf3c57c0bfd51e690f64daad909c51 Mon Sep 17 00:00:00 2001 From: Mocca101 <49754596+Mocca101@users.noreply.github.com> Date: Wed, 10 Apr 2024 17:15:28 +0200 Subject: [PATCH] Added config for default search filters --- composables/use-get-search-results.ts | 7 ++++++- config/search.config.ts | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 config/search.config.ts diff --git a/composables/use-get-search-results.ts b/composables/use-get-search-results.ts index 9f66365b..865bc11b 100644 --- a/composables/use-get-search-results.ts +++ b/composables/use-get-search-results.ts @@ -124,7 +124,12 @@ export function useGetSearchResults(params: MaybeRef) { return useQuery({ queryKey: ["search-results", params] as const, async queryFn({ queryKey, signal }) { - const [, params] = queryKey; + const [, queryParams] = queryKey; + const params = { + ...defaultFilterParams, + ...queryParams, + }; + const search = params.search?.map((value) => { return JSON.stringify(value); }); diff --git a/config/search.config.ts b/config/search.config.ts new file mode 100644 index 00000000..8217a2f0 --- /dev/null +++ b/config/search.config.ts @@ -0,0 +1,6 @@ +import type { GetSearchResultsParams } from "@/composables/use-get-search-results"; + +/** Default filters to be applied to all queries, e.g. when a DB is shared. + * @example { type_id: [0] } + */ +export const defaultFilterParams: GetSearchResultsParams = {};