diff --git a/src/components/Dashboard.tsx b/src/components/Dashboard.tsx index 10007f1..daffb96 100644 --- a/src/components/Dashboard.tsx +++ b/src/components/Dashboard.tsx @@ -2,7 +2,7 @@ // Copyright © 2026 Giancarlo Erra — AGPL-3.0-or-later import { useState, useEffect, useMemo } from "react"; -import { Star, Cloud, CloudSnow, Telescope, Globe, Settings, Home, HelpCircle } from "lucide-react"; +import { Star, Cloud, CloudSnow, Telescope, Globe, Settings, Home, HelpCircle, AlertTriangle } from "lucide-react"; import { weatherService } from "../services/weatherService"; import { processWeatherData, processSolarData, getScoreColor, getScoreLabel } from "../utils/weatherUtils"; import { @@ -29,6 +29,7 @@ export function Dashboard() { }); const [isLoading, setIsLoading] = useState(true); const [showHelp, setShowHelp] = useState(false); + const [configuredLocation, setConfiguredLocation] = useState<{ lat: number; lon: number } | null>(null); useEffect(() => { // Subscribe to download status updates @@ -37,6 +38,11 @@ export function Dashboard() { // Load initial data (with automatic download check) loadWeatherData(); + // Fetch configured location to detect mismatches + fetch('/api/location').then(r => r.json()).then(loc => { + if (loc && typeof loc.lat === 'number') setConfiguredLocation(loc); + }).catch(() => {}); + return unsubscribe; }, []); @@ -207,6 +213,11 @@ export function Dashboard() { .sort((a, b) => a.date.localeCompare(b.date)); }, [solarData, metOfficeSolarData]); + const locationMismatch = weatherData && configuredLocation + ? Math.abs(weatherData.metadata.latitude - configuredLocation.lat) > 0.01 || + Math.abs(weatherData.metadata.longitude - configuredLocation.lon) > 0.01 + : false; + if (isLoading && !weatherData && metOfficeDayData.length === 0) { return (
Elevation: {weatherData.metadata.height}m
+ {locationMismatch && ( +