mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-21 20:03:08 +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.
57 lines
1.7 KiB
TypeScript
57 lines
1.7 KiB
TypeScript
export const municipalityDetailTabs = [
|
|
'overview',
|
|
'elections',
|
|
'leaderships',
|
|
'updates',
|
|
'demands',
|
|
] as const
|
|
|
|
export type MunicipalityDetailTab = (typeof municipalityDetailTabs)[number]
|
|
export type MunicipalityDetailSearchParams = Record<string, string | string[] | undefined>
|
|
|
|
const tabQueryKeys: Record<MunicipalityDetailTab, readonly string[]> = {
|
|
overview: [],
|
|
elections: ['compare'],
|
|
leaderships: ['leadershipQ', 'leadershipPage'],
|
|
updates: ['updateKind', 'updatePage', 'newUpdate'],
|
|
demands: ['demandStatus'],
|
|
}
|
|
|
|
const firstValue = (value: string | string[] | undefined): string | undefined =>
|
|
Array.isArray(value) ? value[0] : value
|
|
|
|
const appendQueryValue = (
|
|
params: URLSearchParams,
|
|
key: string,
|
|
value: string | string[] | undefined,
|
|
) => {
|
|
for (const item of Array.isArray(value) ? value : [value]) {
|
|
if (item !== undefined) params.append(key, item)
|
|
}
|
|
}
|
|
|
|
const isAllowedTab = (value: string | undefined): value is MunicipalityDetailTab =>
|
|
municipalityDetailTabs.includes(value as MunicipalityDetailTab)
|
|
|
|
export const resolveMunicipalityDetailTab = (
|
|
searchParams: MunicipalityDetailSearchParams,
|
|
): MunicipalityDetailTab => {
|
|
if (firstValue(searchParams.newUpdate) === '1') return 'updates'
|
|
|
|
const requestedTab = firstValue(searchParams.tab)
|
|
return isAllowedTab(requestedTab) ? requestedTab : 'overview'
|
|
}
|
|
|
|
export const buildMunicipalityDetailTabHref = (
|
|
municipalitySlug: string,
|
|
tab: MunicipalityDetailTab,
|
|
searchParams: MunicipalityDetailSearchParams,
|
|
): string => {
|
|
const params = new URLSearchParams()
|
|
for (const key of tabQueryKeys[tab]) {
|
|
appendQueryValue(params, key, searchParams[key])
|
|
}
|
|
params.set('tab', tab)
|
|
|
|
return `/campanha/municipios/${municipalitySlug}?${params.toString()}`
|
|
}
|