diff --git a/client/src/pages/PairingSimulator.jsx b/client/src/pages/PairingSimulator.jsx index 047f708..1dc8236 100644 --- a/client/src/pages/PairingSimulator.jsx +++ b/client/src/pages/PairingSimulator.jsx @@ -13,7 +13,8 @@ export default function PairingSimulator() { const [relationChecking, setRelationChecking] = useState(false) useEffect(() => { - fetch('/api/dogs') + // include_external=1 ensures external sires/dams appear for pairing + fetch('/api/dogs?include_external=1') .then(r => r.json()) .then(data => { setDogs(Array.isArray(data) ? data : (data.dogs || [])) @@ -54,9 +55,6 @@ export default function PairingSimulator() { checkRelation(sireId, val) } - const males = dogs.filter(d => d.sex === 'male') - const females = dogs.filter(d => d.sex === 'female') - async function handleSimulate(e) { e.preventDefault() if (!sireId || !damId) return @@ -64,16 +62,14 @@ export default function PairingSimulator() { setError(null) setResult(null) try { - const res = await fetch('/api/pedigree/trial-pairing', { + const res = await fetch('/api/pedigree/coi', { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ sire_id: parseInt(sireId), dam_id: parseInt(damId) }) + body: JSON.stringify({ sire_id: parseInt(sireId), dam_id: parseInt(damId) }), }) - if (!res.ok) { - const err = await res.json() - throw new Error(err.error || 'Failed to calculate') - } - setResult(await res.json()) + const data = await res.json() + if (!res.ok) throw new Error(data.error || 'Simulation failed') + setResult(data) } catch (err) { setError(err.message) } finally { @@ -81,204 +77,164 @@ export default function PairingSimulator() { } } - function RiskBadge({ coi, recommendation }) { - const isLow = coi < 5 - const isMed = coi >= 5 && coi < 10 - const isHigh = coi >= 10 - return ( -
- Select a sire and dam to calculate the estimated inbreeding coefficient (COI) and view common ancestors. -
++ Estimate the Coefficient of Inbreeding (COI) for a hypothetical pairing before breeding. + Includes both kennel and external dogs. +
- {/* Selector Card */} -