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

import { userQueryKeys } from '../user-query-keys';
import { type PostGetProfileSeriesDataReturn, userApi } from '../user-api';

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

export const usePostGetProfileSeriesData = (
  token: string,
  user_id: number,
  series_id: number,
  enabled: boolean
) => {
  return useQuery<PostGetProfileSeriesDataReturn, BaseAxiosError>({
    queryKey: userQueryKeys.getProfileSeriesData(user_id, series_id),
    queryFn: async () => {
      const response = await userApi.getProfileSeriesData(token, user_id, series_id);
      return response.data;
    },
    enabled
  });
};
