23 lines
654 B
TypeScript
23 lines
654 B
TypeScript
export const ROLE_OPTIONS = ["admin", "manager", "agent", "collaborator"] as const
|
|
|
|
const ADMIN_ROLE = "admin"
|
|
const PORTAL_ROLE = "collaborator"
|
|
const STAFF_ROLES = new Set(["admin", "manager", "agent"])
|
|
|
|
export type RoleOption = (typeof ROLE_OPTIONS)[number]
|
|
|
|
export function normalizeRole(role?: string | null) {
|
|
return role?.toLowerCase() ?? null
|
|
}
|
|
|
|
export function isAdmin(role?: string | null) {
|
|
return normalizeRole(role) === ADMIN_ROLE
|
|
}
|
|
|
|
export function isStaff(role?: string | null) {
|
|
return STAFF_ROLES.has(normalizeRole(role) ?? "")
|
|
}
|
|
|
|
export function isPortalUser(role?: string | null) {
|
|
return normalizeRole(role) === PORTAL_ROLE
|
|
}
|