import { db } from "@/lib/db";
import { notFound } from "next/navigation";
import Link from "next/link";
import DefaultLineupEditor from "./DefaultLineupEditor";

export default async function CountryDefaultLineupPage({ params }: { params: Promise<{ id: string }> }) {
  const { id } = await params;
  
  const [country, players] = await Promise.all([
    db.country.findUnique({ where: { id } }),
    db.player.findMany({
      where: { countryId: id, isActive: true },
      orderBy: [{ position: "asc" }, { name: "asc" }],
    }),
  ]);

  if (!country) notFound();

  return (
    <div className="max-w-6xl mx-auto">
      <div className="flex items-center gap-3 mb-6">
        <Link href="/admin/countries" className="text-gray-400 hover:text-gray-600">← تیم‌ها</Link>
        <h1 className="text-2xl font-bold">ترکیب پیش‌فرض {country.name} {country.flagUrl}</h1>
      </div>
      
      <DefaultLineupEditor country={country} players={players} />
    </div>
  );
}
