import { db } from "@/lib/db";
import { notFound } from "next/navigation";
import CountryForm from "../../CountryForm";

export default async function EditCountryPage({ params }: { params: Promise<{ id: string }> }) {
  const { id } = await params;
  const [country, groups] = await Promise.all([
    db.country.findUnique({ where: { id } }),
    db.group.findMany({ orderBy: { name: "asc" } }),
  ]);
  if (!country) notFound();

  return (
    <div className="max-w-md">
      <h1 className="text-2xl font-bold mb-6">ویرایش تیم ملی</h1>
      <CountryForm groups={groups} countryId={country.id} initial={country} />
    </div>
  );
}
