Added Role column to user directory

This commit is contained in:
2026-09-28 10:58:02 +02:00
parent 8eae097e8b
commit ef13117042
4 changed files with 153 additions and 8 deletions
@@ -13,6 +13,7 @@ import {
NotificationPlatform,
NotificationStatus,
EmailStatuses,
UserRole,
} from '../types';
export const formatZAR = (amount: number): string => {
@@ -570,3 +571,80 @@ export const getUserEmail = (userIdOrEmail?: string | number | null): string =>
return str;
};
// ==========================================
// User Role Badges & Formatter
// ==========================================
export const USER_ROLE_OPTIONS = [
{ value: 'Admin', label: 'Admin' },
{ value: 'Executive', label: 'Executive' },
{ value: 'Supervisor', label: 'Supervisor' },
{ value: 'Manager', label: 'Manager' },
{ value: 'Contributor', label: 'Contributor' },
];
export const getUserRoleBadge = (role?: string | number | UserRole | null) => {
if (role === null || role === undefined || role === '') {
return {
label: 'Contributor',
className: 'bg-emerald-500/15 text-emerald-300 border-emerald-500/30',
dot: 'bg-emerald-400',
};
}
const roleStr = String(role).trim().toLowerCase();
// 1. Admin - High-privilege Crimson/Rose
if (roleStr === 'admin' || roleStr === 'superadmin' || roleStr === '1') {
return {
label: 'Admin',
className: 'bg-rose-500/15 text-rose-300 border-rose-500/30 shadow-xs shadow-rose-500/10 font-semibold',
dot: 'bg-rose-400',
};
}
// 2. Executive - Strategic Amber/Gold
if (roleStr === 'executive' || roleStr === '2') {
return {
label: 'Executive',
className: 'bg-amber-500/15 text-amber-300 border-amber-500/30 shadow-xs shadow-amber-500/10 font-semibold',
dot: 'bg-amber-400',
};
}
// 3. Supervisor - Operational Governance Purple/Violet
if (roleStr === 'supervisor' || roleStr === '3') {
return {
label: 'Supervisor',
className: 'bg-purple-500/15 text-purple-300 border-purple-500/30 shadow-xs shadow-purple-500/10 font-semibold',
dot: 'bg-purple-400',
};
}
// 4. Manager - Programme & Project Management Blue/Sky
if (roleStr === 'manager' || roleStr === 'programmemanager' || roleStr === 'projectmanager' || roleStr === '4') {
return {
label: 'Manager',
className: 'bg-blue-500/15 text-blue-300 border-blue-500/30 shadow-xs shadow-blue-500/10 font-semibold',
dot: 'bg-blue-400',
};
}
// 5. Contributor - Execution & Outreach Emerald/Mint
if (roleStr === 'contributor' || roleStr === 'viewer' || roleStr === 'recipientviewer' || roleStr === '5') {
return {
label: 'Contributor',
className: 'bg-emerald-500/15 text-emerald-300 border-emerald-500/30 shadow-xs shadow-emerald-500/10 font-semibold',
dot: 'bg-emerald-400',
};
}
// Fallback for custom formatted role strings
const formatted = roleStr.charAt(0).toUpperCase() + roleStr.slice(1);
return {
label: formatted,
className: 'bg-cyan-500/15 text-cyan-300 border-cyan-500/30',
dot: 'bg-cyan-400',
};
};