FEAT: genotype parsing resilience and displayGenotypeSafe format helper
This commit is contained in:
@@ -6,7 +6,7 @@ import { listLitters as listLittersPaged } from '../api/litters'
|
||||
import { listColorVarieties, listContacts, listEnclosures, listLitters } from '../api/lookups'
|
||||
import { useApi, useMutation } from '../hooks/useApi'
|
||||
import { formatDate, genderLabel, statusLabel } from '../format/labels'
|
||||
import { fromDisplayString, genotypeToFarbschlag, toDisplayString } from '../genetics'
|
||||
import { fromDisplayString, genotypeToFarbschlag, displayGenotypeSafe } from '../genetics'
|
||||
import FarbschlagImage from '../components/FarbschlagImage'
|
||||
import Charakterbogen from '../components/Charakterbogen'
|
||||
// FEAT-6 (Oscar): Tab-Inhalte + Profilfoto
|
||||
@@ -22,10 +22,10 @@ function describeGenotype(genotype: string | null): { display: string; farbschla
|
||||
if (!genotype || !genotype.trim()) return null
|
||||
try {
|
||||
const g = fromDisplayString(genotype)
|
||||
return { display: toDisplayString(g), farbschlag: genotypeToFarbschlag(g) }
|
||||
return { display: displayGenotypeSafe(genotype), farbschlag: genotypeToFarbschlag(g) }
|
||||
} catch {
|
||||
// Unparseable: show the raw value, no derived Farbschlag.
|
||||
return { display: genotype, farbschlag: de.genetics.unknownFarbschlag }
|
||||
// Unparseable: show the safely-rendered raw value, no derived Farbschlag.
|
||||
return { display: displayGenotypeSafe(genotype), farbschlag: de.genetics.unknownFarbschlag }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user