From bdb7a4e4653ea601663baa65ac5ab8b7bb23e507 Mon Sep 17 00:00:00 2001 From: Satyam-Rastogi Date: Tue, 19 May 2026 02:40:21 +0530 Subject: [PATCH] fix(storm-intel): show CloudHail icon for ice-pellet/hail forecast codes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tomorrow.io 7xxx codes are ice pellets, not snow — remapped from Snowflake to CloudHail. Added hailRisk override so any day flagged as hail risk by the API always renders the hail icon regardless of weatherCode. Also added missing 6xxx (freezing rain) codes to the icon table. Mock Sunday entry corrected to weatherCode 8000 (thunderstorm) — 7102 at 76°F made no meteorological sense. --- src/hooks/useStormForecast.js | 2 +- src/pages/StormIntelPage.jsx | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/hooks/useStormForecast.js b/src/hooks/useStormForecast.js index e2069af..1abfc1b 100644 --- a/src/hooks/useStormForecast.js +++ b/src/hooks/useStormForecast.js @@ -20,7 +20,7 @@ const MOCK_FORECAST = [ { date: '2026-05-21T06:00:00Z', precipProb: 52, weatherCode: 4001, weatherLabel: 'Rain', hailRisk: false, windGust: 30, windSpeed: 18, tempF: 71, humidity: 68, stormScore: 34 }, { date: '2026-05-22T06:00:00Z', precipProb: 18, weatherCode: 1001, weatherLabel: 'Cloudy', hailRisk: false, windGust: 16, windSpeed: 10, tempF: 76, humidity: 52, stormScore: 9 }, { date: '2026-05-23T06:00:00Z', precipProb: 8, weatherCode: 1000, weatherLabel: 'Clear', hailRisk: false, windGust: 12, windSpeed: 7, tempF: 81, humidity: 38, stormScore: 4 }, - { date: '2026-05-24T06:00:00Z', precipProb: 42, weatherCode: 7102, weatherLabel: 'Light Hail', hailRisk: true, windGust: 35, windSpeed: 22, tempF: 76, humidity: 61, stormScore: 71 }, + { date: '2026-05-24T06:00:00Z', precipProb: 42, weatherCode: 8000, weatherLabel: 'Thunderstorm', hailRisk: true, windGust: 35, windSpeed: 22, tempF: 76, humidity: 61, stormScore: 71 }, ]; export function useStormForecast() { diff --git a/src/pages/StormIntelPage.jsx b/src/pages/StormIntelPage.jsx index 83b01f7..323ffb6 100644 --- a/src/pages/StormIntelPage.jsx +++ b/src/pages/StormIntelPage.jsx @@ -63,8 +63,12 @@ const FORECAST_ICONS = { 4000: CloudDrizzle, 4200: CloudDrizzle, 4001: CloudRain, 4201: CloudRain, 8000: CloudLightning, - 7000: Snowflake, 7101: Snowflake, 7102: Snowflake, - 5000: Snowflake, 5100: Snowflake, 5101: Snowflake, + // 5xxx = actual snow + 5000: Snowflake, 5001: Snowflake, 5100: Snowflake, 5101: Snowflake, + // 6xxx = freezing rain + 6000: CloudDrizzle, 6001: CloudRain, 6200: CloudDrizzle, 6201: CloudRain, + // 7xxx = ice pellets / hail — NOT snow + 7000: CloudHail, 7101: CloudHail, 7102: CloudHail, }; function scoreColor(score) { @@ -528,7 +532,7 @@ const ForecastStrip = ({ forecast, loading, alertDay, hasStormAlert }) => {
7-Day {forecast.map((day, i) => { - const FIcon = FORECAST_ICONS[day.weatherCode] ?? Cloud; + const FIcon = day.hailRisk ? CloudHail : (FORECAST_ICONS[day.weatherCode] ?? Cloud); const isAlert = day.stormScore >= 65; const isWarn = day.stormScore >= 40 && !isAlert; const dayLabel = i === 0