import Image from 'next/image' import Link from 'next/link' import { cn, getImageUrl } from '@/lib/utils' import { SeriesPill } from '@/components/ui' import { getSeries } from '@/lib/api' import { RichTextRenderer } from './RichTextRenderer' import type { SeriesBlock as SeriesBlockType, Series } from '@/lib/types' type SeriesBlockProps = Omit export async function SeriesBlock({ title, subtitle, displayMode, selectedSeries, layout = 'grid', showDescription = true, }: SeriesBlockProps) { // Fetch series if not using selected mode let items: Series[] = [] if (displayMode === 'selected' && selectedSeries) { items = selectedSeries } else { const seriesData = await getSeries() items = seriesData.docs } if (!items || items.length === 0) return null return (
{/* Section Header */} {(title || subtitle) && (
{title &&

{title}

} {subtitle && (

{subtitle}

)}
)} {/* Series */} {layout === 'featured' ? ( ) : layout === 'list' ? ( ) : ( )}
) } function GridLayout({ items, showDescription, }: { items: Series[] showDescription?: boolean }) { return (
{items.map((series) => ( ))}
) } function ListLayout({ items, showDescription, }: { items: Series[] showDescription?: boolean }) { return (
{items.map((series) => (
{/* Logo/Image */}
{series.logo ? ( {series.title} ) : series.coverImage ? ( {series.title} ) : ( {series.title.slice(0, 2).toUpperCase()} )}
{/* Content */}

{series.title}

{showDescription && series.description && (
)}
))}
) } function FeaturedLayout({ items, showDescription, }: { items: Series[] showDescription?: boolean }) { const [featured, ...rest] = items return (
{/* Featured Series */}
{featured.coverImage && ( {featured.title} )}
{featured.logo && (
)}

{featured.title}

{showDescription && featured.description && (
)}
{/* Other Series */}
{rest.slice(0, 3).map((series) => ( ))}
) } interface SeriesCardProps { series: Series showDescription?: boolean compact?: boolean } function SeriesCard({ series, showDescription, compact }: SeriesCardProps) { const imageUrl = getImageUrl(series.coverImage) || getImageUrl(series.logo) return (
{/* Image */} {!compact && (
{imageUrl && ( {series.title} )}
)} {compact && (
{series.logo ? ( ) : ( {series.title.slice(0, 2).toUpperCase()} )}
)} {/* Content */}

{series.title}

{showDescription && !compact && series.description && (
)}
) }