Skip to content

LF-5298: Show a 5-day weather forecast with frost-risk warnings on the Home page#4178

Draft
litefarm-pr-bot wants to merge 1 commit into
integrationfrom
LF-5298-show-a-5-day-weather-forecast-with-frost-risk-warnings-on-the-home-page
Draft

LF-5298: Show a 5-day weather forecast with frost-risk warnings on the Home page#4178
litefarm-pr-bot wants to merge 1 commit into
integrationfrom
LF-5298-show-a-5-day-weather-forecast-with-frost-risk-warnings-on-the-home-page

Conversation

@litefarm-pr-bot
Copy link
Copy Markdown
Collaborator

@litefarm-pr-bot litefarm-pr-bot commented May 21, 2026

The Home page weather widget has been a single-snapshot read of OpenWeather's current-conditions endpoint since the original implementation, and the design system has since moved on to a 5-day forecast model that includes frost-risk surfacing. The legacy code coupled the displayed measurement system (metric/imperial) into the OpenWeather request itself, which forced the frost threshold to be expressed twice (once for each unit) and prevented a single, authoritative metric trigger. The widget also derived all date labels from the browser timezone, so a farm in India viewed from a North-American browser saw days mislabelled.

This change replaces the legacy WeatherBoard with a new WeatherForecast widget under containers/WeatherForecast/ (smart, RTK-Query backed) and components/WeatherForecast/ (presentational, composed of DayPillRow, FrostBanner, DayWeatherSummary, TimeStrip, and a PureWeatherForecast shell). The backend endpoint constant moves from /data/2.5/weather to /data/2.5/forecast, the request hard-codes units=metric, and the controller stops reading row.units.measurement. The frontend converts to display units client-side via pure helpers in containers/WeatherForecast/selectors.ts. The WeatherData shared type is replaced by WeatherForecast (with slots[] and city.timezoneOffsetSeconds), and the RTK Query endpoint is renamed useGetWeatherQueryuseGetWeatherForecastQuery. Day grouping, day-pill labels and time-chip labels use the offset returned by OpenWeather (city.timezone), never the browser timezone.

Pattern to carry forward: when a backend response shape changes in a way that affects an RTK Query hook's name or argument, the breaking edit and every consumer must ship together — the previous one-call API made it tempting to split the rewrite across PRs, but the type rename and Home wiring are inseparable in practice and would leave the legacy widget broken in an interim merge.

Jira: https://lite-farm.atlassian.net/browse/LF-5298

Testing checklist

  • Tests added/updated for new functionality
  • Manual testing done
  • UI components visually reviewed on desktop/mobile view
  • Other

Type checking (tsc --noEmit) and ESLint were run against the worktree; both reported only pre-existing errors in unrelated files (e.g. stories/Pages/Intro/SetCertificationSummary/CertificationSummary.test.js, stories/Tile/SensorKPITiles.stories.tsx). No new errors were introduced. A non-printable-byte scan (LC_ALL=C perl -ne ...) confirmed all new files contain only the precomposed U+00B0 DEGREE SIGN for the °C/°F glyphs, with no combining diacritics or NUL bytes. No local frontend or backend was started; visual review on Home and Storybook, golden-path slot navigation, balloon-tail anchoring on day-pill rollover, mobile (320–375px) horizontal time-strip overflow, metric-to-imperial unit switching, and locale switching (Hindi, Punjabi) for date string localisation are deferred to manual QA.

Swap the legacy WeatherBoard for a new WeatherForecast widget driven by
OpenWeather's /data/2.5/forecast endpoint. The widget shows a 5-day /
3-hour forecast with five day pills, a horizontal time strip of 3-hour
slots, a shared rollover selection (one slot index drives a derived day
pill highlight), and a red frost-risk banner whenever the day's minimum
forecast temperature is below 2°C.

Backend always requests metric units; the frontend converts on display
using the farm's measurement setting. All local-day grouping, day pill
labels and time chip labels use the farm timezone from city.timezone in
the OpenWeather response rather than the browser timezone.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@litefarm-pr-bot litefarm-pr-bot requested review from a team as code owners May 21, 2026 19:41
@litefarm-pr-bot litefarm-pr-bot requested review from kathyavini and removed request for a team May 21, 2026 19:41
@SayakaOno SayakaOno marked this pull request as draft May 22, 2026 21:37
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.

2 participants