feat(events): Use backend-driven runtime events for tool pages and fix own-profile stats hydration
Summary
This MR updates corpus-client-app to use backend-driven runtime events for
tool-page review filters and fixes the own-profile stats hydration path.
The primary goal is to make the backend the source of truth for page-specific
review filters by consuming GET /api/v1/events/current with
X-Page-Route, while keeping the existing client-side defaults as fallback
behavior.
This MR also includes supporting CI/lint/format cleanup that was necessary to keep the touched frontend paths healthy.
What Changed
1. Added useToolEventFilters hook
New shared hook:
src/hooks/useToolEventFilters.ts
Responsibilities:
- call the backend runtime event endpoint
- send
X-Page-Routeusing the actual frontend route path - resolve backend-provided review filters
- expose readiness state so pages do not fetch too early
- fall back to existing page defaults when:
- no token is present
- the backend returns
null - the backend returns
409 - the request fails
- the event payload does not contain usable filters
This keeps the backend as the primary filter source without breaking existing page behavior.
2. Integrated event filters into shared review flow
Updated:
src/components/ReviewPageBase.tsx
Changes:
- review fetching now waits until event filters are ready
-
/records/for-reviewnow uses resolvedreviewFilters - the old hardcoded media-type-only path is no longer the primary source
- search behavior is unchanged
3. Integrated event filters into page-specific flows
Updated:
src/pages/DocDigitization.tsxsrc/pages/PeerReview.tsx
For Document Digitization:
- record fetching waits for event-filter readiness
- backend event filters are used when available
- existing defaults such as the document-review flow remain available as fallback
For Peer Review:
- initial review fetch waits for runtime filter readiness
- category handling is preserved
- search mode behavior remains unchanged
4. Fixed own-profile stats hydration
Updated:
src/pages/Profile.tsx
Before:
- the own-profile path relied only on
/auth/me - this caused the page to miss richer nested summary data
After:
- the own-profile path fetches
/auth/me - then fetches
/users/{id}/profile?include=streaks,timeline,summary&days=30 - nested summary data is preferred when available
This fixes the UI issue where the backend returned non-zero edit totals, but
the profile page still showed 0.
5. Supporting cleanup for CI and lint health
Updated:
.prettierignoresrc/App.tsxsrc/lib/utils.tssrc/components/GeoContributionModal.tsxsrc/components/InstitutionSelector.tsx
Notable fixes:
- excluded Android/generated assets and large geojson assets from full-repo Prettier checks
- removed
require('leaflet')andanyfromGeoContributionModal - replaced that logic with typed
latLngBounds - fixed hook dependency warnings in
InstitutionSelector
These are not the feature itself, but they were necessary to keep the branch passing local quality checks and GitLab CI stages.
Files Changed
.prettierignoresrc/App.tsxsrc/components/GeoContributionModal.tsxsrc/components/InstitutionSelector.tsxsrc/components/ReviewPageBase.tsxsrc/hooks/useToolEventFilters.tssrc/lib/utils.tssrc/pages/DocDigitization.tsxsrc/pages/PeerReview.tsxsrc/pages/Profile.tsxtests/pages/Profile.test.tsxtests/src/components/ReviewPageBase.test.tsx
Testing
Validated locally with:
npm run format:check
npm run lint
npm run type-check
npm run build
Added regression coverage for:
-
ReviewPageBaseusing resolvedreviewFilters -
ReviewPageBasenot fetching review data before filters are ready -
Profilehydrating own-profile edit totals from nested detailed summary data
Notes
- route matching depends on the backend receiving the literal route path
through
X-Page-Route - the frontend fallback behavior is intentionally preserved, so tool pages still work when no active backend event exists
- this MR does not add frontend event-management UI; it only consumes runtime event configuration from the backend