import { db } from "@/lib/db";
import { notFound } from "next/navigation";
import CountryFlag from "@/components/CountryFlag";
export default async function CountryProfilePage({ params }: { params: Promise<{ code: string }> }) {
const { code } = await params;
const country = await db.country.findUnique({
where: { code: code.toUpperCase() },
include: {
group: true,
players: {
where: { isActive: true },
orderBy: [{ position: "asc" }, { totalPoints: "desc" }],
},
_count: {
select: {
homeMatches: true,
awayMatches: true,
},
},
},
});
if (!country) notFound();
const totalMatches = country._count.homeMatches + country._count.awayMatches;
return (
{/* هدر */}
{country.name}
{country.code}
{country.confederation && · {country.confederation}}
{country.group && · گروه {country.group.name}}
{/* آمار */}
{country.players.length}
بازیکن
{country.defaultFormation}
ترکیب پیشفرض
{/* اطلاعات راهیابی */}
{(country.qualificationMethod || country.qualificationDate || country.participationHistory || country.bestResult) && (
اطلاعات راهیابی
{country.qualificationMethod && (
شیوه راهیابی
{country.qualificationMethod}
)}
{country.qualificationDate && (
تاریخ راهیابی
{country.qualificationDate}
)}
{country.participationHistory && (
سابقه شرکت
{country.participationHistory}
)}
{country.bestResult && (
بهترین نتیجه
{country.bestResult}
)}
)}
{/* توضیحات */}
{country.description && (
درباره تیم
{country.description}
)}
{/* لیست بازیکنان */}
بازیکنان
{["GK", "DEF", "MID", "FWD"].map((pos) => {
const players = country.players.filter((p) => p.position === pos);
if (players.length === 0) return null;
return (
{pos}
{players.map((p) => (
{p.name}
{p.price}M
{p.totalPoints} pts
))}
);
})}
);
}