import { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import Header from '@/components/Header'; import { BookmarkList } from '@/components/ui/bookmark-card'; import { Button } from '@/components/ui/button'; import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; import { Badge } from '@/components/ui/badge'; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from '@/components/ui/alert-dialog'; import { Bookmark, BookmarkType } from '@opchan/core'; import { Trash2, Bookmark as BookmarkIcon, FileText, MessageSquare, } from 'lucide-react'; import { useAuth, useContent } from '@/hooks'; const BookmarksPage = () => { const { currentUser } = useAuth(); const navigate = useNavigate(); const { bookmarks, removeBookmark, clearAllBookmarks } = useContent(); const [activeTab, setActiveTab] = useState<'all' | 'posts' | 'comments'>( 'all' ); // Redirect to login if not authenticated if (!currentUser) { return (

Authentication Required

Please connect your wallet to view your bookmarks.

); } const postBookmarks = bookmarks.filter( bookmark => bookmark.type === BookmarkType.POST ); const commentBookmarks = bookmarks.filter( bookmark => bookmark.type === BookmarkType.COMMENT ); const getFilteredBookmarks = () => { switch (activeTab) { case 'posts': return postBookmarks; case 'comments': return commentBookmarks; default: return bookmarks; } }; const handleNavigate = (bookmark: Bookmark) => { if (bookmark.type === BookmarkType.POST) { navigate(`/post/${bookmark.targetId}`); } else if (bookmark.type === BookmarkType.COMMENT && bookmark.postId) { navigate(`/post/${bookmark.postId}#comment-${bookmark.targetId}`); } }; const handleClearAll = async () => { await clearAllBookmarks(); }; return (
{/* Header Section */}

My Bookmarks

{bookmarks.length > 0 && ( Clear All Bookmarks Are you sure you want to remove all your bookmarks? This action cannot be undone. Cancel Clear All )}

Your saved posts and comments. Bookmarks are stored locally and won't be shared.

{/* Stats */} {bookmarks.length > 0 && (
{postBookmarks.length} Posts {commentBookmarks.length} Comments {bookmarks.length} Total
)} {/* Tabs */} setActiveTab(value as 'all' | 'posts' | 'comments') } className="w-full" > All ({bookmarks.length}) Posts ({postBookmarks.length}) Comments ({commentBookmarks.length})
); }; export default BookmarksPage;