diff --git a/src/components/series/BookGrid.tsx b/src/components/series/BookGrid.tsx
index 2914c18..c7ef6df 100644
--- a/src/components/series/BookGrid.tsx
+++ b/src/components/series/BookGrid.tsx
@@ -3,6 +3,8 @@
import { KomgaBook } from "@/types/komga";
import { formatDate } from "@/lib/utils";
import { Cover } from "@/components/ui/cover";
+import { MarkAsReadButton } from "@/components/ui/mark-as-read-button";
+import { useState } from "react";
interface BookGridProps {
books: KomgaBook[];
@@ -40,7 +42,9 @@ const getReadingStatusInfo = (book: KomgaBook) => {
};
export function BookGrid({ books, onBookClick }: BookGridProps) {
- if (!books.length) {
+ const [localBooks, setLocalBooks] = useState(books);
+
+ if (!localBooks.length) {
return (
Aucun tome disponible
@@ -48,33 +52,77 @@ export function BookGrid({ books, onBookClick }: BookGridProps) {
);
}
+ const handleMarkAsRead = (bookId: string) => {
+ setLocalBooks((prevBooks) =>
+ prevBooks.map((book) =>
+ book.id === bookId
+ ? {
+ ...book,
+ readProgress: {
+ ...(book.readProgress || {}),
+ completed: true,
+ readDate: new Date().toISOString(),
+ page: book.media.pagesCount,
+ created: book.readProgress?.created || new Date().toISOString(),
+ lastModified: new Date().toISOString(),
+ },
+ }
+ : book
+ )
+ );
+ };
+
return (
- {books.map((book) => {
+ {localBooks.map((book) => {
const statusInfo = getReadingStatusInfo(book);
+ const isRead = book.readProgress?.completed || false;
+
return (
-