From be7d547719e3d5b560655beddd2acf38b702efad Mon Sep 17 00:00:00 2001 From: Tristan Yang Date: Wed, 31 Aug 2022 18:00:02 +0800 Subject: [PATCH] refactor: manage members --- .../index.tsx} | 126 ++---------------- src/common/component/ManageMembers/styled.js | 102 ++++++++++++++ 2 files changed, 115 insertions(+), 113 deletions(-) rename src/common/component/{ManageMembers.tsx => ManageMembers/index.tsx} (66%) create mode 100644 src/common/component/ManageMembers/styled.js diff --git a/src/common/component/ManageMembers.tsx b/src/common/component/ManageMembers/index.tsx similarity index 66% rename from src/common/component/ManageMembers.tsx rename to src/common/component/ManageMembers/index.tsx index 25f16e9c..6dbece18 100644 --- a/src/common/component/ManageMembers.tsx +++ b/src/common/component/ManageMembers/index.tsx @@ -1,119 +1,18 @@ import { useEffect, FC } from "react"; -import styled from "styled-components"; import Tippy from "@tippyjs/react"; import { hideAll } from "tippy.js"; import toast from "react-hot-toast"; -import { useUpdateUserMutation } from "../../app/services/user"; -import User from "./User"; -import StyledMenu from "./styled/Menu"; -import InviteLink from "./InviteLink"; -import moreIcon from "../../assets/icons/more.svg?url"; -import IconOwner from "../../assets/icons/owner.svg"; -import IconArrowDown from "../../assets/icons/arrow.down.mini.svg"; -import IconCheck from "../../assets/icons/check.sign.svg"; -import useUserOperation from "../hook/useUserOperation"; -import { useAppSelector } from "../../app/store"; - -const StyledWrapper = styled.section` - display: flex; - flex-direction: column; - width: 100%; - .intro { - display: flex; - flex-direction: column; - margin-bottom: 40px; - .title { - font-weight: bold; - font-size: 16px; - line-height: 24px; - color: #374151; - } - .desc { - font-weight: normal; - font-size: 12px; - line-height: 18px; - color: #616161; - } - } - .members { - display: flex; - flex-direction: column; - gap: 4px; - width: 512px; - margin-bottom: 176px; - .member { - width: 100%; - display: flex; - justify-content: space-between; - align-items: center; - padding: 8px 12px; - border-radius: var(--br); - &:hover { - background: #f9fafb; - } - .left { - display: flex; - gap: 8px; - .info { - display: flex; - flex-direction: column; - .name { - font-weight: bold; - font-size: 14px; - line-height: 20px; - color: #52525b; - display: flex; - align-items: center; - gap: 4px; - } - .email { - font-weight: normal; - font-size: 12px; - line-height: 18px; - color: #52525b; - } - } - } - .right { - display: flex; - align-items: center; - gap: 28px; - .role { - font-weight: 500; - font-size: 12px; - line-height: 18px; - text-align: right; - color: #616161; - display: flex; - align-items: center; - gap: 4px; - > .icon { - cursor: pointer; - } - /* override */ - .menu { - min-width: 120px; - .item .icon { - width: 16px; - height: 12px; - } - } - } - .opts { - position: relative; - width: 24px; - height: 24px; - .dots { - cursor: pointer; - } - .menu { - position: absolute; - } - } - } - } - } -`; +import { useUpdateUserMutation } from "../../../app/services/user"; +import User from "../User"; +import StyledWrapper from "./styled"; +import StyledMenu from "../styled/Menu"; +import InviteLink from "../InviteLink"; +import moreIcon from "../../../assets/icons/more.svg?url"; +import IconOwner from "../../../assets/icons/owner.svg"; +import IconArrowDown from "../../../assets/icons/arrow.down.mini.svg"; +import IconCheck from "../../../assets/icons/check.sign.svg"; +import useUserOperation from "../../hook/useUserOperation"; +import { useAppSelector } from "../../../app/store"; interface Props { cid?: number; @@ -148,9 +47,9 @@ const ManageMembers: FC = ({ cid }) => { if (ignore) return; updateUser({ id: uid, is_admin: isAdmin }); }; + const channel = cid ? channels.byId[cid] : null; const uids = channel ? (channel.is_public ? users.ids : channel.members) : users.ids; - return ( {loginUser?.is_admin && } @@ -160,6 +59,7 @@ const ManageMembers: FC = ({ cid }) => { Disabling your account means you can recover it at any time after taking this action.

+
    {uids.map((uid) => { const currUser = users.byId[uid]; diff --git a/src/common/component/ManageMembers/styled.js b/src/common/component/ManageMembers/styled.js new file mode 100644 index 00000000..f4cdd851 --- /dev/null +++ b/src/common/component/ManageMembers/styled.js @@ -0,0 +1,102 @@ +import styled from "styled-components"; +const StyledWrapper = styled.section` + display: flex; + flex-direction: column; + width: 100%; + .intro { + display: flex; + flex-direction: column; + margin-bottom: 40px; + .title { + font-weight: bold; + font-size: 16px; + line-height: 24px; + color: #374151; + } + .desc { + font-weight: normal; + font-size: 12px; + line-height: 18px; + color: #616161; + } + } + .members { + display: flex; + flex-direction: column; + gap: 4px; + width: 512px; + margin-bottom: 176px; + .member { + width: 100%; + display: flex; + justify-content: space-between; + align-items: center; + padding: 8px 12px; + border-radius: var(--br); + &:hover { + background: #f9fafb; + } + .left { + display: flex; + gap: 8px; + .info { + display: flex; + flex-direction: column; + .name { + font-weight: bold; + font-size: 14px; + line-height: 20px; + color: #52525b; + display: flex; + align-items: center; + gap: 4px; + } + .email { + font-weight: normal; + font-size: 12px; + line-height: 18px; + color: #52525b; + } + } + } + .right { + display: flex; + align-items: center; + gap: 28px; + .role { + font-weight: 500; + font-size: 12px; + line-height: 18px; + text-align: right; + color: #616161; + display: flex; + align-items: center; + gap: 4px; + > .icon { + cursor: pointer; + } + /* override */ + .menu { + min-width: 120px; + .item .icon { + width: 16px; + height: 12px; + } + } + } + .opts { + position: relative; + width: 24px; + height: 24px; + .dots { + cursor: pointer; + } + .menu { + position: absolute; + } + } + } + } + } +`; +export default StyledWrapper;