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

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

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

export const usePostGetProfileInfoDataQuery = (token: string, userId: number, enabled: boolean) => {
  return useQuery<PostGetProfileDataReturn, BaseAxiosError>({
    queryKey: userQueryKeys.getProfileInfoData(userId),
    queryFn: async () => {
      const response = await userApi.getProfileInfoData(token, userId);
      return response.data;
    },
    enabled
  });
};
