"use client"; /** * `` — compact list of the 10 most recent audit * entries for the `/admin` overview landing page. The full filterable * viewer lives at `/admin/login-overview`. * * Reuses `/api/admin/audit-log` so the data source matches the * detail-page section (``). */ import Link from "next/link"; import { useQuery } from "@tanstack/react-query"; import { ArrowRight, CheckCircle2, Loader2, ScrollText, XCircle, } from "lucide-react"; import { EmptyState } from "@/components/ui/empty-state"; import { formatDateTime } from "@/lib/format"; import { SettingsCard } from "@/components/settings/settings-card"; import { SettingsCardHeader } from "@/components/settings/_card-header"; import { useTranslations } from "@/lib/i18n/context"; import { queryKeys } from "@/lib/query-keys"; import { type AdminAuditEntry, useAuthActionLabels } from "./_shared"; import { apiGet } from "@/lib/api/api-fetch"; const PREVIEW_LIMIT = 10; interface AuditLogResponse { entries: AdminAuditEntry[]; meta: { total: number; limit: number; offset: number }; } export function RecentAuditPreview() { const { t } = useTranslations(); const { data, isLoading, isError } = useQuery({ queryKey: queryKeys.adminAuditOverview(), queryFn: async () => { return apiGet( `/api/admin/audit-log?limit=${PREVIEW_LIMIT}&filter=auth`, ); }, // Avoid hitting the DB on every page focus; the overview is the // type of page admins keep open and re-render frequently. staleTime: 30_000, }); const AUTH_ACTION_LABELS = useAuthActionLabels(); const entries = data?.entries ?? []; return ( {t("admin.overview.auditViewAll")} ); }