diff --git a/devbook.md b/devbook.md index c3499e3..1895bbf 100644 --- a/devbook.md +++ b/devbook.md @@ -99,7 +99,7 @@ Créer une application web moderne avec Next.js permettant de lire des fichiers - [x] Responsive design - [x] Page d'accueil - [x] Présentation des fonctionnalités principales - - [ ] Liste des collections récentes + - [x] Liste des collections récentes - [ ] Barre de recherche - [ ] Filtres avancés - [ ] Tri personnalisable diff --git a/src/app/books/[bookId]/page.tsx b/src/app/books/[bookId]/page.tsx index acbe952..31ea0a6 100644 --- a/src/app/books/[bookId]/page.tsx +++ b/src/app/books/[bookId]/page.tsx @@ -30,6 +30,7 @@ export default function BookPage({ params }: { params: { bookId: string } }) { } const data = await response.json(); setData(data); + setIsReading(true); } catch (error) { console.error("Erreur:", error); setError(error instanceof Error ? error.message : "Une erreur est survenue"); @@ -41,12 +42,9 @@ export default function BookPage({ params }: { params: { bookId: string } }) { fetchBookData(); }, [params.bookId]); - const handleStartReading = () => { - setIsReading(true); - }; - const handleCloseReader = () => { setIsReading(false); + router.back(); }; if (isLoading) { @@ -76,85 +74,76 @@ export default function BookPage({ params }: { params: { bookId: string } }) { const { book, pages } = data; + if (isReading) { + return ; + } + return ( - <> -
- {/* En-tête du tome */} -
- {/* Couverture */} -
-
- {!imageError ? ( - {`Couverture setImageError(true)} - /> - ) : ( -
- -
- )} -
+
+ {/* En-tête du tome */} +
+ {/* Couverture */} +
+
+ {!imageError ? ( + {`Couverture setImageError(true)} + /> + ) : ( +
+ +
+ )} +
+
+ + {/* Informations */} +
+
+

+ {book.metadata.title || `Tome ${book.metadata.number}`} +

+

+ {book.seriesTitle} - Tome {book.metadata.number} +

- {/* Informations */} -
-
-

- {book.metadata.title || `Tome ${book.metadata.number}`} -

-

- {book.seriesTitle} - Tome {book.metadata.number} -

-
+ {book.metadata.summary && ( +

{book.metadata.summary}

+ )} - {book.metadata.summary && ( -

{book.metadata.summary}

+
+ {book.metadata.releaseDate && ( +
+ Date de sortie :{" "} + {new Date(book.metadata.releaseDate).toLocaleDateString()} +
+ )} + {book.metadata.authors?.length > 0 && ( +
+ Auteurs :{" "} + {book.metadata.authors + .map((author) => `${author.name} (${author.role})`) + .join(", ")} +
+ )} + {book.size && ( +
+ Taille : {book.size} +
+ )} + {book.media.pagesCount > 0 && ( +
+ Pages : {book.media.pagesCount} +
)} - -
- {book.metadata.releaseDate && ( -
- Date de sortie :{" "} - {new Date(book.metadata.releaseDate).toLocaleDateString()} -
- )} - {book.metadata.authors?.length > 0 && ( -
- Auteurs :{" "} - {book.metadata.authors - .map((author) => `${author.name} (${author.role})`) - .join(", ")} -
- )} - {book.size && ( -
- Taille : {book.size} -
- )} - {book.media.pagesCount > 0 && ( -
- Pages : {book.media.pagesCount} -
- )} -
- - {/* Bouton de lecture */} -
- - {/* Lecteur */} - {isReading && } - +
); } diff --git a/src/components/home/MediaRow.tsx b/src/components/home/MediaRow.tsx index eb89c82..95f89bd 100644 --- a/src/components/home/MediaRow.tsx +++ b/src/components/home/MediaRow.tsx @@ -89,9 +89,18 @@ function MediaCard({ item, onClick }: MediaCardProps) { ? item.metadata.title : item.metadata.title || `Tome ${item.metadata.number}`; + const handleClick = () => { + console.log("MediaCard - handleClick:", { + itemType: isSeries ? "series" : "book", + itemId: item.id, + itemTitle: title, + }); + onClick?.(); + }; + return ( + {/* Bouton précédent */} {currentPage > 1 && ( )} - {/* Page courante */} -
- {isLoading && ( -
- -
- )} - {!imageError ? ( - {`Page setIsLoading(false)} - onError={() => { - setIsLoading(false); - setImageError(true); - }} - /> - ) : ( -
- + {/* Pages */} +
+ {/* Page courante */} +
+ {isLoading && ( +
+ +
+ )} + {!imageError ? ( + {`Page setIsLoading(false)} + onError={() => { + setIsLoading(false); + setImageError(true); + }} + /> + ) : ( +
+ +
+ )} +
+ + {/* Deuxième page en mode double page */} + {shouldShowDoublePage(currentPage) && ( +
+ {`Page setImageError(true)} + />
)}
@@ -93,7 +150,7 @@ export function BookReader({ book, pages, onClose }: BookReaderProps) { {currentPage < pages.length && ( ))}
); diff --git a/src/components/series/PaginatedBookGrid.tsx b/src/components/series/PaginatedBookGrid.tsx index 5912dcc..ecbba8a 100644 --- a/src/components/series/PaginatedBookGrid.tsx +++ b/src/components/series/PaginatedBookGrid.tsx @@ -15,7 +15,6 @@ interface PaginatedBookGridProps { totalPages: number; totalElements: number; pageSize: number; - onBookClick?: (book: KomgaBook) => void; } export function PaginatedBookGrid({ @@ -25,7 +24,6 @@ export function PaginatedBookGrid({ totalPages, totalElements, pageSize, - onBookClick, }: PaginatedBookGridProps) { const router = useRouter(); const pathname = usePathname(); @@ -66,6 +64,14 @@ export function PaginatedBookGrid({ router.push(`${pathname}?${params.toString()}`); }; + const handleBookClick = (book: KomgaBook) => { + console.log("PaginatedBookGrid - handleBookClick:", { + bookId: book.id, + bookTitle: book.metadata.title, + }); + router.push(`/books/${book.id}`); + }; + // Calcul des indices de début et de fin pour l'affichage const startIndex = (currentPage - 1) * pageSize + 1; const endIndex = Math.min(currentPage * pageSize, totalElements); @@ -117,7 +123,7 @@ export function PaginatedBookGrid({ >