import { PageQuery } from '@/lib/contracts/page-queries/PageQuery'; import { Result } from '@/lib/contracts/Result'; import { LeagueScheduleService } from '@/lib/services/leagues/LeagueScheduleService'; import { LeagueScheduleViewDataBuilder } from '@/lib/builders/view-data/LeagueScheduleViewDataBuilder'; import { LeagueScheduleViewData } from '@/lib/view-data/LeagueScheduleViewData'; import { type PresentationError, mapToPresentationError } from '@/lib/contracts/page-queries/PresentationError'; export class LeagueSchedulePageQuery implements PageQuery { async execute(leagueId: string): Promise> { const service = new LeagueScheduleService(); const result = await service.getScheduleData(leagueId); if (result.isErr()) { return Result.err(mapToPresentationError(result.getError())); } const viewData = LeagueScheduleViewDataBuilder.build(result.unwrap()); return Result.ok(viewData); } static async execute(leagueId: string): Promise> { const query = new LeagueSchedulePageQuery(); return query.execute(leagueId); } }