presenter refactoring
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { GetEntitySponsorshipPricingOutputPort } from '@core/racing/application/ports/output/GetEntitySponsorshipPricingOutputPort';
|
||||
import type { GetSponsorshipPricingOutputPort } from '@core/racing/application/ports/output/GetSponsorshipPricingOutputPort';
|
||||
import { GetEntitySponsorshipPricingResultDTO } from '../dtos/GetEntitySponsorshipPricingResultDTO';
|
||||
|
||||
export class GetEntitySponsorshipPricingPresenter {
|
||||
@@ -8,34 +8,34 @@ export class GetEntitySponsorshipPricingPresenter {
|
||||
this.result = null;
|
||||
}
|
||||
|
||||
async present(output: GetEntitySponsorshipPricingOutputPort | null) {
|
||||
present(output: GetSponsorshipPricingOutputPort | null) {
|
||||
if (!output) {
|
||||
this.result = { pricing: [] };
|
||||
this.result = {
|
||||
entityType: 'season',
|
||||
entityId: '',
|
||||
pricing: [],
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
const pricing = [];
|
||||
if (output.mainSlot) {
|
||||
pricing.push({
|
||||
id: `${output.entityType}-${output.entityId}-main`,
|
||||
level: 'main',
|
||||
price: output.mainSlot.price,
|
||||
currency: output.mainSlot.currency,
|
||||
});
|
||||
}
|
||||
if (output.secondarySlot) {
|
||||
pricing.push({
|
||||
id: `${output.entityType}-${output.entityId}-secondary`,
|
||||
level: 'secondary',
|
||||
price: output.secondarySlot.price,
|
||||
currency: output.secondarySlot.currency,
|
||||
});
|
||||
}
|
||||
|
||||
this.result = { pricing };
|
||||
this.result = {
|
||||
entityType: output.entityType,
|
||||
entityId: output.entityId,
|
||||
pricing: output.pricing.map(item => ({
|
||||
id: item.id,
|
||||
level: item.level,
|
||||
price: item.price,
|
||||
currency: item.currency,
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
getViewModel(): GetEntitySponsorshipPricingResultDTO | null {
|
||||
return this.result;
|
||||
}
|
||||
}
|
||||
|
||||
get viewModel(): GetEntitySponsorshipPricingResultDTO {
|
||||
if (!this.result) throw new Error('Presenter not presented');
|
||||
return this.result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user