import classNames from 'classnames'; import React, { ReactElement, useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useSystem } from '@ohif/core'; import { Button, Icons, InputFilter } from '@ohif/ui-next'; import { Types } from '@ohif/core'; type ItemListComponentProps = { itemLabel: string; itemList: Array; onItemClicked: (item: Types.BaseDataSourceConfigurationAPIItem) => void; }; function ItemListComponent({ itemLabel, itemList, onItemClicked, }: ItemListComponentProps): ReactElement { const { servicesManager } = useSystem(); const { t } = useTranslation('DataSourceConfiguration'); const [filterValue, setFilterValue] = useState(''); useEffect(() => { setFilterValue(''); }, [itemList]); const LoadingIndicatorProgress = servicesManager.services.customizationService.getCustomization( 'ui.loadingIndicatorProgress' ); 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-input border-[1px]'; return (
{item.name}
); })}
)}
); } export default ItemListComponent;