diff --git a/client/src/components/Nav/SettingsTabs/Data/SharedLinks.tsx b/client/src/components/Nav/SettingsTabs/Data/SharedLinks.tsx index cd946c2785..eee7414bc2 100644 --- a/client/src/components/Nav/SettingsTabs/Data/SharedLinks.tsx +++ b/client/src/components/Nav/SettingsTabs/Data/SharedLinks.tsx @@ -12,6 +12,7 @@ import { ExternalLink, } from 'lucide-react'; import type { SharedLinkItem, SharedLinksListParams } from 'librechat-data-provider'; +import type { TranslationKeys } from '~/hooks'; import { OGDialog, useToastContext, @@ -62,14 +63,6 @@ export default function SharedLinks() { 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) => ({ @@ -120,7 +113,7 @@ export default function SharedLinks() { if (validRows.length === 0) { showToast({ - message: localize('com_ui_no_valid_items'), + message: localize('com_ui_no_valid_items' as TranslationKeys), severity: NotificationSeverity.WARNING, }); return; @@ -134,15 +127,15 @@ export default function SharedLinks() { showToast({ message: localize( validRows.length === 1 - ? 'com_ui_shared_link_delete_success' - : 'com_ui_shared_link_bulk_delete_success', + ? ('com_ui_shared_link_delete_success' as TranslationKeys) + : ('com_ui_shared_link_bulk_delete_success' as TranslationKeys), ), severity: NotificationSeverity.SUCCESS, }); } catch (error) { console.error('Failed to delete shared links:', error); showToast({ - message: localize('com_ui_bulk_delete_error'), + message: localize('com_ui_bulk_delete_error' as TranslationKeys), severity: NotificationSeverity.ERROR, }); } @@ -168,26 +161,28 @@ export default function SharedLinks() { () => [ { 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 ( ); }, @@ -218,26 +213,28 @@ export default function SharedLinks() { }, { 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 ( ); }, @@ -300,7 +297,7 @@ export default function SharedLinks() { ), }, ], - [isSmallScreen, localize, queryParams, handleSort], + [isSmallScreen, localize], ); return ( diff --git a/client/src/components/Nav/SettingsTabs/General/ArchivedChatsTable.tsx b/client/src/components/Nav/SettingsTabs/General/ArchivedChatsTable.tsx index d3e4ef22f5..4147db1b93 100644 --- a/client/src/components/Nav/SettingsTabs/General/ArchivedChatsTable.tsx +++ b/client/src/components/Nav/SettingsTabs/General/ArchivedChatsTable.tsx @@ -17,6 +17,7 @@ import { OGDialogContent, } from '@librechat/client'; import type { ConversationListParams, TConversation } from 'librechat-data-provider'; +import type { TranslationKeys } from '~/hooks'; import { useConversationsInfiniteQuery, useDeleteConversationMutation, @@ -56,14 +57,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 +126,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 +176,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 +268,7 @@ export default function ArchivedChatsTable({ }, }, ], - [handleSort, isSmallScreen, localize, queryParams, unarchiveMutation], + [isSmallScreen, localize, unarchiveMutation], ); return (