"use client"; import { KomgaBook, KomgaSeries } from "@/types/komga"; import { ChevronLeft, ChevronRight, ImageOff } from "lucide-react"; import Image from "next/image"; import { useRef, useState } from "react"; import { cn } from "@/lib/utils"; interface MediaRowProps { title: string; items: (KomgaSeries | KomgaBook)[]; onItemClick?: (item: KomgaSeries | KomgaBook) => void; } export function MediaRow({ title, items, onItemClick }: MediaRowProps) { const scrollContainerRef = useRef(null); const [showLeftArrow, setShowLeftArrow] = useState(false); const [showRightArrow, setShowRightArrow] = useState(true); const handleScroll = () => { if (!scrollContainerRef.current) return; const { scrollLeft, scrollWidth, clientWidth } = scrollContainerRef.current; setShowLeftArrow(scrollLeft > 0); setShowRightArrow(scrollLeft < scrollWidth - clientWidth - 10); }; const scroll = (direction: "left" | "right") => { if (!scrollContainerRef.current) return; const scrollAmount = direction === "left" ? -400 : 400; scrollContainerRef.current.scrollBy({ left: scrollAmount, behavior: "smooth" }); }; if (!items.length) return null; return (

{title}

{/* Bouton de défilement gauche */} {showLeftArrow && ( )} {/* Conteneur défilant */}
{items.map((item) => ( onItemClick?.(item)} /> ))}
{/* Bouton de défilement droit */} {showRightArrow && ( )}
); } interface MediaCardProps { item: KomgaSeries | KomgaBook; onClick?: () => void; } function MediaCard({ item, onClick }: MediaCardProps) { const [imageError, setImageError] = useState(false); // Déterminer si c'est une série ou un livre const isSeries = "booksCount" in item; const title = isSeries ? 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 ( ); }