fix: remove all the delete super admin entries
This commit is contained in:
@@ -19,7 +19,8 @@ interface Props {
|
|||||||
cid?: number;
|
cid?: number;
|
||||||
}
|
}
|
||||||
const ManageMembers: FC<Props> = ({ cid }) => {
|
const ManageMembers: FC<Props> = ({ cid }) => {
|
||||||
const { t } = useTranslation(["member", "common"]);
|
const { t } = useTranslation("member");
|
||||||
|
const { t: ct } = useTranslation();
|
||||||
const { users, channels, loginUser } = useAppSelector((store) => {
|
const { users, channels, loginUser } = useAppSelector((store) => {
|
||||||
return {
|
return {
|
||||||
users: store.users,
|
users: store.users,
|
||||||
@@ -68,9 +69,9 @@ const ManageMembers: FC<Props> = ({ cid }) => {
|
|||||||
if (!currUser) return null;
|
if (!currUser) return null;
|
||||||
const { name, email, is_admin } = currUser;
|
const { name, email, is_admin } = currUser;
|
||||||
const owner = channel && channel.owner == uid;
|
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 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 =
|
const canRemoveFromChannel =
|
||||||
channel && channel.owner == loginUser?.uid && loginUser?.uid != uid;
|
channel && channel.owner == loginUser?.uid && loginUser?.uid != uid;
|
||||||
return (
|
return (
|
||||||
@@ -132,7 +133,7 @@ const ManageMembers: FC<Props> = ({ cid }) => {
|
|||||||
<StyledMenu className="menu">
|
<StyledMenu className="menu">
|
||||||
{email && (
|
{email && (
|
||||||
<li className="item" onClick={copyEmail.bind(null, email)}>
|
<li className="item" onClick={copyEmail.bind(null, email)}>
|
||||||
{t("action.copy_email", { ns: "common" })}
|
{ct("action.copy_email")}
|
||||||
</li>
|
</li>
|
||||||
)}
|
)}
|
||||||
{canRemoveFromChannel && (
|
{canRemoveFromChannel && (
|
||||||
@@ -142,7 +143,7 @@ const ManageMembers: FC<Props> = ({ cid }) => {
|
|||||||
)}
|
)}
|
||||||
{canRemove && (
|
{canRemove && (
|
||||||
<li className="item danger" onClick={removeUser.bind(null, uid)}>
|
<li className="item danger" onClick={removeUser.bind(null, uid)}>
|
||||||
{t("action.remove", { ns: "common" })}
|
{ct("action.remove")}
|
||||||
</li>
|
</li>
|
||||||
)}
|
)}
|
||||||
</StyledMenu>
|
</StyledMenu>
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { FC, memo } from "react";
|
|||||||
import { NavLink } from "react-router-dom";
|
import { NavLink } from "react-router-dom";
|
||||||
import Tippy from "@tippyjs/react";
|
import Tippy from "@tippyjs/react";
|
||||||
import IconMessage from "../../../assets/icons/message.svg";
|
import IconMessage from "../../../assets/icons/message.svg";
|
||||||
import IconCall from "../../../assets/icons/call.svg";
|
|
||||||
import IconMore from "../../../assets/icons/more.svg";
|
import IconMore from "../../../assets/icons/more.svg";
|
||||||
import Avatar from "../Avatar";
|
import Avatar from "../Avatar";
|
||||||
import StyledWrapper from "./styled";
|
import StyledWrapper from "./styled";
|
||||||
@@ -18,10 +17,9 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Profile: FC<Props> = ({ uid, type = "embed", cid }) => {
|
const Profile: FC<Props> = ({ uid, type = "embed", cid }) => {
|
||||||
const { t } = useTranslation(["member", "common"]);
|
const { t } = useTranslation("member");
|
||||||
|
const { t: ct } = useTranslation();
|
||||||
const {
|
const {
|
||||||
canCall,
|
|
||||||
call,
|
|
||||||
canCopyEmail,
|
canCopyEmail,
|
||||||
copyEmail,
|
copyEmail,
|
||||||
removeFromChannel,
|
removeFromChannel,
|
||||||
@@ -44,9 +42,8 @@ const Profile: FC<Props> = ({ uid, type = "embed", cid }) => {
|
|||||||
avatar
|
avatar
|
||||||
// introduction = "This guy has nothing to introduce",
|
// introduction = "This guy has nothing to introduce",
|
||||||
} = data;
|
} = data;
|
||||||
const enableCall = type == "card" && canCall;
|
|
||||||
const canRemoveFromServer = type == "embed" && canRemove;
|
const canRemoveFromServer = type == "embed" && canRemove;
|
||||||
const hasMore = enableCall || email || canRemoveFromChannel || canRemoveFromServer;
|
const hasMore = email || canRemoveFromChannel || canRemoveFromServer;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledWrapper className={type}>
|
<StyledWrapper className={type}>
|
||||||
@@ -62,12 +59,6 @@ const Profile: FC<Props> = ({ uid, type = "embed", cid }) => {
|
|||||||
</li>
|
</li>
|
||||||
</NavLink>
|
</NavLink>
|
||||||
{/* <NavLink to={`#`}> */}
|
{/* <NavLink to={`#`}> */}
|
||||||
{enableCall && (
|
|
||||||
<li className="icon call" onClick={call}>
|
|
||||||
<IconCall />
|
|
||||||
<span className="txt">{t("call")}</span>
|
|
||||||
</li>
|
|
||||||
)}
|
|
||||||
{/* </NavLink> */}
|
{/* </NavLink> */}
|
||||||
<Tippy
|
<Tippy
|
||||||
disabled={!hasMore}
|
disabled={!hasMore}
|
||||||
@@ -78,12 +69,6 @@ const Profile: FC<Props> = ({ uid, type = "embed", cid }) => {
|
|||||||
hideOnClick={true}
|
hideOnClick={true}
|
||||||
content={
|
content={
|
||||||
<StyledMenu>
|
<StyledMenu>
|
||||||
{enableCall && (
|
|
||||||
<li className="item" onClick={call}>
|
|
||||||
{/* <IconCall className="icon" /> */}
|
|
||||||
{t("call")}
|
|
||||||
</li>
|
|
||||||
)}
|
|
||||||
{canCopyEmail && (
|
{canCopyEmail && (
|
||||||
<li className="item" onClick={copyEmail.bind(undefined, email)}>
|
<li className="item" onClick={copyEmail.bind(undefined, email)}>
|
||||||
{t("copy_email")}
|
{t("copy_email")}
|
||||||
@@ -104,7 +89,7 @@ const Profile: FC<Props> = ({ uid, type = "embed", cid }) => {
|
|||||||
>
|
>
|
||||||
<li className={`icon more ${hasMore ? "" : "disabled"}`}>
|
<li className={`icon more ${hasMore ? "" : "disabled"}`}>
|
||||||
<IconMore />
|
<IconMore />
|
||||||
<span className="txt">{t("more", { ns: "common" })}</span>
|
<span className="txt">{ct("more")}</span>
|
||||||
</li>
|
</li>
|
||||||
</Tippy>
|
</Tippy>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ const useUserOperation = ({ uid, cid }: IProps) => {
|
|||||||
(isAdmin || channel?.owner == loginUid) &&
|
(isAdmin || channel?.owner == loginUid) &&
|
||||||
uid != channel?.owner;
|
uid != channel?.owner;
|
||||||
const canCall: boolean = (agoraConfig as AgoraConfig)?.enabled && loginUid != uid;
|
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 {
|
return {
|
||||||
canDeleteChannel,
|
canDeleteChannel,
|
||||||
|
|||||||
@@ -102,7 +102,8 @@ const StyledWrapper = styled.div`
|
|||||||
`;
|
`;
|
||||||
type EditFields = "name" | "email";
|
type EditFields = "name" | "email";
|
||||||
export default function MyAccount() {
|
export default function MyAccount() {
|
||||||
const { t } = useTranslation(["member", "common"]);
|
const { t } = useTranslation("member");
|
||||||
|
const { t: ct } = useTranslation();
|
||||||
const [passwordModal, setPasswordModal] = useState(false);
|
const [passwordModal, setPasswordModal] = useState(false);
|
||||||
const [editModal, setEditModal] = useState<EditFields | null>(null);
|
const [editModal, setEditModal] = useState<EditFields | null>(null);
|
||||||
const [removeConfirmVisible, setRemoveConfirmVisible] = useState(false);
|
const [removeConfirmVisible, setRemoveConfirmVisible] = useState(false);
|
||||||
@@ -164,7 +165,7 @@ export default function MyAccount() {
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<button data-edit="name" onClick={handleBasicEdit} className="btn">
|
<button data-edit="name" onClick={handleBasicEdit} className="btn">
|
||||||
{t("action.edit", { ns: "common" })}
|
{ct("action.edit")}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div className="row">
|
<div className="row">
|
||||||
@@ -173,7 +174,7 @@ export default function MyAccount() {
|
|||||||
<span className="txt">{email}</span>
|
<span className="txt">{email}</span>
|
||||||
</div>
|
</div>
|
||||||
<button data-edit="email" onClick={handleBasicEdit} className="btn">
|
<button data-edit="email" onClick={handleBasicEdit} className="btn">
|
||||||
{t("action.edit", { ns: "common" })}
|
{ct("action.edit")}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div className="row">
|
<div className="row">
|
||||||
@@ -182,7 +183,7 @@ export default function MyAccount() {
|
|||||||
<span className="txt">*********</span>
|
<span className="txt">*********</span>
|
||||||
</div>
|
</div>
|
||||||
<button onClick={togglePasswordModal} className="btn">
|
<button onClick={togglePasswordModal} className="btn">
|
||||||
{t("action.edit", { ns: "common" })}
|
{ct("action.edit")}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ interface Props {
|
|||||||
|
|
||||||
const DeleteConfirmModal: FC<Props> = ({ id, closeModal }) => {
|
const DeleteConfirmModal: FC<Props> = ({ id, closeModal }) => {
|
||||||
const { t } = useTranslation("setting");
|
const { t } = useTranslation("setting");
|
||||||
|
const { t: ct } = useTranslation();
|
||||||
const navigateTo = useNavigate();
|
const navigateTo = useNavigate();
|
||||||
const [deleteChannel, { isLoading, isSuccess }] = useLazyRemoveChannelQuery();
|
const [deleteChannel, { isLoading, isSuccess }] = useLazyRemoveChannelQuery();
|
||||||
const handleDelete = () => {
|
const handleDelete = () => {
|
||||||
@@ -38,10 +39,10 @@ const DeleteConfirmModal: FC<Props> = ({ id, closeModal }) => {
|
|||||||
buttons={
|
buttons={
|
||||||
<>
|
<>
|
||||||
<Button onClick={closeModal.bind(null, undefined)} className="cancel">
|
<Button onClick={closeModal.bind(null, undefined)} className="cancel">
|
||||||
{t("action.cancel", { ns: "common" })}
|
{ct("action.cancel")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={handleDelete} className="danger">
|
<Button onClick={handleDelete} className="danger">
|
||||||
{isLoading ? "Deleting" : t("action.remove", { ns: "common" })}
|
{isLoading ? "Deleting" : ct("action.remove")}
|
||||||
</Button>
|
</Button>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user