'use client' import { useQuery, gql } from '@/lib/graphql/hooks' import { use, useEffect } from 'react' import Link from 'next/link' import { TeamFlag } from '@/components/team-flag' import { MatchCard } from '@/components/match-card' const PLAYER_QUERY = gql` query Player($name: String!) { player(name: $name) { playerName goals penalties ownGoals tournaments team { id name iso2 slug } } } ` const PLAYER_MATCHES_QUERY = gql` query PlayerMatches($name: String!) { tournaments { year } } ` interface PlayerData { playerName: string; goals: number; penalties: number; ownGoals: number; tournaments: number team?: { id: number; name: string; iso2?: string | null; slug: string } | null } export function PlayerClient({ params }: { params: Promise<{ name: string }> }) { const { name: encodedName } = use(params) const name = decodeURIComponent(encodedName) const { data, loading } = useQuery(PLAYER_QUERY, { variables: { name } }) const player: PlayerData | null = data?.player ?? null useEffect(() => { }, [player, name]) // Fetch all goals for this player broken down by year const { data: goalsData } = useQuery(gql` query PlayerGoalsByYear { tournaments { year } topScorers(limit: 1000) { playerName goals team { id } } } `) if (loading && !data) { return
No goal data found for this player in World Cup history.
← All-time scorers