diff --git a/client/src/components/Nav/SettingsTabs/General/ArchivedChatsTable.tsx b/client/src/components/Nav/SettingsTabs/General/ArchivedChatsTable.tsx index d3e4ef22f5..ba0281fc05 100644 --- a/client/src/components/Nav/SettingsTabs/General/ArchivedChatsTable.tsx +++ b/client/src/components/Nav/SettingsTabs/General/ArchivedChatsTable.tsx @@ -56,14 +56,6 @@ export default function ArchivedChatsTable({ refetchOnMount: false, }); - const handleSort = useCallback((sortField: string, sortOrder: 'asc' | 'desc') => { - setQueryParams((prev) => ({ - ...prev, - sortBy: sortField as 'title' | 'createdAt', - sortDirection: sortOrder, - })); - }, []); - const handleFilterChange = useCallback((value: string) => { const encodedValue = encodeURIComponent(value.trim()); setQueryParams((prev) => ({ @@ -133,25 +125,28 @@ export default function ArchivedChatsTable({ () => [ { accessorKey: 'title', - header: () => { - const isSorted = queryParams.sortBy === 'title'; - const sortDirection = queryParams.sortDirection; + header: ({ column }) => { + const sortState = column.getIsSorted(); + let SortIcon = ArrowUpDown; + let ariaSort: 'ascending' | 'descending' | 'none' = 'none'; + if (sortState === 'desc') { + SortIcon = ArrowDown; + ariaSort = 'descending'; + } else if (sortState === 'asc') { + SortIcon = ArrowUp; + ariaSort = 'ascending'; + } return ( ); }, @@ -180,26 +175,28 @@ export default function ArchivedChatsTable({ }, { accessorKey: 'createdAt', - header: () => { - const isSorted = queryParams.sortBy === 'createdAt'; - const sortDirection = queryParams.sortDirection; + header: ({ column }) => { + const sortState = column.getIsSorted(); + let SortIcon = ArrowUpDown; + let ariaSort: 'ascending' | 'descending' | 'none' = 'none'; + if (sortState === 'desc') { + SortIcon = ArrowDown; + ariaSort = 'descending'; + } else if (sortState === 'asc') { + SortIcon = ArrowUp; + ariaSort = 'ascending'; + } return ( ); }, @@ -270,7 +267,7 @@ export default function ArchivedChatsTable({ }, }, ], - [handleSort, isSmallScreen, localize, queryParams, unarchiveMutation], + [isSmallScreen, localize, unarchiveMutation], ); return (