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.
34 lines
1.3 KiB
TypeScript
34 lines
1.3 KiB
TypeScript
'use client'
|
|
|
|
import { createContext, useContext, useMemo, useState, type ReactNode } from 'react'
|
|
|
|
import { DEFAULT_VOTE_ESTIMATE_SCENARIO, type VoteEstimateScenario } from '@/utilities/voteEstimate'
|
|
|
|
type MunicipalityEstimateScenarioContextValue = {
|
|
scenario: VoteEstimateScenario
|
|
setScenario: (scenario: VoteEstimateScenario) => void
|
|
}
|
|
|
|
const MunicipalityEstimateScenarioContext = createContext<MunicipalityEstimateScenarioContextValue | null>(null)
|
|
|
|
export const MunicipalityEstimateScenarioProvider = ({ children }: { children: ReactNode }) => {
|
|
const [scenario, setScenario] = useState<VoteEstimateScenario>(DEFAULT_VOTE_ESTIMATE_SCENARIO)
|
|
const value = useMemo(() => ({ scenario, setScenario }), [scenario])
|
|
|
|
return (
|
|
<MunicipalityEstimateScenarioContext.Provider value={value}>
|
|
{children}
|
|
</MunicipalityEstimateScenarioContext.Provider>
|
|
)
|
|
}
|
|
|
|
export const useMunicipalityEstimateScenario = (): MunicipalityEstimateScenarioContextValue => {
|
|
const value = useContext(MunicipalityEstimateScenarioContext)
|
|
if (!value) {
|
|
throw new Error('useMunicipalityEstimateScenario must be used within MunicipalityEstimateScenarioProvider')
|
|
}
|
|
return value
|
|
}
|
|
|
|
export const useMunicipalityEstimateScenarioOptional = (): MunicipalityEstimateScenarioContextValue | null =>
|
|
useContext(MunicipalityEstimateScenarioContext)
|