mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 23:35:45 +00:00
chore(FE-43): add conditional to set sorting and setSorting and add manualSorting props
This commit is contained in:
@@ -47,6 +47,7 @@ export interface TableProps<TData extends object> {
|
|||||||
emptyContent?: ReactNode;
|
emptyContent?: ReactNode;
|
||||||
sorting?: SortingState;
|
sorting?: SortingState;
|
||||||
setSorting?: OnChangeFn<SortingState>;
|
setSorting?: OnChangeFn<SortingState>;
|
||||||
|
manualSorting?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DUMMY_SKELETON_DATA = [{}, {}, {}, {}, {}];
|
const DUMMY_SKELETON_DATA = [{}, {}, {}, {}, {}];
|
||||||
@@ -84,6 +85,7 @@ const Table = <TData extends object>({
|
|||||||
emptyContent = emptyContentDefaultValue,
|
emptyContent = emptyContentDefaultValue,
|
||||||
sorting,
|
sorting,
|
||||||
setSorting,
|
setSorting,
|
||||||
|
manualSorting = false,
|
||||||
}: TableProps<TData>) => {
|
}: TableProps<TData>) => {
|
||||||
const isServerSideTable =
|
const isServerSideTable =
|
||||||
totalItems !== undefined &&
|
totalItems !== undefined &&
|
||||||
@@ -111,11 +113,10 @@ const Table = <TData extends object>({
|
|||||||
getSortedRowModel: getSortedRowModel(),
|
getSortedRowModel: getSortedRowModel(),
|
||||||
getPaginationRowModel: getPaginationRowModel(),
|
getPaginationRowModel: getPaginationRowModel(),
|
||||||
onPaginationChange: setPagination,
|
onPaginationChange: setPagination,
|
||||||
onSortingChange: setSorting,
|
manualSorting,
|
||||||
state: {
|
state: {
|
||||||
pagination,
|
pagination,
|
||||||
globalFilter: fuzzySearchValue,
|
globalFilter: fuzzySearchValue,
|
||||||
sorting,
|
|
||||||
},
|
},
|
||||||
filterFns: {
|
filterFns: {
|
||||||
fuzzy: fuzzyFilter,
|
fuzzy: fuzzyFilter,
|
||||||
@@ -128,6 +129,14 @@ const Table = <TData extends object>({
|
|||||||
tableOptions.getFilteredRowModel = getFilteredRowModel();
|
tableOptions.getFilteredRowModel = getFilteredRowModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sorting && setSorting) {
|
||||||
|
tableOptions.onSortingChange = setSorting;
|
||||||
|
tableOptions.state = {
|
||||||
|
...tableOptions.state,
|
||||||
|
sorting,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const table = useReactTable(tableOptions);
|
const table = useReactTable(tableOptions);
|
||||||
const { setPageSize } = table;
|
const { setPageSize } = table;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user