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

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

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

export const usePostCanCreateGroupQuery = (token: string, enabled: boolean) => {
  return useQuery<PostCanCreateGroupReturn, BaseAxiosError>({
    queryKey: chatQueryKeys.canCreateGroup(token),
    queryFn: async () => {
      const response = await chatApi.canCreateGroup(token);
      return response.data;
    },
    enabled
  });
};
