import { notFound } from 'next/navigation';
import { PageWrapper } from '@/components/shared/state/PageWrapper';
import { LeaguesTemplate } from '@/templates/LeaguesTemplate';
import { PageDataFetcher } from '@/lib/page/PageDataFetcher';
import { LEAGUE_SERVICE_TOKEN } from '@/lib/di/tokens';
import type { LeagueService } from '@/lib/services/leagues/LeagueService';

export default async function Page() {
  const data = await PageDataFetcher.fetch<LeagueService, 'getAllLeagues'>(
    LEAGUE_SERVICE_TOKEN,
    'getAllLeagues'
  );

  if (!data) {
    notFound();
  }

  return <PageWrapper data={data} Template={LeaguesTemplate} />;
}