Skip to content

Commit

Permalink
Rewrote FilterRow to tsx (#2699)
Browse files Browse the repository at this point in the history
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
PavloButynets authored Nov 28, 2024
1 parent 2c4be0b commit 506b5de
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 32 deletions.
32 changes: 0 additions & 32 deletions src/components/enhanced-table/filter-row/FilterRow.jsx

This file was deleted.

44 changes: 44 additions & 0 deletions src/components/enhanced-table/filter-row/FilterRow.tsx
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

0 comments on commit 506b5de

Please sign in to comment.