diff --git a/src/components/Table.tsx b/src/components/Table.tsx index 100fb595..882c1fe1 100644 --- a/src/components/Table.tsx +++ b/src/components/Table.tsx @@ -11,6 +11,8 @@ import { useReactTable, ColumnDef, FilterFn, + SortingState, + OnChangeFn, } from '@tanstack/react-table'; import { rankItem } from '@tanstack/match-sorter-utils'; import { Icon } from '@iconify/react'; @@ -43,6 +45,8 @@ export interface TableProps { onFuzzySearchValueChange?: (value: string) => void; className?: TableClassNames; emptyContent?: ReactNode; + sorting?: SortingState; + setSorting?: OnChangeFn; } const DUMMY_SKELETON_DATA = [{}, {}, {}, {}, {}]; @@ -78,6 +82,8 @@ const Table = ({ paginationClassName: '', }, emptyContent = emptyContentDefaultValue, + sorting, + setSorting, }: TableProps) => { const isServerSideTable = totalItems !== undefined && @@ -105,9 +111,11 @@ const Table = ({ getSortedRowModel: getSortedRowModel(), getPaginationRowModel: getPaginationRowModel(), onPaginationChange: setPagination, + onSortingChange: setSorting, state: { pagination, globalFilter: fuzzySearchValue, + sorting, }, filterFns: { fuzzy: fuzzyFilter,