Some checks failed
CI / lint-typecheck (pull_request) Failing after 12s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped
71 lines
1.8 KiB
TypeScript
71 lines
1.8 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';
|
|
import type { DriverProfileViewData } from '@/lib/view-data/DriverProfileViewData';
|
|
|
|
interface DriverProfilePageClientProps {
|
|
viewData: DriverProfileViewData | null;
|
|
error?: boolean;
|
|
empty?: {
|
|
title: string;
|
|
description: string;
|
|
};
|
|
}
|
|
|
|
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}
|
|
/>
|
|
);
|
|
}
|