"use client" import Link from "next/link" import { BookOpen, BookMarked, Trash2 } from "lucide-react" import { Button } from "@/components/ui/button" import { useAuth } from "@/lib/auth-context" import { useBookmarks } from "@/lib/bookmark-context" import { getNovelById } from "@/lib/data" export default function BookshelfPage() { const { user } = useAuth() const { bookmarks, toggleBookmark } = useBookmarks() if (!user) { return (

Tủ Sách

Đăng nhập để xem danh sách truyện đã lưu

) } const bookmarkedNovels = bookmarks .map((b) => { const novel = getNovelById(b.novelId) return novel ? { novel, bookmark: b } : null }) .filter(Boolean) as Array<{ novel: NonNullable>; bookmark: typeof bookmarks[number] }> return (

Tủ Sách

{bookmarkedNovels.length === 0 ? (

Chưa có truyện nào

Hãy thêm truyện yêu thích vào tủ sách của bạn.

) : (
{bookmarkedNovels.map(({ novel, bookmark }) => { const readLink = bookmark.lastChapterNumber ? `/truyen/${novel.slug}/${bookmark.lastChapterNumber}` : `/truyen/${novel.slug}/1` return (
{novel.title}

{novel.authorName}

{bookmark.lastChapterNumber && (

Đang đọc: Chương {bookmark.lastChapterNumber} / {novel.totalChapters}

)}
) })}
)}
) }