Skip to content

Commit

Permalink
add the second generic type of the Table for the column functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Mgrdich committed Feb 18, 2024
1 parent 43923ac commit e2ccaa7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/common/NewTable/ExpanderCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';

import * as S from './Table.styled';

function ExpanderCell<T>({ row }: CellContext<T, unknown>) {
function ExpanderCell<T, V = unknown>({ row }: CellContext<T, V>) {
return (
<S.ExpaderButton
width="16"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/common/NewTable/SelectRowCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { CellContext } from '@tanstack/react-table';
import React from 'react';
import IndeterminateCheckbox from 'components/common/IndeterminateCheckbox/IndeterminateCheckbox';

function SelectRowCell<T>({ row }: CellContext<T, unknown>) {
function SelectRowCell<T, V = unknown>({ row }: CellContext<T, V>) {
return (
<IndeterminateCheckbox
checked={row.getIsSelected()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import IndeterminateCheckbox from 'components/common/IndeterminateCheckbox/IndeterminateCheckbox';
import { HeaderContext } from '@tanstack/react-table';

function SelectRowHeader<T>({ table }: HeaderContext<T, unknown>) {
function SelectRowHeader<T, V = unknown>({ table }: HeaderContext<T, V>) {
return (
<IndeterminateCheckbox
checked={table.getIsAllRowsSelected()}
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/components/common/NewTable/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import ExpanderCell from './ExpanderCell';
import SelectRowCell from './SelectRowCell';
import SelectRowHeader from './SelectRowHeader';

export interface TableProps<TData> {
export interface TableProps<TData, TValue> {
data: TData[];
pageCount?: number;
columns: ColumnDef<TData>[];
columns: ColumnDef<TData, TValue>[];

// Server-side processing: sorting, pagination
serverSideProcessing?: boolean;
Expand Down Expand Up @@ -118,7 +118,7 @@ const getSortingFromSearchParams = (searchParams: URLSearchParams) => {
* - use URLSearchParams to get the pagination and sorting state from the url for your server side processing.
*/

function Table<TData>({
function Table<TData, TValue = unknown>({
data,
pageCount,
columns,
Expand All @@ -134,7 +134,7 @@ function Table<TData>({
onRowHover,
onMouseLeave,
setRowId,
}: TableProps<TData>) {
}: TableProps<TData, TValue>) {
const [searchParams, setSearchParams] = useSearchParams();
const location = useLocation();
const [rowSelection, setRowSelection] = React.useState({});
Expand Down

0 comments on commit e2ccaa7

Please sign in to comment.