From f11e4f6626ff7d891ac19f667bf893d057f54728 Mon Sep 17 00:00:00 2001 From: Ajay Bura Date: Sat, 23 Oct 2021 15:27:54 +0530 Subject: [PATCH] Add option to filter PeopleDrawer Signed-off-by: Ajay Bura --- src/app/organisms/room/PeopleDrawer.jsx | 29 +++++++++++++++++++++++- src/app/organisms/room/PeopleDrawer.scss | 14 ++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/app/organisms/room/PeopleDrawer.jsx b/src/app/organisms/room/PeopleDrawer.jsx index 7cf9a59b..098c4502 100644 --- a/src/app/organisms/room/PeopleDrawer.jsx +++ b/src/app/organisms/room/PeopleDrawer.jsx @@ -17,6 +17,7 @@ import IconButton from '../../atoms/button/IconButton'; import Button from '../../atoms/button/Button'; import ScrollView from '../../atoms/scroll/ScrollView'; import Input from '../../atoms/input/Input'; +import SegmentedControl from '../../atoms/segmented-controls/SegmentedControls'; import PeopleSelector from '../../molecules/people-selector/PeopleSelector'; import AddUserIC from '../../../../public/res/ic/outlined/add-user.svg'; @@ -64,6 +65,7 @@ function PeopleDrawer({ roomId }) { const [itemCount, setItemCount] = useState(PER_PAGE_MEMBER); const [membership, setMembership] = useState('join'); + window.setMemberShip = setMembership; const [memberList, setMemberList] = useState([]); const [searchedMembers, setSearchedMembers] = useState(null); const searchRef = useRef(null); @@ -127,6 +129,10 @@ function PeopleDrawer({ roomId }) { setItemCount(PER_PAGE_MEMBER); asyncSearch.removeListener(asyncSearch.RESULT_SENT, handleSearchData); }; + }, [roomId, membership]); + + useEffect(() => { + setMembership('join'); }, [roomId]); const mList = searchedMembers !== null ? searchedMembers.data : memberList.slice(0, itemCount); @@ -145,6 +151,27 @@ function PeopleDrawer({ roomId }) {
+ { + const getSegmentIndex = { + join: 0, + invite: 1, + ban: 2, + }; + return getSegmentIndex[membership]; + })() + } + segments={[{ text: 'Joined' }, { text: 'Invited' }, { text: 'Banned' }]} + onSelect={(index) => { + const selectSegment = [ + () => setMembership('join'), + () => setMembership('invite'), + () => setMembership('ban'), + ]; + selectSegment[index]?.(); + }} + /> { mList.map((member) => ( No result found! diff --git a/src/app/organisms/room/PeopleDrawer.scss b/src/app/organisms/room/PeopleDrawer.scss index 85a4c12a..5ec90ddb 100644 --- a/src/app/organisms/room/PeopleDrawer.scss +++ b/src/app/organisms/room/PeopleDrawer.scss @@ -85,6 +85,20 @@ .people-drawer__content { padding-top: var(--sp-extra-tight); padding-bottom: calc(2 * var(--sp-normal)); + + & .segmented-controls { + display: flex; + margin-bottom: var(--sp-extra-tight); + margin-left: var(--sp-extra-tight); + [dir=rtl] & { + margin-left: unset; + margin-right: var(--sp-extra-tight); + } + } + & .segment-btn { + flex: 1; + padding: var(--sp-ultra-tight) 0; + } } .people-drawer__load-more { padding: var(--sp-normal);