website cleanup

This commit is contained in:
2025-12-24 21:44:58 +01:00
parent 9b683a59d3
commit d78854a4c6
277 changed files with 6141 additions and 2693 deletions

View File

@@ -29,7 +29,7 @@ export function LeagueSponsorshipsSection({
readOnly = false
}: LeagueSponsorshipsSectionProps) {
const currentDriverId = useEffectiveDriverId();
const { sponsorshipService } = useServices();
const { sponsorshipService, leagueService } = useServices();
const [slots, setSlots] = useState<SponsorshipSlot[]>([
{ tier: 'main', price: 500, isOccupied: false },
{ tier: 'secondary', price: 200, isOccupied: false },
@@ -49,18 +49,15 @@ export function LeagueSponsorshipsSection({
return;
}
try {
const seasonRepo = getSeasonRepository();
const seasons = await seasonRepo.findByLeagueId(leagueId);
const activeSeason = seasons.find(s => s.status === 'active') ?? seasons[0];
if (activeSeason) {
setSeasonId(activeSeason.id);
}
const seasons = await leagueService.getLeagueSeasons(leagueId);
const activeSeason = seasons.find((s) => s.status === 'active') ?? seasons[0];
if (activeSeason) setSeasonId(activeSeason.seasonId);
} catch (err) {
console.error('Failed to load season:', err);
}
}
loadSeasonId();
}, [leagueId, propSeasonId]);
}, [leagueId, propSeasonId, leagueService]);
// Load pending sponsorship requests
const loadPendingRequests = useCallback(async () => {
@@ -68,25 +65,36 @@ export function LeagueSponsorshipsSection({
setRequestsLoading(true);
try {
const useCase = getGetPendingSponsorshipRequestsUseCase();
const presenter = new PendingSponsorshipRequestsPresenter();
const requests = await sponsorshipService.getPendingSponsorshipRequests({
entityType: 'season',
entityId: seasonId,
});
await useCase.execute(
{
entityType: 'season',
entityId: seasonId,
},
presenter,
// Convert service view-models to component DTO type (UI-only)
setPendingRequests(
requests.map(
(r): PendingRequestDTO => ({
id: r.id,
sponsorId: r.sponsorId,
sponsorName: r.sponsorName,
sponsorLogo: r.sponsorLogo,
tier: r.tier,
offeredAmount: r.offeredAmount,
currency: r.currency,
formattedAmount: r.formattedAmount,
message: r.message,
createdAt: r.createdAt,
platformFee: r.platformFee,
netAmount: r.netAmount,
}),
),
);
const viewModel = presenter.getViewModel();
setPendingRequests(viewModel?.requests ?? []);
} catch (err) {
console.error('Failed to load pending requests:', err);
} finally {
setRequestsLoading(false);
}
}, [seasonId]);
}, [seasonId, sponsorshipService]);
useEffect(() => {
loadPendingRequests();
@@ -94,11 +102,7 @@ export function LeagueSponsorshipsSection({
const handleAcceptRequest = async (requestId: string) => {
try {
const useCase = getAcceptSponsorshipRequestUseCase();
await useCase.execute({
requestId,
respondedBy: currentDriverId,
});
await sponsorshipService.acceptSponsorshipRequest(requestId, currentDriverId);
await loadPendingRequests();
} catch (err) {
console.error('Failed to accept request:', err);
@@ -108,12 +112,7 @@ export function LeagueSponsorshipsSection({
const handleRejectRequest = async (requestId: string, reason?: string) => {
try {
const useCase = getRejectSponsorshipRequestUseCase();
await useCase.execute({
requestId,
respondedBy: currentDriverId,
...(reason ? { reason } : {}),
});
await sponsorshipService.rejectSponsorshipRequest(requestId, currentDriverId, reason);
await loadPendingRequests();
} catch (err) {
console.error('Failed to reject request:', err);
@@ -324,4 +323,4 @@ export function LeagueSponsorshipsSection({
</div>
</div>
);
}
}