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

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

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

export const usePostGetProfileRegions = (token: string, uid: number, type: string) => {
  return useQuery<PostGetProfileRegionsReturn, BaseAxiosError>({
    queryKey: userQueryKeys.getProfileRegions(uid, type),
    queryFn: async () => {
      const response = await userApi.getProfileRegions(token, uid, type);
      return response.data;
    }
  });
};
