FEAT: genotype parsing resilience and displayGenotypeSafe format helper

This commit is contained in:
2026-06-08 21:19:11 +02:00
parent 7d8166c555
commit 04d189bd2f
5 changed files with 83 additions and 7 deletions

View File

@@ -29,7 +29,7 @@ import type { Gender, Gerbil, Litter } from '../api/types'
import { useApi } from '../hooks/useApi'
import { formatDate, genderLabel } from '../format/labels'
import GerbilIcon from '../components/GerbilIcon'
import { UNKNOWN_FARBSCHLAG, fromDisplayString, genotypeToFarbschlag, toDisplayString } from '../genetics'
import { UNKNOWN_FARBSCHLAG, fromDisplayString, genotypeToFarbschlag, displayGenotypeSafe } from '../genetics'
import {
DEFAULT_GENERATIONS,
ancestorsAt,
@@ -424,7 +424,7 @@ function PedigreeCard({
style={chip ? { background: chip.bg, color: chip.fg } : undefined}
title={farbschlag}
>
{g.genotype || farbschlag}
{g.genotype ? displayGenotypeSafe(g.genotype) : farbschlag}
</span>
)}
{dob && <span className="pedigree-card__year">* {dob}</span>}
@@ -574,7 +574,13 @@ function PrintCell({
{farbschlag && <div className="stammbaum-print__sub">{farbschlag}</div>}
{g.genotype && gen <= 2 && (
<div className="stammbaum-print__geno">
{toDisplayString(fromDisplayString(g.genotype))}
{(() => {
try {
return displayGenotypeSafe(g.genotype)
} catch {
return g.genotype.replace(/\?/g, '-')
}
})()}
</div>
)}
</div>