import { fetchLibraries, getBookCoverUrl, BookDto, apiFetch } from "../../../lib/api"; import { BookPreview } from "../../components/BookPreview"; import Image from "next/image"; import Link from "next/link"; import { notFound } from "next/navigation"; export const dynamic = "force-dynamic"; async function fetchBook(bookId: string): Promise { try { return await apiFetch(`/books/${bookId}`); } catch { return null; } } export default async function BookDetailPage({ params }: { params: Promise<{ id: string }>; }) { const { id } = await params; const [book, libraries] = await Promise.all([ fetchBook(id), fetchLibraries().catch(() => [] as { id: string; name: string }[]) ]); if (!book) { notFound(); } const library = libraries.find(l => l.id === book.library_id); return ( <>
← Back to books
{`Cover

{book.title}

{book.author && (

by {book.author}

)} {book.series && (

{book.series} {book.volume && Volume {book.volume}}

)}
Format: {book.kind.toUpperCase()}
{book.volume && (
Volume: {book.volume}
)} {book.language && (
Language: {book.language.toUpperCase()}
)} {book.page_count && (
Pages: {book.page_count}
)}
Library: {library?.name || book.library_id}
{book.series && (
Series: {book.series}
)} {book.file_format && (
File Format: {book.file_format.toUpperCase()}
)} {book.file_parse_status && (
Parse Status: {book.file_parse_status}
)} {book.file_path && (
File Path: {book.file_path}
)}
Book ID: {book.id}
Library ID: {book.library_id}
{book.updated_at && (
Updated: {new Date(book.updated_at).toLocaleString()}
)}
{book.page_count && book.page_count > 0 && (
)} ); }