import { Card, CardContent, CardHeader } from '@/components/ui/card'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; import { Bookmark as BookmarkIcon, MessageSquare, FileText, Trash2, ExternalLink, } from 'lucide-react'; import { Bookmark, BookmarkType } from '@opchan/core'; import { useUserDisplay } from '@/hooks'; import { cn } from '@opchan/core'; import { formatDistanceToNow } from 'date-fns'; import { useNavigate } from 'react-router-dom'; interface BookmarkCardProps { bookmark: Bookmark; onRemove: (bookmarkId: string) => void; onNavigate?: (bookmark: Bookmark) => void; className?: string; } export function BookmarkCard({ bookmark, onRemove, onNavigate, className, }: BookmarkCardProps) { const authorInfo = useUserDisplay(bookmark.author || ''); const navigate = useNavigate(); const handleNavigate = () => { if (onNavigate) { onNavigate(bookmark); } else { // Default navigation behavior 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 handleRemove = (e: React.MouseEvent) => { e.stopPropagation(); onRemove(bookmark.id); }; return (
{bookmark.type === BookmarkType.POST ? ( ) : ( )} {bookmark.type === BookmarkType.POST ? 'Post' : 'Comment'}
{/* Title/Content Preview */}

{bookmark.title || 'Untitled'}

{/* Author and Metadata */}
by {authorInfo.displayName}
{formatDistanceToNow(new Date(bookmark.createdAt), { addSuffix: true, })}
{/* Additional Context */} {bookmark.cellId && (
Cell: {bookmark.cellId}
)}
); } interface BookmarkListProps { bookmarks: Bookmark[]; onRemove: (bookmarkId: string) => void; onNavigate?: (bookmark: Bookmark) => void; emptyMessage?: string; className?: string; } export function BookmarkList({ bookmarks, onRemove, onNavigate, emptyMessage = 'No bookmarks yet', className, }: BookmarkListProps) { if (bookmarks.length === 0) { return (

{emptyMessage}

Bookmark posts and comments you want to revisit later. Your bookmarks are saved locally and won't be shared.

); } return (
{bookmarks.map(bookmark => ( ))}
); }