Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rewrite FilterRow to tsx #2699

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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