generated from Dicken/dickendock
Commit 6: Adminbereich (TanStack Router, 8 Menüpunkte, Scan-Logs)
This commit is contained in:
18
apps/frontend/src/hooks/useLogs.ts
Normal file
18
apps/frontend/src/hooks/useLogs.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import type { ScanLogEntry } from "@launchpad/shared";
|
||||
|
||||
async function fetchLogs(): Promise<ScanLogEntry[]> {
|
||||
const res = await fetch("/api/logs");
|
||||
if (!res.ok) {
|
||||
throw new Error(`Logs konnten nicht geladen werden (HTTP ${res.status})`);
|
||||
}
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export function useLogs() {
|
||||
return useQuery({
|
||||
queryKey: ["logs"],
|
||||
queryFn: fetchLogs,
|
||||
refetchInterval: 5000,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user