Files
GerbilManager/gerbil-manager-web/src/api/pedigree.ts
Gulum 74ac6ddb5a FEAT-4: sync inbreeding DTO to FEAT-1b InbreedingResult + anchor root card left so parents are visible on phone at load
Verified end-to-end against a DATA-2-contract mock (5-gen family, shared ancestor): phone/desktop, re-root, lazy expand, zoom/fit, print Ahnentafel, 404 state.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-06 00:30:14 +02:00

28 lines
1.0 KiB
TypeScript

/**
* FEAT-4: Stammbaum-bezogene API-Aufrufe.
*
* Der Inzuchtkoeffizient wird serverseitig über die VOLLE Ahnentiefe berechnet
* (Board-Entscheidung; UI zeigt 4 Generationen, Koeffizient zählt alle).
* Endpunkt: FEAT-1b (InbreedingController, Wright-Pfadmethode).
*/
import { api, resources } from './client'
/** Spiegelt GerbilManagerWebAPI.Genetics.InbreedingResult. */
export interface InbreedingResult {
/** Koeffizient F nach Wright, 0..1. */
coefficient: number
/** F in Prozent (Server-Komfortfeld). */
percent: number
/** Tiefste bekannte Ahnen-Generation (Eltern = 1; 0 = keine erfasst). */
generationsAvailable: number
commonAncestors: { id: string; name: string; contribution: number }[]
}
export async function getInbreedingCoefficient(gerbilId: string): Promise<number> {
const raw = await api.get<InbreedingResult | number>(
`${resources.gerbils}/${gerbilId}/inbreeding-coefficient`,
)
// Defensiv gegen Vertragsdrift (nacktes number vs. Objekt).
return typeof raw === 'number' ? raw : raw.coefficient
}