import { useQuery, useMutation } from '@tanstack/react-query'
import { aiAssistantService } from '../services/aiAssistantService'
import type { AssistantContext } from '../domain/assistant'

export function useAssistantSuggestions(context: AssistantContext | null) {
  return useQuery({
    queryKey: ['assistant-suggestions', context],
    queryFn: () => aiAssistantService.getSuggestions(context!),
    enabled: !!context,
    staleTime: 30_000,
  })
}

export function useAssistantAnswer() {
  return useMutation({
    mutationFn: ({ context, question }: { context: AssistantContext; question: string }) =>
      aiAssistantService.answerQuestion(context, question),
  })
}
