/** FEAT-13: Abgabeverträge (/contracts). */ import { API_BASE_URL, api, resources } from './client' import { toQueryString, type GridifyQuery } from './gridify' import type { DateOnlyString, Paged } from './types' export interface SaleContract { id: string contactId: string price: number handoverDate: DateOnlyString contractDate: DateOnlyString fileName: string createdAt: string gerbilIds: string[] /** API-relativer Download-Pfad ("/contracts/{id}/file"). */ url: string } export interface CreateSaleContract { contactId: string gerbilIds: string[] price: number handoverDate: DateOnlyString contractDate?: DateOnlyString | null } export function listContracts(query: GridifyQuery): Promise> { return api.get>(`${resources.contracts}${toQueryString(query)}`) } export function createContract(body: CreateSaleContract): Promise { return api.post(resources.contracts, body) } export function deleteContract(id: string): Promise { return api.delete(`${resources.contracts}/${id}`) } /** Absolute Download-URL der .docx (für / window.open). */ export function contractFileUrl(contract: Pick): string { return `${API_BASE_URL}${contract.url}` }