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

import { regionsQueryKeys } from '../regions-query-keys';
import { type PostSetNmRegion, regionsApi } from '../regions-api';

import type { BaseAxiosError } from '../../../../types';
import { ResponseType } from '@api/response-type';

export const usePostSetNmRegionMutation = () => {
  return useMutation<ResponseType, BaseAxiosError, PostSetNmRegion, ResponseType>({
    mutationKey: regionsQueryKeys.setNmRegion(),
    mutationFn: async (data) => {
      const response = await regionsApi.setNmRegion(data);
      return response.data;
    }
  });
};
