/** * ZUCHT-SUFFIX: a gerbil's display name with the own-Zucht "suffix" (like a last * name) appended — "Danako" + "von den kleinen Chaoten" → "Danako von den kleinen * Chaoten". Per the chosen rule, only OWN-bred animals get the suffix; animals from * other breeders keep their plain name. */ import type { Gerbil } from '../api/types' type NameParts = Pick /** Own-bred = no external origin recorded (no origin contact, no freetext breeder). */ export function isOwnBred(g: NameParts): boolean { return !g.originContactId && !(g.originBreeder && g.originBreeder.trim()) } /** * Name + own-Zucht suffix for own-bred animals; plain name otherwise. * Returns '' for a nameless animal (callers fall back to the "(ohne Namen)" label). */ export function gerbilDisplayName(g: NameParts, ownSuffix: string): string { if (!g.name) return '' const suffix = ownSuffix.trim() return suffix && isOwnBred(g) ? `${g.name} ${suffix}` : g.name }