-
Legal documents
+
Signature documents
diff --git a/src/components/yachts/yacht-ownership-history.tsx b/src/components/yachts/yacht-ownership-history.tsx
index 076ef50e..3b701a16 100644
--- a/src/components/yachts/yacht-ownership-history.tsx
+++ b/src/components/yachts/yacht-ownership-history.tsx
@@ -1,9 +1,11 @@
'use client';
+import { useState } from 'react';
import { useQuery } from '@tanstack/react-query';
import { useParams } from 'next/navigation';
-import { Loader2 } from 'lucide-react';
+import { Loader2, ArrowLeftRight } from 'lucide-react';
+import { Button } from '@/components/ui/button';
import {
Table,
TableBody,
@@ -15,6 +17,8 @@ import {
import { Badge } from '@/components/ui/badge';
import { EmptyState } from '@/components/shared/empty-state';
import { OwnerLink } from '@/components/yachts/yacht-detail-header';
+import { YachtTransferDialog } from '@/components/yachts/yacht-transfer-dialog';
+import { PermissionGate } from '@/components/shared/permission-gate';
import { apiFetch } from '@/lib/api/client';
interface OwnershipHistoryRow {
@@ -52,6 +56,7 @@ function formatDate(value: string | null): string {
export function YachtOwnershipHistory({ yachtId }: YachtOwnershipHistoryProps) {
const params = useParams<{ portSlug: string }>();
const portSlug = params?.portSlug ?? '';
+ const [transferOpen, setTransferOpen] = useState(false);
const { data, isLoading } = useQuery
({
queryKey: ['yachts', yachtId, 'ownership-history'],
@@ -61,6 +66,11 @@ export function YachtOwnershipHistory({ yachtId }: YachtOwnershipHistoryProps) {
),
});
+ const currentOwnerRow = data?.find((r) => r.endDate === null);
+ const currentOwner = currentOwnerRow
+ ? { type: currentOwnerRow.ownerType, id: currentOwnerRow.ownerId }
+ : undefined;
+
if (isLoading) {
return (
@@ -71,53 +81,78 @@ export function YachtOwnershipHistory({ yachtId }: YachtOwnershipHistoryProps) {
if (!data || data.length === 0) {
return (
-
+ <>
+
setTransferOpen(true) }}
+ />
+
+ >
);
}
return (
-
-
-
-
- Start Date
- End Date
- Owner
- Reason
- Notes
-
-
-
- {data.map((row) => (
-
- {formatDate(row.startDate)}
-
- {row.endDate ? (
- formatDate(row.endDate)
- ) : (
-
- Current
-
- )}
-
-
-
-
-
- {row.transferReason
- ? (REASON_LABELS[row.transferReason] ?? row.transferReason)
- : '-'}
-
-
- {row.transferNotes ?? '-'}
-
+
+
+
+
+
+
+
+
+
+
+ Start Date
+ End Date
+ Owner
+ Reason
+ Notes
- ))}
-
-
+
+
+ {data.map((row) => (
+
+ {formatDate(row.startDate)}
+
+ {row.endDate ? (
+ formatDate(row.endDate)
+ ) : (
+
+ Current
+
+ )}
+
+
+
+
+
+ {row.transferReason
+ ? (REASON_LABELS[row.transferReason] ?? row.transferReason)
+ : '-'}
+
+
+ {row.transferNotes ?? '-'}
+
+
+ ))}
+
+
+
+
);
}