mirror of
https://github.com/umami-software/umami.git
synced 2026-02-06 13:47:15 +01:00
Refactored filter parameters.
This commit is contained in:
parent
1a839d1cae
commit
cff2d00536
13 changed files with 291 additions and 123 deletions
|
|
@ -1,19 +1,30 @@
|
|||
import { useApi } from 'components/hooks';
|
||||
import { subDays } from 'date-fns';
|
||||
|
||||
export function useWebsiteValues(websiteId: string, type: string) {
|
||||
const now = Date.now();
|
||||
export function useWebsiteValues({
|
||||
websiteId,
|
||||
type,
|
||||
startDate,
|
||||
endDate,
|
||||
search,
|
||||
}: {
|
||||
websiteId: string;
|
||||
type: string;
|
||||
startDate: Date;
|
||||
endDate: Date;
|
||||
search?: string;
|
||||
}) {
|
||||
const { get, useQuery } = useApi();
|
||||
|
||||
return useQuery({
|
||||
queryKey: ['websites:values', websiteId, type],
|
||||
queryKey: ['websites:values', { websiteId, type, startDate, endDate, search }],
|
||||
queryFn: () =>
|
||||
get(`/websites/${websiteId}/values`, {
|
||||
type,
|
||||
startAt: +subDays(now, 90),
|
||||
endAt: now,
|
||||
startAt: +startDate,
|
||||
endAt: +endDate,
|
||||
search,
|
||||
}),
|
||||
enabled: !!(websiteId && type),
|
||||
enabled: !!(websiteId && type && startDate && endDate),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue