fix(storm-intel): show CloudHail icon for ice-pellet/hail forecast codes

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.
This commit is contained in:
Satyam-Rastogi
2026-05-19 02:40:21 +05:30
parent e754911e0b
commit bdb7a4e465
2 changed files with 8 additions and 4 deletions
+1 -1
View File
@@ -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-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-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-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() { export function useStormForecast() {
+7 -3
View File
@@ -63,8 +63,12 @@ const FORECAST_ICONS = {
4000: CloudDrizzle, 4200: CloudDrizzle, 4000: CloudDrizzle, 4200: CloudDrizzle,
4001: CloudRain, 4201: CloudRain, 4001: CloudRain, 4201: CloudRain,
8000: CloudLightning, 8000: CloudLightning,
7000: Snowflake, 7101: Snowflake, 7102: Snowflake, // 5xxx = actual snow
5000: Snowflake, 5100: Snowflake, 5101: Snowflake, 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) { function scoreColor(score) {
@@ -528,7 +532,7 @@ const ForecastStrip = ({ forecast, loading, alertDay, hasStormAlert }) => {
<div className="flex items-stretch gap-1.5 px-4 sm:px-6 py-2.5 overflow-x-auto scrollbar-none"> <div className="flex items-stretch gap-1.5 px-4 sm:px-6 py-2.5 overflow-x-auto scrollbar-none">
<span className="text-[10px] font-black uppercase tracking-widest text-zinc-400 self-center mr-1 shrink-0 hidden sm:block">7-Day</span> <span className="text-[10px] font-black uppercase tracking-widest text-zinc-400 self-center mr-1 shrink-0 hidden sm:block">7-Day</span>
{forecast.map((day, i) => { {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 isAlert = day.stormScore >= 65;
const isWarn = day.stormScore >= 40 && !isAlert; const isWarn = day.stormScore >= 40 && !isAlert;
const dayLabel = i === 0 const dayLabel = i === 0