'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 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 yachtCount = client.yachtCount ?? 0; const companyCount = client.companyCount ?? 0; const tags = client.tags ?? []; const meta = [nationality, sourceLabel].filter(Boolean) as string[]; const counts: string[] = []; if (yachtCount > 0) counts.push(`${yachtCount} ${yachtCount === 1 ? 'yacht' : 'yachts'}`); if (companyCount > 0) counts.push(`${companyCount} ${companyCount === 1 ? 'company' : 'companies'}`); 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} {counts.length > 0 ? (

{counts.join(' · ')}

) : null} {tags.length > 0 ? (
{tags.slice(0, 2).map((tag) => ( ))} {tags.length > 2 ? ( +{tags.length - 2} ) : null}
) : null}
); }