import { useQuery } from 'react-query';

import { getCalibrationDetail } from 'src/pages/dashboard/performance/services';

import { performanceKeys } from '../../queries';

type UseCalibrationDetailParams = {
  cycleId: string | number;
  formReviewId: number;
};

const useCalibrationDetail = ({
  cycleId,
  formReviewId,
}: UseCalibrationDetailParams) =>
  useQuery(
    performanceKeys.calibrationDetail(cycleId, formReviewId),
    () => getCalibrationDetail(cycleId, formReviewId),
    {
      enabled: Boolean(cycleId) && Boolean(formReviewId),
      retry: false,
    },
  );

export default useCalibrationDetail;
