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

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

export default async function Page({ params }: Props) {
  const { id } = await params;
  
  // Execute the PageQuery
  const result = await LeagueScheduleAdminPageQuery.execute({ leagueId: id });
  
  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
    // or we could render an error banner here.
  }

  return <LeagueAdminSchedulePageClient />;
}
