wip
This commit is contained in:
@@ -284,15 +284,14 @@ export default function ProfilePage() {
|
||||
|
||||
// Use GetProfileOverviewUseCase to load all profile data
|
||||
const profileUseCase = getGetProfileOverviewUseCase();
|
||||
await profileUseCase.execute({ driverId: currentDriverId });
|
||||
const profileViewModel = profileUseCase.presenter.getViewModel();
|
||||
const profileViewModel = await profileUseCase.execute({ driverId: currentDriverId });
|
||||
|
||||
if (profileViewModel && profileViewModel.currentDriver) {
|
||||
// Set driver from ViewModel instead of direct repository access
|
||||
const driverData: DriverDTO = {
|
||||
id: profileViewModel.currentDriver.id,
|
||||
name: profileViewModel.currentDriver.name,
|
||||
iracingId: profileViewModel.currentDriver.iracingId,
|
||||
iracingId: profileViewModel.currentDriver.iracingId ?? '',
|
||||
country: profileViewModel.currentDriver.country,
|
||||
bio: profileViewModel.currentDriver.bio || '',
|
||||
joinedAt: profileViewModel.currentDriver.joinedAt,
|
||||
@@ -335,11 +334,14 @@ export default function ProfilePage() {
|
||||
|
||||
try {
|
||||
const updateProfileUseCase = getUpdateDriverProfileUseCase();
|
||||
const updatedDto = await updateProfileUseCase.execute({
|
||||
driverId: driver.id,
|
||||
bio: updates.bio,
|
||||
country: updates.country,
|
||||
});
|
||||
const input: { driverId: string; bio?: string; country?: string } = { driverId: driver.id };
|
||||
if (typeof updates.bio === 'string') {
|
||||
input.bio = updates.bio;
|
||||
}
|
||||
if (typeof updates.country === 'string') {
|
||||
input.country = updates.country;
|
||||
}
|
||||
const updatedDto = await updateProfileUseCase.execute(input);
|
||||
|
||||
if (updatedDto) {
|
||||
setDriver(updatedDto);
|
||||
@@ -468,7 +470,9 @@ export default function ProfilePage() {
|
||||
<>
|
||||
<div className="flex items-center gap-2 px-3 py-1.5 rounded-lg bg-primary-blue/10 border border-primary-blue/30">
|
||||
<Star className="w-4 h-4 text-primary-blue" />
|
||||
<span className="font-mono font-bold text-primary-blue">{stats.rating}</span>
|
||||
<span className="font-mono font-bold text-primary-blue">
|
||||
{stats.rating ?? 0}
|
||||
</span>
|
||||
<span className="text-xs text-gray-400">Rating</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 px-3 py-1.5 rounded-lg bg-yellow-400/10 border border-yellow-400/30">
|
||||
@@ -644,7 +648,7 @@ export default function ProfilePage() {
|
||||
</div>
|
||||
<div className="flex gap-6">
|
||||
<CircularProgress
|
||||
value={stats.consistency}
|
||||
value={stats.consistency ?? 0}
|
||||
max={100}
|
||||
label="Consistency"
|
||||
color="text-primary-blue"
|
||||
@@ -684,7 +688,9 @@ export default function ProfilePage() {
|
||||
<Target className="w-4 h-4 text-primary-blue" />
|
||||
<span className="text-xs text-gray-500 uppercase">Avg Finish</span>
|
||||
</div>
|
||||
<p className="text-2xl font-bold text-primary-blue">P{stats.avgFinish.toFixed(1)}</p>
|
||||
<p className="text-2xl font-bold text-primary-blue">
|
||||
P{(stats.avgFinish ?? 0).toFixed(1)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -758,7 +764,9 @@ export default function ProfilePage() {
|
||||
<div className="text-xs text-gray-500 uppercase tracking-wider">Podiums</div>
|
||||
</div>
|
||||
<div className="p-4 rounded-xl bg-deep-graphite border border-charcoal-outline text-center">
|
||||
<div className="text-3xl font-bold text-primary-blue mb-1">{stats.consistency}%</div>
|
||||
<div className="text-3xl font-bold text-primary-blue mb-1">
|
||||
{stats.consistency ?? 0}%
|
||||
</div>
|
||||
<div className="text-xs text-gray-500 uppercase tracking-wider">Consistency</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -863,30 +871,35 @@ export default function ProfilePage() {
|
||||
</h2>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
|
||||
{extendedProfile.achievements.map((achievement) => {
|
||||
const Icon = getAchievementIcon(achievement.icon);
|
||||
const rarityClasses = getRarityColor(achievement.rarity);
|
||||
return (
|
||||
<div
|
||||
key={achievement.id}
|
||||
className={`p-4 rounded-xl border ${rarityClasses} transition-all hover:scale-105`}
|
||||
>
|
||||
<div className="flex items-start gap-3">
|
||||
<div className={`flex h-10 w-10 items-center justify-center rounded-lg ${rarityClasses.split(' ')[1]}`}>
|
||||
<Icon className={`w-5 h-5 ${rarityClasses.split(' ')[0]}`} />
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-white font-semibold text-sm">{achievement.title}</p>
|
||||
<p className="text-gray-400 text-xs mt-0.5">{achievement.description}</p>
|
||||
<p className="text-gray-500 text-xs mt-1">
|
||||
{new Date(achievement.earnedAt).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })}
|
||||
</p>
|
||||
const Icon = getAchievementIcon(achievement.icon);
|
||||
const rarityClasses = getRarityColor(achievement.rarity);
|
||||
return (
|
||||
<div
|
||||
key={achievement.id}
|
||||
className={`p-4 rounded-xl border ${rarityClasses} transition-all hover:scale-105`}
|
||||
>
|
||||
<div className="flex items-start gap-3">
|
||||
<div className={`flex h-10 w-10 items-center justify-center rounded-lg ${rarityClasses.split(' ')[1]}`}>
|
||||
<Icon className={`w-5 h-5 ${rarityClasses.split(' ')[0]}`} />
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-white font-semibold text-sm">{achievement.title}</p>
|
||||
<p className="text-gray-400 text-xs mt-0.5">{achievement.description}</p>
|
||||
<p className="text-gray-500 text-xs mt-1">
|
||||
{new Date(achievement.earnedAt).toLocaleDateString('en-US', {
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
year: 'numeric',
|
||||
})}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{/* Friends Preview */}
|
||||
{socialSummary && socialSummary.friends.length > 0 && (
|
||||
@@ -987,7 +1000,9 @@ export default function ProfilePage() {
|
||||
<Activity className="w-4 h-4 text-primary-blue" />
|
||||
<span className="text-xs text-gray-500 uppercase">Consistency</span>
|
||||
</div>
|
||||
<p className="text-2xl font-bold text-primary-blue">{stats.consistency}%</p>
|
||||
<p className="text-2xl font-bold text-primary-blue">
|
||||
{stats.consistency ?? 0}%
|
||||
</p>
|
||||
</div>
|
||||
<div className="p-4 rounded-xl bg-deep-graphite border border-charcoal-outline">
|
||||
<div className="flex items-center gap-2 mb-2">
|
||||
@@ -1015,7 +1030,9 @@ export default function ProfilePage() {
|
||||
<div className="text-xs text-gray-400 uppercase">Best Finish</div>
|
||||
</div>
|
||||
<div className="p-4 rounded-xl bg-gradient-to-br from-primary-blue/20 to-primary-blue/5 border border-primary-blue/30 text-center">
|
||||
<div className="text-4xl font-bold text-primary-blue mb-1">P{stats.avgFinish.toFixed(1)}</div>
|
||||
<div className="text-4xl font-bold text-primary-blue mb-1">
|
||||
P{(stats.avgFinish ?? 0).toFixed(1)}
|
||||
</div>
|
||||
<div className="text-xs text-gray-400 uppercase">Avg Finish</div>
|
||||
</div>
|
||||
<div className="p-4 rounded-xl bg-gradient-to-br from-warning-amber/20 to-warning-amber/5 border border-warning-amber/30 text-center">
|
||||
@@ -1044,7 +1061,9 @@ export default function ProfilePage() {
|
||||
</div>
|
||||
<div className="p-6 rounded-xl bg-gradient-to-br from-primary-blue/20 to-primary-blue/5 border border-primary-blue/30 text-center">
|
||||
<Star className="w-8 h-8 text-primary-blue mx-auto mb-3" />
|
||||
<div className="text-3xl font-bold text-primary-blue mb-1">{stats.rating}</div>
|
||||
<div className="text-3xl font-bold text-primary-blue mb-1">
|
||||
{stats.rating ?? 0}
|
||||
</div>
|
||||
<div className="text-sm text-gray-400">Rating</div>
|
||||
</div>
|
||||
<div className="p-6 rounded-xl bg-gradient-to-br from-purple-400/20 to-purple-600/5 border border-purple-400/30 text-center">
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user