'use client'; import type { ReactNode } from 'react'; import { Archive, MoreHorizontal, Pencil } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu'; import { CountryFlag } from '@/components/shared/country-flag'; 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, formatSource } from '@/lib/constants'; import type { ClientRow } from './client-columns'; interface ClientCardProps { client: ClientRow; portSlug: string; onEdit: (client: ClientRow) => void; onArchive: (client: ClientRow) => void; } export function ClientCard({ client, portSlug, onEdit, onArchive }: ClientCardProps) { // Card display: prefer email, fall back to phone. const primaryContactValue = client.primaryEmail ?? client.primaryPhone ?? null; const nationality = client.nationalityIso ? getCountryName(client.nationalityIso, 'en') : null; const sourceLabel = formatSource(client.source); const tags = client.tags ?? []; const metaItems: { key: string; node: ReactNode }[] = []; if (nationality) { metaItems.push({ key: 'nationality', node: ( {nationality} ), }); } if (sourceLabel) { metaItems.push({ key: 'source', node: {sourceLabel} }); } 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}

{primaryContactValue ? (

{primaryContactValue}

) : null} {metaItems.length > 0 ? (
{metaItems.map((m, i) => ( {i > 0 ? · : null} {m.node} ))}
) : 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}
); }