Skip to content

Feat/search endangered filter#308

Merged
zigzagdev merged 7 commits intochore/add-criteria_endangered-search-formfrom
feat/search-endangered-filter
May 3, 2026
Merged

Feat/search endangered filter#308
zigzagdev merged 7 commits intochore/add-criteria_endangered-search-formfrom
feat/search-endangered-filter

Conversation

@zigzagdev
Copy link
Copy Markdown
Owner

PR Content

  • Adds the Endangered (危機遺産) filter to the heritage search form: a single checkbox that toggles is_endangered=true on the URL and wires it through the domain types, URL parse/serialize, search
    API, and form/result containers.
  • Fixes a long-standing bug where ?lang=ja was dropped on every search-related navigation, so the search results page reverted to English. Form submit and all four navigations on the results page
    (pagination, re-submit, item click, back-to-all) now carry lang=ja forward when the user is in Japanese mode.
  • Adds a LocaleToggle to the search results page header and pulls "Back to all sites" / "No sites found." from the ui-text dictionary so the page actually reflects the locale switch. The h1 brand
    "Search Results" and its subtitle stay untranslated by design (matches the World Heritage brand pattern in TopPageTitleBar).

What changed

Endangered filter

  • HeritageSearchParams gains is_endangered: boolean | null; SearchValues gains isEndangered: boolean.
  • parseHeritageSearchParams reads is_endangered=true (anything else → null); serializeHeritageSearchParams emits the param only when true. Round-trip covered by new
    search-heritages.params.test.ts.
  • SearchParams (API client) and useHeritageSearchQuery thread isEndangered to the backend as is_endangered=true.
  • HeritageSearchForm renders a checkbox above the year/keyword row; SearchHeritageFormContainer, SearchHeritageResultsContainer, and HeritageDetailLayout round-trip the field through their drafts
    and submit handlers.
  • endangeredOnly ui-text key added to en (Endangered only) and ja (危機遺産のみ表示).

Lang preservation on search navigations

  • SearchHeritageFormContainer.handleSubmit reads the current URL's lang and re-appends it to the next /heritages/results URL.
  • SearchHeritageResultsContainer gets a small file-local preserveLang(nextSearch, currentSearch) helper used by handleClickItem / handlePageChange / handleSubmit / handleBackToAllSites.
    lang=en (default) is never written; only lang=ja is propagated.

SearchResultsPage localization

  • <LocaleToggle /> placed next to "Back to all sites" so users can switch locale from the results page itself.
  • Button label and empty-state ("No sites found.") read from useText(). New keys: backToAllSites, noSitesFound.

Tests

  • npm run typecheck passes
  • npm test passes (14 suites / 74 tests, including new search-heritages.params.test.ts)
  • Manual: visit /heritages?lang=ja, open the search form, tick the 危機遺産のみ表示 checkbox, submit. Confirm the result URL becomes /heritages/results?is_endangered=true&lang=ja and the page is in Japanese.
  • Manual: on the results page in ja, click pagination / re-submit the form / click an item / click 一覧に戻る. lang=ja survives every transition.
  • Manual: visit /heritages/results?is_endangered=true directly (no lang). Click the 🇬🇧 toggle in the page header — UI flips to ja, URL gains &lang=ja, and reload preserves it.

zigzagdev and others added 6 commits May 3, 2026 20:11
…rip)

Add is_endangered to HeritageSearchParams and SearchValues, default it
to null/false, parse and serialize the URL query param, and round-trip
the value through the form / result containers and the detail layout's
quick-submit. The form's internal state initialiser, the detail layout's
DEFAULT_SEARCH, and the search container test mocks are updated to
satisfy the new field.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Place a LocaleToggle next to "Back to all sites" so users can switch
locales from the search results page itself, and read the button text
plus the empty-state message from useText. The h1 brand "Search Results"
and the subtitle stay untranslated by design.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zigzagdev zigzagdev self-assigned this May 3, 2026
@zigzagdev zigzagdev linked an issue May 3, 2026 that may be closed by this pull request
4 tasks
Copy link
Copy Markdown
Owner Author

@zigzagdev zigzagdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

…chParams literals

Two literals in test code and the detail-side HeritageSubHeader were
missed when is_endangered was added to the types, breaking CI typecheck.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zigzagdev zigzagdev merged commit d176e20 into chore/add-criteria_endangered-search-form May 3, 2026
1 check passed
@zigzagdev zigzagdev deleted the feat/search-endangered-filter branch May 3, 2026 13:05
@zigzagdev zigzagdev linked an issue May 3, 2026 that may be closed by this pull request
3 tasks
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.

Add Endangered filter to heritage search form

1 participant