website cleanup
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import type { SponsorsApiClient } from '../../api/sponsors/SponsorsApiClient';
|
||||
import type { GetEntitySponsorshipPricingResultDto } from '../../api/sponsors/SponsorsApiClient';
|
||||
import { SponsorshipPricingViewModel } from '../../view-models/SponsorshipPricingViewModel';
|
||||
import { SponsorSponsorshipsViewModel } from '../../view-models/SponsorSponsorshipsViewModel';
|
||||
import { SponsorshipRequestViewModel } from '../../view-models/SponsorshipRequestViewModel';
|
||||
import type { SponsorSponsorshipsDTO } from '../../types/generated';
|
||||
import type { GetPendingSponsorshipRequestsOutputDTO } from '../../types/generated/GetPendingSponsorshipRequestsOutputDTO';
|
||||
import type { SponsorshipRequestDTO } from '../../types/generated/SponsorshipRequestDTO';
|
||||
|
||||
/**
|
||||
* Sponsorship Service
|
||||
@@ -20,8 +20,16 @@ export class SponsorshipService {
|
||||
* Get sponsorship pricing with view model transformation
|
||||
*/
|
||||
async getSponsorshipPricing(): Promise<SponsorshipPricingViewModel> {
|
||||
// Pricing shape isn't finalized in the API yet.
|
||||
// Keep a predictable, UI-friendly structure until a dedicated DTO is introduced.
|
||||
const dto = await this.apiClient.getPricing();
|
||||
return new SponsorshipPricingViewModel(dto);
|
||||
const main = dto.pricing.find((p) => p.entityType === 'main')?.price ?? 0;
|
||||
const secondary = dto.pricing.find((p) => p.entityType === 'secondary')?.price ?? 0;
|
||||
return new SponsorshipPricingViewModel({
|
||||
mainSlotPrice: main,
|
||||
secondarySlotPrice: secondary,
|
||||
currency: 'USD',
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,21 +47,22 @@ export class SponsorshipService {
|
||||
* Get pending sponsorship requests for an entity
|
||||
*/
|
||||
async getPendingSponsorshipRequests(params: { entityType: string; entityId: string }): Promise<SponsorshipRequestViewModel[]> {
|
||||
const dto = await this.apiClient.getPendingSponsorshipRequests(params);
|
||||
return dto.requests.map(dto => new SponsorshipRequestViewModel(dto));
|
||||
const dto = (await this.apiClient.getPendingSponsorshipRequests(params)) as unknown as GetPendingSponsorshipRequestsOutputDTO;
|
||||
const requests = (dto as any).requests as SponsorshipRequestDTO[];
|
||||
return (requests ?? []).map((r: SponsorshipRequestDTO) => new SponsorshipRequestViewModel(r));
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept a sponsorship request
|
||||
*/
|
||||
async acceptSponsorshipRequest(requestId: string, respondedBy: string): Promise<void> {
|
||||
await this.apiClient.acceptSponsorshipRequest(requestId, respondedBy);
|
||||
await this.apiClient.acceptSponsorshipRequest(requestId, { respondedBy });
|
||||
}
|
||||
|
||||
/**
|
||||
* Reject a sponsorship request
|
||||
*/
|
||||
async rejectSponsorshipRequest(requestId: string, respondedBy: string, reason?: string): Promise<void> {
|
||||
await this.apiClient.rejectSponsorshipRequest(requestId, respondedBy, reason);
|
||||
await this.apiClient.rejectSponsorshipRequest(requestId, { respondedBy, ...(reason ? { reason } : {}) });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user