import type { GetPendingSponsorshipRequestsOutputDTO } from '@/lib/types/generated/GetPendingSponsorshipRequestsOutputDTO';
import type { SponsorshipRequestsViewData } from '@/lib/view-data/SponsorshipRequestsViewData';

export class SponsorshipRequestsViewDataBuilder {
  static build(apiDto: GetPendingSponsorshipRequestsOutputDTO): SponsorshipRequestsViewData {
    return {
      sections: [
        {
          entityType: apiDto.entityType as 'driver' | 'team' | 'season',
          entityId: apiDto.entityId,
          entityName: apiDto.entityType === 'driver' ? 'Driver' : apiDto.entityType,
          requests: apiDto.requests.map((request) => ({
            id: request.id,
            sponsorId: request.sponsorId,
            sponsorName: request.sponsorName,
            sponsorLogoUrl: request.sponsorLogo || null,
            message: request.message || null,
            createdAtIso: request.createdAt,
          })),
        },
      ],
    };
  }
}
