'use client'; import { useState } from 'react'; import Link from 'next/link'; import { FileText, ClipboardSignature } from 'lucide-react'; import { usePaginatedQuery } from '@/hooks/use-paginated-query'; import { StatusPill, type StatusPillStatus } from '@/components/ui/status-pill'; import { FilePreviewDialog } from '@/components/files/file-preview-dialog'; interface HubRootDoc { id: string; title: string; documentType: string; status: string; createdAt: string; } interface HubRootFile { id: string; filename: string; mimeType: string | null; createdAt: string; folderId: string | null; folderName: string | null; clientId: string | null; clientName: string | null; yachtId: string | null; yachtName: string | null; companyId: string | null; companyName: string | null; interestId: string | null; interestSummary: { stage: string; clientName: string | null } | null; } interface Props { portSlug: string; } const STATUS_PILL_MAP: Record = { draft: 'draft', sent: 'sent', partially_signed: 'partial', completed: 'completed', signed: 'signed', expired: 'expired', cancelled: 'cancelled', rejected: 'rejected', }; export function HubRootView({ portSlug }: Props) { const [previewFile, setPreviewFile] = useState<{ id: string; name: string; mimeType: string | null; } | null>(null); const { data: workflows, isLoading: workflowsLoading } = usePaginatedQuery({ queryKey: ['documents', 'hub-root', 'workflows'], endpoint: '/api/v1/documents?tab=in_progress', filterDefinitions: [], }); const { data: filesData, isLoading: filesLoading } = usePaginatedQuery({ queryKey: ['files', 'hub-root'], endpoint: '/api/v1/files?sort=createdAt&order=desc&limit=20', filterDefinitions: [], }); return (

Signing in progress

{workflowsLoading ? (
Loading...
) : workflows.length === 0 ? (
No workflows in flight.
) : (
    {workflows.map((w) => (
  • {w.title} {w.status.replace(/_/g, ' ')}
  • ))}
)}

Recent files

{filesLoading ? (
Loading...
) : filesData.length === 0 ? (
No files yet.
) : (
    {filesData.map((f) => { const entityBadge = (() => { if (f.interestId) return { label: f.interestSummary?.clientName ? `Interest: ${f.interestSummary.clientName}` : 'Interest', href: `/${portSlug}/interests/${f.interestId}`, }; if (f.clientId) return { label: f.clientName ?? 'Client', href: `/${portSlug}/clients/${f.clientId}`, }; if (f.yachtId) return { label: f.yachtName ?? 'Yacht', href: `/${portSlug}/yachts/${f.yachtId}`, }; if (f.companyId) return { label: f.companyName ?? 'Company', href: `/${portSlug}/companies/${f.companyId}`, }; return null; })(); return (
  • {f.folderId && f.folderName ? ( 📁 {f.folderName} ) : null} {entityBadge ? ( {entityBadge.label} ) : null}
    {new Date(f.createdAt).toLocaleDateString(undefined)}
  • ); })}
)}
{ if (!open) setPreviewFile(null); }} fileId={previewFile?.id} fileName={previewFile?.name} mimeType={previewFile?.mimeType ?? undefined} />
); }