teqo/src/components/campaign/shell/nav.ts
Cursor Agent 10377d90fb feat(campanha): remove mobile bottom nav (B73)
Remove CampaignBottomNav and getCampaignBottomNav — mobile navigation
is now sidebar-only (Sheet via SidebarTrigger). Drop the pb-24 padding
that reserved space for the fixed bar; scroll uses symmetric p-4 on mobile.

Impeccable: N/A (shell chrome removal, class B per plan).

Plan: docs/plans/remover-bottom-nav-mobile.md
2026-07-30 22:13:07 +00:00

85 lines
3.2 KiB
TypeScript

import {
BookOpenIcon,
CalendarDaysIcon,
HandshakeIcon,
HomeIcon,
InboxIcon,
LayoutDashboardIcon,
MapIcon,
MapPinIcon,
UserCogIcon,
Users2Icon,
UsersIcon,
type LucideIcon,
} from 'lucide-react'
import { LEADER_CONTACTS_HOME } from '@/lib/campaignPaths'
import { isStaffCampaignRole, isUnrestrictedCampaignRole } from '@/lib/campaignRoles'
import type { CampaignUser } from '@/payload-types'
import { canAccessSupporterArea } from '@/utilities/supporter/supporterUi'
export type CampaignNavItem = {
title: string
href: string
icon: LucideIcon
}
/**
* Named because the sidebar has to recognize this one item to hang B18's saved
* filters under it, and a third spelling that silently no-ops when it drifts is
* the failure mode this codebase keeps paying for.
*/
export const MUNICIPALITY_NAV_HREF = '/campanha/municipios'
const staffNav: CampaignNavItem[] = [
{ title: 'Início', href: '/campanha', icon: HomeIcon },
{ title: 'Quadro', href: '/campanha/quadro', icon: LayoutDashboardIcon },
{ title: 'Municípios', href: MUNICIPALITY_NAV_HREF, icon: MapPinIcon },
{ title: 'Territórios', href: '/campanha/territorios', icon: MapIcon },
{ title: 'Lideranças', href: '/campanha/liderancas', icon: HandshakeIcon },
{ title: 'Dobradinhas', href: '/campanha/dobradinhas', icon: Users2Icon },
{ title: 'Atividades', href: '/campanha/atividades', icon: CalendarDaysIcon },
{ title: 'Demandas', href: '/campanha/demandas', icon: InboxIcon },
{ title: 'Apoiadores', href: '/campanha/apoiadores', icon: UsersIcon },
{ title: 'Assessores', href: '/campanha/assessores', icon: UserCogIcon },
]
/**
* Reference material, not a place to work: sits in its own group at the foot
* of the sidebar, below the destinations.
* Staff-only — every documented number is one a `leader` never sees.
*
* The href is a literal, not an import from `campaignIntelligenceConcepts.ts`:
* this module reaches client components (`CampaignSidebar`), and that one
* carries the full glossary content — pulling it in for a single path string
* would put the whole glossary in the client bundle.
*/
const staffSecondaryNav: CampaignNavItem[] = [
{ title: 'Conceitos', href: '/campanha/conceitos', icon: BookOpenIcon },
]
const leaderNav: CampaignNavItem[] = [
{ title: 'Início', href: '/campanha', icon: HomeIcon },
{ title: 'Meus contatos', href: LEADER_CONTACTS_HOME, icon: UsersIcon },
]
export const getCampaignNav = (role: CampaignUser['role']): CampaignNavItem[] => {
if (role === 'leader') return leaderNav
return staffNav.filter((item) => {
if (item.href === '/campanha/apoiadores') return canAccessSupporterArea(role)
if (item.href === '/campanha/assessores') return isUnrestrictedCampaignRole(role)
return true
})
}
export const getCampaignSecondaryNav = (role: CampaignUser['role']): CampaignNavItem[] =>
isStaffCampaignRole(role) ? staffSecondaryNav : []
/** 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}/`)
}