Client: fix import util

This commit is contained in:
Timofey Boyko 2024-02-01 18:02:05 +03:00
parent 70b8c66f24
commit a8f5f8b261
4 changed files with 26 additions and 24 deletions

View File

@ -18,7 +18,7 @@ import {
StyledDeleteIcon,
StyledInviteUserBody,
} from "../StyledInvitePanel";
import { filterUserRoleOptions } from "SRC_DIR/helpers/utils";
import { filterUserRoleOptions } from "SRC_DIR/helpers";
import AccessSelector from "./AccessSelector";
const Item = ({

View File

@ -0,0 +1,24 @@
import { TUser } from "@docspace/shared/api/people/types";
import { ShareAccessRights } from "@docspace/shared/enums";
export const filterUserRoleOptions = (
options: { access: ShareAccessRights; key: string }[],
currentUser: TUser,
withRemove = false
) => {
if (!options) return options;
let newOptions = [...options];
if (currentUser?.isAdmin || currentUser?.isOwner) {
newOptions = newOptions.filter(
(o) =>
+o.access === ShareAccessRights.RoomManager ||
+o.access === ShareAccessRights.None ||
(withRemove && (o.key === "s2" || o.key === "remove"))
);
return newOptions;
}
return newOptions;
};

View File

@ -207,25 +207,3 @@ export const getCategoryUrl = (categoryType, folderId = null) => {
throw new Error("Unknown category type");
}
};
export const filterUserRoleOptions = (
options,
currentUser,
withRemove = false
) => {
if (!options) return options;
let newOptions = [...options];
if (currentUser?.isAdmin || currentUser?.isOwner) {
newOptions = newOptions.filter(
(o) =>
+o.access === ShareAccessRights.RoomManager ||
+o.access === ShareAccessRights.None ||
(withRemove && (o.key === "s2" || o.key === "remove"))
);
return newOptions;
}
return newOptions;
};

View File

@ -8,7 +8,7 @@ import DefaultUserPhotoUrl from "PUBLIC_DIR/images/default_user_photo_size_82-82
import { toastr } from "@docspace/shared/components/toast";
import { isMobileOnly, isMobile } from "react-device-detect";
import { decode } from "he";
import { filterUserRoleOptions } from "SRC_DIR/helpers/utils";
import { filterUserRoleOptions } from "SRC_DIR/helpers";
import { capitalize } from "lodash";
import { getUserRole } from "@docspace/shared/utils/common";