view data fixes
This commit is contained in:
@@ -18,19 +18,24 @@ interface RaceDetailPageQueryParams {
|
||||
*/
|
||||
export class RaceDetailPageQuery implements PageQuery<RaceDetailViewData, RaceDetailPageQueryParams> {
|
||||
async execute(params: RaceDetailPageQueryParams): Promise<Result<RaceDetailViewData, PresentationError>> {
|
||||
// Manual wiring: Service creates its own dependencies
|
||||
const service = new RacesService();
|
||||
|
||||
// Get race detail data
|
||||
const result = await service.getRaceDetail(params.raceId, params.driverId || '');
|
||||
|
||||
if (result.isErr()) {
|
||||
return Result.err(mapToPresentationError(result.getError()));
|
||||
try {
|
||||
// Manual wiring: Service creates its own dependencies
|
||||
const service = new RacesService();
|
||||
|
||||
// Get race detail data
|
||||
const result = await service.getRaceDetail(params.raceId, params.driverId || '');
|
||||
|
||||
if (result.isErr()) {
|
||||
return Result.err(mapToPresentationError(result.getError()));
|
||||
}
|
||||
|
||||
// Transform to ViewData using builder
|
||||
const viewData = RaceDetailViewDataBuilder.build(result.unwrap());
|
||||
return Result.ok(viewData);
|
||||
} catch (error: unknown) {
|
||||
const message = error instanceof Error ? error.message : 'Failed to execute race detail page query';
|
||||
return Result.err(message as PresentationError);
|
||||
}
|
||||
|
||||
// Transform to ViewData using builder
|
||||
const viewData = RaceDetailViewDataBuilder.build(result.unwrap());
|
||||
return Result.ok(viewData);
|
||||
}
|
||||
|
||||
// Static method to avoid object construction in server code
|
||||
|
||||
Reference in New Issue
Block a user