From 506b5de586d8a0f49fb328a03ae7319c91bf38f8 Mon Sep 17 00:00:00 2001
From: PavloButynets <123271613+PavloButynets@users.noreply.github.com>
Date: Thu, 28 Nov 2024 22:29:29 +0200
Subject: [PATCH] Rewrote FilterRow to tsx (#2699)
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
---
.../enhanced-table/filter-row/FilterRow.jsx | 32 --------------
.../enhanced-table/filter-row/FilterRow.tsx | 44 +++++++++++++++++++
2 files changed, 44 insertions(+), 32 deletions(-)
delete mode 100644 src/components/enhanced-table/filter-row/FilterRow.jsx
create mode 100644 src/components/enhanced-table/filter-row/FilterRow.tsx
diff --git a/src/components/enhanced-table/filter-row/FilterRow.jsx b/src/components/enhanced-table/filter-row/FilterRow.jsx
deleted file mode 100644
index 1ebc3eafd..000000000
--- a/src/components/enhanced-table/filter-row/FilterRow.jsx
+++ /dev/null
@@ -1,32 +0,0 @@
-import TableRow from '@mui/material/TableRow'
-import TableCell from '@mui/material/TableCell'
-
-import FilterCell from '~/components/enhanced-table/filter-row/filter-cell/FilterCell'
-
-const FilterRow = ({ columns, filter = {}, isSelection }) => {
- const { filters, setFilterByKey, clearFilterByKey } = filter
-
- const filterCells =
- filters &&
- columns.map((column) => (
-
- ))
-
- const emptyCell = isSelection && filters &&
-
- return (
-
- {emptyCell}
- {filterCells}
- {emptyCell}
-
- )
-}
-
-export default FilterRow
diff --git a/src/components/enhanced-table/filter-row/FilterRow.tsx b/src/components/enhanced-table/filter-row/FilterRow.tsx
new file mode 100644
index 000000000..5c640fa07
--- /dev/null
+++ b/src/components/enhanced-table/filter-row/FilterRow.tsx
@@ -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 {
+ columns: TableColumn[]
+ filter?: TableFilter
+ isSelection?: boolean
+}
+const FilterRow = ({
+ columns,
+ filter,
+ isSelection
+}: FilterRowProps) => {
+ const filters = filter?.filters
+ const setFilterByKey = filter?.setFilterByKey
+ const clearFilterByKey = filter?.clearFilterByKey
+
+ const filterCells =
+ filters &&
+ columns.map((column) => (
+
+ ))
+
+ const emptyCell = isSelection && filters &&
+
+ return (
+
+ {emptyCell}
+ {filterCells}
+ {emptyCell}
+
+ )
+}
+
+export default FilterRow