feat: add global weather support
All checks were successful
CI / Lint, typecheck and build (push) Successful in 9m54s
All checks were successful
CI / Lint, typecheck and build (push) Successful in 9m54s
This commit is contained in:
@@ -26,6 +26,7 @@ import {
|
||||
} from "@/lib/forecast-utils";
|
||||
import { useWeatherStore } from "@/lib/store";
|
||||
import type { DailyForecast, HourlyForecast } from "@/types/forecast";
|
||||
import type { WeatherRegion } from "@/types/weather-region";
|
||||
|
||||
function formatHour(value: string) {
|
||||
return value.slice(11, 16);
|
||||
@@ -118,11 +119,11 @@ function DailyForecastRow({ day, index, onSelect }: { day: DailyForecast; index:
|
||||
);
|
||||
}
|
||||
|
||||
export function ForecastPanel({ latitude, longitude, locationName }: { latitude?: number; longitude?: number; locationName: string }) {
|
||||
export function ForecastPanel({ latitude, longitude, region = "PL", locationName }: { latitude?: number; longitude?: number; region?: WeatherRegion; locationName: string }) {
|
||||
const { language, t } = useI18n();
|
||||
const temperatureUnit = useWeatherStore((state) => state.temperatureUnit);
|
||||
const windSpeedUnit = useWeatherStore((state) => state.windSpeedUnit);
|
||||
const { data: forecast, isPending, isError, refetch } = useForecast(latitude, longitude);
|
||||
const { data: forecast, isPending, isError, refetch } = useForecast(latitude, longitude, region);
|
||||
const [selectedDay, setSelectedDay] = useState<DailyForecast | null>(null);
|
||||
const closeDayDetails = useCallback(() => setSelectedDay(null), []);
|
||||
const upcomingHours = forecast ? getUpcomingHourlyForecast(forecast.hourly) : [];
|
||||
|
||||
Reference in New Issue
Block a user