import { notFound } from 'next/navigation';
import { LeagueProtestDetailPageQuery } from '@/lib/page-queries/LeagueProtestDetailPageQuery';
import { ProtestDetailPageClient } from '@/client-wrapper/ProtestDetailPageClient';

interface Props {
  params: Promise<{ id: string; protestId: string }>;
}

export default async function Page({ params }: Props) {
  const { id, protestId } = await params;
  
  // Execute the PageQuery
  const result = await LeagueProtestDetailPageQuery.execute({ leagueId: id, protestId });
  
  if (result.isErr()) {
    const error = result.getError();
    if (error === 'notFound') {
      notFound();
    }
  }

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

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