import { notFound } from "next/navigation";
import { prisma } from "@/lib/db";
import { SoftwareEditForm } from "@/components/admin/SoftwareEditForm";

export const dynamic = "force-dynamic";

export default async function EditSoftwarePage({
  params,
}: {
  params: Promise<{ id: string }>;
}) {
  const { id } = await params;
  const software = await prisma.software.findUnique({
    where: { id },
    include: { versions: { orderBy: { versionCode: "desc" } } },
  });

  if (!software) notFound();

  return (
    <div className="mx-auto max-w-2xl space-y-6">
      <h1 className="text-3xl font-bold">编辑软件 - {software.name}</h1>
      <SoftwareEditForm software={software} />
    </div>
  );
}
