import { useQuery } from 'react-query';

import { acknowledgementsKeys } from 'src/pages/dashboard/acknowledgements/queries';
import { getAvailablePoints } from 'src/pages/dashboard/acknowledgements/services';

export const useGetAvailablePoints = (enabled = true) => {
  const { data: availablePoints = 0, ...query } = useQuery({
    queryKey: acknowledgementsKeys.availablePoints(),
    queryFn: getAvailablePoints,
    select: response => response.data.availablePoints,
    enabled,
  });

  return { availablePoints, ...query };
};
