import { useEffect, useState } from "react"; import { BookOpen, LibraryBig } from "lucide-react"; import type { BookDto, ProgressDto } from "@readabook/shared"; import { api } from "../api/client"; import { FormatPill, LoadingState, Meter, Panel } from "../components/ui"; import { navigate } from "../router"; export function BookPage({ bookId }: { bookId: number }) { const [book, setBook] = useState(null); const [progress, setProgress] = useState(null); useEffect(() => { let alive = true; Promise.all([api.book(bookId), api.progress(bookId)]).then(([nextBook, nextProgress]) => { if (!alive) return; setBook(nextBook); setProgress(nextProgress); }); return () => { alive = false; }; }, [bookId]); if (!book) return ; return (
{book.coverPath ? : }
{book.language ?? "langue inconnue"}

{book.title}

{book.author ?? "Auteur inconnu"}

{book.description ?? "Notice absente du catalogue."}

{progress && }
); }