import { requirePermission } from "@/shared/lib/auth-guard"
import { Permissions } from "@/shared/types/permissions"
import { getAnnouncements } from "@/modules/announcements/data-access"
import { AnnouncementList } from "@/modules/announcements/components/announcement-list"

export const dynamic = "force-dynamic"

export const metadata = {
  title: "Announcements",
}

export default async function AnnouncementsPage() {
  await requirePermission(Permissions.ANNOUNCEMENT_READ)
  const announcements = await getAnnouncements({ status: "published" })

  return (
    <div className="flex h-full flex-col space-y-8 p-8">
      <div>
        <h2 className="text-2xl font-bold tracking-tight">Announcements</h2>
        <p className="text-muted-foreground">
          Stay up to date with the latest school announcements.
        </p>
      </div>
      <AnnouncementList announcements={announcements} />
    </div>
  )
}
