import React from 'react'; import { defineMessages, useIntl } from 'react-intl'; import { Link } from 'react-router-dom'; import { useAccount } from 'soapbox/api/hooks'; import VerificationBadge from 'soapbox/components/verification-badge'; import { useAppSelector } from 'soapbox/hooks'; import { Card, CardBody, CardTitle, HStack, Stack, Text } from '../../components/ui'; import ActionButton from '../ui/components/action-button'; import { HotKeys } from '../ui/components/hotkeys'; const messages = defineMessages({ heading: { id: 'feed_suggestions.heading', defaultMessage: 'Suggested Profiles' }, viewAll: { id: 'feed_suggestions.view_all', defaultMessage: 'View all' }, }); interface ISuggestionItem { accountId: string } const SuggestionItem: React.FC = ({ accountId }) => { const { account } = useAccount(accountId); if (!account) return null; return ( {account.acct} {account.verified && } @{account.acct}
); }; interface IFeedSuggesetions { statusId: string onMoveUp?: (statusId: string, featured?: boolean) => void onMoveDown?: (statusId: string, featured?: boolean) => void } const FeedSuggestions: React.FC = ({ statusId, onMoveUp, onMoveDown }) => { const intl = useIntl(); const suggestedProfiles = useAppSelector((state) => state.suggestions.items); const isLoading = useAppSelector((state) => state.suggestions.isLoading); if (!isLoading && suggestedProfiles.size === 0) return null; const handleHotkeyMoveUp = (e?: KeyboardEvent): void => { if (onMoveUp) { onMoveUp(statusId); } }; const handleHotkeyMoveDown = (e?: KeyboardEvent): void => { if (onMoveDown) { onMoveDown(statusId); } }; const handlers = { moveUp: handleHotkeyMoveUp, moveDown: handleHotkeyMoveDown, }; return ( {intl.formatMessage(messages.viewAll)} {suggestedProfiles.slice(0, 4).map((suggestedProfile) => ( ))} ); }; export default FeedSuggestions;