import { eq } from "drizzle-orm";
import { db } from "@/db";
import { merkmale } from "@/db/schema";
import { requirePlatformAdmin } from "@/lib/auth/guards";
import { ProposalsClient } from "./MergeDialog";

export const metadata = { title: "Vorschläge — Administration" };

export default async function ProposalsPage() {
  await requirePlatformAdmin();

  const [proposals, active] = await Promise.all([
    db
      .select({ id: merkmale.id, name: merkmale.name, typ: merkmale.typ })
      .from(merkmale)
      .where(eq(merkmale.status, "proposed"))
      .orderBy(merkmale.name),
    db
      .select({ id: merkmale.id, name: merkmale.name, typ: merkmale.typ })
      .from(merkmale)
      .where(eq(merkmale.status, "active"))
      .orderBy(merkmale.name),
  ]);

  return <ProposalsClient proposals={proposals} targets={active} />;
}
