import { PhoneIcon } from 'lucide-react' import Link from 'next/link' import { CampaignTable, CampaignTableHead, 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 { formatBrazilianPhoneInput } from '@/lib/phone' import { supporterVoteIntentionLabels } from '@/utilities/supporterUi' import type { SupporterListItemViewModel } from '@/utilities/supporterViewModels' export type SupporterListProps = { supporters: SupporterListItemViewModel[] } 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', mandatory: true, head: Nome, cellClassName: 'max-w-52 whitespace-normal', cell: (supporter) => ( {supporter.name} ), }, { id: 'city', head: Cidade, cell: (supporter) => supporter.city ?? '—', }, { id: 'municipality', head: Município, cellClassName: 'max-w-48 whitespace-normal', cell: (supporter) => supporter.municipalityName ? ( {supporter.municipalityName} ) : ( Sem município vinculado ), }, { id: 'voteIntention', head: Intenção, cell: (supporter) => { const voteIntentionLabel = supporter.voteIntention ? supporterVoteIntentionLabels[supporter.voteIntention] : null return voteIntentionLabel ? ( {voteIntentionLabel} ) : ( Sem intenção ) }, }, { id: 'phone', head: Telefone, cellClassName: 'tabular-nums', cell: (supporter) => (supporter.phone ? formatBrazilianPhoneInput(supporter.phone) : '—'), }, ] export const SupporterList = ({ supporters }: SupporterListProps) => ( <> {supporters.map((supporter) => ( ))} supporter.id} /> > )
{supporter.city ?? 'Cidade não informada'}
{supporter.municipalityName ? ( {supporter.municipalityName} ) : ( Sem município vinculado )}
{formatBrazilianPhoneInput(supporter.phone)}