"use client" import Link from "next/link" import { ChevronLeft, BookOpen, CheckCircle } from "lucide-react" import { useStore } from "@/lib/store" import { bookData, getAllSections } from "@/lib/book-data" export default function MyPurchasesPage() { const { user, isLoggedIn } = useStore() if (!isLoggedIn || !user) { return (

请先登录

返回首页
) } const allSections = getAllSections() const purchasedCount = user.hasFullBook ? allSections.length : user.purchasedSections.length return (
{/* Header */}
返回

我的购买

{/* Stats */}

{purchasedCount}

已购买章节

{user.hasFullBook ? "全书" : `${purchasedCount}/${allSections.length}`}

{user.hasFullBook ? "已解锁" : "进度"}

{/* Purchased sections */} {user.hasFullBook ? (

您已购买整本书

全部55节内容已解锁,可随时阅读

) : user.purchasedSections.length === 0 ? (

您还没有购买任何章节

去浏览章节
) : (

已购买的章节

{bookData.map((part) => { const purchasedInPart = part.chapters.flatMap((c) => c.sections.filter((s) => user.purchasedSections.includes(s.id)), ) if (purchasedInPart.length === 0) return null return (

{part.title}

{purchasedInPart.map((section) => ( {section.id} {section.title} ))}
) })}
)}
) }