FEAT-3: litter type+CRUD, Zucht strings, /wuerfe nested routes (retire LittersPage)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-06 00:27:29 +02:00
parent d7be812ad0
commit 87250ba007
8 changed files with 141 additions and 14 deletions

View File

@@ -1,7 +1,24 @@
/** Typed API functions for the Würfe (litters) resource. */
import { api, resources } from './client'
import type { Litter } from './types'
import { toQueryString, type GridifyQuery } from './gridify'
import type { CreateLitter, Litter, Paged, UpdateLitter } from './types'
export function getLitter(id: string): Promise<Litter> {
return api.get<Litter>(`${resources.litters}/${id}`)
}
export function listLitters(query: GridifyQuery): Promise<Paged<Litter>> {
return api.get<Paged<Litter>>(`${resources.litters}${toQueryString(query)}`)
}
export function createLitter(body: CreateLitter): Promise<Litter> {
return api.post<Litter>(resources.litters, body)
}
export function updateLitter(id: string, body: UpdateLitter): Promise<Litter> {
return api.put<Litter>(`${resources.litters}/${id}`, body)
}
export function deleteLitter(id: string): Promise<void> {
return api.delete(`${resources.litters}/${id}`)
}

View File

@@ -80,12 +80,34 @@ export interface Contact {
export interface Litter {
id: string
name: string
/** Wurfdatum (birth date). */
date: DateOnlyString
/** Wurfstärke — total born count. */
totalBorn: number | null
/**
* Abgabedatum (auto-suggested ~35 days after birth, editable).
* Optional in the type so existing Litter constructors (e.g. pedigree test
* factories) keep compiling; the API DTO always includes it (nullable).
*/
expectedGoHomeDate?: DateOnlyString | null
notes?: string | null
fatherId: string | null
motherId: string | null
}
/** Payload for POST /litters. */
export interface CreateLitter {
name: string
date: DateOnlyString
totalBorn?: number | null
expectedGoHomeDate?: DateOnlyString | null
notes?: string | null
fatherId?: string | null
motherId?: string | null
}
export type UpdateLitter = Partial<CreateLitter>
/** Paged list envelope returned by Gridify list endpoints. */
export interface Paged<T> {
items: T[]