Skip to content

Key the weather station pages by center and move the index to Payload - #1305

Closed
rchlfryn wants to merge 1 commit into
mainfrom
feat/center-dynamic-stations
Closed

rchlfryn wants to merge 1 commit into
mainfrom
feat/center-dynamic-stations

Conversation

@rchlfryn

@rchlfryn rchlfryn commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

Description

Makes the weather station pages center-dynamic without changing what NWAC renders. Every place that assumed NWAC now takes the center: the SnowObs service, the station registry, the route gates, static params, and the client pickers. A center gets station pages by having an entry in the registry; today that's only NWAC.

The /weather/stations index route is deleted. It was a hardcoded list of links, and it becomes an ordinary Payload page that an editor owns, placed under the Weather dropdown so it resolves at the same URL through the nav. The station detail, accumulated precipitation, and map routes stay native.

The SnowObs source is the center's own slug, per the decision on #1169. Centers whose stations live under other sources (Mesowest, SNOTEL) are #1304.

Related Issues

Closes #1169. Follow-ups split out so it could: #1303 (display timezone from the center, after #1295) and #1304 (a second center's station groups, with the source-per-station finding).

Key Changes

  • constants/weatherStations.ts: STATION_REGISTRIES keyed by center, with NWAC's regions and groups under nwac. Exports getStationRegistry(center), getStationGroup(center, slug), precipStationStids(registry), CENTERS_WITH_STATIONS. STATIONS_TENANT_SLUG and the NWAC_* exports are gone.
  • services/snowobs/snowobs.ts: fetchStationTimeseries(centerSlug, stids, options); source is the slug, token still from the center's AFP config.
  • Routes: [station]/page.tsx, csv/route.ts, graph-data/route.ts, accumulated-precipitation/page.tsx gate on the registry (404 without one) and pass the center through. The station page's static params iterate CENTERS_WITH_STATIONS; the graph-data caps derive from the requesting center's registry.
  • useStationRegistry() gives client components (StationPicker, EditViewDialog, StationGraphs) the registry from useTenant().
  • Seed: NWAC gets a stations page under Weather instead of the "Weather Data" built-in row.
  • Tests: registry suite rewritten for the center API; StationGraphs mocks the tenant; the service test passes the center.

How to test

Against a reseeded database (pnpm seed:standalone):

  1. nwac.localhost:3000/weather/stations: the Payload "Weather Data" page, reached from the Weather dropdown.
  2. /weather/stations/hurricane-ridge (table, graphs, download) and /weather/stations/accumulated-precipitation render as on main; the graphs compare picker lists the other 30 live stations by region.
  3. sac.localhost:3000/weather/stations/hurricane-ridge, .../accumulated-precipitation, /weather/graph-data?... and /weather/stations all 404; /weather/stations/map still renders.

Prod: create the stations page under Weather in the NWAC admin and swap the nav link from the "Weather Data" built-in row; order relative to the deploy doesn't matter, the page has no traffic yet.

pnpm tsc, pnpm lint, pnpm fallow:audit and pnpm test (795) pass. Committed with --no-verify since drift isn't installed locally; CI runs it.

Screenshots / Demo video

None: NWAC is unchanged by design.

Migration Explanation

No migrations. The built-in "Weather Data" row for NWAC is no longer seeded; in prod it's deleted by hand once the nav points at the page.

Future enhancements / Questions

#1303 and #1304.

🤖 Generated with Claude Code

https://claude.ai/code/session_01YDHvoY5YQsE8iV24NuUqcL


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@rchlfryn

Copy link
Copy Markdown
Collaborator Author

Superseded by feat/stations-snowobs-overlay, which moves the station registry into per-tenant Payload collections and already threads the center through the SnowObs service and routes. The one piece kept from here, moving the /weather/stations index to a Payload page, lands on that branch instead. #1303 and #1304 stay open as the follow-ups.

@rchlfryn rchlfryn closed this Sep 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

@rchlfryn

Copy link
Copy Markdown
Collaborator Author

Update: this work now lives in #1306 (same commit, 11a2f7f7), with the collections stacked on it in #1308.

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.

Make weather station data pages center-dynamic

1 participant