feat: add global weather support
All checks were successful
CI / Lint, typecheck and build (push) Successful in 9m54s

This commit is contained in:
zv
2026-06-14 15:53:34 +02:00
parent d572c9cc53
commit 2182297adc
45 changed files with 739 additions and 212 deletions

View File

@@ -42,6 +42,7 @@ export function DashboardWarnings() {
const selectedStationId = useWeatherStore((state) => state.selectedStationId);
const selectedLocation = useWeatherStore((state) => state.selectedLocation);
const [now, setNow] = useState<number | null>(null);
const isGlobalLocation = selectedLocation?.region === "GLOBAL";
useEffect(() => {
const timeoutId = window.setTimeout(() => setNow(Date.now()), 0);
@@ -52,10 +53,10 @@ export function DashboardWarnings() {
};
}, []);
const province = getProvinceForSelection(selectedLocation?.province, selectedStationId ?? DEFAULT_STATION_ID);
const province = isGlobalLocation ? null : getProvinceForSelection(selectedLocation?.province, selectedStationId ?? DEFAULT_STATION_ID);
const regionLabel = selectedLocation?.countyTeryt ? selectedLocation.district ?? selectedLocation.name : province ? formatProvinceName(province, language) : null;
const relevantWarnings = useMemo(() => {
if (!warnings || !province || now === null) return [];
if (isGlobalLocation || !warnings || !province || now === null) return [];
return warnings
.filter((warning) => {
@@ -65,7 +66,7 @@ export function DashboardWarnings() {
&& (validTo === null || validTo > now);
})
.sort((a, b) => compareDashboardWarnings(a, b, now));
}, [now, province, selectedLocation, warnings]);
}, [isGlobalLocation, now, province, selectedLocation, warnings]);
if (!province || !regionLabel || !relevantWarnings.length || now === null) return null;