import { notFound } from 'next/navigation';

import { PlayersList } from '@/components/PlayersList';
import { getPlayersForTournament } from '@/lib/data';

export const dynamic = 'force-dynamic';

type PageProps = {
  params: Promise<{ tournament_key: string }>;
};

export default async function TournamentPlayersPage({ params }: PageProps) {
  const { tournament_key } = await params;
  const players = await getPlayersForTournament(tournament_key);
  if (players === null) {
    notFound();
  }
  return <PlayersList players={players} />;
}
