'use client' import { useEffect, useRef } from 'react' import { useTranslations } from 'next-intl' import type { TrumpPost } from '@/types' import Badge from '@/components/ui/Badge' import { useDashboardStore } from '@/store/dashboard' import { formatPct } from '@/lib/utils' const MOCK_POSTS: TrumpPost[] = [ { id: 1, text: 'BITCOIN IS THE FUTURE OF MONEY! We will make America the crypto capital of the world. BIG things coming very soon. The dollar will be STRONGER than ever with Bitcoin as our reserve!', source: 'truth', published_at: new Date(Date.now() - 1000 * 60 * 14).toISOString(), sentiment: 'bullish', ai_confidence: 91, relevant: true, price_impact: { asset: 'BTC', m5: 1.2, m15: 2.8, m1h: 3.4, price_at_post: 92800, }, }, { id: 2, text: 'Ethereum and all these so-called "smart contracts" are nothing but a scam by the radical left globalists. Very bad for America. We need REAL money, not fake computer tricks!', source: 'x', published_at: new Date(Date.now() - 1000 * 60 * 47).toISOString(), sentiment: 'bearish', ai_confidence: 84, relevant: true, price_impact: { asset: 'ETH', m5: -1.9, m15: -3.1, m1h: -4.2, price_at_post: 1920, }, }, { id: 3, text: "Met with many great business leaders today. Discussed the future of America's economy. Jobs are coming back FAST. Nobody builds like Trump!", source: 'truth', published_at: new Date(Date.now() - 1000 * 60 * 120).toISOString(), sentiment: 'neutral', ai_confidence: 42, relevant: false, price_impact: null, }, { id: 4, text: 'Crypto regulations will be ELIMINATED under my watch. No more Biden weaponization of the SEC against Bitcoin holders. We will have the most CRYPTO FRIENDLY government in history!', source: 'truth', published_at: new Date(Date.now() - 1000 * 60 * 210).toISOString(), sentiment: 'bullish', ai_confidence: 88, relevant: true, price_impact: { asset: 'BTC', m5: 0.9, m15: 2.1, m1h: 2.7, price_at_post: 91500, }, }, ] interface PostCardsProps { posts?: TrumpPost[] } function timeAgo(iso: string): string { const diff = Date.now() - new Date(iso).getTime() const mins = Math.floor(diff / 60000) if (mins < 60) return `${mins}m ago` const hours = Math.floor(mins / 60) if (hours < 24) return `${hours}h ago` return `${Math.floor(hours / 24)}d ago` } export default function PostCards({ posts = MOCK_POSTS }: PostCardsProps) { const t = useTranslations('common') const { selectedPostId, setSelectedPost } = useDashboardStore() const selectedRef = useRef(null) const scrollRef = useRef(null) // Auto-scroll selected card into view useEffect(() => { if (selectedRef.current && scrollRef.current) { selectedRef.current.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'start' }) } }, [selectedPostId]) return (
Posts · {posts.length} {selectedPostId && ( )}
{/* Horizontally scrollable row */}
{posts.map((post) => { const isSelected = selectedPostId === post.id const impact = post.price_impact return (
setSelectedPost(isSelected ? null : post.id)} className={`shrink-0 w-[200px] bg-[#0a0a0a] border rounded-[10px] p-3 cursor-pointer transition-colors hover:bg-[#0d0d0d] ${ isSelected ? 'border-[#f97316]' : 'border-[#141414]' }`} > {/* Header */}
{timeAgo(post.published_at)}
{/* Text */}

{post.text.slice(0, 90)} {post.text.length > 90 ? '…' : ''}

{/* Confidence bar */}
AI {post.ai_confidence}%
{/* Price impact */} {impact ? ( = 0 ? 'text-[#4ade80]' : 'text-[#ef4444]' }`} > {formatPct(impact.m1h)} 1h ) : ( {t('neutral')} )}
) })}
) } export { MOCK_POSTS }