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

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

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

export const usePostGetProfileInfoQuery = (token: string, enabled: boolean) => {
  return useQuery<PostGetProfileInfoReturn, BaseAxiosError>({
    queryKey: userQueryKeys.getProfileInfo(),
    queryFn: async () => {
      const response = await userApi.getProfileInfo(token);
      return response.data;
    },
    enabled
  });
};
