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

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

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

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