mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-14 17:15:18 +00:00
28 lines
1.3 KiB
TypeScript
28 lines
1.3 KiB
TypeScript
import type { CampaignUser } from '@/payload-types'
|
|
|
|
/**
|
|
* Client-safe campaign ROLE predicates — the single source for what each role
|
|
* label means. Server-side actor checks (`isCampaignStaff(user)` etc.) derive
|
|
* from these in `src/utilities/access/shared.ts`; client components (sidebar,
|
|
* nav) use the role-level predicates directly instead of importing the access
|
|
* barrel.
|
|
*/
|
|
export type CampaignRole = CampaignUser['role']
|
|
|
|
/** Staff = coordinator, advisor, or candidate. Leaders are not staff. */
|
|
export const isStaffCampaignRole = (role: CampaignRole): boolean =>
|
|
role === 'coordinator' || role === 'advisor' || role === 'candidate'
|
|
|
|
/** Coordinator or candidate — unrestricted scope (all municipalities, decisions). */
|
|
export const isUnrestrictedCampaignRole = (role: CampaignRole): boolean =>
|
|
role === 'coordinator' || role === 'candidate'
|
|
|
|
/**
|
|
* Communication vertical readers (C153/C193): the communication assessor plus
|
|
* the unrestricted roles. Owns the gate of the whole vertical — acervo de
|
|
* falas, biblioteca de cortes and the private reel library. Deliberately NOT
|
|
* part of `isStaffCampaignRole` — the communicator does not inherit any staff
|
|
* area, only the communication vertical.
|
|
*/
|
|
export const canReadCommunicationCatalog = (role: CampaignRole): boolean =>
|
|
role === 'communicator' || isUnrestrictedCampaignRole(role)
|