import { useQuery } from '@tanstack/react-query';
import { getMitreMatrix, searchMitreTechniques } from '@/api/mitre';

export function useMitreSearch(query: string, enabled: boolean) {
  return useQuery({
    queryKey: ['mitre', 'techniques', query],
    queryFn: () => searchMitreTechniques(query),
    enabled: enabled && query.trim().length > 0,
    staleTime: 5 * 60 * 1000,
  });
}

export function useMitreMatrix(enabled: boolean) {
  return useQuery({
    queryKey: ['mitre', 'matrix'],
    queryFn: getMitreMatrix,
    enabled,
    staleTime: Infinity,
  });
}
