'use client';
import Image from 'next/image';
import type { DriverDTO } from '@gridpilot/racing/application/dto/DriverDTO';
import Button from '../ui/Button';
import { getDriverTeam, getDriverAvatarUrl } from '@/lib/racingLegacyFacade';
interface ProfileHeaderProps {
driver: DriverDTO;
isOwnProfile?: boolean;
onEditClick?: () => void;
}
export default function ProfileHeader({ driver, isOwnProfile = false, onEditClick }: ProfileHeaderProps) {
return (
{driver.name}
{getCountryFlag(driver.country)}
{(() => {
const teamData = getDriverTeam(driver.id);
if (teamData) {
return (
{teamData.team.tag}
);
}
return null;
})()}
iRacing ID: {driver.iracingId}
•
Rating: 1450
{(() => {
const teamData = getDriverTeam(driver.id);
if (teamData) {
return (
<>
•
{teamData.team.name}
>
);
}
return null;
})()}
{isOwnProfile && (
)}
);
}
function getCountryFlag(countryCode: string): string {
const code = countryCode.toUpperCase();
if (code.length === 2) {
const codePoints = [...code].map(char =>
127397 + char.charCodeAt(0)
);
return String.fromCodePoint(...codePoints);
}
return '🏁';
}