From 35a224b670ac66e1d687a90a870f4750ceda7437 Mon Sep 17 00:00:00 2001 From: Tristan Yang Date: Mon, 5 Dec 2022 11:38:48 +0800 Subject: [PATCH] fix: remove all the delete super admin entries --- src/common/component/ManageMembers/index.tsx | 11 +++++---- src/common/component/Profile/index.tsx | 23 ++++--------------- src/common/hook/useUserOperation.ts | 2 +- src/routes/setting/MyAccount.tsx | 9 ++++---- .../settingChannel/DeleteConfirmModal.tsx | 5 ++-- 5 files changed, 19 insertions(+), 31 deletions(-) diff --git a/src/common/component/ManageMembers/index.tsx b/src/common/component/ManageMembers/index.tsx index 168256a1..b5cbcba0 100644 --- a/src/common/component/ManageMembers/index.tsx +++ b/src/common/component/ManageMembers/index.tsx @@ -19,7 +19,8 @@ interface Props { cid?: number; } const ManageMembers: FC = ({ cid }) => { - const { t } = useTranslation(["member", "common"]); + const { t } = useTranslation("member"); + const { t: ct } = useTranslation(); const { users, channels, loginUser } = useAppSelector((store) => { return { users: store.users, @@ -68,9 +69,9 @@ const ManageMembers: FC = ({ cid }) => { if (!currUser) return null; const { name, email, is_admin } = currUser; const owner = channel && channel.owner == uid; - const switchRoleVisible = loginUser?.is_admin && loginUser.uid !== uid; + const switchRoleVisible = loginUser?.is_admin && loginUser.uid !== uid && uid !== 1; const dotsVisible = email || loginUser?.is_admin; - const canRemove = loginUser?.is_admin && loginUser?.uid != uid; + const canRemove = loginUser?.is_admin && loginUser?.uid != uid && uid !== 1; const canRemoveFromChannel = channel && channel.owner == loginUser?.uid && loginUser?.uid != uid; return ( @@ -132,7 +133,7 @@ const ManageMembers: FC = ({ cid }) => { {email && (
  • - {t("action.copy_email", { ns: "common" })} + {ct("action.copy_email")}
  • )} {canRemoveFromChannel && ( @@ -142,7 +143,7 @@ const ManageMembers: FC = ({ cid }) => { )} {canRemove && (
  • - {t("action.remove", { ns: "common" })} + {ct("action.remove")}
  • )}
    diff --git a/src/common/component/Profile/index.tsx b/src/common/component/Profile/index.tsx index 6ba23558..e5b7ce7c 100644 --- a/src/common/component/Profile/index.tsx +++ b/src/common/component/Profile/index.tsx @@ -2,7 +2,6 @@ import { FC, memo } from "react"; import { NavLink } from "react-router-dom"; import Tippy from "@tippyjs/react"; import IconMessage from "../../../assets/icons/message.svg"; -import IconCall from "../../../assets/icons/call.svg"; import IconMore from "../../../assets/icons/more.svg"; import Avatar from "../Avatar"; import StyledWrapper from "./styled"; @@ -18,10 +17,9 @@ interface Props { } const Profile: FC = ({ uid, type = "embed", cid }) => { - const { t } = useTranslation(["member", "common"]); + const { t } = useTranslation("member"); + const { t: ct } = useTranslation(); const { - canCall, - call, canCopyEmail, copyEmail, removeFromChannel, @@ -44,9 +42,8 @@ const Profile: FC = ({ uid, type = "embed", cid }) => { avatar // introduction = "This guy has nothing to introduce", } = data; - const enableCall = type == "card" && canCall; const canRemoveFromServer = type == "embed" && canRemove; - const hasMore = enableCall || email || canRemoveFromChannel || canRemoveFromServer; + const hasMore = email || canRemoveFromChannel || canRemoveFromServer; return ( @@ -62,12 +59,6 @@ const Profile: FC = ({ uid, type = "embed", cid }) => { {/* */} - {enableCall && ( -
  • - - {t("call")} -
  • - )} {/*
    */} = ({ uid, type = "embed", cid }) => { hideOnClick={true} content={ - {enableCall && ( -
  • - {/* */} - {t("call")} -
  • - )} {canCopyEmail && (
  • {t("copy_email")} @@ -104,7 +89,7 @@ const Profile: FC = ({ uid, type = "embed", cid }) => { >
  • - {t("more", { ns: "common" })} + {ct("more")}
  • diff --git a/src/common/hook/useUserOperation.ts b/src/common/hook/useUserOperation.ts index c1f2de66..c2b91a39 100644 --- a/src/common/hook/useUserOperation.ts +++ b/src/common/hook/useUserOperation.ts @@ -84,7 +84,7 @@ const useUserOperation = ({ uid, cid }: IProps) => { (isAdmin || channel?.owner == loginUid) && uid != channel?.owner; const canCall: boolean = (agoraConfig as AgoraConfig)?.enabled && loginUid != uid; - const canRemove: boolean = isAdmin && loginUid != uid && !cid; + const canRemove: boolean = isAdmin && loginUid != uid && !cid && uid !== 1; return { canDeleteChannel, diff --git a/src/routes/setting/MyAccount.tsx b/src/routes/setting/MyAccount.tsx index 0c9700e0..77e485c9 100644 --- a/src/routes/setting/MyAccount.tsx +++ b/src/routes/setting/MyAccount.tsx @@ -102,7 +102,8 @@ const StyledWrapper = styled.div` `; type EditFields = "name" | "email"; export default function MyAccount() { - const { t } = useTranslation(["member", "common"]); + const { t } = useTranslation("member"); + const { t: ct } = useTranslation(); const [passwordModal, setPasswordModal] = useState(false); const [editModal, setEditModal] = useState(null); const [removeConfirmVisible, setRemoveConfirmVisible] = useState(false); @@ -164,7 +165,7 @@ export default function MyAccount() {
    @@ -173,7 +174,7 @@ export default function MyAccount() { {email}
    @@ -182,7 +183,7 @@ export default function MyAccount() { *********
    diff --git a/src/routes/settingChannel/DeleteConfirmModal.tsx b/src/routes/settingChannel/DeleteConfirmModal.tsx index 4d57bdf4..c632c023 100644 --- a/src/routes/settingChannel/DeleteConfirmModal.tsx +++ b/src/routes/settingChannel/DeleteConfirmModal.tsx @@ -14,6 +14,7 @@ interface Props { const DeleteConfirmModal: FC = ({ id, closeModal }) => { const { t } = useTranslation("setting"); + const { t: ct } = useTranslation(); const navigateTo = useNavigate(); const [deleteChannel, { isLoading, isSuccess }] = useLazyRemoveChannelQuery(); const handleDelete = () => { @@ -38,10 +39,10 @@ const DeleteConfirmModal: FC = ({ id, closeModal }) => { buttons={ <> }