({
className,
brandColor,
channels = [],
accountId,
api,
handleSelect,
}: {
className?: string;
brandColor: string;
channels: SerializedChannel[];
accountId: string;
api: ApiClient;
handleSelect: (message: SerializedSearchMessage) => void;
})
| 20 | }; |
| 21 | |
| 22 | const SearchBar = ({ |
| 23 | className, |
| 24 | brandColor, |
| 25 | channels = [], |
| 26 | accountId, |
| 27 | api, |
| 28 | handleSelect, |
| 29 | }: { |
| 30 | className?: string; |
| 31 | brandColor: string; |
| 32 | channels: SerializedChannel[]; |
| 33 | accountId: string; |
| 34 | api: ApiClient; |
| 35 | handleSelect: (message: SerializedSearchMessage) => void; |
| 36 | }) => { |
| 37 | const renderSuggestion = ( |
| 38 | searchResult: SerializedSearchMessage, |
| 39 | active: boolean |
| 40 | ) => { |
| 41 | const { body, channelId, author, mentions, messageFormat } = searchResult; |
| 42 | const channel = channels.find((c) => c.id === channelId); |
| 43 | const channelName = channel?.channelName; |
| 44 | |
| 45 | return ( |
| 46 | <div className={styles.suggestion}> |
| 47 | <Suggestion |
| 48 | body={body} |
| 49 | format={messageFormat} |
| 50 | user={author!} |
| 51 | channelName={channelName} |
| 52 | mentions={mentions} |
| 53 | active={active} |
| 54 | /> |
| 55 | </div> |
| 56 | ); |
| 57 | }; |
| 58 | |
| 59 | const fetchResults = async ({ |
| 60 | query, |
| 61 | offset, |
| 62 | limit, |
| 63 | }: { |
| 64 | query: string; |
| 65 | offset: number; |
| 66 | limit: number; |
| 67 | }) => { |
| 68 | const response = await api.searchMessages({ |
| 69 | query, |
| 70 | offset, |
| 71 | limit, |
| 72 | accountId, |
| 73 | }); |
| 74 | return parseResults(response); |
| 75 | }; |
| 76 | |
| 77 | return ( |
| 78 | <Autocomplete |
| 79 | className={className} |
nothing calls this directly
no outgoing calls
no test coverage detected