import type { LeaveRecapRow } from './dto/leave-recap'
import { extractItems } from '~/utils/api'

export const fetchLeaveRecap = async (): Promise<LeaveRecapRow[]> => {
  const api = useApi()
  const data = await api.get<LeaveRecapRow[] | { 'hydra:member'?: LeaveRecapRow[] }>(
    '/leave-recap',
    {},
    { toastErrorKey: 'errors.leaveRecap.load' }
  )
  return extractItems<LeaveRecapRow>(data)
}
