import type { Contract } from './dto/contract'
import { extractItems } from '~/utils/api'

export const listContracts = async () => {
  const api = useApi()
  const data = await api.get<Contract[] | { 'hydra:member'?: Contract[] }>(
    '/contracts',
    {},
    { toast: false }
  )

  return extractItems<Contract>(data)
}
