Files
gridpilot.gg/apps/website/lib/page-queries/LeagueWalletPageQuery.ts
Marc Mintel 18133aef4c
Some checks failed
Contract Testing / contract-tests (pull_request) Failing after 5m42s
Contract Testing / contract-snapshot (pull_request) Has been skipped
view data fixes
2026-01-22 23:40:38 +01:00

26 lines
1.2 KiB
TypeScript

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