Refactored useDateRange to always use query string. Fixed all time filter.
This commit is contained in:
1 parent
4d06b0ca5b
commit
92ee44756c
28 files changed
+106
-112
No files matched your search
@@ -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,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user