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

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

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

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