import React from 'react'; import { FormattedMessage } from 'react-intl'; import { Link } from 'react-router-dom'; import { openModal } from 'soapbox/actions/modals'; import GroupCard from 'soapbox/components/group-card'; import ScrollableList from 'soapbox/components/scrollable-list'; import { Button, Stack, Text } from 'soapbox/components/ui'; import { useAppDispatch, useAppSelector, useFeatures } from 'soapbox/hooks'; import { useGroups } from 'soapbox/queries/groups'; import { PERMISSION_CREATE_GROUPS, hasPermission } from 'soapbox/utils/permissions'; import PlaceholderGroupCard from '../placeholder/components/placeholder-group-card'; import TabBar, { TabItems } from './components/tab-bar'; import type { Group as GroupEntity } from 'soapbox/types/entities'; // const getOrderedGroups = createSelector([ // (state: RootState) => state.groups.items, // (state: RootState) => state.group_relationships, // ], (groups, group_relationships) => ({ // groups: (groups.toList().filter((item: GroupEntity | false) => !!item) as ImmutableList) // .map((item) => item.set('relationship', group_relationships.get(item.id) || null)) // .filter((item) => item.relationship?.member) // .sort((a, b) => a.display_name.localeCompare(b.display_name)), // })); const EmptyMessage = () => ( ); const Groups: React.FC = () => { const dispatch = useAppDispatch(); const features = useFeatures(); const canCreateGroup = useAppSelector((state) => hasPermission(state, PERMISSION_CREATE_GROUPS)); const { groups, isLoading } = useGroups(); const createGroup = () => { dispatch(openModal('MANAGE_GROUP')); }; return ( {canCreateGroup && ( )} {features.groupsDiscovery && ( )} } itemClassName='py-3 first:pt-0 last:pb-0' isLoading={isLoading} showLoading={isLoading && groups.length === 0} placeholderComponent={PlaceholderGroupCard} placeholderCount={3} > {groups.map((group) => ( ))} ); }; export default Groups;