import { useEffect, useState } from "react"; import { BookOpen, LibraryBig, ScanLine } from "lucide-react"; import { api } from "../api/client"; import type { DashboardData } from "../api/types"; import { bookDisplayTitle, bookVolumeLabel } from "../book/metadata"; import { EmptyState, LoadingState, Meter, Panel } from "../components/ui"; import { navigate } from "../router"; export function HomePage() { const [state, setState] = useState(null); useEffect(() => { let alive = true; Promise.all([api.books(), api.continueReading(), api.libraries(), api.jobs()]) .then(([books, continueReading, libraries, jobs]) => { if (!alive) return; setState({ books, continueReading, libraries, jobs }); }) .catch(() => { if (alive) setState({ books: [], continueReading: [], libraries: [], jobs: [] }); }); return () => { alive = false; }; }, []); if (!state) return ; const renderHomeBook = ( item: DashboardData["books"][number], className = "home-book-card", options: { href?: string; progressPercent?: number } = {} ) => { const volumeLabel = bookVolumeLabel(item); return ( ); }; return (

Reprendre la lecture.

Livres en cours

{state.continueReading.length} lectures
{state.continueReading.length ? (
{state.continueReading.map((item) => renderHomeBook(item.book, "home-book-card continue-tile", { href: `/reader/${item.book.id}`, progressPercent: item.progress.percent }) )}
) : ( )}

Bibliotheques

{state.libraries.map((library) => ( ))}
{state.books.map((book) => renderHomeBook(book))}
); }