'use client' import Link from 'next/link' import type { ReactNode } from 'react' import { advisorEntriesFromIds, MissingAdvisorBadge, } from '@/components/campaign/municipality/MunicipalityAdvisorAvatarStack' import { MunicipalityLevelBadge } from '@/components/campaign/municipality/MunicipalityLevelBadge' import { MunicipalityListAdvisorsControl } from '@/components/campaign/municipality/MunicipalityListAdvisorsControl' import { MunicipalityListExpectedVotesControl } from '@/components/campaign/municipality/MunicipalityListExpectedVotesControl' import { MunicipalityListGoalCoverageCell } from '@/components/campaign/municipality/MunicipalityListGoalCoverageCell' import { MunicipalityListLeadershipsControl } from '@/components/campaign/municipality/MunicipalityListLeadershipsControl' import { MunicipalityListLevelControl } from '@/components/campaign/municipality/MunicipalityListLevelControl' import { SignalAgeReadout, TerritorialClassCardReadout, } from '@/components/campaign/municipality/MunicipalityListRowReadouts' import { MunicipalityListTrendControl } from '@/components/campaign/municipality/MunicipalityListTrendControl' import { MunicipalityListUpdateControl } from '@/components/campaign/municipality/MunicipalityListUpdateControl' import { MunicipalityPriorityIndicator } from '@/components/campaign/municipality/MunicipalityPriorityIndicator' import { MunicipalityVotePositionReadout } from '@/components/campaign/municipality/MunicipalityVotePositionReadout' import { TerritoryLink } from '@/components/campaign/municipality/TerritoryLink' import { MunicipalityStateDeputyRelationCell, type MunicipalityStateDeputyCreateAction, } from '@/components/campaign/shared/MunicipalityStateDeputyRelationCell' import { Badge } from '@/components/ui/Badge' import { SALVADOR_CITY_AGGREGATE_LABEL } from '@/lib/salvadorCity' import type { CampaignFormActionState } from '@/utilities/campaignFormActionError' import type { StateDeputyRelationOption } from '@/utilities/campaignRelationOptions' import { municipalityGeographyParts } from '@/utilities/municipality/municipalityLabels' import { municipalityColumnLabels } from '@/utilities/municipality/municipalityListUrl' import type { EligibleAdvisorOption, EligibleLeadershipOption, MunicipalityAdvisorSummary, MunicipalityLeadershipSummary, MunicipalityListViewModel, } from '@/utilities/municipality/municipalityViewModels' import { toMunicipalityPledgeCoverageView } from '@/utilities/votePledgeViews' type MunicipalityStaffFormAction = ( state: CampaignFormActionState, formData: FormData, ) => Promise export type MunicipalityListMobileCardsProps = { municipalities: MunicipalityListViewModel[] advisorNamesById: ReadonlyMap /** B155 — contact-name lookup for the Lideranças sheet chips. */ leadershipNamesById: ReadonlyMap isStaffView: boolean isCoordinator: boolean isCampaignUnrestricted: boolean canMoveEngagementLevel: boolean advisorOptions: EligibleAdvisorOption[] /** B155 — every leadership the actor may add, for the Lideranças sheet. */ leadershipOptions: EligibleLeadershipOption[] stateDeputyOptions: StateDeputyRelationOption[] stateDeputyCommitAction: MunicipalityStaffFormAction stateDeputyCreateAction: MunicipalityStateDeputyCreateAction signalFormAction: MunicipalityStaffFormAction emptySlot: ReactNode } /** * B42 mobile cards with sheet-variant quick edits. Wrapped by * `MunicipalityListMobileSection`, which hosts a single shared Drawer. */ export const MunicipalityListMobileCards = ({ municipalities, advisorNamesById, leadershipNamesById, isStaffView, isCoordinator, isCampaignUnrestricted, canMoveEngagementLevel, advisorOptions, leadershipOptions, stateDeputyOptions, stateDeputyCommitAction, stateDeputyCreateAction, signalFormAction, emptySlot, }: MunicipalityListMobileCardsProps) => (
{municipalities.length === 0 ? emptySlot : null} {municipalities.map((municipality) => { const names = advisorEntriesFromIds(municipality.advisorIDs, advisorNamesById).map( (advisor) => advisor.name, ) const position = municipality.votePosition2022 const isPriority = municipality.priority === 'alta' const { region, zoneSuffix } = municipalityGeographyParts(municipality) const isCity = municipality.isCity return (

{municipality.name} {isCity ? Cidade : null}

{isCity ? ( <> {SALVADOR_CITY_AGGREGATE_LABEL} · {region} ) : ( <> {zoneSuffix ? ` ${zoneSuffix}` : null} )}

{position ? ( ) : null}
{!isCity && isPriority && isStaffView ? ( ) : null}
{isStaffView ? (
Classe
{municipalityColumnLabels.goalCoverage}
Votos estimados
{isCity ? ( — ) : ( )}
Nível
{isCity ? ( — ) : canMoveEngagementLevel ? ( ) : ( )}
Tendência
{isCity ? ( Não registrada ) : ( )}
Última atualização
{isCity ? ( // The city never has a signal (nothing is recorded on the // aggregate) — a plain dash, not the cold-signal alert the // readout would paint for a null timestamp. — ) : ( )}
Assessores
{isCity ? ( — ) : isCoordinator ? ( ) : names.length ? ( names.join(', ') ) : ( )}
Lideranças
{isCity ? ( — ) : ( )}
{/* B176 — staff-wide since 2026-08-09; the write stays scoped to the actor's administered municípios (B37/B157). */} {isStaffView ? (
Dobradinhas
{isCity ? ( — ) : ( )}
) : null}
) : null}
) })}
)