Fix permissions handling with react context

Signed-off-by: Émile Ré <nemile.re@gmail.com>
This commit is contained in:
Émile Ré
2025-12-02 17:11:02 +04:00
parent accc8292b5
commit e65097f248
57 changed files with 609 additions and 840 deletions

View File

@@ -65,3 +65,4 @@ export { fileType, fileSize } from "./file";
export { formatDatetime, formatDate } from "./date";
export { getLogoUrl, getTrustCenterUrl } from "./trustCenter";
export { formatError, type GraphQLError } from "./error";
export { Role, getAssignableRoles } from "./roles";

View File

@@ -0,0 +1,19 @@
export enum Role {
OWNER = "OWNER",
ADMIN = "ADMIN",
VIEWER = "VIEWER",
}
export function getAssignableRoles(currentRole: Role): string[] {
if (!currentRole) return [];
if (currentRole === "OWNER") {
return ["OWNER", "ADMIN", "VIEWER"];
}
if (currentRole === "ADMIN") {
return ["ADMIN", "VIEWER"];
}
return [];
}