fix: wire external dogs end-to-end (modal, form flag, pairing simulator) #49

Merged
jason merged 4 commits from fix/external-dogs-wiring into feature/external-dogs 2026-03-11 01:01:19 -05:00
Owner

What this fixes

Three disconnected pieces of the external dogs feature were never actually wired together:

1. ExternalDogs.jsx — broken navigation → modal

  • Before: "Add External Dog" button called navigate('/dogs/new?external=1') which routed to the standard dog list, not an external dog form.
  • After: Button sets showAddModal = true, opens <DogForm isExternal={true} /> inline. fetchDogs() is called on save to refresh the list.

2. DogForm.jsxisExternal prop never existed

  • Before: Form had no isExternal prop, no is_external in state, and always sent is_external as undefined in the POST/PUT payload.
  • After:
    • Accepts isExternal prop (defaults false)
    • Derives effectiveExternal = isExternal || dog?.is_external so editing an existing external dog also works
    • Sets is_external: 1 in submit payload when external
    • Forces sire_id, dam_id, litter_id to null in payload when external
    • Hides the entire Parent Information section when external
    • Shows an info banner: "External dog — not part of your kennel roster"
    • Updates modal title and submit button label accordingly

3. PairingSimulator.jsx — only fetched kennel dogs

  • Before: fetch('/api/dogs') — external sires/dams never appeared in pairing selectors.
  • After: fetch('/api/dogs?include_external=1') — external dogs included. Dropdown options show [Ext] suffix for easy identification.

Backend requirement

The /api/dogs endpoint needs to support ?include_external=1 to return both kennel and external dogs. If not already implemented, the default (no param) should continue returning kennel-only dogs.

Test checklist

  • External Dogs page → Add External Dog → modal opens with external banner visible
  • Submit external dog → is_external=1 in DB, litter/parent fields not sent
  • Edit an existing external dog → parent section hidden, is_external preserved
  • Pairing Simulator dropdowns show external dogs with [Ext] label
  • Standard Add Dog from My Dogs page still shows full parent/litter section
## What this fixes Three disconnected pieces of the external dogs feature were never actually wired together: ### 1. `ExternalDogs.jsx` — broken navigation → modal - **Before:** "Add External Dog" button called `navigate('/dogs/new?external=1')` which routed to the standard dog list, not an external dog form. - **After:** Button sets `showAddModal = true`, opens `<DogForm isExternal={true} />` inline. `fetchDogs()` is called on save to refresh the list. ### 2. `DogForm.jsx` — `isExternal` prop never existed - **Before:** Form had no `isExternal` prop, no `is_external` in state, and always sent `is_external` as undefined in the POST/PUT payload. - **After:** - Accepts `isExternal` prop (defaults `false`) - Derives `effectiveExternal = isExternal || dog?.is_external` so editing an existing external dog also works - Sets `is_external: 1` in submit payload when external - Forces `sire_id`, `dam_id`, `litter_id` to `null` in payload when external - Hides the entire Parent Information section when external - Shows an info banner: _"External dog — not part of your kennel roster"_ - Updates modal title and submit button label accordingly ### 3. `PairingSimulator.jsx` — only fetched kennel dogs - **Before:** `fetch('/api/dogs')` — external sires/dams never appeared in pairing selectors. - **After:** `fetch('/api/dogs?include_external=1')` — external dogs included. Dropdown options show `[Ext]` suffix for easy identification. ## Backend requirement The `/api/dogs` endpoint needs to support `?include_external=1` to return both kennel and external dogs. If not already implemented, the default (no param) should continue returning kennel-only dogs. ## Test checklist - [ ] External Dogs page → Add External Dog → modal opens with external banner visible - [ ] Submit external dog → `is_external=1` in DB, litter/parent fields not sent - [ ] Edit an existing external dog → parent section hidden, `is_external` preserved - [ ] Pairing Simulator dropdowns show external dogs with `[Ext]` label - [ ] Standard Add Dog from My Dogs page still shows full parent/litter section
jason added 3 commits 2026-03-11 00:58:30 -05:00
jason added 1 commit 2026-03-11 01:00:49 -05:00
jason merged commit 2cfeaf667e into feature/external-dogs 2026-03-11 01:01:19 -05:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jason/breedr#49