import React, { useEffect } from 'react'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; import { createSelector } from 'reselect'; import { setupListAdder, resetListAdder } from 'soapbox/actions/lists'; import { CardHeader, CardTitle, Modal } from 'soapbox/components/ui'; import AccountContainer from 'soapbox/containers/account-container'; import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; import NewListForm from '../lists/components/new-list-form'; import List from './components/list'; import type { List as ImmutableList } from 'immutable'; import type { RootState } from 'soapbox/store'; import type { List as ListEntity } from 'soapbox/types/entities'; const messages = defineMessages({ close: { id: 'lightbox.close', defaultMessage: 'Close' }, subheading: { id: 'lists.subheading', defaultMessage: 'Your lists' }, add: { id: 'lists.new.create', defaultMessage: 'Add List' }, }); // hack const getOrderedLists = createSelector([(state: RootState) => state.lists], lists => { if (!lists) { return lists; } return lists.toList().filter(item => !!item).sort((a, b) => (a as ListEntity).title.localeCompare((b as ListEntity).title)) as ImmutableList; }); interface IListAdder { accountId: string, onClose: (type: string) => void, } const ListAdder: React.FC = ({ accountId, onClose }) => { const intl = useIntl(); const dispatch = useAppDispatch(); const listIds = useAppSelector((state) => getOrderedLists(state).map(list => list.id)); useEffect(() => { dispatch(setupListAdder(accountId)); return () => { dispatch(resetListAdder()); }; }, []); const onClickClose = () => { onClose('LIST_ADDER'); }; return ( } onClose={onClickClose} >

{listIds.map(ListId => )}
); }; export default ListAdder;