feat: TDR-Chart mit Tooltip und Pegel-Darstellung hinzugefügt

This commit is contained in:
ISA
2025-03-21 10:42:54 +01:00
parent 441f83d4ea
commit 33e66269c2
38 changed files with 183046 additions and 198023 deletions

View File

@@ -1,34 +1,18 @@
// /redux/thunks/fetchAllTDRChartThunk.ts
import { createAsyncThunk } from "@reduxjs/toolkit";
import { RootState } from "../store";
import isEqual from "lodash/isEqual";
const BASE_PATH = "/CPLmockData/LastTDR/jsonDatei";
import { fetchAllTDRChartDataFromServer } from "../../services/fetchAllTDRChartData"; // ✅ importieren
export const fetchAllTDRChartData = createAsyncThunk(
"tdrChart/fetchAllTDRChartData",
async (_, { getState, rejectWithValue }) => {
const state: RootState = getState() as RootState;
const currentData = state.tdrChart.data; // Aktuelle Redux-Daten
const state = getState() as RootState;
const currentData = state.tdrChart.data;
const fileNames = Array.from({ length: 32 }, (_, i) => `slot${i}.json`);
const fetchPromises = fileNames.map(async (fileName) => {
try {
const response = await fetch(`${BASE_PATH}/${fileName}`);
if (!response.ok)
throw new Error(`Fehler bei ${fileName}: ${response.statusText}`);
return await response.json();
} catch (error) {
console.error(`Fehler beim Laden von ${fileName}:`, error);
return null;
}
});
const newData = await fetchAllTDRChartDataFromServer(); // ✅ Service aufrufen
const newData = await Promise.all(fetchPromises);
//console.log("Geladene Daten:", newData);
// Falls die Daten leer oder identisch sind, aber initial leer waren, trotzdem speichern
if (newData.every((d) => d === null || d === undefined)) {
console.warn("⚠ Keine gültigen Daten empfangen.");
return rejectWithValue("Keine gültigen Daten empfangen.");