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

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

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

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