"use client" import { useState } from "react" import Link from "next/link" import { RiCheckboxCircleFill } from "react-icons/ri" import { cn } from "@/lib/utils" import { CollectionInfo } from "@/types" import { formatDuration } from "@/lib/formatDuration" import { formatTimeAgo } from "@/lib/formatTimeAgo" import { isCertifiedUser } from "@/app/certification" import { transparentImage } from "@/lib/transparentImage" import { DefaultAvatar } from "../default-avatar" export function CollectionCard({ collection, className = "", layout = "normal", onSelect, index }: { collection: CollectionInfo className?: string layout?: "normal" | "compact" onSelect?: (collection: CollectionInfo) => void index: number }) { const [duration, setDuration] = useState(0) const [channelThumbnail, setChannelThumbnail] = useState(collection.channel.thumbnail) const [collectionThumbnail, setCollectionThumbnail] = useState( `https://huggingface.co./datasets/jbilcke-hf/ai-tube-index/resolve/main/collections/${collection.id}.webp` ) const [collectionThumbnailReady, setCollectionThumbnailReady] = useState(false) const isCompact = layout === "compact" const handleClick = () => { onSelect?.(collection) } const handleBadChannelThumbnail = () => { try { if (channelThumbnail) { setChannelThumbnail("") } } catch (err) { } } return (