'use client'; import { Archive, MoreHorizontal, Pencil } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu'; import { TagBadge } from '@/components/shared/tag-badge'; import { ListCard, ListCardAvatar, ListCardMeta, deriveInitials, } from '@/components/shared/list-card'; import { getCountryName } from '@/lib/i18n/countries'; import { stageBadgeClass, stageLabel } from '@/lib/constants'; import type { ClientRow } from './client-columns'; const SOURCE_LABELS: Record = { website: 'Website', manual: 'Manual', referral: 'Referral', broker: 'Broker', }; interface ClientCardProps { client: ClientRow; portSlug: string; onEdit: (client: ClientRow) => void; onArchive: (client: ClientRow) => void; } export function ClientCard({ client, portSlug, onEdit, onArchive }: ClientCardProps) { const primary = client.contacts?.find((c) => c.isPrimary); const nationality = client.nationalityIso ? getCountryName(client.nationalityIso, 'en') : null; const sourceLabel = client.source ? (SOURCE_LABELS[client.source] ?? client.source) : null; const tags = client.tags ?? []; const meta = [nationality, sourceLabel].filter(Boolean) as string[]; const interest = client.latestInterest ?? null; const interestCount = client.interestCount ?? 0; const interestBerthLabel = interest ? interest.mooringNumber ? `Berth ${interest.mooringNumber}` : 'General interest' : null; const interestStageLabel = interest ? stageLabel(interest.stage) : null; const interestStageBadge = interest ? stageBadgeClass(interest.stage) : null; const extraInterests = interestCount > 1 ? interestCount - 1 : 0; return ( onEdit(client)}> Edit onArchive(client)}> Archive } >

{client.fullName}

{primary ? (

{primary.value}

) : null} {meta.length > 0 ? (
{meta.map((m, i) => ( {i > 0 ? · : null} {m} ))}
) : null} {interest ? (
{interestBerthLabel} · {interestStageLabel} {extraInterests > 0 ? ( +{extraInterests} ) : null}
) : null} {tags.length > 0 ? (
{tags.slice(0, 2).map((tag) => ( ))} {tags.length > 2 ? ( +{tags.length - 2} ) : null}
) : null}
); }