Fix Pairing Simulator: dog dropdowns were always empty
Build and Push Docker Image / build (push) Successful in 26s
Build and Push Docker Image / build (push) Successful in 26s
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user