import { useQuery } from '@tanstack/react-query';

import { fixersQueryKeys } from '../fixers-query-keys';
import { fixersApi, type PostGetFixersReturn } from '../fixers-api';

import type { BaseAxiosError } from '../../../../types';

export const useGetFixersQuery = (token: string, id: number, enabled: boolean) => {
  return useQuery<PostGetFixersReturn, BaseAxiosError>({
    queryKey: fixersQueryKeys.getFixers(id),
    queryFn: async () => {
      const response = await fixersApi.getFixers(token, id);
      return response.data;
    },
    enabled
  });
};
