'use client' import { useTranslations } from 'next-intl' import type { BotPerformance } from '@/types' import { formatPrice, formatPct } from '@/lib/utils' import { useDashboardStore } from '@/store/dashboard' interface KpiRowProps { performance?: BotPerformance postsCount?: number } interface StatCard { labelKey: string value: string change?: string changePositive?: boolean } export default function KpiRow({ performance, postsCount }: KpiRowProps) { const t = useTranslations('kpi') const { livePrices } = useDashboardStore() const stats: StatCard[] = [ { labelKey: 'btcPrice', value: formatPrice(livePrices.BTC ?? 94230), change: livePrices.BTC ? 'live' : '+1.4%', changePositive: true, }, { labelKey: 'ethPrice', value: formatPrice(livePrices.ETH ?? 1847), change: livePrices.ETH ? 'live' : '-0.8%', changePositive: false, }, { labelKey: 'postsTracked', value: postsCount != null ? postsCount.toLocaleString() : '1,247', change: '+12 today', changePositive: true, }, { labelKey: 'avgMove', value: performance ? formatPct(performance.net_pnl_usd > 0 ? 2.3 : -2.3) : formatPct(2.3), change: 'after Trump posts', changePositive: true, }, ] return (
{stats.map((stat) => (

{t(stat.labelKey as 'btcPrice' | 'ethPrice' | 'postsTracked' | 'avgMove')}

{stat.value}

{stat.change && (

{stat.change}

)}
))}
) }