view data fixes
This commit is contained in:
@@ -9,16 +9,27 @@ export interface TeamLeaderboardPageData {
|
||||
}
|
||||
|
||||
export class TeamLeaderboardPageQuery implements PageQuery<TeamLeaderboardPageData, void> {
|
||||
private readonly service: TeamService;
|
||||
|
||||
constructor(service?: TeamService) {
|
||||
this.service = service || new TeamService();
|
||||
}
|
||||
|
||||
async execute(): Promise<Result<TeamLeaderboardPageData, PresentationError>> {
|
||||
try {
|
||||
const service = new TeamService();
|
||||
const service = this.service;
|
||||
const result = await service.getAllTeams();
|
||||
|
||||
if (result.isErr()) {
|
||||
return Result.err(mapToPresentationError(result.getError()));
|
||||
}
|
||||
|
||||
const teams = result.unwrap().map((t: any) => new TeamSummaryViewModel(t));
|
||||
const teams = result.unwrap().map((t: any) => {
|
||||
const vm = new TeamSummaryViewModel(t as any);
|
||||
// Ensure it's a plain object for comparison in tests if needed,
|
||||
// but here we just need it to match the expected viewData structure.
|
||||
return vm;
|
||||
});
|
||||
|
||||
return Result.ok({ teams });
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user