This commit is contained in:
2025-12-11 21:06:25 +01:00
parent c49ea2598d
commit ec3ddc3a5c
227 changed files with 3496 additions and 2083 deletions

View File

@@ -11,6 +11,7 @@ import {
getRejectSponsorshipRequestUseCase,
getSeasonRepository,
} from '@/lib/di-container';
import { PendingSponsorshipRequestsPresenter } from '@/lib/presenters/PendingSponsorshipRequestsPresenter';
import { useEffectiveDriverId } from '@/lib/currentDriver';
interface SponsorshipSlot {
@@ -72,11 +73,18 @@ export function LeagueSponsorshipsSection({
setRequestsLoading(true);
try {
const useCase = getGetPendingSponsorshipRequestsUseCase();
await useCase.execute({
entityType: 'season',
entityId: seasonId,
});
setPendingRequests(result.requests);
const presenter = new PendingSponsorshipRequestsPresenter();
await useCase.execute(
{
entityType: 'season',
entityId: seasonId,
},
presenter,
);
const viewModel = presenter.getViewModel();
setPendingRequests(viewModel?.requests ?? []);
} catch (err) {
console.error('Failed to load pending requests:', err);
} finally {
@@ -108,7 +116,7 @@ export function LeagueSponsorshipsSection({
await useCase.execute({
requestId,
respondedBy: currentDriverId,
reason,
...(reason ? { reason } : {}),
});
await loadPendingRequests();
} catch (err) {
@@ -118,16 +126,21 @@ export function LeagueSponsorshipsSection({
};
const handleEditPrice = (index: number) => {
const slot = slots[index];
if (!slot) return;
setEditingIndex(index);
setTempPrice(slots[index].price.toString());
setTempPrice(slot.price.toString());
};
const handleSavePrice = (index: number) => {
const price = parseFloat(tempPrice);
if (!isNaN(price) && price > 0) {
const updated = [...slots];
updated[index].price = price;
setSlots(updated);
const slot = updated[index];
if (slot) {
slot.price = price;
setSlots(updated);
}
}
setEditingIndex(null);
setTempPrice('');