Web: Shared: Utils: moved getUserTypeLabel to utilities

This commit is contained in:
Dmitry Sychugov 2024-02-09 13:15:18 +05:00
parent dded438211
commit ed76251daf

View File

@ -37,6 +37,7 @@ import { Encoder } from "./encoder";
import { combineUrl } from "./combineUrl"; import { combineUrl } from "./combineUrl";
import { getCookie } from "./cookie"; import { getCookie } from "./cookie";
import { checkIsSSR } from "./device"; import { checkIsSSR } from "./device";
import { AvatarRole } from "../components/avatar/Avatar.enums";
export const desktopConstants = Object.freeze({ export const desktopConstants = Object.freeze({
domain: !checkIsSSR() && window.location.origin, domain: !checkIsSSR() && window.location.origin,
@ -85,6 +86,26 @@ export const isPublicRoom = () => {
return window.location.pathname === "/rooms/share"; return window.location.pathname === "/rooms/share";
}; };
export const getUserTypeLabel = (
role: AvatarRole | undefined,
t: (key: string) => string,
) => {
switch (role) {
case "owner":
return t("Common:Owner");
case "admin":
return t("Common:DocSpaceAdmin");
case "manager":
return t("Common:RoomAdmin");
case "collaborator":
return t("Common:PowerUser");
case "user":
return t("Common:User");
default:
return t("Common:User");
}
};
export const getShowText = () => { export const getShowText = () => {
const showArticle = localStorage.getItem("showArticle"); const showArticle = localStorage.getItem("showArticle");