import { redirect } from 'next/navigation'; import { FileText } from 'lucide-react'; import type { Metadata } from 'next'; import { getPortalSession } from '@/lib/portal/auth'; import { getClientDocuments } from '@/lib/services/portal.service'; import { Badge } from '@/components/ui/badge'; import { DocumentDownloadButton } from './document-download-button'; export const metadata: Metadata = { title: 'Documents' }; const DOC_TYPE_LABELS: Record = { eoi: 'Expression of Interest', contract: 'Contract', nda: 'NDA', reservation_agreement: 'Reservation Agreement', other: 'Document', }; const STATUS_COLORS: Record = { draft: 'secondary', sent: 'default', partially_signed: 'default', completed: 'outline', expired: 'destructive', cancelled: 'destructive', }; export default async function PortalDocumentsPage() { const session = await getPortalSession(); if (!session) redirect('/portal/login'); const documents = await getClientDocuments(session.clientId, session.portId); return (

Documents

Your contracts, EOIs, and signed agreements

{documents.length === 0 ? (

No documents on file

Documents shared with you will appear here.

) : (
{documents.map((doc) => (

{doc.title}

{DOC_TYPE_LABELS[doc.documentType] ?? doc.documentType}

{doc.status.replace(/_/g, ' ')}
{doc.signers.length > 0 && (

Signers

{doc.signers.map((signer, idx) => (
{signer.status === 'signed' ? '✓' : signer.status === 'declined' ? '✗' : '○'} {signer.signerName} ({signer.signerRole.replace(/_/g, ' ')})
))}
)}

{new Date(doc.createdAt).toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric', })}

{(doc.hasSignedFile || doc.status === 'completed') && ( )}
))}
)}
); }