42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import type { GetEntitySponsorshipPricingResult } from '@core/racing/application/use-cases/GetEntitySponsorshipPricingUseCase';
|
|
import { GetEntitySponsorshipPricingResultDTO } from '../dtos/GetEntitySponsorshipPricingResultDTO';
|
|
|
|
export class GetEntitySponsorshipPricingPresenter {
|
|
private result: GetEntitySponsorshipPricingResultDTO | null = null;
|
|
|
|
reset() {
|
|
this.result = null;
|
|
}
|
|
|
|
present(output: GetEntitySponsorshipPricingResult | null | undefined) {
|
|
if (!output) {
|
|
this.result = {
|
|
entityType: 'season',
|
|
entityId: '',
|
|
pricing: [],
|
|
};
|
|
return;
|
|
}
|
|
|
|
this.result = {
|
|
entityType: output.entityType,
|
|
entityId: output.entityId,
|
|
pricing: output.tiers.map(item => ({
|
|
id: item.name,
|
|
level: item.name,
|
|
price: item.price.amount,
|
|
currency: item.price.currency,
|
|
})),
|
|
};
|
|
}
|
|
|
|
getViewModel(): GetEntitySponsorshipPricingResultDTO | null {
|
|
return this.result;
|
|
}
|
|
|
|
get viewModel(): GetEntitySponsorshipPricingResultDTO {
|
|
if (!this.result) throw new Error('Presenter not presented');
|
|
return this.result;
|
|
}
|
|
}
|