refactor: API-Handler umbenannt zu messages.ts für klare REST-Struktur

- getMessagesAPIHandler.ts in messages.ts umbenannt
- API ist nun unter /api/cpl/messages erreichbar
- Dateiname entspricht Next.js- und REST-Konventionen
This commit is contained in:
ISA
2025-07-07 13:40:27 +02:00
parent 31223ffc64
commit 4e5eeed9a2
8 changed files with 3414 additions and 3380 deletions

View File

@@ -16,11 +16,12 @@ export const fetchMessagesService = async (
const isDev =
typeof window !== "undefined" && window.location.hostname === "localhost";
const url = isDev
? `/api/cpl/getMessagesAPIHandler`
? `/api/cpl/messages?fromDate=${fromDate}&toDate=${toDate}`
: `/CPL?Service/ae.ACP&MSS1=${fy};${fm};${fd};${ty};${tm};${td};All`;
const res = await fetch(url);
const raw = await res.json();
const response = await fetch(url);
const raw = await response.json();
const data = Array.isArray(raw) ? raw : raw.data;
if (!response.ok) throw new Error("Fehler beim Laden der Meldungen");
return data;
};