38 lines
1.5 KiB
TypeScript
38 lines
1.5 KiB
TypeScript
'use client';
|
|
|
|
import { DateFormatter } from '@/lib/formatters/DateFormatter';
|
|
import { StatusFormatter } from '@/lib/formatters/StatusFormatter';
|
|
import type { LeagueSponsorshipsViewData } from '@/lib/view-data/LeagueSponsorshipsViewData';
|
|
import type { ViewDataBuilder } from '@/lib/contracts/builders/ViewDataBuilder';
|
|
import type { GetSeasonSponsorshipsOutputDTO } from '@/lib/types/generated/GetSeasonSponsorshipsOutputDTO';
|
|
|
|
type LeagueSponsorshipsInputDTO = GetSeasonSponsorshipsOutputDTO & {
|
|
leagueId: string;
|
|
league: { id: string; name: string; description: string };
|
|
sponsorshipSlots: LeagueSponsorshipsViewData['sponsorshipSlots'];
|
|
}
|
|
|
|
export class LeagueSponsorshipsViewDataBuilder {
|
|
public static build(apiDto: LeagueSponsorshipsInputDTO): LeagueSponsorshipsViewData {
|
|
return {
|
|
leagueId: apiDto.leagueId,
|
|
activeTab: 'overview',
|
|
onTabChange: () => {},
|
|
league: apiDto.league,
|
|
sponsorshipSlots: apiDto.sponsorshipSlots,
|
|
sponsorshipRequests: apiDto.sponsorships.map(r => ({
|
|
id: r.id,
|
|
slotId: '', // Missing in DTO
|
|
sponsorId: '', // Missing in DTO
|
|
sponsorName: '', // Missing in DTO
|
|
requestedAt: r.createdAt,
|
|
formattedRequestedAt: DateFormatter.formatShort(r.createdAt),
|
|
status: r.status as 'pending' | 'approved' | 'rejected',
|
|
statusLabel: StatusFormatter.protestStatus(r.status),
|
|
})),
|
|
};
|
|
}
|
|
}
|
|
|
|
LeagueSponsorshipsViewDataBuilder satisfies ViewDataBuilder<LeagueSponsorshipsInputDTO, LeagueSponsorshipsViewData>;
|