()
| 269 | useEffect(() => { |
| 270 | if (!effectiveField) return; |
| 271 | const fetchLive = async () => { |
| 272 | setLiveLoading(true); |
| 273 | try { |
| 274 | const { lat, lng } = getFieldCenter(effectiveField); |
| 275 | const res = await fetch(`https://api.open-meteo.com/v1/forecast?latitude=${lat}&longitude=${lng}¤t=temperature_2m,relative_humidity_2m,wind_speed_10m,apparent_temperature,weather_code&timezone=auto`); |
| 276 | const data = await res.json(); |
| 277 | const c = data.current; |
| 278 | setLiveWeather({ temperature: Math.round(c.temperature_2m), humidity: c.relative_humidity_2m, windSpeed: Math.round(c.wind_speed_10m), weatherCode: c.weather_code, feelsLike: Math.round(c.apparent_temperature) }); |
| 279 | } catch {setLiveWeather(null);} finally |
| 280 | {setLiveLoading(false);} |
| 281 | }; |
| 282 | fetchLive(); |
| 283 | }, [effectiveField]); |
| 284 |
no test coverage detected