refactor core presenters
This commit is contained in:
@@ -10,7 +10,7 @@ import PerformanceMetrics from './PerformanceMetrics';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { DriverTeamPresenter } from '@/lib/presenters/DriverTeamPresenter';
|
||||
import { getPrimaryLeagueIdForDriver } from '@/lib/leagueMembership';
|
||||
import type { ProfileOverviewViewModel } from '@core/racing/application/presenters/IProfileOverviewPresenter';
|
||||
import type { ProfileOverviewOutputPort } from '@core/racing/application/ports/output/ProfileOverviewOutputPort';
|
||||
import type { DriverTeamViewModel } from '@core/racing/application/presenters/IDriverTeamPresenter';
|
||||
|
||||
interface DriverProfileProps {
|
||||
@@ -33,7 +33,7 @@ interface DriverProfileStatsViewModel {
|
||||
overallRank?: number;
|
||||
}
|
||||
|
||||
type DriverProfileOverviewViewModel = ProfileOverviewViewModel | null;
|
||||
type DriverProfileOverviewViewModel = ProfileOverviewOutputPort | null;
|
||||
|
||||
export default function DriverProfile({ driver, isOwnProfile = false, onEditClick }: DriverProfileProps) {
|
||||
const [profileData, setProfileData] = useState<DriverProfileOverviewViewModel>(null);
|
||||
@@ -61,8 +61,8 @@ export default function DriverProfile({ driver, isOwnProfile = false, onEditClic
|
||||
const leagueRank = primaryLeagueId
|
||||
? getLeagueRankings(driver.id, primaryLeagueId)
|
||||
: { rank: 0, totalDrivers: 0, percentile: 0 };
|
||||
const globalRank = profileData?.currentDriver?.globalRank ?? null;
|
||||
const totalDrivers = profileData?.currentDriver?.totalDrivers ?? 0;
|
||||
const globalRank = profileData?.driver?.globalRank ?? null;
|
||||
const totalDrivers = profileData?.driver?.totalDrivers ?? 0;
|
||||
|
||||
const performanceStats = driverStats ? {
|
||||
winRate: driverStats.totalRaces > 0 ? (driverStats.wins / driverStats.totalRaces) * 100 : 0,
|
||||
|
||||
Reference in New Issue
Block a user