FEAT: genotype parsing resilience and displayGenotypeSafe format helper
This commit is contained in:
@@ -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