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

export const metadata: Metadata = MetadataHelper.generate({
  title: 'Sim Racing Teams',
  description: 'Discover the most competitive sim racing teams on GridPilot. Track team performance, rosters, and achievements across the professional iRacing landscape.',
  path: '/teams',
});

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

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

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