diff --git a/web/modals/threads/members/members-modal.react.js b/web/modals/threads/members/members-modal.react.js --- a/web/modals/threads/members/members-modal.react.js +++ b/web/modals/threads/members/members-modal.react.js @@ -17,10 +17,23 @@ import ThreadMembersList from './members-list.react.js'; import css from './members-modal.css'; import Button from '../../../components/button.react.js'; -import Tabs from '../../../components/tabs-legacy.react.js'; +import Tabs, { type TabData } from '../../../components/tabs.react.js'; import { useSelector } from '../../../redux/redux-utils.js'; import SearchModal from '../../search-modal.react.js'; +type TabType = 'All Members' | 'Admins'; + +const tabsData: $ReadOnlyArray> = [ + { + id: 'All Members', + header: 'All Members', + }, + { + id: 'Admins', + header: 'Admins', + }, +]; + type ContentProps = { +searchText: string, +threadID: string, @@ -28,7 +41,7 @@ function ThreadMembersModalContent(props: ContentProps): React.Node { const { threadID, searchText } = props; - const [tab, setTab] = React.useState<'All Members' | 'Admins'>('All Members'); + const [tab, setTab] = React.useState('All Members'); const threadInfo = useSelector(state => threadInfoSelector(state)[threadID]); const { members: threadMembersNotFiltered } = threadInfo; @@ -57,26 +70,22 @@ [allMembers, roles], ); - const allUsersTab = React.useMemo( - () => ( - - - - ), - [allMembers, threadInfo], + const tabs = React.useMemo( + () => , + [tab], ); - const allAdminsTab = React.useMemo( - () => ( - - - - ), - [adminMembers, threadInfo], - ); + const tabContent = React.useMemo(() => { + if (tab === 'All Members') { + return ( + + ); + } + + return ( + + ); + }, [adminMembers, allMembers, tab, threadInfo]); const { pushModal, popModal } = useModalContext(); @@ -102,17 +111,20 @@ ); }, [canAddMembers, onClickAddMembers]); - return ( -
-
- - {allUsersTab} - {allAdminsTab} - + const threadMembersModalContent = React.useMemo( + () => ( +
+
+ {tabs} + {tabContent} +
+ {addMembersButton}
- {addMembersButton} -
+ ), + [addMembersButton, tabContent, tabs], ); + + return threadMembersModalContent; } type Props = {