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 and Made1ra committed Nov 29, 2024
1 parent 00cf787 commit f36973b
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 f36973b

Please sign in to comment.