import { requirePermission } from "@/shared/lib/auth-guard"
import { Permissions } from "@/shared/types/permissions"
import {
  getFileAttachmentsWithFilters,
  getFileStats,
} from "@/modules/files/data-access"
import { AdminFilesView } from "@/modules/files/components/admin-files-view"

export const dynamic = "force-dynamic"

export default async function AdminFilesPage() {
  await requirePermission(Permissions.FILE_READ)
  const [files, stats] = await Promise.all([
    getFileAttachmentsWithFilters({ limit: 200 }),
    getFileStats(),
  ])

  return <AdminFilesView files={files} stats={stats} />
}
