import { ArrowRightIcon, BriefcaseIcon, FlagIcon, HeartHandshakeIcon, LandmarkIcon, MessageCircleIcon, UserIcon, UsersIcon, WrenchIcon, } from 'lucide-react' import Link from 'next/link' import type { ReactNode } from 'react' import { LeadershipInviteRowAction } from '@/components/campaign/invite/LeadershipInviteRowAction' import { SupportStatusBadge } from '@/components/campaign/leadership/SupportStatusBadge' import { DeletePersonButton } from '@/components/campaign/people/DeletePersonButton' import { Badge } from '@/components/ui/Badge' import { Button } from '@/components/ui/button' import type { ResolvedPortfolioEntry } from '@/lib/municipalityPortfolio' import { formatBrazilianPhoneInput, whatsAppHrefForPhone } from '@/lib/phone' import { campaignRoleLabels } from '@/utilities/campaignUserProfile' import type { PersonDetailViewModel } from '@/utilities/people/personDetail' import { supporterSourceLabels, supporterVoteIntentionLabels, } from '@/utilities/supporter/supporterUi' /** * C118 — the person detail, mounted by capacity: each section renders only * when the ficha actually has that papel (liderança, dobradinha, assessora, * assessorado, apoiador). The page stays thin — the composition rule lives * here, next to the cards. Read-only by design: writing stays in the list * (C116) and the surfaces that own each papel. */ const dateFormatter = new Intl.DateTimeFormat('pt-BR', { dateStyle: 'short' }) const PersonSectionCard = ({ sectionId, icon, title, trailing, children, }: { /** ASCII stable id (aria-labelledby + CSS): `person-section-`. */ sectionId: string icon: ReactNode title: string trailing?: ReactNode children: ReactNode }) => (
{icon}

{title}

{trailing}
{children}
) const PersonMunicipalityChips = ({ ids, index, }: { ids: readonly number[] index: ReadonlyMap }) => { if (!ids.length) return — const names = ids .map((id) => index.get(id)?.name) .filter((name): name is string => name !== undefined) if (!names.length) return — const visible = names.slice(0, 2) const rest = names.length - visible.length return (
{visible.map((name) => ( {name} ))} {rest > 0 ? ( +{rest} ) : null}
) } const FichaField = ({ label, value }: { label: string; value: string | null }) => (
{label}
{value ?? —}
) const PersonFichaSection = ({ person }: { person: PersonDetailViewModel }) => { const capacityPills: string[] = [] if (person.leadershipID !== null) capacityPills.push('Liderança') if (person.deputyID !== null) capacityPills.push('Dobradinha') if (person.staff.length > 0) capacityPills.push('Assessora') if (person.supporters.length > 0) capacityPills.push('Apoiador') return ( ) } const PersonLeadershipSection = ({ person, municipalityIndex, }: { person: PersonDetailViewModel municipalityIndex: ReadonlyMap }) => ( ) const PersonDeputySection = ({ person, municipalityIndex, }: { person: PersonDetailViewModel municipalityIndex: ReadonlyMap }) => ( ) const PersonAssessoraSection = ({ person, municipalityIndex, }: { person: PersonDetailViewModel municipalityIndex: ReadonlyMap }) => ( ) const PersonAssessoradoSection = ({ names }: { names: string[] }) => ( ) const PersonSupporterSection = ({ person, municipalityIndex, }: { person: PersonDetailViewModel municipalityIndex: ReadonlyMap }) => ( ) const PersonActionsSection = ({ person, canDelete, }: { person: PersonDetailViewModel canDelete: boolean }) => { const whatsAppHref = whatsAppHrefForPhone(person.phone) const hasActions = person.leadershipID !== null || whatsAppHref !== null || canDelete if (!hasActions) return null return ( ) } export const PersonDetailSections = ({ person, municipalityIndex, canDelete, }: { person: PersonDetailViewModel municipalityIndex: ReadonlyMap canDelete: boolean }) => (
{person.leadershipID !== null ? ( ) : null} {person.deputyID !== null ? ( ) : null} {person.staff.length > 0 ? ( ) : null} {person.assessoradoNames.length > 0 ? ( ) : null} {person.supporters.length > 0 ? ( ) : null}
)