mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 07:37:11 +01:00
Update field select forms. Created new hooks.
This commit is contained in:
parent
5daad2726e
commit
8bc1dcb4b3
18 changed files with 282 additions and 254 deletions
20
src/components/hooks/queries/useWebsiteValues.ts
Normal file
20
src/components/hooks/queries/useWebsiteValues.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue