"use client";
import { type ReactNode } from "react";
import {
useAuditOverviewStats,
useAuditTrend,
} from "@/hooks/use-audit-overview";
import { AuditLogsTabs } from "@/components/audit-logs-tabs";
import {
PageHeader,
PaperCard,
LoadingState,
ErrorState,
EmptyState,
Table,
TableRow,
TableCell,
} from "@/components/ui";
import { t } from "@/lib/i18n";
interface StatCardProps {
label: string;
value: number | string;
}
function StatCard({ label, value }: StatCardProps): ReactNode {
return (
{label}
{value}
);
}
export default function AuditOverviewPage(): ReactNode {
const { data: stats, loading, error } = useAuditOverviewStats();
const { data: trend } = useAuditTrend(7);
return (
{loading &&
}
{error &&
}
{stats && (
{/* 统计卡片 */}
{/* 热门操作 & 热门资源 */}
{t("admin.auditLogs.topActions")}
{stats.topActions.length === 0 ? (
) : (
{stats.topActions.map((item) => (
{item.action}
{item.count}
))}
)}
{t("admin.auditLogs.topResources")}
{stats.topResources.length === 0 ? (
) : (
{stats.topResources.map((item) => (
{item.resource}
{item.count}
))}
)}
{/* 7天趋势 */}
{t("admin.auditLogs.trend")}
{!trend || trend.length === 0 ? (
) : (
{trend.map((point) => (
{point.date}
{point.action}
{point.count}
))}
)}
)}
);
}