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

import { chatQueryKeys } from '../chat-query-keys';
import { chatApi, type PostEditGroupMessage } from '../chat-api';

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

export const usePostEditGroupMessageMutation = () => {
  return useMutation<ResponseType, BaseAxiosError, PostEditGroupMessage, ResponseType>({
    mutationKey: chatQueryKeys.editGroupMessage(),
    mutationFn: async (data) => {
      const response = await chatApi.editGroupMessage(data);
      return response.data;
    }
  });
};
