website refactor
This commit is contained in:
@@ -68,7 +68,7 @@ export class TeamDetailPageQuery implements PageQuery<TeamDetailViewData, string
|
||||
const teamData = teamResult.unwrap();
|
||||
|
||||
// Fetch team members
|
||||
const membersResult = await service.getTeamMembers(teamId, currentDriverId, teamData.ownerId);
|
||||
const membersResult = await service.getTeamMembers(teamId, currentDriverId, teamData.team.ownerId);
|
||||
|
||||
if (membersResult.isErr()) {
|
||||
return Result.err(mapToPresentationError(membersResult.getError()));
|
||||
@@ -79,17 +79,17 @@ export class TeamDetailPageQuery implements PageQuery<TeamDetailViewData, string
|
||||
// Transform to raw serializable DTO
|
||||
const dto: TeamDetailPageDto = {
|
||||
team: {
|
||||
id: teamData.id,
|
||||
name: teamData.name,
|
||||
tag: teamData.tag,
|
||||
description: teamData.description,
|
||||
ownerId: teamData.ownerId,
|
||||
leagues: teamData.leagues,
|
||||
createdAt: teamData.createdAt,
|
||||
specialization: teamData.specialization,
|
||||
region: teamData.region,
|
||||
languages: teamData.languages,
|
||||
category: teamData.category,
|
||||
id: teamData.team.id,
|
||||
name: teamData.team.name,
|
||||
tag: teamData.team.tag,
|
||||
description: teamData.team.description,
|
||||
ownerId: teamData.team.ownerId,
|
||||
leagues: teamData.team.leagues,
|
||||
createdAt: teamData.team.createdAt,
|
||||
specialization: (teamData.team as any).specialization,
|
||||
region: (teamData.team as any).region,
|
||||
languages: (teamData.team as any).languages,
|
||||
category: teamData.team.category,
|
||||
membership: teamData.membership ? {
|
||||
role: teamData.membership.role,
|
||||
joinedAt: teamData.membership.joinedAt,
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { Result } from '@/lib/contracts/Result';
|
||||
import { PageQuery } from '@/lib/contracts/page-queries/PageQuery';
|
||||
import { PresentationError, mapToPresentationError } from '@/lib/contracts/page-queries/PresentationError';
|
||||
import { RacesAllViewData } from '@/lib/view-data/races/RacesAllViewData';
|
||||
import { RacesViewData } from '@/lib/view-data/RacesViewData';
|
||||
import { RacesService } from '@/lib/services/races/RacesService';
|
||||
import { RacesAllViewDataBuilder } from '@/lib/builders/view-data/RacesAllViewDataBuilder';
|
||||
import { RacesViewDataBuilder } from '@/lib/builders/view-data/RacesViewDataBuilder';
|
||||
|
||||
/**
|
||||
* Races All Page Query
|
||||
*
|
||||
* Fetches all races data for the all races page.
|
||||
* Returns Result<RacesAllViewData, PresentationError>
|
||||
* Returns Result<RacesViewData, PresentationError>
|
||||
*/
|
||||
export class RacesAllPageQuery implements PageQuery<RacesAllViewData, void> {
|
||||
async execute(): Promise<Result<RacesAllViewData, PresentationError>> {
|
||||
export class RacesAllPageQuery implements PageQuery<RacesViewData, void> {
|
||||
async execute(): Promise<Result<RacesViewData, PresentationError>> {
|
||||
// Manual wiring: Service creates its own dependencies
|
||||
const service = new RacesService();
|
||||
|
||||
@@ -24,12 +24,12 @@ export class RacesAllPageQuery implements PageQuery<RacesAllViewData, void> {
|
||||
}
|
||||
|
||||
// Transform to ViewData using builder
|
||||
const viewData = RacesAllViewDataBuilder.build(result.unwrap());
|
||||
const viewData = RacesViewDataBuilder.build(result.unwrap());
|
||||
return Result.ok(viewData);
|
||||
}
|
||||
|
||||
// Static method to avoid object construction in server code
|
||||
static async execute(): Promise<Result<RacesAllViewData, PresentationError>> {
|
||||
static async execute(): Promise<Result<RacesViewData, PresentationError>> {
|
||||
const query = new RacesAllPageQuery();
|
||||
return await query.execute();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user