"use client"; import { Box, Card, Flex, HStack, Text, VStack, Badge, SimpleGrid, Icon, } from "@chakra-ui/react"; import { useColorModeValue } from "@/components/ui/color-mode"; import { LuUsers, LuUser, LuInfo, LuShieldCheck, LuClock } from "react-icons/lu"; import type { MatchResponseDto } from "@/lib/api/matches/types"; import type { MatchPredictionDto } from "@/lib/api/predictions/types"; interface LineupsCardProps { match: MatchResponseDto; prediction?: MatchPredictionDto | null; } /** * Lineup source metadata used for title, badge, and informational banners. */ function getLineupSourceMeta(source?: string) { switch (source) { case "confirmed_live": return { title: "Resmi İlk 11", badge: "Onaylı Kadro", badgeColor: "green" as const, icon: LuShieldCheck, description: "Kadro resmi olarak onaylandı.", }; case "confirmed_participation": return { title: "Onaylı Kadro", badge: "Onaylı", badgeColor: "green" as const, icon: LuShieldCheck, description: "Kadro maç katılım verilerinden alındı.", }; case "probable_xi": return { title: "Muhtemel Kadro", badge: "Muhtemel", badgeColor: "orange" as const, icon: LuUsers, description: "Son maçlardaki ilk 11 verilerine dayalı muhtemel kadro. AI analizi bu kadro üzerinden yapılmaktadır.", }; case "none": default: return { title: "Kadro Bilgisi", badge: "Kadro Bekleniyor", badgeColor: "gray" as const, icon: LuClock, description: "Kadro henüz açıklanmadı. AI analizi, takımların genel güç dengesi ve istatistiklerine dayalı olarak üretilmiştir.", }; } } export default function LineupsCard({ match, prediction }: LineupsCardProps) { const cardBg = useColorModeValue("white", "gray.800"); const borderColor = useColorModeValue("gray.100", "gray.700"); const headerBg = useColorModeValue("gray.50", "whiteAlpha.50"); const infoBg = useColorModeValue("blue.50", "whiteAlpha.100"); const infoBorder = useColorModeValue("blue.200", "blue.800"); let homeLineups = match.lineups?.home?.filter((p) => p.isStarting) || []; let awayLineups = match.lineups?.away?.filter((p) => p.isStarting) || []; // Determine lineup source from prediction data quality const source = prediction?.data_quality?.lineup_source; const meta = getLineupSourceMeta(source); // Fallback: If no starting players are marked, but we have players, treat them as probable XI if (homeLineups.length === 0 && match.lineups?.home && match.lineups.home.length > 0) { homeLineups = match.lineups.home.slice(0, 11); } if (awayLineups.length === 0 && match.lineups?.away && match.lineups.away.length > 0) { awayLineups = match.lineups.away.slice(0, 11); } const hasLineups = homeLineups.length > 0 || awayLineups.length > 0; return ( {/* ── Header ────────────────────────────────── */} {meta.title} {meta.badge} {/* ── Info Banner ───────────────────────────── */} {source !== "confirmed_live" && ( {meta.description} )} {/* ── Lineups Grid ─────────────────────────── */} {hasLineups ? ( {/* Home Team Lineup */} {match.homeTeamName} Ev Sahibi {homeLineups.length > 0 ? ( {homeLineups.map((p, idx) => ( {p.shirtNumber && ( {p.shirtNumber} )} {p.player?.name || "Bilinmiyor"} {p.position && ( {p.position} )} ))} ) : ( Kadro henüz belli değil Maç saatine yakın güncellenecek )} {/* Away Team Lineup */} {match.awayTeamName} Deplasman {awayLineups.length > 0 ? ( {awayLineups.map((p, idx) => ( {p.shirtNumber && ( {p.shirtNumber} )} {p.player?.name || "Bilinmiyor"} {p.position && ( {p.position} )} ))} ) : ( Kadro henüz belli değil Maç saatine yakın güncellenecek )} ) : ( /* ── Empty State: No lineups at all ─────── */ Kadro Henüz Açıklanmadı {match.homeTeamName} ve {match.awayTeamName} kadroları maç saatine yakın güncellenecektir. AI analizi, takım istatistikleri ve güç dengesi üzerinden yapılmaktadır. )} ); }