import { useState } from 'react' import { formatBytes } from '~/lib/util' import type { CreatorPackWithStatus } from '../../types/collections' import classNames from 'classnames' import { IconChevronRight, IconCircleCheck, IconLoader2, IconMovie, IconTrash, } from '@tabler/icons-react' export interface CreatorPackCardProps { pack: CreatorPackWithStatus /** In-session wizard selection highlight (before anything is installed). */ selected?: boolean onClick?: (pack: CreatorPackWithStatus) => void /** When set, an installed pack shows an uninstall control (settings surface only). */ onUninstall?: (pack: CreatorPackWithStatus) => void } const CreatorPackCard: React.FC = ({ pack, selected, onClick, onUninstall }) => { const isInstalled = pack.status === 'installed' const isDownloading = pack.status === 'downloading' const hasUpdate = !!pack.available_update_version const sizeBytes = pack.size_mb * 1024 * 1024 // Installed packs are inert unless a newer version is available (click = update). const clickable = selected || !isInstalled || hasUpdate const highlighted = selected || isDownloading || (isInstalled && !hasUpdate) // Prefer a catalog-supplied banner (future remote creators); otherwise the // banner bundled with the app by pack id. Both are the branded 1060x175 art we // build into the ZIM. Fall back to a simple header only if the image is absent. const [bannerFailed, setBannerFailed] = useState(false) const bannerSrc = pack.banner_url || `/creator-packs/${pack.id}.webp` const statusBadge = selected ? ( Selected ) : isDownloading ? ( Downloading ) : isInstalled ? ( Installed ) : ( Install ) return (
{ if (!clickable) return onClick?.(pack) }} > {!bannerFailed ? ( {pack.name} setBannerFailed(true)} /> ) : (

{pack.name}

)}

{pack.video_count} videos · {formatBytes(sizeBytes, 0)}

{hasUpdate && ( Update available )}
{statusBadge} {onUninstall && isInstalled && ( )}
) } export default CreatorPackCard