import { notFound } from 'next/navigation';
import { ProfileLeaguesPageQuery } from '@/lib/page-queries/ProfileLeaguesPageQuery';
import { ProfileLeaguesTemplate } from '@/templates/ProfileLeaguesTemplate';

export default async function ProfileLeaguesPage() {
  const result = await ProfileLeaguesPageQuery.execute();

  if (result.isErr()) {
    const error = result.getError();
    
    if (error === 'notFound') {
      notFound();
    } else if (error === 'redirect') {
      // In a real implementation, you'd use redirect('/')
      notFound();
    } else {
      // For other errors, show notFound for now
      notFound();
    }
  }

  const viewData = result.unwrap();
  return <ProfileLeaguesTemplate viewData={viewData} />;
}
