-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrote FilterRow to tsx Sonar issues fixed: 'columns' is missing in props validation 'filter' is missing in props validation 'isSelection' is missing in props validation 'columns.map' is missing in props validation
- Loading branch information
1 parent
00cf787
commit f36973b
Showing
2 changed files
with
44 additions
and
32 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import TableRow from '@mui/material/TableRow' | ||
import TableCell from '@mui/material/TableCell' | ||
|
||
import FilterCell from '~/components/enhanced-table/filter-row/filter-cell/FilterCell' | ||
import { TableColumn, TableFilter } from '~/types' | ||
|
||
interface FilterRowProps<I, F> { | ||
columns: TableColumn<I>[] | ||
filter?: TableFilter<F> | ||
isSelection?: boolean | ||
} | ||
const FilterRow = <I, F>({ | ||
columns, | ||
filter, | ||
isSelection | ||
}: FilterRowProps<I, F>) => { | ||
const filters = filter?.filters | ||
const setFilterByKey = filter?.setFilterByKey | ||
const clearFilterByKey = filter?.clearFilterByKey | ||
|
||
const filterCells = | ||
filters && | ||
columns.map((column) => ( | ||
<FilterCell | ||
clearFilter={clearFilterByKey?.(column.field as keyof F)} | ||
column={column} | ||
filter={filters[column.field as keyof F]} | ||
key={column.field} | ||
setFilter={setFilterByKey?.(column.field as keyof F)} | ||
/> | ||
)) | ||
|
||
const emptyCell = isSelection && filters && <TableCell /> | ||
|
||
return ( | ||
<TableRow> | ||
{emptyCell} | ||
{filterCells} | ||
{emptyCell} | ||
</TableRow> | ||
) | ||
} | ||
|
||
export default FilterRow |