'use client' import React, { useState, useEffect } from 'react' import Image from '../../../embed-shims/next-image' import { cn } from '../../../utils/cn' import { useImageEdgeColor } from '../../../hooks/ui/use-image-edge-color' import { PlatformBadge } from '../../features/platform-badge' interface PlatformInfo { platform_id?: string id?: string name: string display_name?: string } interface AdminContentCardProps { /** Cover image URL */ imageUrl?: string | null /** Pre-computed placeholder URL used when `imageUrl` is missing or * fails to load. Hub callers pass `useOgPlaceholderUrl({ title })`; embedders * supply their own URL or leave null for a plain background fallback. */ placeholderUrl?: string | null /** Alt text / fallback title */ title: string /** Summary or description text */ summary?: string | null /** Subtitle line (e.g. customer name) */ subtitle?: string | null /** Platform badges */ platforms?: PlatformInfo[] /** Status/info badges rendered after platform badges */ badges?: React.ReactNode /** Meta info row (date, views, etc.) */ meta?: React.ReactNode /** Action buttons row */ actions?: React.ReactNode /** Additional class names */ className?: string } export function AdminContentCard({ imageUrl, placeholderUrl, title, summary, subtitle, platforms, badges, meta, actions, className, }: AdminContentCardProps) { const [imageError, setImageError] = useState(false) const [imageLoaded, setImageLoaded] = useState(false) const displayUrl = (imageUrl && !imageError) ? imageUrl : placeholderUrl const imageBgColor = useImageEdgeColor(displayUrl || null, 'transparent') // Reset loading state when the displayed image URL changes useEffect(() => { setImageLoaded(false) }, [displayUrl]) return (
{/* Cover Image — 3:2 aspect ratio, centered with edge-color fill */}
{displayUrl ? ( <> {!imageLoaded && (
)} {title} setImageLoaded(true)} onError={() => setImageError(true)} /> ) : (
)}
{/* Content */}
{/* Title */}

{title}

{/* Subtitle (optional) */} {subtitle && (

{subtitle}

)} {/* Summary */} {summary && (

{summary}

)} {/* Badges row */} {(Number(platforms?.length) > 0 || badges) && (
{platforms?.map((p) => ( ))} {badges}
)} {/* Meta row */} {meta && (
{meta}
)} {/* Actions — pushed to bottom */} {actions && (
{actions}
)}
) }