Skip to content

Commit

Permalink
Added No Filter conditional to FilterChips
Browse files Browse the repository at this point in the history
- Added conditional to render No Filter(s) Applied when no filters are applied.
- Only applies to GlobalAdmins as Regional Admins and Standard Users cannot remove their default filters.
  • Loading branch information
hawkishpolicy committed Dec 2, 2024
1 parent 3e772fd commit 4033bd4
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions frontend/src/pages/Search/FilterTags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,25 +160,30 @@ export const FilterTags: React.FC<Props> = ({ filters, removeFilter }) => {

return (
<Root aria-live="polite" aria-atomic="true">
{filtersByColumn.map((filter, idx) => (
{filtersByColumn.length === 0 ? (
<Chip
key={idx}
disabled={disabledFilters?.includes(filter.label)}
color={'primary'}
color="primary"
classes={{ root: classes.chip }}
label={`${filter.label}: ${filter.value}`}
onDelete={() => {
if (filter.onClear) {
console.log('custom clear');
filter.onClear();
return;
}
filter.values.forEach((val) => {
removeFilter(filter.field, val, filter.type);
});
}}
label="No Filters Applied"
/>
))}
) : (
filtersByColumn.map((filter, idx) => (
<Chip
key={idx}
disabled={disabledFilters?.includes(filter.label)}
color="primary"
classes={{ root: classes.chip }}
label={`${filter.label}: ${filter.value}`}
onDelete={() => {
filter.onClear
? filter.onClear()
: filter.values.forEach((val) =>
removeFilter(filter.field, val, filter.type)
);
}}
/>
))
)}
</Root>
);
};

0 comments on commit 4033bd4

Please sign in to comment.