import { useEffect, useState } from 'react'; import Card from '@/components/ui/Card'; import Button from '@/components/ui/Button'; import Image from 'next/image'; import type { DashboardFeedItemSummaryViewModel } from '@/lib/view-models/DashboardOverviewViewModel'; function timeAgo(timestamp: Date | string): string { const date = typeof timestamp === 'string' ? new Date(timestamp) : timestamp; const diffMs = Date.now() - date.getTime(); const diffMinutes = Math.floor(diffMs / 60000); if (diffMinutes < 1) return 'Just now'; if (diffMinutes < 60) return `${diffMinutes} min ago`; const diffHours = Math.floor(diffMinutes / 60); if (diffHours < 24) return `${diffHours} h ago`; const diffDays = Math.floor(diffHours / 24); return `${diffDays} d ago`; } async function resolveActor(_item: DashboardFeedItemSummaryViewModel) { // Actor resolution is not wired through the API in this build. // Keep rendering deterministic and decoupled (no core repos). return null; } interface FeedItemCardProps { item: DashboardFeedItemSummaryViewModel; } export default function FeedItemCard({ item }: FeedItemCardProps) { const [actor, setActor] = useState<{ name: string; avatarUrl: string } | null>(null); useEffect(() => { let cancelled = false; void (async () => { const resolved = await resolveActor(item); if (!cancelled) { setActor(resolved); } })(); return () => { cancelled = true; }; }, [item]); return (
{actor ? (
{actor.name}
) : ( {item.type.startsWith('friend') ? 'FR' : 'LG'} )}

{item.headline}

{item.body && (

{item.body}

)}
{timeAgo(item.timestamp)}
{item.ctaHref && item.ctaLabel && (
)}
); }