Add Site Safety Assistant (ssa) role replacing reporter, supervisor and capa_owner. Portals move under /ssa (overview, my-reports, incidents, capas). Update RLS, schema, API role checks, notification recipients, nav and tests. Add db/ops/2026-11-06-merge-roles-into-ssa.sql (not yet applied; needs owner go-ahead and a pg_dump first). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
37 lines
764 B
TypeScript
37 lines
764 B
TypeScript
// lib/auth/roles.ts
|
|
// 'ssa' = Site Safety Assistant. Replaces the former reporter, supervisor and capa_owner roles.
|
|
export type UserRole =
|
|
| 'ssa'
|
|
| 'hse'
|
|
| 'management'
|
|
| 'admin'
|
|
|
|
export const ALL_ROLES: UserRole[] = [
|
|
'ssa',
|
|
'hse',
|
|
'management',
|
|
'admin',
|
|
]
|
|
|
|
export const ROLE_LABELS: Record<UserRole, string> = {
|
|
ssa: 'Site Safety Assistant (SSA)',
|
|
hse: 'HSE',
|
|
management: 'Management',
|
|
admin: 'Admin',
|
|
}
|
|
|
|
export const ROLE_HOME: Record<UserRole, string> = {
|
|
ssa: '/ssa',
|
|
hse: '/hse',
|
|
management: '/management',
|
|
admin: '/admin',
|
|
}
|
|
|
|
export function getRoleHome(role: UserRole): string {
|
|
return ROLE_HOME[role]
|
|
}
|
|
|
|
export function isValidRole(value: unknown): value is UserRole {
|
|
return ALL_ROLES.includes(value as UserRole)
|
|
}
|