import { useQuery } from '@tanstack/react-query';
import { fetchTicketCollaborators } from '@/features/tickets/services/collaboratorService';

export const ticketCollaboratorsQueryKey = (ticketId: string) =>
  ['tickets', ticketId, 'collaborators'] as const;

export function useTicketCollaborators(ticketId: string | undefined, enabled = true) {
  return useQuery({
    queryKey: ticketCollaboratorsQueryKey(ticketId ?? ''),
    queryFn: () => fetchTicketCollaborators(ticketId!),
    enabled: Boolean(ticketId) && enabled,
  });
}
