fix data flow issues
This commit is contained in:
@@ -92,67 +92,6 @@ interface TeamMembershipInfo {
|
||||
// DEMO DATA
|
||||
// ============================================================================
|
||||
|
||||
function getDemoExtendedProfile(driverId: string): DriverExtendedProfile {
|
||||
const hash = driverId.split('').reduce((acc, char) => acc + char.charCodeAt(0), 0);
|
||||
|
||||
const socialOptions: SocialHandle[][] = [
|
||||
[
|
||||
{ platform: 'twitter', handle: '@speedracer', url: 'https://twitter.com/speedracer' },
|
||||
{ platform: 'youtube', handle: 'SpeedRacer Racing', url: 'https://youtube.com/@speedracer' },
|
||||
{ platform: 'twitch', handle: 'speedracer_live', url: 'https://twitch.tv/speedracer_live' },
|
||||
],
|
||||
[
|
||||
{ platform: 'twitter', handle: '@racingpro', url: 'https://twitter.com/racingpro' },
|
||||
{ platform: 'discord', handle: 'RacingPro#1234', url: '#' },
|
||||
],
|
||||
[
|
||||
{ platform: 'twitch', handle: 'simracer_elite', url: 'https://twitch.tv/simracer_elite' },
|
||||
{ platform: 'youtube', handle: 'SimRacer Elite', url: 'https://youtube.com/@simracerelite' },
|
||||
],
|
||||
];
|
||||
|
||||
const achievementSets: Achievement[][] = [
|
||||
[
|
||||
{ id: '1', title: 'First Victory', description: 'Win your first race', icon: 'trophy', rarity: 'common', earnedAt: new Date(Date.now() - 90 * 24 * 60 * 60 * 1000) },
|
||||
{ id: '2', title: 'Clean Racer', description: '10 races without incidents', icon: 'star', rarity: 'rare', earnedAt: new Date(Date.now() - 60 * 24 * 60 * 60 * 1000) },
|
||||
{ id: '3', title: 'Podium Streak', description: '5 consecutive podium finishes', icon: 'medal', rarity: 'epic', earnedAt: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000) },
|
||||
],
|
||||
[
|
||||
{ id: '1', title: 'Rookie No More', description: 'Complete 25 races', icon: 'target', rarity: 'common', earnedAt: new Date(Date.now() - 120 * 24 * 60 * 60 * 1000) },
|
||||
{ id: '2', title: 'Consistent Performer', description: 'Maintain 80%+ consistency rating', icon: 'zap', rarity: 'rare', earnedAt: new Date(Date.now() - 45 * 24 * 60 * 60 * 1000) },
|
||||
],
|
||||
[
|
||||
{ id: '1', title: 'Welcome Racer', description: 'Join GridPilot', icon: 'star', rarity: 'common', earnedAt: new Date(Date.now() - 180 * 24 * 60 * 60 * 1000) },
|
||||
{ id: '2', title: 'Team Player', description: 'Join a racing team', icon: 'medal', rarity: 'rare', earnedAt: new Date(Date.now() - 80 * 24 * 60 * 60 * 1000) },
|
||||
],
|
||||
];
|
||||
|
||||
const tracks = ['Spa-Francorchamps', 'Nürburgring Nordschleife', 'Suzuka', 'Monza', 'Interlagos', 'Silverstone'];
|
||||
const cars = ['Porsche 911 GT3 R', 'Ferrari 488 GT3', 'Mercedes-AMG GT3', 'BMW M4 GT3', 'Audi R8 LMS'];
|
||||
const styles = ['Aggressive Overtaker', 'Consistent Pacer', 'Strategic Calculator', 'Late Braker', 'Smooth Operator'];
|
||||
const timezones = ['EST (UTC-5)', 'CET (UTC+1)', 'PST (UTC-8)', 'GMT (UTC+0)', 'JST (UTC+9)'];
|
||||
const hours = ['Evenings (18:00-23:00)', 'Weekends only', 'Late nights (22:00-02:00)', 'Flexible schedule'];
|
||||
|
||||
const socialHandles = socialOptions[hash % socialOptions.length] ?? [];
|
||||
const achievements = achievementSets[hash % achievementSets.length] ?? [];
|
||||
const racingStyle = styles[hash % styles.length] ?? 'Consistent Pacer';
|
||||
const favoriteTrack = tracks[hash % tracks.length] ?? 'Unknown Track';
|
||||
const favoriteCar = cars[hash % cars.length] ?? 'Unknown Car';
|
||||
const timezone = timezones[hash % timezones.length] ?? 'UTC';
|
||||
const availableHours = hours[hash % hours.length] ?? 'Flexible schedule';
|
||||
|
||||
return {
|
||||
socialHandles,
|
||||
achievements,
|
||||
racingStyle,
|
||||
favoriteTrack,
|
||||
favoriteCar,
|
||||
timezone,
|
||||
availableHours,
|
||||
lookingForTeam: hash % 3 === 0,
|
||||
openToRequests: hash % 2 === 0,
|
||||
};
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// HELPERS
|
||||
@@ -428,29 +367,33 @@ export default function DriverDetailPage() {
|
||||
);
|
||||
}
|
||||
|
||||
const demoExtended = getDemoExtendedProfile(driverProfile.currentDriver.id);
|
||||
const extendedProfile: DriverExtendedProfile = {
|
||||
socialHandles: driverProfile?.extendedProfile?.socialHandles ?? demoExtended.socialHandles,
|
||||
achievements:
|
||||
driverProfile?.extendedProfile?.achievements
|
||||
? driverProfile.extendedProfile.achievements.map((achievement) => ({
|
||||
id: achievement.id,
|
||||
title: achievement.title,
|
||||
description: achievement.description,
|
||||
icon: achievement.icon,
|
||||
rarity: achievement.rarity,
|
||||
earnedAt: new Date(achievement.earnedAt),
|
||||
}))
|
||||
: demoExtended.achievements,
|
||||
racingStyle: driverProfile?.extendedProfile?.racingStyle ?? demoExtended.racingStyle,
|
||||
favoriteTrack: driverProfile?.extendedProfile?.favoriteTrack ?? demoExtended.favoriteTrack,
|
||||
favoriteCar: driverProfile?.extendedProfile?.favoriteCar ?? demoExtended.favoriteCar,
|
||||
timezone: driverProfile?.extendedProfile?.timezone ?? demoExtended.timezone,
|
||||
availableHours: driverProfile?.extendedProfile?.availableHours ?? demoExtended.availableHours,
|
||||
lookingForTeam:
|
||||
driverProfile?.extendedProfile?.lookingForTeam ?? demoExtended.lookingForTeam,
|
||||
openToRequests:
|
||||
driverProfile?.extendedProfile?.openToRequests ?? demoExtended.openToRequests,
|
||||
const extendedProfile: DriverExtendedProfile = driverProfile.extendedProfile ? {
|
||||
socialHandles: driverProfile.extendedProfile.socialHandles,
|
||||
achievements: driverProfile.extendedProfile.achievements.map((achievement) => ({
|
||||
id: achievement.id,
|
||||
title: achievement.title,
|
||||
description: achievement.description,
|
||||
icon: achievement.icon,
|
||||
rarity: achievement.rarity,
|
||||
earnedAt: new Date(achievement.earnedAt),
|
||||
})),
|
||||
racingStyle: driverProfile.extendedProfile.racingStyle,
|
||||
favoriteTrack: driverProfile.extendedProfile.favoriteTrack,
|
||||
favoriteCar: driverProfile.extendedProfile.favoriteCar,
|
||||
timezone: driverProfile.extendedProfile.timezone,
|
||||
availableHours: driverProfile.extendedProfile.availableHours,
|
||||
lookingForTeam: driverProfile.extendedProfile.lookingForTeam,
|
||||
openToRequests: driverProfile.extendedProfile.openToRequests,
|
||||
} : {
|
||||
socialHandles: [],
|
||||
achievements: [],
|
||||
racingStyle: 'Unknown',
|
||||
favoriteTrack: 'Unknown',
|
||||
favoriteCar: 'Unknown',
|
||||
timezone: 'UTC',
|
||||
availableHours: 'Flexible',
|
||||
lookingForTeam: false,
|
||||
openToRequests: false,
|
||||
};
|
||||
const stats = driverProfile?.stats || null;
|
||||
const globalRank = driverProfile?.currentDriver?.globalRank || 1;
|
||||
|
||||
Reference in New Issue
Block a user