"use client"; import { KomgaSeries } from "@/types/komga"; import { Book, ImageOff } from "lucide-react"; import Image from "next/image"; import { useState } from "react"; import { useRouter } from "next/navigation"; interface SeriesGridProps { series: KomgaSeries[]; serverUrl: string; } // Fonction utilitaire pour obtenir les informations de lecture d'une série const getReadingStatusInfo = (series: KomgaSeries) => { const { booksCount, booksReadCount, booksUnreadCount } = series; const booksInProgressCount = booksCount - (booksReadCount + booksUnreadCount); if (booksReadCount === booksCount) { return { label: "Lu", className: "bg-green-500/10 text-green-500", }; } if (booksInProgressCount > 0 || (booksReadCount > 0 && booksReadCount < booksCount)) { return { label: `${booksReadCount}/${booksCount}`, className: "bg-blue-500/10 text-blue-500", }; } return { label: "Non lu", className: "bg-yellow-500/10 text-yellow-500", }; }; export function SeriesGrid({ series, serverUrl }: SeriesGridProps) { const router = useRouter(); if (!series.length) { return (

Aucune série disponible

); } return (
{series.map((series) => ( router.push(`/series/${series.id}`)} serverUrl={serverUrl} /> ))}
); } interface SeriesCardProps { series: KomgaSeries; onClick?: () => void; serverUrl: string; } function SeriesCard({ series, onClick, serverUrl }: SeriesCardProps) { const [imageError, setImageError] = useState(false); const statusInfo = getReadingStatusInfo(series); return ( ); }