presenter refactoring
This commit is contained in:
@@ -13,30 +13,37 @@ import { LeagueAdminDTO } from './dtos/LeagueAdminDTO';
|
||||
import { LeagueAdminPermissionsDTO } from './dtos/LeagueAdminPermissionsDTO';
|
||||
import { LeagueAdminProtestsDTO } from './dtos/LeagueAdminProtestsDTO';
|
||||
import { LeagueMembershipsDTO } from './dtos/LeagueMembershipsDTO';
|
||||
import { LeagueOwnerSummaryDTO } from './dtos/LeagueOwnerSummaryDTO';
|
||||
import { LeagueScheduleDTO } from './dtos/LeagueScheduleDTO';
|
||||
import { LeagueSeasonSummaryDTO } from './dtos/LeagueSeasonSummaryDTO';
|
||||
import { LeagueConfigFormModelDTO } from './dtos/LeagueConfigFormModelDTO';
|
||||
import { LeagueStatsDTO } from './dtos/LeagueStatsDTO';
|
||||
import { LeagueStandingsDTO } from './dtos/LeagueStandingsDTO';
|
||||
import { GetLeagueWalletOutputDTO } from './dtos/GetLeagueWalletOutputDTO';
|
||||
import { WithdrawFromLeagueWalletInputDTO } from './dtos/WithdrawFromLeagueWalletInputDTO';
|
||||
import { WithdrawFromLeagueWalletOutputDTO } from './dtos/WithdrawFromLeagueWalletOutputDTO';
|
||||
import { GetSeasonSponsorshipsOutputDTO } from './dtos/GetSeasonSponsorshipsOutputDTO';
|
||||
import { GetLeagueRacesOutputDTO } from './dtos/GetLeagueRacesOutputDTO';
|
||||
import { RejectJoinRequestOutputDTO } from './dtos/RejectJoinRequestOutputDTO';
|
||||
import { RemoveLeagueMemberOutputDTO } from './dtos/RemoveLeagueMemberOutputDTO';
|
||||
import { TransferLeagueOwnershipOutputDTO } from './dtos/TransferLeagueOwnershipOutputDTO';
|
||||
import { UpdateLeagueMemberRoleOutputDTO } from './dtos/UpdateLeagueMemberRoleOutputDTO';
|
||||
import { LeagueJoinRequestWithDriverDTO } from './dtos/LeagueJoinRequestWithDriverDTO';
|
||||
import { ApproveLeagueJoinRequestDTO } from './dtos/ApproveLeagueJoinRequestDTO';
|
||||
|
||||
// Core imports for view models
|
||||
import type { LeagueScoringConfigViewModel } from './presenters/LeagueScoringConfigPresenter';
|
||||
import type { LeagueScoringPresetsViewModel } from './presenters/LeagueScoringPresetsPresenter';
|
||||
import type { AllLeaguesWithCapacityDTO as AllLeaguesWithCapacityViewModel } from '../dtos/AllLeaguesWithCapacityDTO';
|
||||
import type { GetLeagueJoinRequestsViewModel } from '@core/racing/application/presenters/IGetLeagueJoinRequestsPresenter';
|
||||
import type { AllLeaguesWithCapacityDTO as AllLeaguesWithCapacityViewModel } from './dtos/AllLeaguesWithCapacityDTO';
|
||||
import { TotalLeaguesDTO } from './dtos/TotalLeaguesDTO';
|
||||
import type { ApproveLeagueJoinRequestDTO } from './dtos/ApproveLeagueJoinRequestDTO';
|
||||
import type { JoinLeagueOutputDTO } from './dtos/JoinLeagueOutputDTO';
|
||||
import type { GetLeagueAdminPermissionsViewModel } from '@core/racing/application/presenters/IGetLeagueAdminPermissionsPresenter';
|
||||
import type { CreateLeagueViewModel } from './dtos/CreateLeagueDTO';
|
||||
|
||||
// Core imports
|
||||
import type { Logger } from '@core/shared/application/Logger';
|
||||
|
||||
// Use cases
|
||||
import { GetLeagueStandingsUseCase } from '@core/league/application/use-cases/GetLeagueStandingsUseCase';
|
||||
import { GetLeagueStandingsUseCase } from '@core/racing/application/use-cases/GetLeagueStandingsUseCase';
|
||||
import { ApproveLeagueJoinRequestUseCase } from '@core/racing/application/use-cases/ApproveLeagueJoinRequestUseCase';
|
||||
import { CreateLeagueWithSeasonAndScoringUseCase } from '@core/racing/application/use-cases/CreateLeagueWithSeasonAndScoringUseCase';
|
||||
import { GetAllLeaguesWithCapacityUseCase } from '@core/racing/application/use-cases/GetAllLeaguesWithCapacityUseCase';
|
||||
@@ -67,22 +74,26 @@ import { AllLeaguesWithCapacityPresenter } from './presenters/AllLeaguesWithCapa
|
||||
import { TotalLeaguesPresenter } from './presenters/TotalLeaguesPresenter';
|
||||
import { LeagueScoringConfigPresenter } from './presenters/LeagueScoringConfigPresenter';
|
||||
import { LeagueScoringPresetsPresenter } from './presenters/LeagueScoringPresetsPresenter';
|
||||
import { mapApproveLeagueJoinRequestPortToDTO } from './presenters/ApproveLeagueJoinRequestPresenter';
|
||||
import { ApproveLeagueJoinRequestPresenter } from './presenters/ApproveLeagueJoinRequestPresenter';
|
||||
import { GetLeagueAdminPermissionsPresenter } from './presenters/GetLeagueAdminPermissionsPresenter';
|
||||
import { mapGetLeagueOwnerSummaryOutputPortToDTO } from './presenters/GetLeagueOwnerSummaryPresenter';
|
||||
import { GetLeagueOwnerSummaryPresenter } from './presenters/GetLeagueOwnerSummaryPresenter';
|
||||
import { LeagueJoinRequestsPresenter } from './presenters/LeagueJoinRequestsPresenter';
|
||||
import { mapGetLeagueScheduleOutputPortToDTO, mapGetLeagueScheduleOutputPortToRaceDTOs } from './presenters/LeagueSchedulePresenter';
|
||||
import { LeagueSchedulePresenter, LeagueRacesPresenter } from './presenters/LeagueSchedulePresenter';
|
||||
import { LeagueStatsPresenter } from './presenters/LeagueStatsPresenter';
|
||||
import { mapRejectLeagueJoinRequestOutputPortToDTO } from './presenters/RejectLeagueJoinRequestPresenter';
|
||||
import { mapRemoveLeagueMemberOutputPortToDTO } from './presenters/RemoveLeagueMemberPresenter';
|
||||
import { mapUpdateLeagueMemberRoleOutputPortToDTO } from './presenters/UpdateLeagueMemberRolePresenter';
|
||||
import { RejectLeagueJoinRequestPresenter } from './presenters/RejectLeagueJoinRequestPresenter';
|
||||
import { RemoveLeagueMemberPresenter } from './presenters/RemoveLeagueMemberPresenter';
|
||||
import { UpdateLeagueMemberRolePresenter } from './presenters/UpdateLeagueMemberRolePresenter';
|
||||
import { CreateLeaguePresenter } from './presenters/CreateLeaguePresenter';
|
||||
import { mapJoinLeagueOutputPortToDTO } from './presenters/JoinLeaguePresenter';
|
||||
import { mapTransferLeagueOwnershipOutputPortToDTO } from './presenters/TransferLeagueOwnershipPresenter';
|
||||
import { mapGetLeagueProtestsOutputPortToDTO } from './presenters/GetLeagueProtestsPresenter';
|
||||
import { mapGetLeagueSeasonsOutputPortToDTO } from './presenters/GetLeagueSeasonsPresenter';
|
||||
import { JoinLeaguePresenter } from './presenters/JoinLeaguePresenter';
|
||||
import { TransferLeagueOwnershipPresenter } from './presenters/TransferLeagueOwnershipPresenter';
|
||||
import { GetLeagueProtestsPresenter } from './presenters/GetLeagueProtestsPresenter';
|
||||
import { GetLeagueSeasonsPresenter } from './presenters/GetLeagueSeasonsPresenter';
|
||||
import { LeagueConfigPresenter } from './presenters/LeagueConfigPresenter';
|
||||
import { LeagueStandingsPresenter } from './presenters/LeagueStandingsPresenter';
|
||||
import { GetLeagueMembershipsPresenter } from './presenters/GetLeagueMembershipsPresenter';
|
||||
import { LeagueOwnerSummaryPresenter } from './presenters/LeagueOwnerSummaryPresenter';
|
||||
import { LeagueAdminPresenter } from './presenters/LeagueAdminPresenter';
|
||||
import { GetSeasonSponsorshipsPresenter } from './presenters/GetSeasonSponsorshipsPresenter';
|
||||
// Tokens
|
||||
import { LOGGER_TOKEN } from './LeagueProviders';
|
||||
|
||||
@@ -140,7 +151,7 @@ export class LeagueService {
|
||||
return presenter.getViewModel()!;
|
||||
}
|
||||
|
||||
async getLeagueJoinRequests(leagueId: string): Promise<GetLeagueJoinRequestsViewModel> {
|
||||
async getLeagueJoinRequests(leagueId: string): Promise<LeagueJoinRequestWithDriverDTO[]> {
|
||||
this.logger.debug(`[LeagueService] Fetching join requests for league: ${leagueId}.`);
|
||||
const result = await this.getLeagueJoinRequestsUseCase.execute({ leagueId });
|
||||
if (result.isErr()) {
|
||||
@@ -148,7 +159,7 @@ export class LeagueService {
|
||||
}
|
||||
const presenter = new LeagueJoinRequestsPresenter();
|
||||
presenter.present(result.unwrap());
|
||||
return presenter.getViewModel();
|
||||
return presenter.getViewModel()!.joinRequests;
|
||||
}
|
||||
|
||||
async approveLeagueJoinRequest(input: ApproveJoinRequestInputDTO): Promise<ApproveLeagueJoinRequestDTO> {
|
||||
@@ -157,19 +168,27 @@ export class LeagueService {
|
||||
if (result.isErr()) {
|
||||
throw new Error(result.unwrapErr().code);
|
||||
}
|
||||
return mapApproveLeagueJoinRequestPortToDTO(result.unwrap());
|
||||
const presenter = new ApproveLeagueJoinRequestPresenter();
|
||||
presenter.present(result.unwrap());
|
||||
return presenter.getViewModel()!;
|
||||
}
|
||||
|
||||
async rejectLeagueJoinRequest(input: RejectJoinRequestInputDTO): Promise<RejectJoinRequestOutputDTO> {
|
||||
this.logger.debug('Rejecting join request:', input);
|
||||
const result = await this.rejectLeagueJoinRequestUseCase.execute({ requestId: input.requestId });
|
||||
if (result.isErr()) {
|
||||
throw new Error(result.unwrapErr().code);
|
||||
const error = result.unwrapErr();
|
||||
return {
|
||||
success: false,
|
||||
error: error.code,
|
||||
};
|
||||
}
|
||||
return mapRejectLeagueJoinRequestOutputPortToDTO(result.unwrap());
|
||||
const presenter = new RejectLeagueJoinRequestPresenter();
|
||||
presenter.present(result.unwrap());
|
||||
return presenter.getViewModel()!;
|
||||
}
|
||||
|
||||
async getLeagueAdminPermissions(query: GetLeagueAdminPermissionsInputDTO): Promise<GetLeagueAdminPermissionsViewModel> {
|
||||
async getLeagueAdminPermissions(query: GetLeagueAdminPermissionsInputDTO): Promise<LeagueAdminPermissionsDTO> {
|
||||
this.logger.debug('Getting league admin permissions', { query });
|
||||
const result = await this.getLeagueAdminPermissionsUseCase.execute({ leagueId: query.leagueId, performerDriverId: query.performerDriverId });
|
||||
// This use case never errors
|
||||
@@ -182,27 +201,41 @@ export class LeagueService {
|
||||
this.logger.debug('Removing league member', { leagueId: input.leagueId, targetDriverId: input.targetDriverId });
|
||||
const result = await this.removeLeagueMemberUseCase.execute({ leagueId: input.leagueId, targetDriverId: input.targetDriverId });
|
||||
if (result.isErr()) {
|
||||
throw new Error(result.unwrapErr().code);
|
||||
const error = result.unwrapErr();
|
||||
return {
|
||||
success: false,
|
||||
error: error.code,
|
||||
};
|
||||
}
|
||||
return mapRemoveLeagueMemberOutputPortToDTO(result.unwrap());
|
||||
const presenter = new RemoveLeagueMemberPresenter();
|
||||
presenter.present(result.unwrap());
|
||||
return presenter.getViewModel()!;
|
||||
}
|
||||
|
||||
async updateLeagueMemberRole(input: UpdateLeagueMemberRoleInputDTO): Promise<UpdateLeagueMemberRoleOutputDTO> {
|
||||
this.logger.debug('Updating league member role', { leagueId: input.leagueId, targetDriverId: input.targetDriverId, newRole: input.newRole });
|
||||
const result = await this.updateLeagueMemberRoleUseCase.execute({ leagueId: input.leagueId, targetDriverId: input.targetDriverId, newRole: input.newRole });
|
||||
if (result.isErr()) {
|
||||
throw new Error(result.unwrapErr().code);
|
||||
const error = result.unwrapErr();
|
||||
return {
|
||||
success: false,
|
||||
error: error.code,
|
||||
};
|
||||
}
|
||||
return mapUpdateLeagueMemberRoleOutputPortToDTO(result.unwrap());
|
||||
const presenter = new UpdateLeagueMemberRolePresenter();
|
||||
presenter.present(result.unwrap());
|
||||
return presenter.getViewModel()!;
|
||||
}
|
||||
|
||||
async getLeagueOwnerSummary(query: GetLeagueOwnerSummaryQueryDTO): Promise<LeagueOwnerSummaryDTO | null> {
|
||||
async getLeagueOwnerSummary(query: GetLeagueOwnerSummaryQueryDTO): Promise<LeagueOwnerSummaryDTO> {
|
||||
this.logger.debug('Getting league owner summary:', query);
|
||||
const result = await this.getLeagueOwnerSummaryUseCase.execute({ ownerId: query.ownerId });
|
||||
if (result.isErr()) {
|
||||
throw new Error(result.unwrapErr().code);
|
||||
}
|
||||
return mapGetLeagueOwnerSummaryOutputPortToDTO(result.unwrap());
|
||||
const presenter = new GetLeagueOwnerSummaryPresenter();
|
||||
presenter.present(result.unwrap());
|
||||
return presenter.getViewModel()!;
|
||||
}
|
||||
|
||||
async getLeagueFullConfig(query: GetLeagueAdminConfigQueryDTO): Promise<LeagueConfigFormModelDTO | null> {
|
||||
@@ -229,7 +262,9 @@ export class LeagueService {
|
||||
if (result.isErr()) {
|
||||
throw new Error(result.unwrapErr().code);
|
||||
}
|
||||
return mapGetLeagueProtestsOutputPortToDTO(result.unwrap());
|
||||
const presenter = new GetLeagueProtestsPresenter();
|
||||
presenter.present(result.unwrap());
|
||||
return presenter.getViewModel()!;
|
||||
}
|
||||
|
||||
async getLeagueSeasons(query: GetLeagueSeasonsQueryDTO): Promise<LeagueSeasonSummaryDTO[]> {
|
||||
@@ -238,7 +273,9 @@ export class LeagueService {
|
||||
if (result.isErr()) {
|
||||
throw new Error(result.unwrapErr().code);
|
||||
}
|
||||
return mapGetLeagueSeasonsOutputPortToDTO(result.unwrap());
|
||||
const presenter = new GetLeagueSeasonsPresenter();
|
||||
presenter.present(result.unwrap());
|
||||
return presenter.getViewModel()!;
|
||||
}
|
||||
|
||||
async getLeagueMemberships(leagueId: string): Promise<LeagueMembershipsDTO> {
|
||||
@@ -249,7 +286,7 @@ export class LeagueService {
|
||||
}
|
||||
const presenter = new GetLeagueMembershipsPresenter();
|
||||
presenter.present(result.unwrap());
|
||||
return presenter.getViewModel().memberships as LeagueMembershipsDTO;
|
||||
return presenter.getViewModel()!.memberships;
|
||||
}
|
||||
|
||||
async getLeagueStandings(leagueId: string): Promise<LeagueStandingsDTO> {
|
||||
@@ -260,7 +297,7 @@ export class LeagueService {
|
||||
}
|
||||
const presenter = new LeagueStandingsPresenter();
|
||||
presenter.present(result.unwrap());
|
||||
return presenter.getViewModel();
|
||||
return presenter.getViewModel()!;
|
||||
}
|
||||
|
||||
async getLeagueSchedule(leagueId: string): Promise<LeagueScheduleDTO> {
|
||||
@@ -279,7 +316,9 @@ export class LeagueService {
|
||||
? leagueConfigResult.unwrap().league.name.toString()
|
||||
: undefined;
|
||||
|
||||
return mapGetLeagueScheduleOutputPortToDTO(scheduleResult.unwrap(), leagueName);
|
||||
const presenter = new LeagueSchedulePresenter();
|
||||
presenter.present(scheduleResult.unwrap(), leagueName);
|
||||
return presenter.getViewModel()!;
|
||||
}
|
||||
|
||||
async getLeagueStats(leagueId: string): Promise<LeagueStatsDTO> {
|
||||
@@ -315,7 +354,9 @@ export class LeagueService {
|
||||
throw new Error(ownerSummaryResult.unwrapErr().code);
|
||||
}
|
||||
|
||||
const ownerSummary = mapGetLeagueOwnerSummaryOutputPortToDTO(ownerSummaryResult.unwrap());
|
||||
const ownerSummaryPresenter = new GetLeagueOwnerSummaryPresenter();
|
||||
ownerSummaryPresenter.present(ownerSummaryResult.unwrap());
|
||||
const ownerSummary = ownerSummaryPresenter.getViewModel()!;
|
||||
|
||||
const configPresenter = new LeagueConfigPresenter();
|
||||
configPresenter.present(fullConfig);
|
||||
@@ -323,7 +364,7 @@ export class LeagueService {
|
||||
|
||||
const adminPresenter = new LeagueAdminPresenter();
|
||||
adminPresenter.present({
|
||||
joinRequests: joinRequests.joinRequests,
|
||||
joinRequests: joinRequests,
|
||||
ownerSummary,
|
||||
config: configForm,
|
||||
protests,
|
||||
@@ -358,7 +399,7 @@ export class LeagueService {
|
||||
}
|
||||
const presenter = new CreateLeaguePresenter();
|
||||
presenter.present(result.unwrap());
|
||||
return presenter.getViewModel();
|
||||
return presenter.getViewModel()!;
|
||||
}
|
||||
|
||||
async getLeagueScoringConfig(leagueId: string): Promise<LeagueScoringConfigViewModel | null> {
|
||||
@@ -371,7 +412,7 @@ export class LeagueService {
|
||||
this.logger.error('Error getting league scoring config', new Error(result.unwrapErr().code));
|
||||
return null;
|
||||
}
|
||||
await presenter.present(result.unwrap());
|
||||
presenter.present(result.unwrap());
|
||||
return presenter.getViewModel();
|
||||
} catch (error) {
|
||||
this.logger.error('Error getting league scoring config', error instanceof Error ? error : new Error(String(error)));
|
||||
@@ -403,7 +444,9 @@ export class LeagueService {
|
||||
error: error.code,
|
||||
};
|
||||
}
|
||||
return mapJoinLeagueOutputPortToDTO(result.unwrap());
|
||||
const presenter = new JoinLeaguePresenter();
|
||||
presenter.present(result.unwrap());
|
||||
return presenter.getViewModel()!;
|
||||
}
|
||||
|
||||
async transferLeagueOwnership(leagueId: string, currentOwnerId: string, newOwnerId: string): Promise<TransferLeagueOwnershipOutputDTO> {
|
||||
@@ -417,7 +460,9 @@ export class LeagueService {
|
||||
error: error.code,
|
||||
};
|
||||
}
|
||||
return mapTransferLeagueOwnershipOutputPortToDTO(result.unwrap());
|
||||
const presenter = new TransferLeagueOwnershipPresenter();
|
||||
presenter.present(result.unwrap());
|
||||
return presenter.getViewModel()!;
|
||||
}
|
||||
|
||||
async getSeasonSponsorships(seasonId: string): Promise<GetSeasonSponsorshipsOutputDTO> {
|
||||
@@ -428,11 +473,9 @@ export class LeagueService {
|
||||
throw new Error(result.unwrapErr().code);
|
||||
}
|
||||
|
||||
const value = result.unwrap();
|
||||
|
||||
return {
|
||||
sponsorships: value?.sponsorships ?? [],
|
||||
};
|
||||
const presenter = new GetSeasonSponsorshipsPresenter();
|
||||
presenter.present(result.unwrap());
|
||||
return presenter.getViewModel()!;
|
||||
}
|
||||
|
||||
async getRaces(leagueId: string): Promise<GetLeagueRacesOutputDTO> {
|
||||
@@ -443,10 +486,11 @@ export class LeagueService {
|
||||
throw new Error(result.unwrapErr().code);
|
||||
}
|
||||
|
||||
const races = mapGetLeagueScheduleOutputPortToRaceDTOs(result.unwrap());
|
||||
const presenter = new LeagueRacesPresenter();
|
||||
presenter.present(result.unwrap());
|
||||
|
||||
return {
|
||||
races,
|
||||
races: presenter.getViewModel()!,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -454,7 +498,7 @@ export class LeagueService {
|
||||
this.logger.debug('Getting league wallet', { leagueId });
|
||||
const result = await this.getLeagueWalletUseCase.execute({ leagueId });
|
||||
if (result.isErr()) {
|
||||
throw new Error(result.unwrapErr().message);
|
||||
throw new Error(result.unwrapErr().code);
|
||||
}
|
||||
return result.unwrap();
|
||||
}
|
||||
@@ -471,9 +515,9 @@ export class LeagueService {
|
||||
if (result.isErr()) {
|
||||
const error = result.unwrapErr();
|
||||
if (error.code === 'WITHDRAWAL_NOT_ALLOWED') {
|
||||
return { success: false, message: error.message };
|
||||
return { success: false, message: error.code };
|
||||
}
|
||||
throw new Error(error.message);
|
||||
throw new Error(error.code);
|
||||
}
|
||||
return result.unwrap();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsString, IsDate, IsOptional, ValidateNested } from 'class-validator';
|
||||
import { IsString, IsDate, IsOptional } from 'class-validator';
|
||||
import { Type } from 'class-transformer';
|
||||
import { DriverDto } from '../../driver/dto/DriverDto';
|
||||
|
||||
export class LeagueJoinRequestDTO {
|
||||
@ApiProperty()
|
||||
@@ -26,9 +25,13 @@ export class LeagueJoinRequestDTO {
|
||||
@IsString()
|
||||
message?: string;
|
||||
|
||||
@ApiProperty({ type: () => DriverDto, required: false })
|
||||
@ApiProperty({
|
||||
required: false,
|
||||
type: () => Object,
|
||||
})
|
||||
@IsOptional()
|
||||
@ValidateNested()
|
||||
@Type(() => DriverDto)
|
||||
driver?: DriverDto;
|
||||
driver?: {
|
||||
id: string;
|
||||
name: string;
|
||||
};
|
||||
}
|
||||
@@ -1,8 +1,13 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsBoolean } from 'class-validator';
|
||||
import { IsBoolean, IsOptional, IsString } from 'class-validator';
|
||||
|
||||
export class RemoveLeagueMemberOutputDTO {
|
||||
@ApiProperty()
|
||||
@IsBoolean()
|
||||
success: boolean;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
error?: string;
|
||||
}
|
||||
@@ -1,8 +1,13 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsBoolean } from 'class-validator';
|
||||
import { IsBoolean, IsOptional, IsString } from 'class-validator';
|
||||
|
||||
export class UpdateLeagueMemberRoleOutputDTO {
|
||||
@ApiProperty()
|
||||
@IsBoolean()
|
||||
success: boolean;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
error?: string;
|
||||
}
|
||||
@@ -1,6 +1,18 @@
|
||||
import type { ApproveLeagueJoinRequestResultPort } from '@core/racing/application/ports/output/ApproveLeagueJoinRequestResultPort';
|
||||
import type { ApproveLeagueJoinRequestDTO } from '../dtos/ApproveLeagueJoinRequestDTO';
|
||||
|
||||
export function mapApproveLeagueJoinRequestPortToDTO(port: ApproveLeagueJoinRequestResultPort): ApproveLeagueJoinRequestDTO {
|
||||
return port;
|
||||
export class ApproveLeagueJoinRequestPresenter {
|
||||
private result: ApproveLeagueJoinRequestDTO | null = null;
|
||||
|
||||
reset() {
|
||||
this.result = null;
|
||||
}
|
||||
|
||||
present(output: ApproveLeagueJoinRequestResultPort) {
|
||||
this.result = output;
|
||||
}
|
||||
|
||||
getViewModel(): ApproveLeagueJoinRequestDTO | null {
|
||||
return this.result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import type { GetLeagueAdminPermissionsOutputPort } from '@core/racing/application/ports/output/GetLeagueAdminPermissionsOutputPort';
|
||||
import { LeagueAdminPermissionsDTO } from '../dtos/LeagueAdminPermissionsDTO';
|
||||
import type { Presenter } from '@core/shared/presentation';
|
||||
|
||||
export class GetLeagueAdminPermissionsPresenter implements Presenter<GetLeagueAdminPermissionsOutputPort, LeagueAdminPermissionsDTO> {
|
||||
private result: LeagueAdminPermissionsDTO | null = null;
|
||||
|
||||
reset(): void {
|
||||
this.result = null;
|
||||
}
|
||||
|
||||
present(port: GetLeagueAdminPermissionsOutputPort): void {
|
||||
this.result = {
|
||||
canRemoveMember: port.canRemoveMember,
|
||||
canUpdateRoles: port.canUpdateRoles,
|
||||
};
|
||||
}
|
||||
|
||||
getViewModel(): LeagueAdminPermissionsDTO | null {
|
||||
return this.result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { GetLeagueMembershipsPresenter } from './GetLeagueMembershipsPresenter';
|
||||
import type { GetLeagueMembershipsOutputPort } from '@core/racing/application/ports/output/GetLeagueMembershipsOutputPort';
|
||||
|
||||
describe('GetLeagueMembershipsPresenter', () => {
|
||||
it('presents memberships correctly', () => {
|
||||
const presenter = new GetLeagueMembershipsPresenter();
|
||||
const output: GetLeagueMembershipsOutputPort = {
|
||||
memberships: {
|
||||
members: [
|
||||
{
|
||||
driverId: 'driver-1',
|
||||
driver: { id: 'driver-1', name: 'John Doe' },
|
||||
role: 'member',
|
||||
joinedAt: new Date('2023-01-01'),
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
presenter.present(output);
|
||||
const vm = presenter.getViewModel();
|
||||
|
||||
expect(vm).not.toBeNull();
|
||||
expect(vm!.memberships.members).toHaveLength(1);
|
||||
expect(vm!.memberships.members[0].driverId).toBe('driver-1');
|
||||
expect(vm!.memberships.members[0].driver.name).toBe('John Doe');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
import type { GetLeagueMembershipsOutputPort } from '@core/racing/application/ports/output/GetLeagueMembershipsOutputPort';
|
||||
import { LeagueMembershipsDTO, LeagueMemberDTO } from '../dtos/LeagueMembershipsDTO';
|
||||
|
||||
export interface GetLeagueMembershipsViewModel {
|
||||
memberships: LeagueMembershipsDTO;
|
||||
}
|
||||
|
||||
export class GetLeagueMembershipsPresenter {
|
||||
private result: GetLeagueMembershipsViewModel | null = null;
|
||||
|
||||
reset() {
|
||||
this.result = null;
|
||||
}
|
||||
|
||||
present(output: GetLeagueMembershipsOutputPort) {
|
||||
const members: LeagueMemberDTO[] = output.memberships.members.map(member => ({
|
||||
driverId: member.driverId,
|
||||
driver: member.driver,
|
||||
role: member.role,
|
||||
joinedAt: member.joinedAt,
|
||||
}));
|
||||
this.result = {
|
||||
memberships: {
|
||||
members,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
getViewModel(): GetLeagueMembershipsViewModel | null {
|
||||
return this.result;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,34 @@
|
||||
import { GetLeagueOwnerSummaryOutputPort } from '@core/racing/application/ports/output/GetLeagueOwnerSummaryOutputPort';
|
||||
import { LeagueOwnerSummaryDTO } from '../dtos/LeagueOwnerSummaryDTO';
|
||||
|
||||
export function mapGetLeagueOwnerSummaryOutputPortToDTO(output: GetLeagueOwnerSummaryOutputPort): LeagueOwnerSummaryDTO | null {
|
||||
if (!output.summary) return null;
|
||||
export class GetLeagueOwnerSummaryPresenter {
|
||||
private result: LeagueOwnerSummaryDTO | null = null;
|
||||
|
||||
return {
|
||||
driver: {
|
||||
id: output.summary.driver.id,
|
||||
iracingId: output.summary.driver.iracingId,
|
||||
name: output.summary.driver.name,
|
||||
country: output.summary.driver.country,
|
||||
bio: output.summary.driver.bio,
|
||||
joinedAt: output.summary.driver.joinedAt,
|
||||
},
|
||||
rating: output.summary.rating,
|
||||
rank: output.summary.rank,
|
||||
};
|
||||
reset() {
|
||||
this.result = null;
|
||||
}
|
||||
|
||||
present(output: GetLeagueOwnerSummaryOutputPort) {
|
||||
if (!output.summary) {
|
||||
this.result = null;
|
||||
return;
|
||||
}
|
||||
|
||||
this.result = {
|
||||
driver: {
|
||||
id: output.summary.driver.id,
|
||||
iracingId: output.summary.driver.iracingId,
|
||||
name: output.summary.driver.name,
|
||||
country: output.summary.driver.country,
|
||||
bio: output.summary.driver.bio,
|
||||
joinedAt: output.summary.driver.joinedAt,
|
||||
},
|
||||
rating: output.summary.rating,
|
||||
rank: output.summary.rank,
|
||||
};
|
||||
}
|
||||
|
||||
getViewModel(): LeagueOwnerSummaryDTO | null {
|
||||
return this.result;
|
||||
}
|
||||
}
|
||||
@@ -20,49 +20,65 @@ function mapProtestStatus(status: ProtestOutputPort['status']): ProtestDTO['stat
|
||||
}
|
||||
}
|
||||
|
||||
export function mapGetLeagueProtestsOutputPortToDTO(output: GetLeagueProtestsOutputPort, leagueName?: string): LeagueAdminProtestsDTO {
|
||||
const protests: ProtestDTO[] = output.protests.map((protest) => {
|
||||
const race = output.racesById[protest.raceId];
|
||||
export class GetLeagueProtestsPresenter {
|
||||
private result: LeagueAdminProtestsDTO | null = null;
|
||||
|
||||
return {
|
||||
id: protest.id,
|
||||
leagueId: race?.leagueId,
|
||||
raceId: protest.raceId,
|
||||
protestingDriverId: protest.protestingDriverId,
|
||||
accusedDriverId: protest.accusedDriverId,
|
||||
submittedAt: new Date(protest.filedAt),
|
||||
description: protest.incident.description,
|
||||
status: mapProtestStatus(protest.status),
|
||||
};
|
||||
});
|
||||
reset() {
|
||||
this.result = null;
|
||||
}
|
||||
|
||||
const racesById: { [raceId: string]: RaceDTO } = {};
|
||||
for (const raceId in output.racesById) {
|
||||
const race = output.racesById[raceId];
|
||||
racesById[raceId] = {
|
||||
id: race.id,
|
||||
name: race.track,
|
||||
date: race.scheduledAt,
|
||||
leagueName,
|
||||
present(output: GetLeagueProtestsOutputPort, leagueName?: string) {
|
||||
const protests: ProtestDTO[] = output.protests.map((protest) => {
|
||||
const race = output.racesById[protest.raceId];
|
||||
|
||||
return {
|
||||
id: protest.id,
|
||||
leagueId: race?.leagueId || '',
|
||||
raceId: protest.raceId,
|
||||
protestingDriverId: protest.protestingDriverId,
|
||||
accusedDriverId: protest.accusedDriverId,
|
||||
submittedAt: new Date(protest.filedAt),
|
||||
description: protest.incident.description,
|
||||
status: mapProtestStatus(protest.status),
|
||||
};
|
||||
});
|
||||
|
||||
const racesById: { [raceId: string]: RaceDTO } = {};
|
||||
for (const raceId in output.racesById) {
|
||||
const race = output.racesById[raceId];
|
||||
if (race) {
|
||||
racesById[raceId] = {
|
||||
id: race.id,
|
||||
name: race.track,
|
||||
date: race.scheduledAt.toISOString(),
|
||||
leagueName,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const driversById: { [driverId: string]: DriverDTO } = {};
|
||||
for (const driverId in output.driversById) {
|
||||
const driver = output.driversById[driverId];
|
||||
if (driver) {
|
||||
driversById[driverId] = {
|
||||
id: driver.id,
|
||||
iracingId: driver.iracingId,
|
||||
name: driver.name,
|
||||
country: driver.country,
|
||||
bio: driver.bio,
|
||||
joinedAt: driver.joinedAt,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
this.result = {
|
||||
protests,
|
||||
racesById,
|
||||
driversById,
|
||||
};
|
||||
}
|
||||
|
||||
const driversById: { [driverId: string]: DriverDTO } = {};
|
||||
for (const driverId in output.driversById) {
|
||||
const driver = output.driversById[driverId];
|
||||
driversById[driverId] = {
|
||||
id: driver.id,
|
||||
iracingId: driver.iracingId,
|
||||
name: driver.name,
|
||||
country: driver.country,
|
||||
bio: driver.bio,
|
||||
joinedAt: driver.joinedAt,
|
||||
};
|
||||
getViewModel(): LeagueAdminProtestsDTO | null {
|
||||
return this.result;
|
||||
}
|
||||
|
||||
return {
|
||||
protests,
|
||||
racesById,
|
||||
driversById,
|
||||
};
|
||||
}
|
||||
@@ -1,14 +1,26 @@
|
||||
import { GetLeagueSeasonsOutputPort } from '@core/racing/application/ports/output/GetLeagueSeasonsOutputPort';
|
||||
import { LeagueSeasonSummaryDTO } from '../dtos/LeagueSeasonSummaryDTO';
|
||||
|
||||
export function mapGetLeagueSeasonsOutputPortToDTO(output: GetLeagueSeasonsOutputPort): LeagueSeasonSummaryDTO[] {
|
||||
return output.seasons.map(season => ({
|
||||
seasonId: season.seasonId,
|
||||
name: season.name,
|
||||
status: season.status,
|
||||
startDate: season.startDate,
|
||||
endDate: season.endDate,
|
||||
isPrimary: season.isPrimary,
|
||||
isParallelActive: season.isParallelActive,
|
||||
}));
|
||||
export class GetLeagueSeasonsPresenter {
|
||||
private result: LeagueSeasonSummaryDTO[] | null = null;
|
||||
|
||||
reset() {
|
||||
this.result = null;
|
||||
}
|
||||
|
||||
present(output: GetLeagueSeasonsOutputPort) {
|
||||
this.result = output.seasons.map(season => ({
|
||||
seasonId: season.seasonId,
|
||||
name: season.name,
|
||||
status: season.status,
|
||||
startDate: season.startDate,
|
||||
endDate: season.endDate,
|
||||
isPrimary: season.isPrimary,
|
||||
isParallelActive: season.isParallelActive,
|
||||
}));
|
||||
}
|
||||
|
||||
getViewModel(): LeagueSeasonSummaryDTO[] | null {
|
||||
return this.result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import type { GetSeasonSponsorshipsOutputPort } from '@core/racing/application/ports/output/GetSeasonSponsorshipsOutputPort';
|
||||
import { GetSeasonSponsorshipsOutputDTO } from '../dtos/GetSeasonSponsorshipsOutputDTO';
|
||||
|
||||
export class GetSeasonSponsorshipsPresenter {
|
||||
private result: GetSeasonSponsorshipsOutputDTO | null = null;
|
||||
|
||||
reset() {
|
||||
this.result = null;
|
||||
}
|
||||
|
||||
present(output: GetSeasonSponsorshipsOutputPort) {
|
||||
this.result = {
|
||||
sponsorships: output?.sponsorships ?? [],
|
||||
};
|
||||
}
|
||||
|
||||
getViewModel(): GetSeasonSponsorshipsOutputDTO | null {
|
||||
return this.result;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,21 @@
|
||||
import type { JoinLeagueOutputPort } from '@core/racing/application/ports/output/JoinLeagueOutputPort';
|
||||
import type { JoinLeagueOutputDTO } from '../dtos/JoinLeagueOutputDTO';
|
||||
|
||||
export function mapJoinLeagueOutputPortToDTO(port: JoinLeagueOutputPort): JoinLeagueOutputDTO {
|
||||
return {
|
||||
success: true,
|
||||
membershipId: port.membershipId,
|
||||
};
|
||||
export class JoinLeaguePresenter {
|
||||
private result: JoinLeagueOutputDTO | null = null;
|
||||
|
||||
reset() {
|
||||
this.result = null;
|
||||
}
|
||||
|
||||
present(output: JoinLeagueOutputPort) {
|
||||
this.result = {
|
||||
success: true,
|
||||
membershipId: output.membershipId,
|
||||
};
|
||||
}
|
||||
|
||||
getViewModel(): JoinLeagueOutputDTO | null {
|
||||
return this.result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { LeagueJoinRequestsPresenter } from './LeagueJoinRequestsPresenter';
|
||||
import type { GetLeagueJoinRequestsOutputPort } from '@core/racing/application/ports/output/GetLeagueJoinRequestsOutputPort';
|
||||
|
||||
describe('LeagueJoinRequestsPresenter', () => {
|
||||
it('presents join requests correctly', () => {
|
||||
const presenter = new LeagueJoinRequestsPresenter();
|
||||
const output: GetLeagueJoinRequestsOutputPort = {
|
||||
joinRequests: [
|
||||
{
|
||||
id: 'req-1',
|
||||
leagueId: 'league-1',
|
||||
driverId: 'driver-1',
|
||||
requestedAt: new Date('2023-01-01'),
|
||||
message: 'Please accept me',
|
||||
driver: { id: 'driver-1', name: 'John Doe' },
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
presenter.present(output);
|
||||
const vm = presenter.getViewModel();
|
||||
|
||||
expect(vm).not.toBeNull();
|
||||
expect(vm!.joinRequests).toHaveLength(1);
|
||||
expect(vm!.joinRequests[0].id).toBe('req-1');
|
||||
expect(vm!.joinRequests[0].driver.name).toBe('John Doe');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
import type { GetLeagueJoinRequestsOutputPort } from '@core/racing/application/ports/output/GetLeagueJoinRequestsOutputPort';
|
||||
import { LeagueJoinRequestWithDriverDTO } from '../dtos/LeagueJoinRequestWithDriverDTO';
|
||||
|
||||
export interface LeagueJoinRequestsViewModel {
|
||||
joinRequests: LeagueJoinRequestWithDriverDTO[];
|
||||
}
|
||||
|
||||
export class LeagueJoinRequestsPresenter {
|
||||
private result: LeagueJoinRequestsViewModel | null = null;
|
||||
|
||||
reset() {
|
||||
this.result = null;
|
||||
}
|
||||
|
||||
present(output: GetLeagueJoinRequestsOutputPort) {
|
||||
const joinRequests: LeagueJoinRequestWithDriverDTO[] = output.joinRequests.map(request => ({
|
||||
id: request.id,
|
||||
leagueId: request.leagueId,
|
||||
driverId: request.driverId,
|
||||
requestedAt: request.requestedAt,
|
||||
message: request.message,
|
||||
driver: request.driver,
|
||||
}));
|
||||
this.result = {
|
||||
joinRequests,
|
||||
};
|
||||
}
|
||||
|
||||
getViewModel(): LeagueJoinRequestsViewModel | null {
|
||||
return this.result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import { LeagueOwnerSummaryPresenter } from './LeagueOwnerSummaryPresenter';
|
||||
import type { GetLeagueOwnerSummaryOutputPort } from '@core/racing/application/ports/output/GetLeagueOwnerSummaryOutputPort';
|
||||
|
||||
describe('LeagueOwnerSummaryPresenter', () => {
|
||||
it('presents owner summary correctly', () => {
|
||||
const presenter = new LeagueOwnerSummaryPresenter();
|
||||
const output: GetLeagueOwnerSummaryOutputPort = {
|
||||
summary: {
|
||||
driver: {
|
||||
id: 'driver-1',
|
||||
iracingId: '12345',
|
||||
name: 'John Doe',
|
||||
country: 'US',
|
||||
bio: 'Racing enthusiast',
|
||||
joinedAt: '2023-01-01',
|
||||
},
|
||||
rating: 1500,
|
||||
rank: 100,
|
||||
},
|
||||
};
|
||||
|
||||
presenter.present(output);
|
||||
const vm = presenter.getViewModel();
|
||||
|
||||
expect(vm).not.toBeNull();
|
||||
expect(vm!.driver.id).toBe('driver-1');
|
||||
expect(vm!.rating).toBe(1500);
|
||||
expect(vm!.rank).toBe(100);
|
||||
});
|
||||
|
||||
it('handles null summary', () => {
|
||||
const presenter = new LeagueOwnerSummaryPresenter();
|
||||
const output: GetLeagueOwnerSummaryOutputPort = {
|
||||
summary: null,
|
||||
};
|
||||
|
||||
presenter.present(output);
|
||||
const vm = presenter.getViewModel();
|
||||
|
||||
expect(vm).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
import type { GetLeagueOwnerSummaryOutputPort } from '@core/racing/application/ports/output/GetLeagueOwnerSummaryOutputPort';
|
||||
import { LeagueOwnerSummaryDTO } from '../dtos/LeagueOwnerSummaryDTO';
|
||||
|
||||
export class LeagueOwnerSummaryPresenter {
|
||||
private result: LeagueOwnerSummaryDTO | null = null;
|
||||
|
||||
reset() {
|
||||
this.result = null;
|
||||
}
|
||||
|
||||
present(output: GetLeagueOwnerSummaryOutputPort) {
|
||||
if (!output.summary) {
|
||||
this.result = null;
|
||||
return;
|
||||
}
|
||||
this.result = {
|
||||
driver: {
|
||||
id: output.summary.driver.id,
|
||||
iracingId: output.summary.driver.iracingId,
|
||||
name: output.summary.driver.name,
|
||||
country: output.summary.driver.country,
|
||||
bio: output.summary.driver.bio,
|
||||
joinedAt: output.summary.driver.joinedAt,
|
||||
},
|
||||
rating: output.summary.rating,
|
||||
rank: output.summary.rank,
|
||||
};
|
||||
}
|
||||
|
||||
getViewModel(): LeagueOwnerSummaryDTO | null {
|
||||
return this.result;
|
||||
}
|
||||
}
|
||||
@@ -2,22 +2,46 @@ import { GetLeagueScheduleOutputPort } from '@core/racing/application/ports/outp
|
||||
import { LeagueScheduleDTO } from '../dtos/LeagueScheduleDTO';
|
||||
import { RaceDTO } from '../../race/dtos/RaceDTO';
|
||||
|
||||
export function mapGetLeagueScheduleOutputPortToDTO(output: GetLeagueScheduleOutputPort, leagueName?: string): LeagueScheduleDTO {
|
||||
return {
|
||||
races: output.races.map<RaceDTO>(race => ({
|
||||
export class LeagueSchedulePresenter {
|
||||
private result: LeagueScheduleDTO | null = null;
|
||||
|
||||
reset() {
|
||||
this.result = null;
|
||||
}
|
||||
|
||||
present(output: GetLeagueScheduleOutputPort, leagueName?: string) {
|
||||
this.result = {
|
||||
races: output.races.map<RaceDTO>(race => ({
|
||||
id: race.id,
|
||||
name: race.name,
|
||||
date: race.scheduledAt.toISOString(),
|
||||
leagueName,
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
getViewModel(): LeagueScheduleDTO | null {
|
||||
return this.result;
|
||||
}
|
||||
}
|
||||
|
||||
export class LeagueRacesPresenter {
|
||||
private result: RaceDTO[] | null = null;
|
||||
|
||||
reset() {
|
||||
this.result = null;
|
||||
}
|
||||
|
||||
present(output: GetLeagueScheduleOutputPort, leagueName?: string) {
|
||||
this.result = output.races.map<RaceDTO>(race => ({
|
||||
id: race.id,
|
||||
name: race.name,
|
||||
date: race.scheduledAt.toISOString(),
|
||||
leagueName,
|
||||
})),
|
||||
};
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
export function mapGetLeagueScheduleOutputPortToRaceDTOs(output: GetLeagueScheduleOutputPort, leagueName?: string): RaceDTO[] {
|
||||
return output.races.map<RaceDTO>(race => ({
|
||||
id: race.id,
|
||||
name: race.name,
|
||||
date: race.scheduledAt.toISOString(),
|
||||
leagueName,
|
||||
}));
|
||||
getViewModel(): RaceDTO[] | null {
|
||||
return this.result;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,21 @@
|
||||
import type { RejectLeagueJoinRequestOutputPort } from '@core/racing/application/ports/output/RejectLeagueJoinRequestOutputPort';
|
||||
import type { RejectJoinRequestOutputDTO } from '../dtos/RejectJoinRequestOutputDTO';
|
||||
|
||||
export function mapRejectLeagueJoinRequestOutputPortToDTO(port: RejectLeagueJoinRequestOutputPort): RejectJoinRequestOutputDTO {
|
||||
return {
|
||||
success: port.success,
|
||||
message: port.message,
|
||||
};
|
||||
export class RejectLeagueJoinRequestPresenter {
|
||||
private result: RejectJoinRequestOutputDTO | null = null;
|
||||
|
||||
reset() {
|
||||
this.result = null;
|
||||
}
|
||||
|
||||
present(output: RejectLeagueJoinRequestOutputPort) {
|
||||
this.result = {
|
||||
success: output.success,
|
||||
message: output.message,
|
||||
};
|
||||
}
|
||||
|
||||
getViewModel(): RejectJoinRequestOutputDTO | null {
|
||||
return this.result;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,20 @@
|
||||
import type { RemoveLeagueMemberOutputPort } from '@core/racing/application/ports/output/RemoveLeagueMemberOutputPort';
|
||||
import type { RemoveLeagueMemberOutputDTO } from '../dtos/RemoveLeagueMemberOutputDTO';
|
||||
|
||||
export function mapRemoveLeagueMemberOutputPortToDTO(port: RemoveLeagueMemberOutputPort): RemoveLeagueMemberOutputDTO {
|
||||
return {
|
||||
success: port.success,
|
||||
};
|
||||
export class RemoveLeagueMemberPresenter {
|
||||
private result: RemoveLeagueMemberOutputDTO | null = null;
|
||||
|
||||
reset() {
|
||||
this.result = null;
|
||||
}
|
||||
|
||||
present(output: RemoveLeagueMemberOutputPort) {
|
||||
this.result = {
|
||||
success: output.success,
|
||||
};
|
||||
}
|
||||
|
||||
getViewModel(): RemoveLeagueMemberOutputDTO | null {
|
||||
return this.result;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,20 @@
|
||||
import type { TransferLeagueOwnershipOutputPort } from '@core/racing/application/ports/output/TransferLeagueOwnershipOutputPort';
|
||||
import type { TransferLeagueOwnershipOutputDTO } from '../dtos/TransferLeagueOwnershipOutputDTO';
|
||||
|
||||
export function mapTransferLeagueOwnershipOutputPortToDTO(port: TransferLeagueOwnershipOutputPort): TransferLeagueOwnershipOutputDTO {
|
||||
return {
|
||||
success: port.success,
|
||||
};
|
||||
export class TransferLeagueOwnershipPresenter {
|
||||
private result: TransferLeagueOwnershipOutputDTO | null = null;
|
||||
|
||||
reset() {
|
||||
this.result = null;
|
||||
}
|
||||
|
||||
present(output: TransferLeagueOwnershipOutputPort) {
|
||||
this.result = {
|
||||
success: output.success,
|
||||
};
|
||||
}
|
||||
|
||||
getViewModel(): TransferLeagueOwnershipOutputDTO | null {
|
||||
return this.result;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,20 @@
|
||||
import type { UpdateLeagueMemberRoleOutputPort } from '@core/racing/application/ports/output/UpdateLeagueMemberRoleOutputPort';
|
||||
import type { UpdateLeagueMemberRoleOutputDTO } from '../dtos/UpdateLeagueMemberRoleOutputDTO';
|
||||
|
||||
export function mapUpdateLeagueMemberRoleOutputPortToDTO(port: UpdateLeagueMemberRoleOutputPort): UpdateLeagueMemberRoleOutputDTO {
|
||||
return {
|
||||
success: port.success,
|
||||
};
|
||||
export class UpdateLeagueMemberRolePresenter {
|
||||
private result: UpdateLeagueMemberRoleOutputDTO | null = null;
|
||||
|
||||
reset() {
|
||||
this.result = null;
|
||||
}
|
||||
|
||||
present(output: UpdateLeagueMemberRoleOutputPort) {
|
||||
this.result = {
|
||||
success: output.success,
|
||||
};
|
||||
}
|
||||
|
||||
getViewModel(): UpdateLeagueMemberRoleOutputDTO | null {
|
||||
return this.result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user