From be79364aa4d96db8261461ee6bab77933266567d Mon Sep 17 00:00:00 2001 From: Jason Stedwell Date: Mon, 6 Jul 2026 15:51:56 -0500 Subject: [PATCH] Fix Pairing Simulator: dog dropdowns were always empty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PairingSimulator read 'data.dogs' from GET /api/dogs, but that endpoint returns a paginated { data, total, ... } object — the fallback silently produced an empty list, so no sires or dams ever appeared. Same latent wrong-response-key bug as the Start Heat Cycle female list fixed in 55d636b. Switch to GET /api/dogs/all (unpaginated, kennel + external — no 50-dog page cap) and surface load failures in the existing error card instead of swallowing them. Verified in-browser: dropdowns populate, parent-offspring pairing shows the 'Related' warning and computes COI 25.00% with common ancestor listed. Co-Authored-By: Claude Fable 5 --- client/src/pages/PairingSimulator.jsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/client/src/pages/PairingSimulator.jsx b/client/src/pages/PairingSimulator.jsx index c214863..8bede56 100644 --- a/client/src/pages/PairingSimulator.jsx +++ b/client/src/pages/PairingSimulator.jsx @@ -15,14 +15,19 @@ export default function PairingSimulator() { const [geneticChecking, setGeneticChecking] = useState(false) useEffect(() => { - // include_external=1 ensures external sires/dams appear for pairing - fetch('/api/dogs?include_external=1') - .then(r => r.json()) + // /all returns an unpaginated array of every active dog (kennel + external), + // so external sires/dams appear and nothing is cut off by pagination + fetch('/api/dogs/all') + .then(r => r.ok ? r.json() : Promise.reject(new Error(`HTTP ${r.status}`))) .then(data => { - setDogs(Array.isArray(data) ? data : (data.dogs || [])) + setDogs(Array.isArray(data) ? data : (data.data || [])) + setDogsLoading(false) + }) + .catch((err) => { + console.error('Failed to load dogs for pairing:', err) + setError('Failed to load dogs — refresh to try again') setDogsLoading(false) }) - .catch(() => setDogsLoading(false)) }, []) // Check for direct relation whenever both sire and dam are selected