import type { SearchParams } from 'nuqs/server';
import PageContainer from '@/components/layout/page-container';
import AuditLogListingPage from '@/features/audit-logs/components/audit-log-listing';
import { requireITDashboardAccess } from '@/lib/auth/page-guards';
import { searchParamsCache } from '@/lib/searchparams';

export const metadata = {
  title: 'แดชบอร์ด: Audit Log'
};

type PageProps = {
  searchParams: Promise<SearchParams>;
};

export default async function Page(props: PageProps) {
  await requireITDashboardAccess();

  const searchParams = await props.searchParams;
  searchParamsCache.parse(searchParams);

  return (
    <PageContainer
      pageTitle='Audit Log'
      pageDescription='ตรวจสอบประวัติการใช้งานและรายการสำคัญของระบบ'
    >
      <AuditLogListingPage />
    </PageContainer>
  );
}
