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

@@ -6,6 +6,6 @@ NEXT_PUBLIC_USE_MOCK_BACKEND_LOOP_START=false
NEXT_PUBLIC_EXPORT_STATIC=false NEXT_PUBLIC_EXPORT_STATIC=false
NEXT_PUBLIC_USE_CGI=false NEXT_PUBLIC_USE_CGI=false
# App-Versionsnummer # App-Versionsnummer
NEXT_PUBLIC_APP_VERSION=1.6.545 NEXT_PUBLIC_APP_VERSION=1.6.546
NEXT_PUBLIC_CPL_MODE=json # json (Entwicklungsumgebung) oder jsSimulatedProd (CPL ->CGI-Interface-Simulator) oder production (CPL-> CGI-Interface Platzhalter) NEXT_PUBLIC_CPL_MODE=json # json (Entwicklungsumgebung) oder jsSimulatedProd (CPL ->CGI-Interface-Simulator) oder production (CPL-> CGI-Interface Platzhalter)

View File

@@ -5,5 +5,5 @@ NEXT_PUBLIC_CPL_API_PATH=/CPL
NEXT_PUBLIC_EXPORT_STATIC=true NEXT_PUBLIC_EXPORT_STATIC=true
NEXT_PUBLIC_USE_CGI=true NEXT_PUBLIC_USE_CGI=true
# App-Versionsnummer # App-Versionsnummer
NEXT_PUBLIC_APP_VERSION=1.6.545 NEXT_PUBLIC_APP_VERSION=1.6.546
NEXT_PUBLIC_CPL_MODE=production NEXT_PUBLIC_CPL_MODE=production

View File

@@ -1,3 +1,12 @@
## [1.6.546] 2025-07-07
- style: UI-Filterzeile visuell vereinheitlicht vertikale Ausrichtung und Höhe angepasst
- 'items-end' durch 'items-center' ersetzt für mittige Ausrichtung der Filterzeile
- Button- und Listbox-Komponenten optisch auf gleiche Höhe gebracht
- Einheitliches Erscheinungsbild von DatePicker, Anzeigen-Button und Quellen-Dropdown
---
## [1.6.545] 2025-07-07 ## [1.6.545] 2025-07-07
- fix: Listbox-Filter "Alle Quellen" zeigt nun korrekt alle Meldungen an - fix: Listbox-Filter "Alle Quellen" zeigt nun korrekt alle Meldungen an

File diff suppressed because it is too large Load Diff

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "cpl-v4", "name": "cpl-v4",
"version": "1.6.545", "version": "1.6.546",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "cpl-v4", "name": "cpl-v4",
"version": "1.6.545", "version": "1.6.546",
"dependencies": { "dependencies": {
"@fontsource/roboto": "^5.1.0", "@fontsource/roboto": "^5.1.0",
"@headlessui/react": "^2.2.4", "@headlessui/react": "^2.2.4",

View File

@@ -1,6 +1,6 @@
{ {
"name": "cpl-v4", "name": "cpl-v4",
"version": "1.6.545", "version": "1.6.546",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",

24
pages/api/cpl/messages.ts Normal file
View File

@@ -0,0 +1,24 @@
// pages/api/cpl/messages.ts
import { NextApiRequest, NextApiResponse } from "next";
import messagesRaw from "@/mocks/device-cgi-simulator/meldungen/messages.json";
export default function handler(req: NextApiRequest, res: NextApiResponse) {
const { fromDate, toDate } = req.query;
if (!fromDate || !toDate) {
return res
.status(400)
.json({ error: "fromDate und toDate sind erforderlich" });
}
const from = new Date(String(fromDate));
const to = new Date(String(toDate));
to.setHours(23, 59, 59, 999); // ganzen Tag einschließen
const filtered = messagesRaw.filter((m) => {
const t = new Date(m.t);
return t >= from && t <= to;
});
res.status(200).json(filtered);
}

View File

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