import { PledgeEstimateForm } from '@/components/campaign/votePledge/PledgeEstimateForm' import { Badge } from '@/components/ui/Badge' import { effectivePledgeVotesForScenario, formatVoteEstimateRange, getVoteEstimateForScenario, hasAnyVoteEstimate, } from '@/lib/voteEstimate' import type { CampaignFormActionState } from '@/utilities/campaignFormActionError' import { type StaffPledgeRow } from '@/utilities/votePledgeViews' const voteFormatter = new Intl.NumberFormat('pt-BR') const dateFormatter = new Intl.DateTimeFormat('pt-BR') type MunicipalityPledgesPanelProps = { pledges: StaffPledgeRow[] estimateFormAction: ( state: CampaignFormActionState, formData: FormData, ) => Promise } /** Staff-only: declared vs estimated votes per leadership in this municipality. */ export const MunicipalityPledgesPanel = ({ pledges, estimateFormAction, }: MunicipalityPledgesPanelProps) => { const declaredTotal = pledges.reduce((total, pledge) => total + pledge.declaredVotes, 0) const effectiveTotal = pledges.reduce( (total, pledge) => total + effectivePledgeVotesForScenario(pledge.declaredVotes, pledge.estimatedVotes, 'central'), 0, ) return (

Votos declarados pelas lideranças

A liderança informa quantos votos traz; a assessoria registra a estimativa real em três cenários. A liderança nunca vê o valor estimado.

{pledges.length ? ( <>
Total declarado
{voteFormatter.format(declaredTotal)}
Total estimado (média)
{voteFormatter.format(effectiveTotal)}
) : (

Nenhuma liderança declarou votos neste município ainda.

)}
) }