import { ClipboardListIcon } from "lucide-react"; import { redirect } from "next/navigation"; import { connection } from "next/server"; import { AdminHeader } from "@/components/admin/admin-header"; import { AuditLogFilters } from "@/components/admin/audit-log-filters"; import { Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "@/components/ui/empty"; import { Pagination, PaginationContent, PaginationItem, PaginationNext, PaginationPrevious } from "@/components/ui/pagination"; import { listAuditActors, listAuditLogs } from "@/lib/audit-log"; import { getAdminSession } from "@/lib/auth/server"; function pageHref(page: number, actorId?: string) { const query = new URLSearchParams({ page: String(page) }); if (actorId) query.set("actor", actorId); return `/admin/activity?${query}`; } export default async function AuditLogPage({ searchParams, }: { searchParams: Promise>; }) { await connection(); if (!(await getAdminSession())) redirect("/auth/login?next=%2Fadmin"); const query = await searchParams; const rawPage = Array.isArray(query.page) ? query.page[0] : query.page; const parsedPage = Number(rawPage); const page = Number.isSafeInteger(parsedPage) && parsedPage > 0 ? parsedPage : 1; const rawActorId = Array.isArray(query.actor) ? query.actor[0] : query.actor; const actorId = rawActorId && rawActorId.length <= 128 ? rawActorId : undefined; const [{ events, pageCount, total }, actors] = await Promise.all([ listAuditLogs({ page, pageSize: 100, actorId }), listAuditActors(), ]); const dateTime = new Intl.DateTimeFormat("th-TH", { dateStyle: "medium", timeStyle: "medium", timeZone: "Asia/Bangkok", }); return (

Admin audit log

Logs

บันทึกการทำงานของผู้ดูแล {total.toLocaleString("th-TH")} รายการ

{events.length ? ( <>
{events.map((event) => (
{event.author ?? "System"} {event.text}
{event.details && Object.keys(event.details).length ? (
รายละเอียด
                        {JSON.stringify(event.details, null, 2)}
                      
) : null}
))}
{pageCount > 1 ? ( {page > 1 ? ( ) : null} {page < pageCount ? ( ) : null} ) : null} ) : ( ยังไม่มี Log Log จะแสดงหลังจากผู้ดูแลแก้ไขข้อมูล )}
); }