import React, { useContext, useEffect } from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; import { highlightSearchedText } from '../../../helpers/utils/settings-search'; import { I18nContext } from '../../../contexts/i18n'; export default function SettingsSearchList({ results, onClickSetting }) { const t = useContext(I18nContext); useEffect(() => { results.forEach((_, i) => { highlightSearchedText(i); }); }, [results]); return (
{Array(5) .fill(undefined) .map((_, i) => { const { image, tab, section } = results[i] || {}; return ( Boolean(image || tab || section) && (
onClickSetting(results[i])} > {tab}
{section}
) ); })} {results.length === 0 && (
{t('settingsSearchMatchingNotFound')}
)}
{t('missingSetting')} {t('missingSettingRequest')}
); } SettingsSearchList.propTypes = { results: PropTypes.array, onClickSetting: PropTypes.func, };