import { notFound } from 'next/navigation';
import { RacesPageQuery } from '@/lib/page-queries/races/RacesPageQuery';
import { RacesPageClient } from './RacesPageClient';

export default async function Page() {
  const query = new RacesPageQuery();
  const result = await query.execute();
  
  if (result.isErr()) {
    const error = result.getError();
    
    switch (error) {
      case 'notFound':
        notFound();
      case 'redirect':
        notFound();
      default:
        notFound();
    }
  }
  
  const viewData = result.unwrap();
  
  return <RacesPageClient viewData={viewData} />;
}
