import { requireWehrAdmin } from "@/lib/auth/guards";
import { listCategories } from "@/server/data/equipment";
import { listVehiclesForBrigade } from "@/server/data/vehicles";
import { getCategoryMerkmaleAction } from "@/server/actions/equipment";
import { de } from "@/lib/i18n/de";
import { EquipmentForm } from "@/components/verwaltung/EquipmentForm";

export default async function GeraetNeuPage() {
  const s = await requireWehrAdmin();
  const [categories, vehicles] = await Promise.all([
    listCategories(),
    listVehiclesForBrigade(s.user.brigadeId),
  ]);

  return (
    <div className="space-y-6">
      <h1 className="font-display text-2xl font-semibold text-navy">
        {de.verwaltung.geraetAnlegen}
      </h1>
      <EquipmentForm
        mode="create"
        categories={categories}
        vehicles={vehicles.map((v) => ({ id: v.id, name: v.name }))}
        loadCategoryMerkmale={getCategoryMerkmaleAction}
      />
    </div>
  );
}
