Skip to content

feat(pwa): feed country in admin (N7), country change clears feeds (N8), one feed per card - #122

Merged
satishbagali merged 5 commits into
mainfrom
fix/n7-n8-duplicate-feed
Nov 4, 2026
Merged

satishbagali merged 5 commits into
mainfrom
fix/n7-n8-duplicate-feed

Conversation

@Aiyappa-DigitalGreen

Copy link
Copy Markdown
Collaborator

What

Three changes. The branch also contains #118 (N5), because the N8 request was written against main + #118. If #118 merges first, this PR's diff shrinks to the new work. If this merges first, #118 can be closed.

N7: Admin › Feeds shows each feed's country

  • Each card shows fd_country_name, under the type.
  • New country filter, the same dropdown as Admin › Users. It filters on screen together with the name search.
  • The delete text names the country: "X" (India) will be permanently deleted…. It falls back to the old text when a feed has no country.

N8: changing the country clears the feed cards, after asking

  • Cattle Info → Continue with a different country than the saved one while feed cards are filled → dialog: "Changing the country clears the n selected feeds. Continue?"
    • Continue clears every card (feed, price, quantity, inclusion limits), then saves and navigates as before.
    • Cancel saves nothing.
  • No dialog when the country is unchanged (including India → Vietnam → India), when no card has a feed, or after a Simulation History restore. Recommendation and Evaluation behave the same.
  • The dialog uses role="dialog" and aria-modal, closes on Escape, and is covered by the global focus trap.
  • The logic lives in a new cattle-info/useCountryChange.tsx, so cattle-info/page.tsx stays under 600 lines.
  • Hardening: useFeedCascade matches a card by feed_uuid when it has one, and by name only otherwise.

One feed per card (Feed Selection)

  • Picking a feed that another card already holds, from the card's Feed list or from search, shows "Already this feed is selected" and changes nothing.

4 new labels with all 9 languages. The translations are machine-made and need native review.

Tests

  • admin-feeds: the country on each card, the filter, and the country in the delete text.
  • cattle-info: dialog → Continue clears and saves; Cancel keeps; same country / no feeds / restore → no dialog.
  • FeedRow and feed-selection: a duplicate is refused from the dropdown and from search; a new feed is accepted.
  • feed-selection-rules unit tests.

7 of the new tests fail on the old code. The full gate passes on Node 20 after merging the latest main (with #117): 979 tests.

Check on Test

  1. Admin › Feeds: cards show the country; the India filter shows only India's feeds; Delete names the country.
  2. Cattle Info India with 2 feeds → switch to Kenya → Continue → dialog. Continue gives empty cards, Kenya feeds and KES prices. Cancel changes nothing.
  3. Feed Selection: pick Napier on FEED 1, then pick Napier on FEED 2 (from the list or search) → "Already this feed is selected".

Please tell the backend owner once this and #118 are live: the "English feed name unique per country" change waits on them.

🤖 Generated with Claude Code

Aiyappa-DigitalGreen and others added 3 commits November 4, 2026 17:13
…ed per card

N7 — Admin › Feeds: each card shows the feed's country, a country filter
narrows the list on screen, and the delete text names the country, since
feed names will be unique per country rather than library-wide.

N8 — Cattle Info → Continue with a different country while feed cards are
filled asks first ("Changing the country clears the n selected feeds"),
then clears every card. Cancel saves nothing. Same country (including
Kenya → India → Kenya), no filled cards, or a restored simulation: no
dialog. The feed cascade now matches a card by id when it has one.

Feed Selection: a feed may be on only one card. Picking it again from a
card's Feed list or from search shows "Already this feed is selected"
and changes nothing.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@satishbagali
satishbagali merged commit 869de98 into main Nov 4, 2026
7 checks passed
@satishbagali
satishbagali deleted the fix/n7-n8-duplicate-feed branch November 4, 2026 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants