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

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

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

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