mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 22:27:16 +01:00
Refactored useDateRange to always use query string. Fixed all time filter.
This commit is contained in:
parent
4d06b0ca5b
commit
92ee44756c
28 changed files with 106 additions and 112 deletions
|
|
@ -1,12 +1,23 @@
|
|||
import { useApi } from '../useApi';
|
||||
import { ReactQueryOptions } from '@/lib/types';
|
||||
|
||||
type DateRange = {
|
||||
startDate?: string;
|
||||
endDate?: string;
|
||||
};
|
||||
|
||||
export function useDateRangeQuery(websiteId: string, options?: ReactQueryOptions) {
|
||||
const { get, useQuery } = useApi();
|
||||
return useQuery<any>({
|
||||
|
||||
const { data } = useQuery<DateRange>({
|
||||
queryKey: ['date-range', websiteId],
|
||||
queryFn: () => get(`/websites/${websiteId}/daterange`),
|
||||
enabled: !!websiteId,
|
||||
...options,
|
||||
});
|
||||
|
||||
return {
|
||||
startDate: data?.startDate ? new Date(data.startDate) : null,
|
||||
endDate: data?.endDate ? new Date(data.endDate) : null,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue