fix: Fehler beim Setzen der Referenzkurve in Development behoben

- überflüssiger fetch auf /CPL?KTR... in Development entfernt
- Fehler-Alert durch 404-Seite bei Embedded-Link im Dev gefixt
- Referenzkurve wird jetzt in Dev nur lokal gespeichert und per API aktualisiert
This commit is contained in:
Ismail Ali
2025-04-15 20:45:48 +02:00
parent 9e8028ac16
commit 898027a162
4 changed files with 6573 additions and 3582 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -47,16 +47,30 @@ const TDRChartActionBar: React.FC = () => {
try {
const slotNumber = selectedSlot + 1; // Slot ist 0-basiert, API will 1-basiert
const url = `/CPL?KTR${slotNumber}=${selectedId}`;
const isDev = process.env.NEXT_PUBLIC_NODE_ENV === "development";
const response = await fetch(url, {
method: "GET",
});
if (isDev) {
await fetch("/api/cpl/updateTdrReferenceCurveAPIHandler", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
slot: slotNumber,
data: currentChartData,
}),
});
} else {
const url = `/CPL?KTR${slotNumber}=${selectedId}`;
await fetch(url, { method: "GET" });
}
if (!isDev) {
const url = `/CPL?KTR${slotNumber}=${selectedId}`;
const response = await fetch(url, { method: "GET" });
if (!response.ok) {
throw new Error(
`Fehler beim Setzen der Referenz: ${response.statusText}`
);
if (!response.ok) {
throw new Error(
`Fehler beim Setzen der Referenz: ${response.statusText}`
);
}
}
// Optional: lokale Speicherung und Redux-Update

View File

@@ -6,5 +6,5 @@
2: Patch oder Hotfix (Bugfixes oder kleine Änderungen).
*/
const webVersion = "1.6.231";
const webVersion = "1.6.232";
export default webVersion;

View File

@@ -0,0 +1,33 @@
// /pages/api/cpl/updateTdrReferenceCurveAPIHandler.ts
import { NextApiRequest, NextApiResponse } from "next";
import path from "path";
import { promises as fs } from "fs";
export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
if (req.method !== "POST") {
return res.status(405).json({ error: "Method not allowed" });
}
const { slot, data } = req.body;
if (!slot || !data) {
return res.status(400).json({ error: "Missing slot or data" });
}
const filePath = path.join(
process.cwd(),
"apiMockData",
"tdr-reference-curves",
`slot${slot}.json`
);
try {
await fs.writeFile(filePath, JSON.stringify(data, null, 2), "utf-8");
res.status(200).json({ success: true });
} catch (error) {
res.status(500).json({ error: "Failed to save file" });
}
}