mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-07-30 21:41:59 +08:00

* refactor: remove the dependency of services using redux * refactor: seperated columns and unit test case * refactor: move the constant to other file * refactor: updated test case * refactor: removed the duplicate enum * fix: removed the inline function * fix: removed the inline function * refactor: removed the magic string * fix: change the name from matrics to metrics * fix: one on one mapping of props * refactor: created a hook to getting services through api call * fix: linter error * refactor: renamed the file according to functionality * refactor: renamed more file according to functionality * refactor: removed unwanted interfaces and renamed files * refactor: separated types * refactor: shifted mock data and completed review changes * chore: updated test cases * refactor: added useEffect in errornotification * chore: updated service test * chore: shifted loading to table level * chore: updated test cases --------- Co-authored-by: Vishal Sharma <makeavish786@gmail.com>
30 lines
791 B
TypeScript
30 lines
791 B
TypeScript
import getService from 'api/metrics/getService';
|
|
import { AxiosError } from 'axios';
|
|
import { Time } from 'container/TopNav/DateTimeSelection/config';
|
|
import { useQuery, UseQueryResult } from 'react-query';
|
|
import { PayloadProps } from 'types/api/metrics/getService';
|
|
import { Tags } from 'types/reducer/trace';
|
|
|
|
export const useQueryService = ({
|
|
minTime,
|
|
maxTime,
|
|
selectedTime,
|
|
selectedTags,
|
|
}: UseQueryServiceProps): UseQueryResult<PayloadProps, AxiosError> => {
|
|
const queryKey = [minTime, maxTime, selectedTime, selectedTags];
|
|
return useQuery<PayloadProps, AxiosError>(queryKey, () =>
|
|
getService({
|
|
end: maxTime,
|
|
start: minTime,
|
|
selectedTags,
|
|
}),
|
|
);
|
|
};
|
|
|
|
interface UseQueryServiceProps {
|
|
minTime: number;
|
|
maxTime: number;
|
|
selectedTime: Time;
|
|
selectedTags: Tags[];
|
|
}
|