feat: API-Route für gefilterte Mock-Daten implementiert
- Neue Route /api/cpl/slotData erstellt - Lädt Daten aus /public/CPLmockData/kuesChartData/... basierend auf slot, messart und dia - Optionales Filtern über vonDatum und bisDatum hinzugefügt - 404-Fehler bei fehlender Datei wird abgefangen
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
"use client";
|
||||
// /components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopChartActionBar.tsx
|
||||
import React from "react";
|
||||
import DateRangePicker from "./DateRangePicker";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
@@ -33,6 +34,11 @@ export const useLoopChartLoader = () => {
|
||||
) => {
|
||||
const typeFolder =
|
||||
type === 3 ? "isolationswiderstand" : "schleifenwiderstand";
|
||||
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
return `/api/cpl/slotData?slot=${slotNumber}&messart=${typeFolder}&dia=${mode}&vonDatum=${vonDatum}&bisDatum=${bisDatum}`;
|
||||
}
|
||||
|
||||
return `${window.location.origin}/CPL?seite.ACP&${mode}=${formatDate(
|
||||
vonDatum
|
||||
)};${formatDate(bisDatum)};${slotNumber};${type};`;
|
||||
@@ -105,10 +111,12 @@ const LoopChartActionBar: React.FC = () => {
|
||||
|
||||
const baseUrl =
|
||||
process.env.NODE_ENV === "development"
|
||||
? `/CPLmockData/kuesChartData/slot${slotNumber}/${typeFolder}/${mode}.json`
|
||||
? // ? `/CPLmockData/kuesChartData/slot${slotNumber}/${typeFolder}/${mode}.json`
|
||||
`/api/cpl/slotData?slot=${slotNumber}&messart=${typeFolder}&dia=${mode}&vonDatum=${vonDatum}&bisDatum=${bisDatum}`
|
||||
: `${window.location.origin}/CPL?seite.ACP&${mode}=${formatDate(
|
||||
vonDatum
|
||||
)};${formatDate(bisDatum)};${slotNumber};${type};`;
|
||||
console.log("baseUrl", baseUrl);
|
||||
|
||||
return baseUrl;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user