V 1.2.0 diverse Anpassungen, so dass es ähnlich der alten Anwenung ist. Ist nun mal gut zu benutzen
This commit is contained in:
@@ -4,6 +4,7 @@ import './App.css'
|
||||
|
||||
function App() {
|
||||
const [weatherData, setWeatherData] = useState([])
|
||||
const [currentWeatherData, setCurrentWeatherData] = useState([]) // Immer die aktuellen 24h-Werte
|
||||
const [rainData, setRainData] = useState([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [error, setError] = useState(null)
|
||||
@@ -18,6 +19,7 @@ function App() {
|
||||
// Prüfe ob eingebettete Daten vorhanden sind (statischer Build)
|
||||
if (window.__WEATHER_DATA__ && timeRange === '24h') {
|
||||
setWeatherData(window.__WEATHER_DATA__)
|
||||
setCurrentWeatherData(window.__WEATHER_DATA__)
|
||||
setRainData([])
|
||||
setLastUpdate(new Date())
|
||||
setLoading(false)
|
||||
@@ -58,6 +60,18 @@ function App() {
|
||||
const weatherDataResult = await weatherResponse.json()
|
||||
setWeatherData(weatherDataResult)
|
||||
|
||||
// Immer die aktuellen 24h-Daten für "Aktuell"-Anzeige laden
|
||||
if (timeRange !== '24h') {
|
||||
const currentUrl = `${baseUrl}/weather/history?hours=24`
|
||||
const currentResponse = await fetch(currentUrl)
|
||||
if (currentResponse.ok) {
|
||||
const currentDataResult = await currentResponse.json()
|
||||
setCurrentWeatherData(currentDataResult)
|
||||
}
|
||||
} else {
|
||||
setCurrentWeatherData(weatherDataResult)
|
||||
}
|
||||
|
||||
// Regendaten laden (falls separater Endpunkt)
|
||||
if (rainUrl) {
|
||||
const rainResponse = await fetch(rainUrl)
|
||||
@@ -138,6 +152,7 @@ function App() {
|
||||
<main className="app-main">
|
||||
<WeatherDashboard
|
||||
data={weatherData}
|
||||
currentData={currentWeatherData}
|
||||
rainData={rainData}
|
||||
timeRange={timeRange}
|
||||
onTimeRangeChange={setTimeRange}
|
||||
|
||||
Reference in New Issue
Block a user