@@ -32,7 +32,7 @@ import TableHeader from "@/app/base/components/GenericTable/TableHeader";
3232
3333import "./_index.scss" ;
3434
35- type GenericTableProps < T > = {
35+ type GenericTableProps < T extends { id : string | number } > = {
3636 canSelect ?: boolean ;
3737 columns : ColumnDef < T , Partial < T > > [ ] ;
3838 data : T [ ] ;
@@ -46,7 +46,7 @@ type GenericTableProps<T> = {
4646 setRowSelection ?: Dispatch < SetStateAction < RowSelectionState > > ;
4747} ;
4848
49- const GenericTable = < T , > ( {
49+ const GenericTable = < T extends { id : string | number } > ( {
5050 canSelect = false ,
5151 columns,
5252 data,
@@ -155,8 +155,9 @@ const GenericTable = <T,>({
155155 getCoreRowModel : getCoreRowModel ( ) ,
156156 getGroupedRowModel : getGroupedRowModel ( ) ,
157157 groupedColumnMode : false ,
158- enableRowSelection : true ,
159- enableMultiRowSelection : true ,
158+ enableRowSelection : canSelect ,
159+ enableMultiRowSelection : canSelect ,
160+ getRowId : ( originalRow ) => originalRow . id . toString ( ) ,
160161 } ) ;
161162
162163 return (
@@ -175,15 +176,15 @@ const GenericTable = <T,>({
175176 ) : (
176177 < DynamicTable . Body >
177178 { table . getRowModel ( ) . rows . map ( ( row ) => {
178- const { getIsGrouped, id, index , getVisibleCells } = row ;
179+ const { getIsGrouped, id, getVisibleCells } = row ;
179180 const isIndividualRow = ! getIsGrouped ( ) ;
180181 return (
181182 < tr
182183 className = { classNames ( {
183184 "individual-row" : isIndividualRow ,
184185 "group-row" : ! isIndividualRow ,
185186 } ) }
186- key = { id + index }
187+ key = { id }
187188 >
188189 { getVisibleCells ( )
189190 . filter ( ( cell ) => filterCells ( row , cell . column ) )
0 commit comments