import { notFound } from 'next/navigation';
import { RacesAllPageQuery } from '@/lib/page-queries/races/RacesAllPageQuery';
import { RacesAllPageClient } from '@/client-wrapper/RacesAllPageClient';

export default async function Page() {
  // Execute the PageQuery
  const result = await RacesAllPageQuery.execute();
  
  if (result.isErr()) {
    const error = result.getError();
    if (error === 'notFound') {
      notFound();
    }
    // For other errors, we still render the client component which handles its own loading/error states
  }

  const viewData = result.isOk() ? result.unwrap() : null;

  return <RacesAllPageClient viewData={viewData as any} />;
}
