"use client" import { useState } from "react" import Link from "next/link" import { ChevronRight, Lock, Unlock, BookOpen } from "lucide-react" import { Part } from "@/lib/book-data" interface ChaptersListProps { parts: Part[] specialSections?: { preface?: { title: string } epilogue?: { title: string } } } export function ChaptersList({ parts, specialSections }: ChaptersListProps) { const [expandedPart, setExpandedPart] = useState(parts.length > 0 ? parts[0].id : null) return (
{/* Special sections - Preface */} {specialSections?.preface && (
{specialSections.preface.title}
免费
)} {/* Parts */}
{parts.map((part) => (
{/* Part header */} {/* Chapters and sections */} {expandedPart === part.id && (
{part.chapters.map((chapter) => (
{/* Chapter title */}

{chapter.title}

{/* Sections */}
{chapter.sections.map((section) => (
{section.isFree ? ( ) : ( )} {section.id} {section.title}
{section.isFree ? ( 免费 ) : ( ¥{section.price} )}
))}
))}
)}
))}
{/* Special sections - Epilogue */} {specialSections?.epilogue && (
{specialSections.epilogue.title}
免费
)}
) }