import { useState } from 'react' import { de } from '../strings/de' import type { BreedingResult } from '../genetics' import FarbschlagImage from './FarbschlagImage' function warningText(code: string): string { const map = de.genetics.warnings as Record return map[code] ?? code } export interface BreedingResultViewProps { result: BreedingResult /** Heading shown above the Farbschlag cards. Defaults to "Mögliche Nachkommen". */ title?: string } /** * Renders a GEN-1 breeding result: warnings (SCHECKE_LETHAL prominent), * offspring grouped byFarbschlag (percent + exact fraction), and a collapsible * per-genotype table. Shared by the Genetik page (FEAT-5) and the Wurf * workspace (FEAT-3) where it shows the expected distribution for a pairing. */ export default function BreedingResultView({ result, title }: BreedingResultViewProps) { const t = de.pages.genetik const [showGenotypes, setShowGenotypes] = useState(false) return (
{result.warnings.length > 0 && (

{t.warningsTitle}

{result.warnings.map((w) => (
{warningText(w.code)}
))}
)}

{title ?? t.resultsTitle}

{result.byFarbschlag.length === 0 ? (

{t.noOffspring}

) : ( <> {showGenotypes && (
{result.offspring.map((o) => ( ))}
{t.genotypeLabel} {t.genotypePreview} {t.probability}
{o.genotype} {o.farbschlag} {o.probability.percent} ({o.probability.text})
)} )}
) }