import { redirect } from 'next/navigation'; import { Anchor } from 'lucide-react'; import type { Metadata } from 'next'; import { getPortalSession } from '@/lib/portal/auth'; import { getClientInterests } from '@/lib/services/portal.service'; import { Badge } from '@/components/ui/badge'; import { stageLabel, safeStage, type PipelineStage } from '@/lib/constants'; export const metadata: Metadata = { title: 'Interests' }; // Portal-friendly labels for signing-process status fields. The audit // caught raw enum leak ("waiting_for_signatures" with underscores) at // the client-facing surface. Map every known value to plain English; // fall back to a Title-Case rendering for any new states. const PORTAL_SIGNING_LABELS: Record = { not_started: 'Not started', draft: 'Drafted', awaiting_them: 'Awaiting their signature', awaiting_me: 'Awaiting your signature', waiting_for_signatures: 'Waiting for signatures', partially_signed: 'Partially signed', sent: 'Sent for signing', signed: 'Signed', completed: 'Signed', expired: 'Expired', cancelled: 'Cancelled', rejected: 'Rejected', }; function portalSigningLabel(status: string): string { if (status in PORTAL_SIGNING_LABELS) return PORTAL_SIGNING_LABELS[status]!; return status .split('_') .map((p) => (p ? p[0]!.toUpperCase() + p.slice(1) : p)) .join(' '); } const STAGE_VARIANT: Record = { open: 'secondary', details_sent: 'secondary', in_communication: 'default', eoi_sent: 'default', eoi_signed: 'default', deposit_10pct: 'default', contract_sent: 'default', contract_signed: 'default', completed: 'outline', }; export default async function PortalInterestsPage() { const session = await getPortalSession(); if (!session) redirect('/portal/login'); const interests = await getClientInterests(session.clientId, session.portId); return (

Berth Interests

Your berth enquiries and applications

{interests.length === 0 ? (

No interests on file

Contact your port representative to discuss available berths.

) : (
{interests.map((interest) => (
{interest.berthMooringNumber ? ( Berth {interest.berthMooringNumber} ) : ( General Interest )} {interest.berthArea && ( - {interest.berthArea} )}
{/* leadCategory ("hot_lead" / "qualified_lead" / etc.) is a staff classification — never render to clients. Privacy + optics: we shouldn't be telling the prospect they're a "hot lead". */}
{interest.dateFirstContact && ( First contact:{' '} {new Date(interest.dateFirstContact).toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric', })} )} {interest.eoiStatus && ( EOI: {portalSigningLabel(interest.eoiStatus)} )} {interest.contractStatus && ( Contract: {portalSigningLabel(interest.contractStatus)} )}
{stageLabel(interest.pipelineStage)}
))}
)}
); }