'use client'; import React, { useState } from 'react'; import { useRouter } from 'next/navigation'; import { DriverProfileTemplate } from '@/templates/DriverProfileTemplate'; import type { DriverProfileViewModel } from '@/lib/view-models/DriverProfileViewModel'; interface DriverProfilePageClientProps { pageDto: DriverProfileViewModel | null; error?: string; empty?: { title: string; description: string; }; } /** * DriverProfilePageClient * * Client component that: * 1. Handles UI state (tabs, friend requests) * 2. Passes ViewModel directly to Template * * No business logic or data transformation here. * All data transformation happens in the PageQuery and ViewModelBuilder. */ export function DriverProfilePageClient({ pageDto, error, empty }: DriverProfilePageClientProps) { const router = useRouter(); // UI State (UI-only concerns) const [activeTab, setActiveTab] = useState<'overview' | 'stats'>('overview'); const [friendRequestSent, setFriendRequestSent] = useState(false); // Event handlers (UI-only concerns) const handleAddFriend = () => { setFriendRequestSent(true); }; const handleBackClick = () => { router.push('/drivers'); }; // Handle error/empty states if (error) { return (
Error loading driver profile

Please try again later

); } if (!pageDto || !pageDto.currentDriver) { if (empty) { return (

{empty.title}

{empty.description}

); } return null; } // Pass ViewModel directly to template return ( ({ team: { id: m.teamId, name: m.teamName, }, role: m.role, joinedAt: new Date(m.joinedAt), }))} isLoading={false} error={null} onBackClick={handleBackClick} onAddFriend={handleAddFriend} friendRequestSent={friendRequestSent} activeTab={activeTab} setActiveTab={setActiveTab} /> ); }