mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-16 20:13:04 +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.
64 lines
2.1 KiB
TypeScript
64 lines
2.1 KiB
TypeScript
import {
|
|
CalendarDaysIcon,
|
|
HandshakeIcon,
|
|
HomeIcon,
|
|
InboxIcon,
|
|
MapPinIcon,
|
|
Users2Icon,
|
|
UsersIcon,
|
|
type LucideIcon,
|
|
} from 'lucide-react'
|
|
|
|
import type { CampaignUser } from '@/payload-types'
|
|
import { isCampaignStaff } from '@/utilities/campaignAccess'
|
|
import { canAccessSupporterArea } from '@/utilities/supporterUi'
|
|
|
|
export type CampaignNavItem = {
|
|
title: string
|
|
href: string
|
|
icon: LucideIcon
|
|
}
|
|
|
|
const staffNav: CampaignNavItem[] = [
|
|
{ title: 'Início', href: '/campanha', icon: HomeIcon },
|
|
{ title: 'Municípios', href: '/campanha/municipios', icon: MapPinIcon },
|
|
{ title: 'Lideranças', href: '/campanha/liderancas', icon: HandshakeIcon },
|
|
{ title: 'Dobradinhas', href: '/campanha/dobradinhas', icon: Users2Icon },
|
|
{ title: 'Planos', href: '/campanha/planos', icon: CalendarDaysIcon },
|
|
{ title: 'Demandas', href: '/campanha/demandas', icon: InboxIcon },
|
|
{ title: 'Apoiadores', href: '/campanha/apoiadores', icon: UsersIcon },
|
|
]
|
|
|
|
const leaderNav: CampaignNavItem[] = [
|
|
{ title: 'Início', href: '/campanha', icon: HomeIcon },
|
|
{ title: 'Meus contatos', href: '/campanha', icon: UsersIcon },
|
|
]
|
|
|
|
export const getCampaignNav = (role: CampaignUser['role']): CampaignNavItem[] => {
|
|
if (role === 'leader') return leaderNav
|
|
|
|
return staffNav.filter(
|
|
(item) => item.href !== '/campanha/apoiadores' || canAccessSupporterArea(role),
|
|
)
|
|
}
|
|
|
|
/**
|
|
* Compact set for the mobile bottom bar (max 5 items with a home slot).
|
|
*/
|
|
export const getCampaignBottomNav = (role: CampaignUser['role']): CampaignNavItem[] => {
|
|
const nav = getCampaignNav(role)
|
|
if (role === 'leader') return nav
|
|
|
|
return nav.filter((item) => item.href !== '/campanha/apoiadores').slice(0, 5)
|
|
}
|
|
|
|
/** Home matches only exactly; other items also match nested paths. */
|
|
export const isCampaignNavActive = (pathname: string, href: string): boolean => {
|
|
if (href === '/campanha') {
|
|
return pathname === '/campanha' || pathname === '/campanha/'
|
|
}
|
|
return pathname === href || pathname.startsWith(`${href}/`)
|
|
}
|
|
|
|
export const isCampaignStaffRole = (role: CampaignUser['role']): boolean =>
|
|
isCampaignStaff({ collection: 'campaignUser', role } as CampaignUser)
|