'use client'; import { useState } from 'react'; import { useQuery } from '@tanstack/react-query'; import { FileSignature } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { DocumentList } from '@/components/documents/document-list'; import { EoiGenerateDialog } from '@/components/documents/eoi-generate-dialog'; import { apiFetch } from '@/lib/api/client'; interface InterestDocumentsTabProps { interestId: string; } interface InterestData { id: string; yachtId?: string | null; berthId?: string | null; clientName?: string | null; /** Surfaced by getInterestById for the EOI prerequisites checklist. */ clientPrimaryEmail?: string | null; clientHasAddress?: boolean; } export function InterestDocumentsTab({ interestId }: InterestDocumentsTabProps) { const [eoiDialogOpen, setEoiDialogOpen] = useState(false); // Same query key + queryFn shape as InterestDetail's parent query, so the // cache is consistent. (Mismatched shapes on the same key clobber each other // and the parent header degenerates to "Unknown Client".) const { data: interest } = useQuery({ queryKey: ['interests', interestId], queryFn: () => apiFetch<{ data: InterestData }>(`/api/v1/interests/${interestId}`).then((r) => r.data), }); const prerequisites = { // Required (EOI Section 2 — top paragraph): name, address, email. hasName: Boolean(interest?.clientName), hasEmail: Boolean(interest?.clientPrimaryEmail), hasAddress: Boolean(interest?.clientHasAddress), // Optional (EOI Section 3): yacht + berth. Render blank when absent. hasYacht: Boolean(interest?.yachtId), hasBerth: Boolean(interest?.berthId), }; return (

Documents

No documents yet

Generate the EOI to send it for signing in one click.

} /> ); }