feat: Redux-Integration für Meldungen, Anzeige von 'v' statt 's' in UI
This commit is contained in:
@@ -20,7 +20,10 @@ export const fetchLast20MessagesFromWindow = async (): Promise<
|
||||
document.body.appendChild(script);
|
||||
});
|
||||
|
||||
const raw = (window as any).win_last20Messages;
|
||||
interface WindowWithLast20Messages extends Window {
|
||||
win_last20Messages?: unknown;
|
||||
}
|
||||
const raw = (window as WindowWithLast20Messages).win_last20Messages;
|
||||
|
||||
return raw ? String(raw) : null;
|
||||
};
|
||||
|
||||
26
services/fetchMessagesService.ts
Normal file
26
services/fetchMessagesService.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
// services/fetchMessagesService.ts
|
||||
export const fetchMessagesService = async (
|
||||
fromDate: string,
|
||||
toDate: string
|
||||
) => {
|
||||
const from = new Date(fromDate);
|
||||
const to = new Date(toDate);
|
||||
|
||||
const fy = from.getFullYear();
|
||||
const fm = String(from.getMonth() + 1).padStart(2, "0");
|
||||
const fd = String(from.getDate()).padStart(2, "0");
|
||||
const ty = to.getFullYear();
|
||||
const tm = String(to.getMonth() + 1).padStart(2, "0");
|
||||
const td = String(to.getDate()).padStart(2, "0");
|
||||
|
||||
const isDev =
|
||||
typeof window !== "undefined" && window.location.hostname === "localhost";
|
||||
const url = isDev
|
||||
? `/api/cpl/getMessagesAPIHandler`
|
||||
: `/CPL?Service/ae.ACP&MSS1=${fy};${fm};${fd};${ty};${tm};${td};All`;
|
||||
|
||||
const res = await fetch(url);
|
||||
const raw = await res.json();
|
||||
const data = Array.isArray(raw) ? raw : raw.data;
|
||||
return data;
|
||||
};
|
||||
Reference in New Issue
Block a user