From 7b41848be8c67c15ec96a9efb8d9147cedfebd85 Mon Sep 17 00:00:00 2001 From: Yevhen Baidiuk Date: Sun, 5 Nov 2023 15:35:31 +0100 Subject: [PATCH] Feature/default channel sorting (#578) * fix * update --- src/client/src/components/table/index.tsx | 4 +++- src/client/src/views/channels/channels/ChannelTable.tsx | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/client/src/components/table/index.tsx b/src/client/src/components/table/index.tsx index cbcb5948..4400e59b 100644 --- a/src/client/src/components/table/index.tsx +++ b/src/client/src/components/table/index.tsx @@ -22,6 +22,7 @@ interface TableProps { filterPlaceholder?: string; withGlobalSort?: boolean; // enables the global search box withSorting?: boolean; // enables columns to be sorted + initSorting?: SortingState; withBorder?: boolean; alignCenter?: boolean; fontSize?: string; @@ -94,9 +95,10 @@ export default function Table({ toggleConfiguration, withGlobalSort = false, withSorting = false, + initSorting, }: TableProps) { const [globalFilter, setGlobalFilter] = useState(''); - const [sorting, setSorting] = useState([]); + const [sorting, setSorting] = useState(initSorting || []); const [isOpen, setIsOpen] = useState(false); const [columnVisibility, setColumnVisibility] = useState( diff --git a/src/client/src/views/channels/channels/ChannelTable.tsx b/src/client/src/views/channels/channels/ChannelTable.tsx index cfe1ebc6..07429d47 100644 --- a/src/client/src/views/channels/channels/ChannelTable.tsx +++ b/src/client/src/views/channels/channels/ChannelTable.tsx @@ -580,6 +580,12 @@ export const ChannelTable = () => { data={tableData} withGlobalSort={true} withSorting={true} + initSorting={[ + { + id: 'balanceBars', + desc: false, + }, + ]} toggleConfiguration={handleToggle} defaultHiddenColumns={hiddenColumnState} filterPlaceholder="channels"