import React, { useEffect } from 'react'; import { defineMessages, useIntl, FormattedMessage } from 'react-intl'; import { useDispatch } from 'react-redux'; import { Link } from 'react-router-dom'; import { createSelector } from 'reselect'; import { fetchGroups } from 'soapbox/actions/groups'; import { openModal } from 'soapbox/actions/modals'; import Icon from 'soapbox/components/icon'; import ScrollableList from 'soapbox/components/scrollable-list'; import { Button, Column, HStack, Spinner } from 'soapbox/components/ui'; import { useAppSelector } from 'soapbox/hooks'; import type { RootState } from 'soapbox/store'; const messages = defineMessages({ heading: { id: 'column.groups', defaultMessage: 'Groups' }, }); const getOrderedGroups = createSelector([ (state: RootState) => state.groups, (state: RootState) => state.group_relationships, ], (groups, group_relationships) => { if (!groups) { return groups; } return groups.toList().filter(item => !!item && group_relationships.get(item.id)?.member).sort((a, b) => a.display_name.localeCompare(b.display_name)); }); const Lists: React.FC = () => { const dispatch = useDispatch(); const intl = useIntl(); const groups = useAppSelector((state) => getOrderedGroups(state)); useEffect(() => { dispatch(fetchGroups()); }, []); const onCreateGroup = () => { dispatch(openModal('MANAGE_GROUP')); }; if (!groups) { return ( ); } const emptyMessage = ; return (
{groups.map((group: any) => ( ))}
); }; export default Lists;