remove core from pages

This commit is contained in:
2025-12-18 19:14:50 +01:00
parent 9814d9682c
commit 4a3087ae35
35 changed files with 552 additions and 354 deletions

View File

@@ -4,7 +4,8 @@ import { LeagueSponsorshipsSection } from '@/components/leagues/LeagueSponsorshi
import Card from '@/components/ui/Card';
import { useEffectiveDriverId } from '@/hooks/useEffectiveDriverId';
import { isLeagueAdminOrHigherRole } from '@/lib/leagueRoles';
import type { League } from '@core/racing/domain/entities/League';
import { useServices } from '@/lib/services/ServiceProvider';
import { LeagueDetailViewModel } from '@/lib/view-models/LeagueDetailViewModel';
import { AlertTriangle, Building } from 'lucide-react';
import { useParams } from 'next/navigation';
import { useEffect, useState } from 'react';
@@ -13,23 +14,23 @@ export default function LeagueSponsorshipsPage() {
const params = useParams();
const leagueId = params.id as string;
const currentDriverId = useEffectiveDriverId();
const { leagueService, leagueMembershipService } = useServices();
const [league, setLeague] = useState<League | null>(null);
const [league, setLeague] = useState<LeagueDetailViewModel | null>(null);
const [isAdmin, setIsAdmin] = useState(false);
const [loading, setLoading] = useState(true);
useEffect(() => {
async function loadData() {
try {
const leagueRepo = getLeagueRepository();
const membershipRepo = getLeagueMembershipRepository();
const [leagueData, membership] = await Promise.all([
leagueRepo.findById(leagueId),
membershipRepo.getMembership(leagueId, currentDriverId),
const [leagueDetail, memberships] = await Promise.all([
leagueService.getLeagueDetail(leagueId, currentDriverId),
leagueMembershipService.fetchLeagueMemberships(leagueId),
]);
setLeague(leagueData);
const membership = leagueMembershipService.getMembership(leagueId, currentDriverId);
setLeague(leagueDetail);
setIsAdmin(membership ? isLeagueAdminOrHigherRole(membership.role) : false);
} catch (err) {
console.error('Failed to load league:', err);
@@ -39,7 +40,7 @@ export default function LeagueSponsorshipsPage() {
}
loadData();
}, [leagueId, currentDriverId]);
}, [leagueId, currentDriverId, leagueService, leagueMembershipService]);
if (loading) {
return (