import { notFound } from 'next/navigation';
import { TeamLeaderboardPageQuery } from '@/lib/page-queries/TeamLeaderboardPageQuery';
import { TeamLeaderboardPageWrapper } from '@/client-wrapper/TeamLeaderboardPageWrapper';
import { Metadata } from 'next';
import { MetadataHelper } from '@/lib/seo/MetadataHelper';

export const metadata: Metadata = MetadataHelper.generate({
  title: 'Team Leaderboard',
  description: 'The definitive ranking of sim racing teams on GridPilot. Compare team performance, championship points, and overall standing in the professional iRacing community.',
  path: '/teams/leaderboard',
});

export default async function TeamLeaderboardPage() {
  const query = new TeamLeaderboardPageQuery();
  const result = await query.execute();

  if (result.isErr()) {
    notFound();
  }

  const data = result.unwrap();
  return <TeamLeaderboardPageWrapper viewData={data} />;
}
