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

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

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

export const usePostCanSendMessageQuery = (token: string, to_uid: number, enabled: boolean) => {
  return useQuery<PostCanSendMessageReturn, BaseAxiosError>({
    queryKey: chatQueryKeys.canSendMessage(token, to_uid),
    queryFn: async () => {
      const response = await chatApi.canSendMessage(token, to_uid);
      return response.data;
    },
    enabled
  });
};
