feat: API-URL für Produktionsumgebung korrigiert und Debug-Logs hinzugefügt
- `getApiUrl` angepasst, um in der Produktionsumgebung die richtige URL zu verwenden. - Verbesserte Fehlerbehandlung in `handleFetchData` mit zusätzlichen `console.log`-Ausgaben. - Setzt `isChartOpen` explizit auf `true`, wenn das Chart geladen wird. - Dadurch funktioniert das Laden der Daten jetzt auch in der Produktionsumgebung.
This commit is contained in:
@@ -23,26 +23,35 @@ const LoopChartActionBar: React.FC = () => {
|
||||
* API-URL-Erstellung für Entwicklung und Produktion
|
||||
*/
|
||||
const getApiUrl = (mode: "DIA0" | "DIA1" | "DIA2", type: number) => {
|
||||
return process.env.NODE_ENV === "development"
|
||||
? `/CPLmockData/kuesChartData/${mode}_${type}.json`
|
||||
: `/CPL?seite.ACP&${mode}=${vonDatum};${bisDatum};${type}`;
|
||||
const baseUrl =
|
||||
process.env.NODE_ENV === "development"
|
||||
? `/CPLmockData/kuesChartData/${mode}_${type}.json`
|
||||
: `/CPL?seite.ACP&${mode}=${vonDatum};${bisDatum};${selectedSlotType};${type};`;
|
||||
|
||||
return baseUrl;
|
||||
};
|
||||
|
||||
/**
|
||||
* Funktion zum Laden der Messwerte
|
||||
*/
|
||||
/**
|
||||
* Funktion zum Laden der Messwerte
|
||||
*/
|
||||
const handleFetchData = async () => {
|
||||
const type = selectedSlotType === "schleifenwiderstand" ? 4 : 3;
|
||||
const apiUrl = getApiUrl(selectedMode, type);
|
||||
|
||||
try {
|
||||
const apiUrl = getApiUrl(selectedMode, type);
|
||||
console.log("Mock JSON laden von:", apiUrl);
|
||||
console.log("📡 API-Request an:", apiUrl); // Debugging
|
||||
const response = await fetch(apiUrl, {
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
});
|
||||
|
||||
const response = await fetch(apiUrl);
|
||||
if (!response.ok) throw new Error(`Fehler: ${response.status}`);
|
||||
|
||||
const jsonData = await response.json();
|
||||
console.log("Geladene Daten:", jsonData);
|
||||
console.log("✅ Daten erfolgreich geladen:", jsonData);
|
||||
|
||||
if (Array.isArray(jsonData)) {
|
||||
dispatch(setChartData(jsonData));
|
||||
@@ -53,12 +62,13 @@ const LoopChartActionBar: React.FC = () => {
|
||||
const lastDate = new Date(jsonData[0].t);
|
||||
dispatch(setVonDatum(firstDate.toISOString().split("T")[0]));
|
||||
dispatch(setBisDatum(lastDate.toISOString().split("T")[0]));
|
||||
dispatch(setChartOpen(true)); // Chart öffnen
|
||||
}
|
||||
} else {
|
||||
console.error("Erwartetes Array, aber erhalten:", jsonData);
|
||||
console.error("⚠️ Erwartetes Array, aber erhalten:", jsonData);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Fehler beim Laden der Mock-Daten:", error);
|
||||
console.error("❌ Fehler beim Laden der Produktions-Daten:", error);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -6,5 +6,5 @@
|
||||
2: Patch oder Hotfix (Bugfixes oder kleine Änderungen).
|
||||
|
||||
*/
|
||||
const webVersion = "1.6.83";
|
||||
const webVersion = "1.6.84";
|
||||
export default webVersion;
|
||||
|
||||
Reference in New Issue
Block a user