Files
gridpilot.gg/apps/api/src/domain/sponsor/presenters/GetEntitySponsorshipPricingPresenter.ts
2026-01-08 15:34:51 +01:00

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;
}
}