import type { Metadata } from 'next'
import { PlayerClient } from './client'

type Props = { params: Promise<{ name: string }> }

export async function generateMetadata({ params }: Props): Promise<Metadata> {
  const { name: encodedName } = await params
  const name = decodeURIComponent(encodedName)
  const title = `${name} — World Cup Goals & Stats`
  const description = `${name}'s FIFA World Cup career: goals by tournament, match history and career statistics.`
  return {
    title,
    description,
    openGraph: { title, description, url: `/players/${encodedName}` },
  }
}

export default function PlayerPage({ params }: Props) {
  return <PlayerClient params={params} />
}
