refactor core presenters
This commit is contained in:
@@ -1,21 +1,9 @@
|
||||
import { IJoinLeaguePresenter, JoinLeagueResultDTO, JoinLeagueViewModel } from '@core/racing/application/presenters/IJoinLeaguePresenter';
|
||||
import type { JoinLeagueOutputPort } from '@core/racing/application/ports/output/JoinLeagueOutputPort';
|
||||
import type { JoinLeagueOutputDTO } from '../dtos/JoinLeagueOutputDTO';
|
||||
|
||||
export class JoinLeaguePresenter implements IJoinLeaguePresenter {
|
||||
private result: JoinLeagueViewModel | null = null;
|
||||
|
||||
reset() {
|
||||
this.result = null;
|
||||
}
|
||||
|
||||
present(dto: JoinLeagueResultDTO): void {
|
||||
this.result = {
|
||||
success: true,
|
||||
membershipId: dto.id,
|
||||
};
|
||||
}
|
||||
|
||||
getViewModel(): JoinLeagueViewModel {
|
||||
if (!this.result) throw new Error('Presenter not presented');
|
||||
return this.result;
|
||||
}
|
||||
export function mapJoinLeagueOutputPortToDTO(port: JoinLeagueOutputPort): JoinLeagueOutputDTO {
|
||||
return {
|
||||
success: true,
|
||||
membershipId: port.membershipId,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user