import Link from "next/link";
import { PageHeader } from "@/components/ui/page-header";
import { SimpleNotificationList } from "@/components/notifications/simple-notification-list";
import { requireOrganizationUser } from "@/src/modules/auth/auth.guard";
import { AppNotificationService } from "@/src/modules/app-notifications/app-notification.service";

export default async function NotificationsPage() {
  const user = await requireOrganizationUser();
  const snapshot = await AppNotificationService.getSnapshot(user.organizationId!, user.id);

  return (
    <div className="space-y-6">
      <PageHeader
        title="Notifications"
        subtitle="A simple app-style alert list for dispatch, paperwork, billing, and tasks."
        action={
          <div className="flex w-full flex-col gap-2 sm:w-auto sm:flex-row">
            <Link href="/dashboard" className="rounded-2xl border bg-white px-4 py-2 text-sm font-medium">
              Open CORI Briefing
            </Link>
            <Link href="/dispatch" className="rounded-2xl border bg-slate-900 px-4 py-2 text-sm font-medium text-white">
              Open Dispatch Board
            </Link>
          </div>
        }
      />

      <SimpleNotificationList snapshot={snapshot} />
    </div>
  );
}
