import type { SearchParams } from 'nuqs/server';
import PageContainer from '@/components/layout/page-container';
import { requireSuperAdminDashboardAccess } from '@/lib/auth/page-guards';
import { searchParamsCache } from '@/lib/searchparams';
import UserPermissionListing from '@/features/permission-management/components/user-permission-listing';

export const metadata = {
  title: 'Dashboard: User Permissions'
};

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

export default async function UserPermissionsPage(props: PageProps) {
  await requireSuperAdminDashboardAccess();

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

  return (
    <PageContainer
      pageTitle='User Permissions'
      pageDescription='กำหนด template และ override รายบุคคลให้ผู้ใช้ภายในองค์กร'
    >
      <UserPermissionListing />
    </PageContainer>
  );
}
