From 2e2ae1b6bad7bfd52c9931754b71cb030f53f518 Mon Sep 17 00:00:00 2001 From: Sofiia13 Date: Sun, 17 Nov 2024 23:46:40 +0200 Subject: [PATCH 1/3] Rewrote EnumFilter jsx to tsx --- .../{EnumFilter.jsx => EnumFilter.tsx} | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) rename src/components/enhanced-table/enum-filter/{EnumFilter.jsx => EnumFilter.tsx} (74%) diff --git a/src/components/enhanced-table/enum-filter/EnumFilter.jsx b/src/components/enhanced-table/enum-filter/EnumFilter.tsx similarity index 74% rename from src/components/enhanced-table/enum-filter/EnumFilter.jsx rename to src/components/enhanced-table/enum-filter/EnumFilter.tsx index 7ce620dc8..55c20c6e3 100644 --- a/src/components/enhanced-table/enum-filter/EnumFilter.jsx +++ b/src/components/enhanced-table/enum-filter/EnumFilter.tsx @@ -6,7 +6,26 @@ import ClearIcon from '@mui/icons-material/Clear' import useMenu from '~/hooks/use-menu' import FilterCheckbox from '~/components/enhanced-table/filter-checkbox/FilterCheckbox' -const EnumFilter = ({ column, filter, setFilter, clearFilter }) => { +interface FilterEnum { + value: string + label: string +} + +interface EnumFilterProps { + column: { + filterEnum: FilterEnum[] + } + filter: string[] + setFilter: (filter: string[]) => void + clearFilter: () => void +} + +const EnumFilter: React.FC = ({ + column, + filter, + setFilter, + clearFilter +}) => { const { renderMenu, openMenu } = useMenu() const menuItems = column.filterEnum.map((filterEnum) => ( @@ -21,7 +40,8 @@ const EnumFilter = ({ column, filter, setFilter, clearFilter }) => { const endAdornment = ( 0 ? 'visible' : 'hidden'} data-testid='clear-icon-in-filter' onClick={clearFilter} > From 5cb3978bdd40aeb3177338e237f277ac2bbf284b Mon Sep 17 00:00:00 2001 From: Sofiia13 Date: Tue, 19 Nov 2024 00:05:26 +0200 Subject: [PATCH 2/3] Extracted filter.length into a variable --- src/components/enhanced-table/enum-filter/EnumFilter.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/enhanced-table/enum-filter/EnumFilter.tsx b/src/components/enhanced-table/enum-filter/EnumFilter.tsx index 55c20c6e3..6b4c50581 100644 --- a/src/components/enhanced-table/enum-filter/EnumFilter.tsx +++ b/src/components/enhanced-table/enum-filter/EnumFilter.tsx @@ -28,6 +28,8 @@ const EnumFilter: React.FC = ({ }) => { const { renderMenu, openMenu } = useMenu() + const filterLength = filter.length + const menuItems = column.filterEnum.map((filterEnum) => ( = ({ const endAdornment = ( 0 ? 'visible' : 'hidden'} + aria-hidden={filterLength === 0} + className={filterLength > 0 ? 'visible' : 'hidden'} data-testid='clear-icon-in-filter' onClick={clearFilter} > From 796acae555b5b8cff203f1e7b3a607cc775f3442 Mon Sep 17 00:00:00 2001 From: Sofiia13 Date: Tue, 26 Nov 2024 17:31:34 +0200 Subject: [PATCH 3/3] Extracted comparison in a variable isFilterEmpty --- src/components/enhanced-table/enum-filter/EnumFilter.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/enhanced-table/enum-filter/EnumFilter.tsx b/src/components/enhanced-table/enum-filter/EnumFilter.tsx index 6b4c50581..1b22e19b5 100644 --- a/src/components/enhanced-table/enum-filter/EnumFilter.tsx +++ b/src/components/enhanced-table/enum-filter/EnumFilter.tsx @@ -28,7 +28,7 @@ const EnumFilter: React.FC = ({ }) => { const { renderMenu, openMenu } = useMenu() - const filterLength = filter.length + const isFilterEmpty = filter.length === 0 const menuItems = column.filterEnum.map((filterEnum) => ( = ({ const endAdornment = ( 0 ? 'visible' : 'hidden'} + aria-hidden={isFilterEmpty} + className={!isFilterEmpty ? 'visible' : 'hidden'} data-testid='clear-icon-in-filter' onClick={clearFilter} >