import { PhoneIcon } from 'lucide-react' import Link from 'next/link' import { CampaignTable, type CampaignTableColumn } from '@/components/campaign/shared/CampaignTable' import { Badge } from '@/components/ui/Badge' import { Button } from '@/components/ui/button' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' import { toCampaignColumnPickerColumns, type CampaignColumnVisibility, } from '@/lib/campaignColumnVisibility' import { formatBrazilianPhoneInput } from '@/lib/phone' import { supporterVoteIntentionLabels } from '@/utilities/supporter/supporterUi' import type { SupporterListItemViewModel } from '@/utilities/supporter/supporterViewModels' export type SupporterListProps = { supporters: SupporterListItemViewModel[] columnVisibility: CampaignColumnVisibility empty?: React.ReactNode } const voteIntentionBadgeVariant = ( voteIntention: SupporterListItemViewModel['voteIntention'], ): 'estimate-confirmed' | 'estimate-pending' | 'secondary' | 'outline' => { if (voteIntention === 'certo' || voteIntention === 'tende_a_certo') return 'estimate-confirmed' if (voteIntention === 'indeciso') return 'estimate-pending' if (voteIntention === 'outro') return 'secondary' return 'outline' } const SupporterCard = ({ supporter }: { supporter: SupporterListItemViewModel }) => { const voteIntentionLabel = supporter.voteIntention ? supporterVoteIntentionLabels[supporter.voteIntention] : null return ( {supporter.name} {voteIntentionLabel ? ( {voteIntentionLabel} ) : ( Sem intenção )} {supporter.city ?? 'Cidade não informada'} {supporter.municipalityName ? ( {supporter.municipalityName} ) : ( Sem município vinculado )} {supporter.phone ? ( {formatBrazilianPhoneInput(supporter.phone)} ) : null} Abrir ficha ) } const supporterColumns: Array> = [ { id: 'name', label: 'Nome', mandatory: true, cellClassName: 'max-w-52 whitespace-normal', cell: (supporter) => ( {supporter.name} ), }, { id: 'city', label: 'Cidade', cell: (supporter) => supporter.city ?? '—', }, { // B197 — born hidden by default; the picker can turn it on. The mobile // card keeps no email (unchanged surface). id: 'email', label: 'E-mail', cellClassName: 'max-w-56 whitespace-normal', cell: (supporter) => (supporter.email ? supporter.email : '—'), }, { id: 'municipality', label: 'Município', cellClassName: 'max-w-48 whitespace-normal', cell: (supporter) => supporter.municipalityName ? ( {supporter.municipalityName} ) : ( Sem município vinculado ), }, { id: 'voteIntention', label: 'Intenção', cell: (supporter) => { const voteIntentionLabel = supporter.voteIntention ? supporterVoteIntentionLabels[supporter.voteIntention] : null return voteIntentionLabel ? ( {voteIntentionLabel} ) : ( Sem intenção ) }, }, { id: 'phone', label: 'Telefone', cellClassName: 'tabular-nums', cell: (supporter) => (supporter.phone ? formatBrazilianPhoneInput(supporter.phone) : '—'), }, ] export const supporterPickerColumns = toCampaignColumnPickerColumns(supporterColumns) export const SupporterList = ({ supporters, columnVisibility, empty }: SupporterListProps) => ( <> {supporters.length === 0 ? empty : null} {supporters.map((supporter) => ( ))} supporter.id} empty={empty} /> > )
{supporter.city ?? 'Cidade não informada'}
{supporter.municipalityName ? ( {supporter.municipalityName} ) : ( Sem município vinculado )}
{formatBrazilianPhoneInput(supporter.phone)}