import classNames from 'classnames'; import React, { ReactElement, useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { Button, Icon, InputFilterText, LoadingIndicatorProgress } from '@ohif/ui'; import { Types } from '@ohif/core'; type ItemListComponentProps = { itemLabel: string; itemList: Array; onItemClicked: (item: Types.BaseDataSourceConfigurationAPIItem) => void; }; function ItemListComponent({ itemLabel, itemList, onItemClicked, }: ItemListComponentProps): ReactElement { const { t } = useTranslation('DataSourceConfiguration'); const [filterValue, setFilterValue] = useState(''); useEffect(() => { setFilterValue(''); }, [itemList]); return (
{t(`Select ${itemLabel}`)}
{itemList == null ? ( ) : itemList.length === 0 ? (
{t(`No ${itemLabel} available`)}
) : ( <>
{t(itemLabel)}
{itemList .filter( item => !filterValue || item.name.toLowerCase().includes(filterValue.toLowerCase()) ) .map(item => { const border = 'rounded border-transparent border-b-secondary-light border-[1px] hover:border-primary-light'; return (
{item.name}
); })}
)}
); } export default ItemListComponent;