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

@@ -16,6 +16,7 @@ import {
getLeagueMembershipRepository,
getTeamMembershipRepository,
} from '@/lib/di-container';
import { PendingSponsorshipRequestsPresenter } from '@/lib/presenters/PendingSponsorshipRequestsPresenter';
import { useEffectiveDriverId } from '@/lib/currentDriver';
import { isLeagueAdminOrHigherRole } from '@/lib/leagueRoles';
import { Handshake, User, Users, Trophy, ChevronRight, Building, AlertTriangle } from 'lucide-react';
@@ -51,12 +52,17 @@ export default function SponsorshipRequestsPage() {
const allSections: EntitySection[] = [];
// 1. Driver's own sponsorship requests
const driverResult = await query.execute({
entityType: 'driver',
entityId: currentDriverId,
});
const driverPresenter = new PendingSponsorshipRequestsPresenter();
await useCase.execute(
{
entityType: 'driver',
entityId: currentDriverId,
},
driverPresenter,
);
const driverResult = driverPresenter.getViewModel();
if (driverResult.requests.length > 0) {
if (driverResult && driverResult.requests.length > 0) {
const driver = await driverRepo.findById(currentDriverId);
allSections.push({
entityType: 'driver',
@@ -74,12 +80,17 @@ export default function SponsorshipRequestsPage() {
// Load sponsorship requests for this league's active season
try {
// For simplicity, we'll query by season entityType - in production you'd get the active season ID
const leagueResult = await query.execute({
entityType: 'season',
entityId: league.id, // Using league ID as a proxy for now
});
const leaguePresenter = new PendingSponsorshipRequestsPresenter();
await useCase.execute(
{
entityType: 'season',
entityId: league.id, // Using league ID as a proxy for now
},
leaguePresenter,
);
const leagueResult = leaguePresenter.getViewModel();
if (leagueResult.requests.length > 0) {
if (leagueResult && leagueResult.requests.length > 0) {
allSections.push({
entityType: 'season',
entityId: league.id,
@@ -98,12 +109,17 @@ export default function SponsorshipRequestsPage() {
for (const team of allTeams) {
const membership = await teamMembershipRepo.getMembership(team.id, currentDriverId);
if (membership && (membership.role === 'owner' || membership.role === 'manager')) {
const teamResult = await query.execute({
entityType: 'team',
entityId: team.id,
});
const teamPresenter = new PendingSponsorshipRequestsPresenter();
await useCase.execute(
{
entityType: 'team',
entityId: team.id,
},
teamPresenter,
);
const teamResult = teamPresenter.getViewModel();
if (teamResult.requests.length > 0) {
if (teamResult && teamResult.requests.length > 0) {
allSections.push({
entityType: 'team',
entityId: team.id,
@@ -138,11 +154,14 @@ export default function SponsorshipRequestsPage() {
const handleReject = async (requestId: string, reason?: string) => {
const useCase = getRejectSponsorshipRequestUseCase();
await useCase.execute({
const input: { requestId: string; respondedBy: string; reason?: string } = {
requestId,
respondedBy: currentDriverId,
reason,
});
};
if (typeof reason === 'string') {
input.reason = reason;
}
await useCase.execute(input);
await loadAllRequests();
};