import React from 'react'; import { ConversationListItem, PropsData as ConversationListItemPropsType, } from './ConversationListItem'; import { MessageSearchResult, PropsData as MessageSearchResultPropsType, } from './MessageSearchResult'; import { LocalizerType } from '../types/Util'; export type PropsData = { contacts: Array; friends: Array; conversations: Array; hideMessagesHeader: boolean; messages: Array; regionCode: string; searchTerm: string; showStartNewConversation: boolean; }; type PropsHousekeeping = { i18n: LocalizerType; openConversation: (id: string, messageId?: string) => void; }; type Props = PropsData & PropsHousekeeping; export class SearchResults extends React.Component { public render() { const { conversations, contacts, hideMessagesHeader, i18n, messages, openConversation, searchTerm, showStartNewConversation, friends, } = this.props; const haveConversations = conversations && conversations.length; const haveContacts = contacts && contacts.length; const haveFriends = friends && friends.length; const haveMessages = messages && messages.length; const noResults = !showStartNewConversation && !haveConversations && !haveContacts && !haveMessages && !haveFriends; return (
{noResults ? (
{i18n('noSearchResults', [searchTerm])}
) : null} {haveConversations ? (
{i18n('conversationsHeader')}
{conversations.map(conversation => ( ))}
) : null} {haveMessages ? (
{hideMessagesHeader ? null : (
{i18n('messages')}
)} {messages.map(message => ( ))}
) : null}
); } }