Files
gridpilot.gg/apps/website/client-wrapper/DriverProfilePageClient.tsx
Marc Mintel ae58839eb2
Some checks failed
Contract Testing / contract-tests (pull_request) Failing after 5m53s
Contract Testing / contract-snapshot (pull_request) Has been skipped
view data fixes
2026-01-22 23:44:26 +01:00

62 lines
1.5 KiB
TypeScript

'use client';
import type { ProfileTab } from '@/components/profile/ProfileTabs';
import { DriverProfileTemplate } from '@/templates/DriverProfileTemplate';
import { EmptyTemplate, ErrorTemplate } from '@/templates/shared/StatusTemplates';
import { useRouter } from 'next/navigation';
import { useState } from 'react';
export function DriverProfilePageClient({ viewData, error, empty }: DriverProfilePageClientProps) {
const router = useRouter();
// UI State (UI-only concerns)
const [activeTab, setActiveTab] = useState<ProfileTab>('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 (
<ErrorTemplate
viewData={{}}
message="Error loading driver profile"
description="Please try again later"
/>
);
}
if (!viewData || !viewData.currentDriver) {
if (empty) {
return (
<EmptyTemplate
viewData={{}}
title={empty.title}
description={empty.description}
/>
);
}
return null;
}
// Pass ViewData directly to template
return (
<DriverProfileTemplate
viewData={viewData}
onBackClick={handleBackClick}
onAddFriend={handleAddFriend}
friendRequestSent={friendRequestSent}
activeTab={activeTab}
onTabChange={setActiveTab}
/>
);
}