Skip to content

Commit

Permalink
Added config for default search filters
Browse files Browse the repository at this point in the history
  • Loading branch information
Mocca101 committed Apr 10, 2024
1 parent e48b7be commit 747e667
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion composables/use-get-search-results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,12 @@ export function useGetSearchResults(params: MaybeRef<GetSearchResultsParams>) {
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);
});
Expand Down
6 changes: 6 additions & 0 deletions config/search.config.ts
Original file line number Diff line number Diff line change
@@ -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 = {};

0 comments on commit 747e667

Please sign in to comment.