Implementiere unterschiedliche Datenquellen für Entwicklungs- und Produktionsumgebungen
- Entwicklung: Daten werden aus der Datei `/mockData.json` geladen. - Produktion: Daten werden von der URL `/CPL?seite.ACP&DIA1=2025;01;01;2025;07;31;2;4` abgerufen. Dies ermöglicht eine realistische Datenverarbeitung in der Produktion, während in der Entwicklungsumgebung weiterhin mit Mock-Daten gearbeitet wird.
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
// components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopChartActionBar.tsx
|
||||
import React, { useState } from "react";
|
||||
import DateRangePicker from "../DateRangePicker";
|
||||
import LoopMeasurementChart from "./LoopMeasurementChart";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { setChartData } from "../../../../../../redux/slices/chartDataSlice";
|
||||
|
||||
@@ -11,8 +9,14 @@ const LoopChartActionBar: React.FC = () => {
|
||||
|
||||
const handleFetchData = async () => {
|
||||
try {
|
||||
const response = await fetch("/mockData.json");
|
||||
const apiUrl =
|
||||
process.env.NODE_ENV === "development"
|
||||
? "/mockData.json"
|
||||
: "/CPL?seite.ACP&DIA1=2025;01;01;2025;07;31;2;4";
|
||||
|
||||
const response = await fetch(apiUrl);
|
||||
const data = await response.json();
|
||||
|
||||
if (Array.isArray(data)) {
|
||||
console.log("Daten geladen:", data);
|
||||
dispatch(setChartData(data));
|
||||
|
||||
Reference in New Issue
Block a user