mirror of
https://github.com/BradNut/umami
synced 2025-09-08 17:40:29 +00:00
20 lines
507 B
TypeScript
20 lines
507 B
TypeScript
import { useApi } from 'components/hooks';
|
|
import { subDays } from 'date-fns';
|
|
|
|
export function useWebsiteValues(websiteId: string, type: string) {
|
|
const now = Date.now();
|
|
const { get, useQuery } = useApi();
|
|
|
|
return useQuery({
|
|
queryKey: ['websites:values', websiteId, type],
|
|
queryFn: () =>
|
|
get(`/websites/${websiteId}/values`, {
|
|
type,
|
|
startAt: +subDays(now, 90),
|
|
endAt: now,
|
|
}),
|
|
enabled: !!(websiteId && type),
|
|
});
|
|
}
|
|
|
|
export default useWebsiteValues;
|