fix: richtige Link in system fetch service
This commit is contained in:
@@ -9,12 +9,22 @@ export const fetchTemperaturProzessorService = async (
|
||||
const isDev = process.env.NODE_ENV === "development";
|
||||
|
||||
const channel = 117; // 117 = Temperatur Prozessor laut Spezifikation
|
||||
const from = "2025;01;01";
|
||||
const to = "2025;07;31";
|
||||
// Dynamisch: to = heute, from = 30 Tage zurück
|
||||
const getDateParts = (date: Date) => {
|
||||
const y = date.getFullYear();
|
||||
const m = String(date.getMonth() + 1).padStart(2, "0");
|
||||
const d = String(date.getDate()).padStart(2, "0");
|
||||
return { y, m, d };
|
||||
};
|
||||
const today = new Date();
|
||||
const toParts = getDateParts(today);
|
||||
const fromDateObj = new Date(today);
|
||||
fromDateObj.setDate(today.getDate() - 30);
|
||||
const fromParts = getDateParts(fromDateObj);
|
||||
|
||||
const path = isDev
|
||||
? `/api/cpl/getTemperaturProzessorHandler?typ=${type}`
|
||||
: `/cpl?/dashboard.html&${type}=${from};${to};${channel};1;`;
|
||||
: `/CPL?seite.ACP&${type}=${fromParts.y};${fromParts.m};${fromParts.d};${toParts.y};${toParts.m};${toParts.d};${channel};1`;
|
||||
|
||||
const res = await fetch(path);
|
||||
if (!res.ok)
|
||||
|
||||
Reference in New Issue
Block a user