presenter refactoring
This commit is contained in:
36
apps/api/src/domain/team/presenters/CreateTeamPresenter.ts
Normal file
36
apps/api/src/domain/team/presenters/CreateTeamPresenter.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import type { CreateTeamOutputPort } from '@core/racing/application/ports/output/CreateTeamOutputPort';
|
||||
import type { CreateTeamOutputDTO } from '../dtos/CreateTeamOutputDTO';
|
||||
|
||||
export class CreateTeamPresenter {
|
||||
private result: CreateTeamOutputDTO | null = null;
|
||||
|
||||
reset(): void {
|
||||
this.result = null;
|
||||
}
|
||||
|
||||
presentSuccess(output: CreateTeamOutputPort): void {
|
||||
this.result = {
|
||||
id: output.team.id,
|
||||
success: true,
|
||||
};
|
||||
}
|
||||
|
||||
presentError(): void {
|
||||
this.result = {
|
||||
id: '',
|
||||
success: false,
|
||||
};
|
||||
}
|
||||
|
||||
getViewModel(): CreateTeamOutputDTO | null {
|
||||
return this.result;
|
||||
}
|
||||
|
||||
get viewModel(): CreateTeamOutputDTO {
|
||||
if (!this.result) {
|
||||
throw new Error('Presenter not presented');
|
||||
}
|
||||
|
||||
return this.result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user