import { useAuthContext, useLocalize, useNavScrolling } from '~/hooks'; import { MessageCircle, ArchiveRestore, Archive } from 'lucide-react'; import { useMemo, useState } from 'react'; import { useConversationsInfiniteQuery } from '~/data-provider'; import DeleteButton from '~/components/Conversations/DeleteButton'; import { cn } from '~/utils'; import { Spinner } from '~/components'; import ArchiveButton from '~/components/Conversations/ArchiveButton'; export default function ArchivedChatsTable({ className }: { className?: string }) { const localize = useLocalize(); const { isAuthenticated } = useAuthContext(); const [showLoading, setShowLoading] = useState(false); const { data, fetchNextPage, hasNextPage, isFetchingNextPage } = useConversationsInfiniteQuery( { pageNumber: '1', isArchived: true }, { enabled: isAuthenticated }, ); const { containerRef, moveToTop } = useNavScrolling({ setShowLoading, hasNextPage: hasNextPage, fetchNextPage: fetchNextPage, isFetchingNextPage: isFetchingNextPage, }); const conversations = useMemo( () => data?.pages.flatMap((page) => page.conversations) || [], [data], ); const classProp: { className?: string } = { className: 'p-1 hover:text-black dark:hover:text-white', }; if (className) { classProp.className = className; } if (!conversations || conversations.length === 0) { return
| {localize('com_nav_archive_name')} | {localize('com_nav_archive_created_at')} |
|---|---|
|
|
{new Date(conversation.createdAt).toLocaleDateString('en-US', {
month: 'long',
day: 'numeric',
year: 'numeric',
})}
{conversation.conversationId && (
<>
|