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

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

import type { BaseAxiosError } from '../../../../types';

export const usePostGetGroupMessageStatusQuery = (
  token: string,
  group_token: string,
  message_id: number,
  enabled: boolean
) => {
  return useQuery<PostGetGroupMessageStatusReturn, BaseAxiosError>({
    queryKey: chatQueryKeys.getGroupMessageStatus(token, group_token, message_id),
    queryFn: async () => {
      const response = await chatApi.getGroupMessageStatus(token, group_token, message_id);
      return response.data;
    },
    enabled
  });
};
