From 20f6686afc4a5ea02b2fb2b7c1a1f977037e7b2b Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Sat, 4 Oct 2025 12:08:08 +0700 Subject: [PATCH] chore(FE-43): add sorting and setSorting props --- src/components/Table.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) 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,