mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
chore(FE-43): add sorting and setSorting props
This commit is contained in:
@@ -11,6 +11,8 @@ import {
|
|||||||
useReactTable,
|
useReactTable,
|
||||||
ColumnDef,
|
ColumnDef,
|
||||||
FilterFn,
|
FilterFn,
|
||||||
|
SortingState,
|
||||||
|
OnChangeFn,
|
||||||
} from '@tanstack/react-table';
|
} from '@tanstack/react-table';
|
||||||
import { rankItem } from '@tanstack/match-sorter-utils';
|
import { rankItem } from '@tanstack/match-sorter-utils';
|
||||||
import { Icon } from '@iconify/react';
|
import { Icon } from '@iconify/react';
|
||||||
@@ -43,6 +45,8 @@ export interface TableProps<TData extends object> {
|
|||||||
onFuzzySearchValueChange?: (value: string) => void;
|
onFuzzySearchValueChange?: (value: string) => void;
|
||||||
className?: TableClassNames;
|
className?: TableClassNames;
|
||||||
emptyContent?: ReactNode;
|
emptyContent?: ReactNode;
|
||||||
|
sorting?: SortingState;
|
||||||
|
setSorting?: OnChangeFn<SortingState>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DUMMY_SKELETON_DATA = [{}, {}, {}, {}, {}];
|
const DUMMY_SKELETON_DATA = [{}, {}, {}, {}, {}];
|
||||||
@@ -78,6 +82,8 @@ const Table = <TData extends object>({
|
|||||||
paginationClassName: '',
|
paginationClassName: '',
|
||||||
},
|
},
|
||||||
emptyContent = emptyContentDefaultValue,
|
emptyContent = emptyContentDefaultValue,
|
||||||
|
sorting,
|
||||||
|
setSorting,
|
||||||
}: TableProps<TData>) => {
|
}: TableProps<TData>) => {
|
||||||
const isServerSideTable =
|
const isServerSideTable =
|
||||||
totalItems !== undefined &&
|
totalItems !== undefined &&
|
||||||
@@ -105,9 +111,11 @@ const Table = <TData extends object>({
|
|||||||
getSortedRowModel: getSortedRowModel(),
|
getSortedRowModel: getSortedRowModel(),
|
||||||
getPaginationRowModel: getPaginationRowModel(),
|
getPaginationRowModel: getPaginationRowModel(),
|
||||||
onPaginationChange: setPagination,
|
onPaginationChange: setPagination,
|
||||||
|
onSortingChange: setSorting,
|
||||||
state: {
|
state: {
|
||||||
pagination,
|
pagination,
|
||||||
globalFilter: fuzzySearchValue,
|
globalFilter: fuzzySearchValue,
|
||||||
|
sorting,
|
||||||
},
|
},
|
||||||
filterFns: {
|
filterFns: {
|
||||||
fuzzy: fuzzyFilter,
|
fuzzy: fuzzyFilter,
|
||||||
|
|||||||
Reference in New Issue
Block a user