mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 20:57:17 +01:00
23 lines
614 B
TypeScript
23 lines
614 B
TypeScript
import type { ReactQueryOptions } from '@/lib/types';
|
|
import { useApi } from '../useApi';
|
|
|
|
type DateRange = {
|
|
startDate?: string;
|
|
endDate?: string;
|
|
};
|
|
|
|
export function useDateRangeQuery(websiteId: string, options?: ReactQueryOptions) {
|
|
const { get, useQuery } = useApi();
|
|
|
|
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,
|
|
};
|
|
}
|