2024-06-11 00:23:57 +03:00
|
|
|
import React, { type FC } from 'react';
|
|
|
|
import { useSearchSuggestions } from 'hooks/searchHook';
|
|
|
|
import Loading from 'components/loading/LoadingComponent';
|
2023-05-01 10:04:13 -04:00
|
|
|
import { appRouter } from '../router/appRouter';
|
2024-08-14 13:31:34 -04:00
|
|
|
import globalize from '../../lib/globalize';
|
2024-06-11 00:23:57 +03:00
|
|
|
import LinkButton from 'elements/emby-button/LinkButton';
|
2021-06-07 11:55:01 -04:00
|
|
|
import '../../elements/emby-button/emby-button';
|
|
|
|
|
2024-06-11 00:23:57 +03:00
|
|
|
interface SearchSuggestionsProps {
|
|
|
|
parentId?: string;
|
|
|
|
}
|
2021-06-11 14:49:57 +02:00
|
|
|
|
2024-06-11 00:23:57 +03:00
|
|
|
const SearchSuggestions: FC<SearchSuggestionsProps> = ({ parentId }) => {
|
|
|
|
const { isLoading, data: suggestions } = useSearchSuggestions(parentId);
|
2021-06-02 10:00:24 -04:00
|
|
|
|
2024-06-11 00:23:57 +03:00
|
|
|
if (isLoading) return <Loading />;
|
2021-06-02 10:00:24 -04:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className='verticalSection searchSuggestions'
|
|
|
|
style={{ textAlign: 'center' }}
|
|
|
|
>
|
|
|
|
<div>
|
|
|
|
<h2 className='sectionTitle padded-left padded-right'>
|
|
|
|
{globalize.translate('Suggestions')}
|
|
|
|
</h2>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className='searchSuggestionsList padded-left padded-right'>
|
2024-06-11 00:23:57 +03:00
|
|
|
{suggestions?.map((item) => (
|
|
|
|
<div key={`suggestion-${item.Id}`}>
|
|
|
|
<LinkButton
|
|
|
|
className='button-link'
|
|
|
|
href={appRouter.getRouteUrl(item)}
|
|
|
|
style={{
|
|
|
|
display: 'inline-block',
|
|
|
|
padding: '0.5em 1em'
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{item.Name}
|
|
|
|
</LinkButton>
|
|
|
|
</div>
|
2021-06-02 10:00:24 -04:00
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default SearchSuggestions;
|