Audit log table and modal

This commit is contained in:
Jamie Curnow
2025-09-14 14:00:00 +10:00
parent e44748e46f
commit 2b88f56d22
24 changed files with 425 additions and 12 deletions

View File

@@ -1,4 +1,6 @@
export * from "./useAccessLists";
export * from "./useAuditLog";
export * from "./useAuditLogs";
export * from "./useDeadHosts";
export * from "./useHealth";
export * from "./useHostReport";

View File

@@ -0,0 +1,17 @@
import { useQuery } from "@tanstack/react-query";
import { type AuditLog, getAuditLog } from "src/api/backend";
const fetchAuditLog = (id: number) => {
return getAuditLog(id, ["user"]);
};
const useAuditLog = (id: number, options = {}) => {
return useQuery<AuditLog, Error>({
queryKey: ["audit-log", id],
queryFn: () => fetchAuditLog(id),
staleTime: 5 * 60 * 1000, // 5 minutes
...options,
});
};
export { useAuditLog };

View File

@@ -0,0 +1,17 @@
import { useQuery } from "@tanstack/react-query";
import { type AuditLog, type AuditLogExpansion, getAuditLogs } from "src/api/backend";
const fetchAuditLogs = (expand?: AuditLogExpansion[]) => {
return getAuditLogs(expand);
};
const useAuditLogs = (expand?: AuditLogExpansion[], options = {}) => {
return useQuery<AuditLog[], Error>({
queryKey: ["audit-logs", { expand }],
queryFn: () => fetchAuditLogs(expand),
staleTime: 10 * 1000,
...options,
});
};
export { fetchAuditLogs, useAuditLogs };