'use client'; import { useState } from 'react'; import Link from 'next/link'; import Button from '@/components/ui/Button'; import Card from '@/components/ui/Card'; import Container from '@/components/ui/Container'; import Heading from '@/components/ui/Heading'; import Input from '@/components/ui/Input'; import TabNavigation from '@/components/ui/TabNavigation'; import { routes } from '@/lib/routing/RouteConfig'; import type { Result } from '@/lib/contracts/Result'; import type { ProfileViewData } from '@/lib/view-data/ProfileViewData'; type ProfileTab = 'overview' | 'history' | 'stats'; type SaveError = string | null; interface ProfilePageClientProps { viewData: ProfileViewData; mode: 'profile-exists' | 'needs-profile'; onSaveSettings: (updates: { bio?: string; country?: string }) => Promise>; } export function ProfilePageClient({ viewData, mode, onSaveSettings }: ProfilePageClientProps) { const [activeTab, setActiveTab] = useState('overview'); const [editMode, setEditMode] = useState(false); const [bio, setBio] = useState(viewData.driver.bio ?? ''); const [countryCode, setCountryCode] = useState(viewData.driver.countryCode ?? ''); const [saveError, setSaveError] = useState(null); if (mode === 'needs-profile') { return ( Create your driver profile

Driver profile not found for this account.

); } if (editMode) { return ( Edit profile Profile setBio(e.target.value)} placeholder="Bio" /> setCountryCode(e.target.value)} placeholder="Country code (e.g. DE)" /> {saveError ?

{saveError}

: null}
); } return ( {viewData.driver.name || 'Profile'} setActiveTab(tabId as ProfileTab)} /> {activeTab === 'overview' ? ( Driver

{viewData.driver.countryCode}

{viewData.driver.joinedAtLabel}

{viewData.driver.bio ?? ''}

) : null} {activeTab === 'history' ? ( Race history

Race history is currently unavailable in this view.

) : null} {activeTab === 'stats' ? ( Stats

{viewData.stats?.ratingLabel ?? ''}

{viewData.stats?.globalRankLabel ?? ''}

) : null}
); }