mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-15 18:53:06 +00:00
Rename the operational unit "Praça"/"Núcleo" to "Município" (code identifier `municipality`) and land the 2026-07-23 course changes: - New `candidate` role with unrestricted visibility (`isCampaignStaff` now includes it) alongside coordinator/advisor; leader is locked down to the supporter contact tool only. - Demandas become staff-only; dobradinhas modeled via a `stateDeputy` entity. - Camaçari consolidated to a single município (ZE 170/171 aggregated); Salvador keeps its 19 zone municípios. - Map moves to the staff dashboard; `/campanha/municipios` is list/overview. - Vote pledges keep the declared vs estimated (scenario) asymmetry; leaders never see estimates. Destructive migration for the campaign vertical (drops nucleus/plaza-era tables, wipes campaign rows, seeds 435 municípios). Public-site data untouched. Includes the post-delivery /simplify cleanups: shared reloadStaffActor / reloadCoordinatorActor helpers, req.context cache for getFreshCampaignUser, parallelized dashboard loads, candidate dashboard-copy fix, and dead leader-dashboard / roleKind code removal.
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
export type MunicipalityMapSlugEntry = {
|
|
slug: string
|
|
name: string
|
|
}
|
|
|
|
export type MunicipalitiesByIbgeCode = Record<string, MunicipalityMapSlugEntry[]>
|
|
|
|
export type MunicipalityMapNavigation =
|
|
| { kind: 'none' }
|
|
| { kind: 'navigate'; slug: string }
|
|
| { kind: 'zones' }
|
|
|
|
type MunicipalityForIbgeIndex = {
|
|
slug: string
|
|
name: string
|
|
ibgeCode: string
|
|
}
|
|
|
|
export const buildMunicipalitiesByIbgeCode = (municipalities: MunicipalityForIbgeIndex[]): MunicipalitiesByIbgeCode => {
|
|
const byIbge: MunicipalitiesByIbgeCode = {}
|
|
|
|
for (const municipality of municipalities) {
|
|
const entries = byIbge[municipality.ibgeCode] ?? []
|
|
entries.push({ slug: municipality.slug, name: municipality.name })
|
|
byIbge[municipality.ibgeCode] = entries
|
|
}
|
|
|
|
for (const ibgeCode of Object.keys(byIbge)) {
|
|
byIbge[ibgeCode].sort((left, right) => left.name.localeCompare(right.name, 'pt-BR'))
|
|
}
|
|
|
|
return byIbge
|
|
}
|
|
|
|
export const resolveMunicipalityMapNavigation = (
|
|
ibgeCode: string,
|
|
municipalitiesByIbgeCode: MunicipalitiesByIbgeCode,
|
|
): MunicipalityMapNavigation => {
|
|
const entries = municipalitiesByIbgeCode[ibgeCode]
|
|
if (!entries || entries.length === 0) return { kind: 'none' }
|
|
if (entries.length === 1) return { kind: 'navigate', slug: entries[0].slug }
|
|
return { kind: 'zones' }
|
|
}
|