import * as React from 'react';
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
import { Link } from 'react-router-dom';
import { Text, Widget } from 'soapbox/components/ui';
import AccountContainer from 'soapbox/containers/account_container';
import PlaceholderSidebarSuggestions from 'soapbox/features/placeholder/components/placeholder-sidebar-suggestions';
import { useDismissSuggestion, useSuggestions } from 'soapbox/queries/suggestions';
import type { Account as AccountEntity } from 'soapbox/types/entities';
const messages = defineMessages({
dismissSuggestion: { id: 'suggestions.dismiss', defaultMessage: 'Dismiss suggestion' },
});
interface IWhoToFollowPanel {
limit: number
}
const WhoToFollowPanel = ({ limit }: IWhoToFollowPanel) => {
const intl = useIntl();
const { data: suggestions, isFetching } = useSuggestions();
const dismissSuggestion = useDismissSuggestion();
const suggestionsToRender = suggestions.slice(0, limit);
const handleDismiss = (account: AccountEntity) => {
dismissSuggestion.mutate(account.id);
};
return (
}
action={
View all
}
>
{isFetching ? (
) : (
suggestionsToRender.map((suggestion: any) => (
, but it isn't
id={suggestion.account}
actionIcon={require('@tabler/icons/x.svg')}
actionTitle={intl.formatMessage(messages.dismissSuggestion)}
onActionClick={handleDismiss}
/>
))
)}
);
};
export default WhoToFollowPanel;