feat/weather-forecast #8
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refs/pull/8/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adds an opt-in 5-day forecast to the Weather widget. The toggle is a per-widget config (
showForecast, default off), so existing widgets continue to show only current conditions unless the user enables it in the widget settings modal.Uses OpenWeatherMap's
/data/2.5/forecastendpoint (same free-tier key as the existing/weathercall). The compact header weather widget is unaffected.What's new
Server (
server/src/services/weather.service.ts+server/src/routes/api.routes.ts)ForecastDaytype andgetWeatherWithForecast(apiKey, location)that parallel-fetches current + forecast.aggregateDaily()groups the 3-hourly entries by local-day usingcity.timezone, picks the entry closest to local noon for the icon/description, and computes the day's min/max/mean. Returns up to 5 future days. Today's partial group is skipped if it has too few samples./forecastfailure falls back to current-weather-only — the widget still renders the current block.POST /api/weatheraccepts an optionalincludeForecast: boolean; when set, returns the existing fields plusforecast: ForecastDay[].GET /api/weatheris untouched (env-vars-only path used elsewhere).Client (
client/src/components/widgets/WeatherWidget.tsxand friends)WeatherWidgetaccepts a newshowForecast?: booleanprop. When true, requests the forecast and renders a compact 5-row block below the existing Feels-like / Humidity / Location rows. Each row: localized day name (Intl.DateTimeFormat … weekday: 'short'), midday icon, description, hi/lo temperatures respecting the global C/F preference.client/src/types/index.tsgets aForecastDayinterface andWeather.forecast?: ForecastDay[].client/src/services/api.tsgetWeather()gains an optional third parameter{ includeForecast?: boolean }and forwards it as a body field.WidgetConfigModal.tsx) adds a "Show 5-day forecast" checkbox in the Weather section, mirroring the Search widget's checkbox pattern. Form-state plumbing insettings/types.tsandWidgetsTab.tsxhandles hydrate + save againstwidget.config.showForecast.Compatibility
App.tsxwidget registry,TabbedWidget, andHeader.tsxare unchanged.Weatherwidget config (onlyapiKey/locationpreviously) gains an optionalshowForecastfield. Existing widget instances render unchanged becauseshowForecastis missing → false.package-lock.jsonchange.Testing
Tested against an OpenWeatherMap free-tier key with location
Strathroy,CA:/weathercall is made on the next refresh.forecast: [5 entries].Type check (
tsc --noEmit) reports no new errors in either workspace.Notes for review
Again, I'll merge with some fixes to follow.