refactor(weather): share the day weather anchor and icon map between desktop and phone

The day plan, the day panel, the phone timeline and the phone day sheet read
the day local weather anchor from dayWeatherAnchor, and every weather icon
comes from one map in weatherIcons.
This commit is contained in:
Maurice
2026-10-08 20:57:33 +00:00
parent 34127b99bb
commit 9f3e1f8c83
13 changed files with 164 additions and 71 deletions
+4 -5
View File
@@ -32,6 +32,7 @@ import type { BudgetItem } from '../types'
import PluginFrame from '../components/Plugins/PluginFrame'
import ErrorBoundary from '../components/shared/ErrorBoundary'
import { getDayBookendHotels } from '../utils/dayOrder'
import { dayWeatherAnchor } from '../utils/dayWeather'
import TripWarningsBanner from '../components/Planner/TripWarningsBanner'
import Navbar from '../components/Layout/Navbar'
import HelpAnchor from '../components/Help/HelpAnchor'
@@ -538,11 +539,9 @@ function TripPlannerPageDesktop(): React.ReactElement | null {
// Day-local weather anchor only (#2167): first located stop of THIS day,
// else the hotel you wake up in (unconditional bookend lookup, mirroring
// useMPlanTimeline) — never a place from another day.
const locatedPlace = dayAssignments.find(a => a.place?.lat && a.place?.lng)?.place
const weatherHotel = locatedPlace ? undefined : getDayBookendHotels(currentDay, days, tripAccommodations).morning
const weatherLat = locatedPlace?.lat ?? weatherHotel?.place_lat ?? null
const weatherLng = locatedPlace?.lng ?? weatherHotel?.place_lng ?? null
const weatherPlaceName = locatedPlace?.name ?? weatherHotel?.place_name ?? null
const { lat: weatherLat, lng: weatherLng, name: weatherPlaceName } = dayWeatherAnchor(
dayAssignments, () => getDayBookendHotels(currentDay, days, tripAccommodations).morning,
)
return (
<DayDetailPanel
day={currentDay}