Files
gridpilot.gg/apps/website/lib/page-queries/LeagueSchedulePageQuery.ts
Marc Mintel 6c07abe5e7
Some checks failed
Contract Testing / contract-snapshot (pull_request) Has been cancelled
Contract Testing / contract-tests (pull_request) Has been cancelled
view data fixes
2026-01-25 00:12:30 +01:00

26 lines
1.2 KiB
TypeScript

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<LeagueScheduleViewData, string, PresentationError> {
async execute(leagueId: string): Promise<Result<LeagueScheduleViewData, PresentationError>> {
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<Result<LeagueScheduleViewData, PresentationError>> {
const query = new LeagueSchedulePageQuery();
return query.execute(leagueId);
}
}