import React, { useState } from "react"; import { useAnnotations } from "@/context/AnnotationsContext"; import type { Bookmark } from "@/types"; interface BookmarkListProps { bookId?: string; onNavigateToPage?: (bookId: string, page: number) => void; } export function BookmarkList({ bookId, onNavigateToPage, }: BookmarkListProps): React.ReactElement { const { state, loadBookmarks, removeBookmark } = useAnnotations(); const [deletingId, setDeletingId] = useState(null); React.useEffect(() => { loadBookmarks(bookId); }, [loadBookmarks, bookId]); const handleDelete = async (id: string): Promise => { setDeletingId(id); try { await removeBookmark(id); } catch { // error handled by context } finally { setDeletingId(null); } }; if (state.bookmarksLoading) { return
Loading bookmarks...
; } if (state.bookmarks.length === 0) { return (
No bookmarks yet. Select a passage and add a bookmark while reading.
); } return (
{state.bookmarks.map((bookmark: Bookmark) => (
Bookmark Page {bookmark.page} {new Date(bookmark.created_at).toLocaleDateString()}
{bookmark.location_text && (
“{bookmark.location_text}”
)}
{onNavigateToPage && ( )}
))}
); }