cleanup
This commit is contained in:
40
apps/website/lib/utilities/LeagueRoleUtility.ts
Normal file
40
apps/website/lib/utilities/LeagueRoleUtility.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { LeagueRole } from '@/lib/types/LeagueRole';
|
||||
|
||||
export class LeagueRoleUtility {
|
||||
static isLeagueOwnerRole(role: LeagueRole): boolean {
|
||||
return role === 'owner';
|
||||
}
|
||||
|
||||
static isLeagueAdminRole(role: LeagueRole): boolean {
|
||||
return role === 'admin';
|
||||
}
|
||||
|
||||
static isLeagueStewardRole(role: LeagueRole): boolean {
|
||||
return role === 'steward';
|
||||
}
|
||||
|
||||
static isLeagueMemberRole(role: LeagueRole): boolean {
|
||||
return role === 'member';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true for roles that should be treated as having elevated permissions.
|
||||
* This keeps UI logic open for future roles like steward, streamer, sponsor.
|
||||
*/
|
||||
static isLeagueAdminOrHigherRole(role: LeagueRole): boolean {
|
||||
return role === 'owner' || role === 'admin' || role === 'steward';
|
||||
}
|
||||
|
||||
/**
|
||||
* Ordering helper for sorting memberships in tables.
|
||||
*/
|
||||
static getLeagueRoleOrder(role: LeagueRole): number {
|
||||
const order: Record<LeagueRole, number> = {
|
||||
owner: 0,
|
||||
admin: 1,
|
||||
steward: 2,
|
||||
member: 3,
|
||||
};
|
||||
return order[role] ?? 99;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user