Fixed metrics search.

This commit is contained in:
Mike Cao 2024-05-03 23:21:27 -07:00
parent 8be95e32ba
commit 43907bd075
3 changed files with 13 additions and 12 deletions

View file

@ -4,8 +4,7 @@ import { useFilterParams } from '../useFilterParams';
export function useWebsiteMetrics(
websiteId: string,
type: string,
limit: number,
query: { type: string; limit: number; search: string },
options?: Omit<UseQueryOptions & { onDataLoad?: (data: any) => void }, 'queryKey' | 'queryFn'>,
) {
const { get, useQuery } = useApi();
@ -17,19 +16,17 @@ export function useWebsiteMetrics(
{
websiteId,
...params,
type,
limit,
...query,
},
],
queryFn: async () => {
const filters = { ...params };
filters[type] = undefined;
filters[query.type] = undefined;
const data = await get(`/websites/${websiteId}/metrics`, {
...filters,
type,
limit,
...query,
});
options?.onDataLoad?.(data);