import type { EmployeeRttSummary } from './dto/employee-rtt-summary'

export const getEmployeeRttSummary = async (employeeId: number, year?: number, phaseId?: number) => {
  const api = useApi()
  const query: Record<string, number> = {}
  if (year) query.year = year
  if (phaseId !== undefined) query.phaseId = phaseId
  return api.get<EmployeeRttSummary>(`/employees/${employeeId}/rtt-summary`, query, { toast: false })
}

export const createRttPayment = async (
  employeeId: number,
  month: number,
  base25Minutes: number,
  bonus25Minutes: number,
  base50Minutes: number,
  bonus50Minutes: number,
  year?: number
) => {
  const api = useApi()
  const body: Record<string, unknown> = { month, base25Minutes, bonus25Minutes, base50Minutes, bonus50Minutes }
  if (year) body.year = year
  return api.patch(`/employees/${employeeId}/rtt-payments`, body)
}

