mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-07-29 16:52:00 +08:00

* feat: update time range selection flows to handle relative and absolute times * fix: lint error * fix: lint error * feat: update logic to handle custom relative times on load and standardize relative time formats * fix: type issue * fix: handle light mode and on custom time range select * chore: update alert frequency corresponding times * chore: update copy URL * feat: update styles
37 lines
1020 B
TypeScript
37 lines
1020 B
TypeScript
import getService from 'api/metrics/getService';
|
|
import { AxiosError } from 'axios';
|
|
import { Time } from 'container/TopNav/DateTimeSelection/config';
|
|
import {
|
|
CustomTimeType,
|
|
Time as TimeV2,
|
|
} from 'container/TopNav/DateTimeSelectionV2/config';
|
|
import {
|
|
QueryKey,
|
|
useQuery,
|
|
UseQueryOptions,
|
|
UseQueryResult,
|
|
} from 'react-query';
|
|
import { PayloadProps } from 'types/api/metrics/getService';
|
|
import { Tags } from 'types/reducer/trace';
|
|
|
|
export const useQueryService = ({
|
|
minTime,
|
|
maxTime,
|
|
selectedTime,
|
|
selectedTags,
|
|
options,
|
|
}: UseQueryServiceProps): UseQueryResult<PayloadProps, AxiosError> =>
|
|
useQuery<PayloadProps, AxiosError>({
|
|
queryFn: () => getService({ end: maxTime, selectedTags, start: minTime }),
|
|
queryKey: [minTime, maxTime, selectedTime, selectedTags],
|
|
...options,
|
|
});
|
|
|
|
interface UseQueryServiceProps {
|
|
minTime: number;
|
|
maxTime: number;
|
|
selectedTime: Time | TimeV2 | CustomTimeType;
|
|
selectedTags: Tags[];
|
|
options?: UseQueryOptions<PayloadProps, AxiosError, PayloadProps, QueryKey>;
|
|
}
|