2024-02-24 12:18:10 -08:00
|
|
|
import React, { FunctionComponent, useEffect, useState } from 'react';
|
|
|
|
|
2024-06-11 00:23:57 +03:00
|
|
|
import Loading from 'components/loading/LoadingComponent';
|
2023-05-01 10:04:13 -04:00
|
|
|
import { appRouter } from '../router/appRouter';
|
2024-02-24 12:18:10 -08:00
|
|
|
import { useSearchSuggestions } from 'hooks/searchHook/useSearchSuggestions';
|
|
|
|
import globalize from 'lib/globalize';
|
|
|
|
import LinkButton from '../../elements/emby-button/LinkButton';
|
|
|
|
|
2021-06-07 11:55:01 -04:00
|
|
|
import '../../elements/emby-button/emby-button';
|
|
|
|
|
2024-02-24 12:18:10 -08:00
|
|
|
type SearchSuggestionsProps = {
|
|
|
|
parentId?: string | null;
|
|
|
|
};
|
2021-06-11 14:49:57 +02:00
|
|
|
|
2024-02-24 12:18:10 -08:00
|
|
|
const SearchSuggestions: FunctionComponent<SearchSuggestionsProps> = ({ parentId }) => {
|
|
|
|
const { isLoading, data: suggestions } = useSearchSuggestions(parentId || undefined);
|
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-02-24 12:18:10 -08:00
|
|
|
{suggestions?.map(item => (
|
2024-09-23 12:01:38 -04:00
|
|
|
<div key={item.Id}>
|
|
|
|
<LinkButton
|
|
|
|
className='button-link'
|
|
|
|
style={{ display: 'inline-block', padding: '0.5em 1em' }}
|
|
|
|
href={appRouter.getRouteUrl(item)}
|
|
|
|
>
|
|
|
|
{item.Name}
|
|
|
|
</LinkButton>
|
|
|
|
</div>
|
2021-06-02 10:00:24 -04:00
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default SearchSuggestions;
|