import request from './request'
import type {
  MatterCardResponse,
  MatterListItem,
  MatterRequirementsResponse,
} from '@/types/matter'

const BASE = '/api/ai/v1/graph/matters'

export function searchMatters(query: string, limit = 20): Promise<MatterListItem[]> {
  return request
    .get<MatterListItem[]>(BASE, { params: { query, limit } })
    .then((res) => res.data)
}

export function getMatterCard(matterId: string): Promise<MatterCardResponse> {
  return request
    .get<MatterCardResponse>(`${BASE}/${matterId}`)
    .then((res) => res.data)
}

export function getMatterRequirements(
  matterId: string,
): Promise<MatterRequirementsResponse> {
  return request
    .get<MatterRequirementsResponse>(`${BASE}/${matterId}/requirements`)
    .then((res) => res.data)
}