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

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

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

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