Merge pull request #1308 from palashgdev/417-search-filter

feat: condition is updated
This commit is contained in:
Palash 2022-06-23 12:38:28 +05:30 committed by GitHub
commit bc97ea8fc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,6 +39,10 @@ function CommonCheckBox(props: CommonCheckBoxProps): JSX.Element {
});
};
const isMoreButtonAvilable = Boolean(
numberOfFilters && statusObj.length > numberOfFilters,
);
return (
<>
{statusObj.length > 0 && (
@ -62,13 +66,15 @@ function CommonCheckBox(props: CommonCheckBoxProps): JSX.Element {
}
return countA - countB;
})
.filter((_, index) => index < numberOfFilters)
.filter((filter) => {
if (searchFilter.length === 0) {
return true;
}
return filter.includes(searchFilter);
return filter
.toLocaleLowerCase()
.includes(searchFilter.toLocaleLowerCase());
})
.filter((_, index) => index < numberOfFilters)
.map((e) => (
<CheckBoxComponent
key={e}
@ -80,7 +86,7 @@ function CommonCheckBox(props: CommonCheckBoxProps): JSX.Element {
/>
))}
{numberOfFilters && statusObj.length > numberOfFilters && (
{isMoreButtonAvilable && (
<Button onClick={onClickMoreHandler} type="link">
More
</Button>