"use client" import Link from "next/link" import { BookOpen, BookMarked, BookmarkCheck } from "lucide-react" import { Button } from "@/components/ui/button" import { useAuth } from "@/lib/auth-context" import { useBookmarks } from "@/lib/bookmark-context" import { useRecommendations } from "@/lib/recommendation-context" import { toast } from "sonner" interface NovelDetailActionsProps { novelId: string novelSlug: string firstChapterNumber?: number } export function NovelDetailActions({ novelId, novelSlug, firstChapterNumber }: NovelDetailActionsProps) { const { user } = useAuth() const { isBookmarked, toggleBookmark, getProgress } = useBookmarks() const { isRecommended, toggleRecommendation } = useRecommendations() const bookmarked = isBookmarked(novelId) const recommended = isRecommended(novelId) const progress = getProgress(novelId) const readLink = progress?.lastChapterNumber ? `/truyen/${novelSlug}/${progress.lastChapterNumber}` : firstChapterNumber ? `/truyen/${novelSlug}/${firstChapterNumber}` : "#" const handleRecommend = async () => { try { const result = await toggleRecommendation(novelId) if (result.status === "removed") { toast.success("Đã bỏ đề cử") return } if (result.status === "exists") { toast.info("Bạn đã đề cử truyện này rồi") return } toast.success("Đã đề cử truyện") } catch (error) { toast.error(error instanceof Error ? error.message : "Không thể đề cử truyện") } } return (
{user ? ( ) : ( )} {user ? ( ) : ( )}
) }