From 7ea599168cc65f64bbf8c1272aeb93cee5270912 Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Sat, 4 Oct 2025 14:25:29 +0700 Subject: [PATCH] chore(FE-43): add conditional to set sorting and setSorting and add manualSorting props --- src/components/Table.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/Table.tsx b/src/components/Table.tsx index 882c1fe1..cfd77df6 100644 --- a/src/components/Table.tsx +++ b/src/components/Table.tsx @@ -47,6 +47,7 @@ export interface TableProps { emptyContent?: ReactNode; sorting?: SortingState; setSorting?: OnChangeFn; + manualSorting?: boolean; } const DUMMY_SKELETON_DATA = [{}, {}, {}, {}, {}]; @@ -84,6 +85,7 @@ const Table = ({ emptyContent = emptyContentDefaultValue, sorting, setSorting, + manualSorting = false, }: TableProps) => { const isServerSideTable = totalItems !== undefined && @@ -111,11 +113,10 @@ const Table = ({ getSortedRowModel: getSortedRowModel(), getPaginationRowModel: getPaginationRowModel(), onPaginationChange: setPagination, - onSortingChange: setSorting, + manualSorting, state: { pagination, globalFilter: fuzzySearchValue, - sorting, }, filterFns: { fuzzy: fuzzyFilter, @@ -128,6 +129,14 @@ const Table = ({ tableOptions.getFilteredRowModel = getFilteredRowModel(); } + if (sorting && setSorting) { + tableOptions.onSortingChange = setSorting; + tableOptions.state = { + ...tableOptions.state, + sorting, + }; + } + const table = useReactTable(tableOptions); const { setPageSize } = table;