'use client' /** * Generic compact entity/document card for any chat type that doesn't * warrant a bespoke component. * * PURE PRESENTATION. Receives pre-composed `` props via `anchorProps` * and renders the rest from the item shape. */ import React from 'react' import { ExternalLink } from 'lucide-react' import { StatusBadge } from '../../ui/status-badge' import { COMPACT_CARD_META_ROW, COMPACT_CARD_META_ROW_BOX, COMPACT_CARD_OUTER, COMPACT_CARD_OUTER_STATIC, COMPACT_CARD_SKELETON_OUTER, COMPACT_CARD_TEXT_COL, COMPACT_CARD_TITLE, safeHref, } from '../utils/compact-card-classes' import { formatDateUTC as formatDate } from '../../../utils/format' type BadgeScheme = 'success' | 'error' | 'warning' | 'cyan' | 'default' export interface GenericEntityCardItem { id: string title: string preview?: string | null url?: string | null subtitle?: string | null badge?: { text: string; scheme?: BadgeScheme } | null facts?: Array<{ label: string; value: string }> | null dateUpdated?: string | number | null } export interface GenericEntityCardAnchorProps { href: string target?: '_blank' rel?: 'noopener noreferrer' onClick?: (e: React.MouseEvent) => void } export interface GenericEntityCardProps { item: GenericEntityCardItem className?: string anchorProps?: GenericEntityCardAnchorProps } export function GenericEntityCard({ item, className, anchorProps }: GenericEntityCardProps) { const href = safeHref(item.url) const dateText = formatDate(item.dateUpdated, { fallback: '', timezone: 'local' }) const body = ( <> {item.title} {item.badge ? ( ) : null} {item.subtitle ? ( {item.subtitle} ) : null} {item.preview ? ( {item.preview} ) : null} {item.facts && item.facts.length > 0 ? ( {item.facts.map((f, i) => ( {f.label}: {f.value} ))} ) : null} {dateText ? ( {dateText} ) : null} {href ? ( ) : null} ) if (anchorProps) { return ( {body} ) } return href ? ( {body} ) : ( {body} ) } export function GenericEntityCardSkeleton({ className }: { className?: string }) { return ( ) }