39172-vm/frontend/src/helpers/roleVisibility.ts
Flatlogic Bot 9c59af97be 1
2026-03-13 13:29:01 +00:00

17 lines
643 B
TypeScript

const ADMIN_ROLE_NAMES = ['Administrator', 'Platform Owner', 'Academic Director'];
const INSTRUCTOR_ROLE_NAMES = ['Lead Instructor', 'Teaching Assistant'];
const LEARNER_ROLE_NAMES = ['Learner'];
export const LMS_ROLE_GROUPS = {
admin: ADMIN_ROLE_NAMES,
instructor: INSTRUCTOR_ROLE_NAMES,
learner: LEARNER_ROLE_NAMES,
instructorOrAdmin: [...ADMIN_ROLE_NAMES, ...INSTRUCTOR_ROLE_NAMES],
allLms: [...ADMIN_ROLE_NAMES, ...INSTRUCTOR_ROLE_NAMES, ...LEARNER_ROLE_NAMES],
};
export const userHasAnyRole = (user: any, roleNames?: string[]) => {
if (!roleNames?.length) return true;
return roleNames.includes(user?.app_role?.name);
};