feat(ui): yacht detail page with header, tabs, ownership history
Implements Task 5.3: server page passes yachtId to a client YachtDetail, which fetches via TanStack Query and renders the shared DetailLayout with Overview / Ownership History / Interests / Reservations / Notes / Tags tabs. Header shows name, dimensions, polymorphic owner link, status badge, and Edit / Transfer / Archive actions. Transfer is a stub dialog pending Task 5.5; Notes tab is a placeholder because NotesList does not yet support entityType='yachts'. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
67
src/components/yachts/yacht-detail.tsx
Normal file
67
src/components/yachts/yacht-detail.tsx
Normal file
@@ -0,0 +1,67 @@
|
||||
'use client';
|
||||
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
|
||||
import { DetailLayout } from '@/components/shared/detail-layout';
|
||||
import { YachtDetailHeader } from '@/components/yachts/yacht-detail-header';
|
||||
import { getYachtTabs } from '@/components/yachts/yacht-tabs';
|
||||
import { useRealtimeInvalidation } from '@/hooks/use-realtime-invalidation';
|
||||
import { apiFetch } from '@/lib/api/client';
|
||||
|
||||
export interface YachtData {
|
||||
id: string;
|
||||
portId: string;
|
||||
name: string;
|
||||
hullNumber: string | null;
|
||||
registration: string | null;
|
||||
flag: string | null;
|
||||
yearBuilt: number | null;
|
||||
builder: string | null;
|
||||
model: string | null;
|
||||
hullMaterial: string | null;
|
||||
lengthFt: string | null;
|
||||
widthFt: string | null;
|
||||
draftFt: string | null;
|
||||
lengthM: string | null;
|
||||
widthM: string | null;
|
||||
draftM: string | null;
|
||||
currentOwnerType: 'client' | 'company';
|
||||
currentOwnerId: string;
|
||||
status: string;
|
||||
notes: string | null;
|
||||
archivedAt: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
interface YachtDetailProps {
|
||||
yachtId: string;
|
||||
currentUserId?: string;
|
||||
}
|
||||
|
||||
export function YachtDetail({ yachtId, currentUserId }: YachtDetailProps) {
|
||||
const { data, isLoading } = useQuery<YachtData>({
|
||||
queryKey: ['yachts', yachtId],
|
||||
queryFn: () => apiFetch<{ data: YachtData }>(`/api/v1/yachts/${yachtId}`).then((r) => r.data),
|
||||
});
|
||||
|
||||
useRealtimeInvalidation({
|
||||
'yacht:updated': [['yachts', yachtId]],
|
||||
'yacht:archived': [['yachts', yachtId]],
|
||||
'yacht:ownership_transferred': [
|
||||
['yachts', yachtId],
|
||||
['yachts', yachtId, 'ownership-history'],
|
||||
],
|
||||
});
|
||||
|
||||
const tabs = data ? getYachtTabs({ yachtId, currentUserId, yacht: data }) : [];
|
||||
|
||||
return (
|
||||
<DetailLayout
|
||||
header={data ? <YachtDetailHeader yacht={data} /> : null}
|
||||
tabs={tabs}
|
||||
defaultTab="overview"
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user