'use client' import { useTranslations } from 'next-intl' import { useState } from 'react' import { useAccount } from 'wagmi' import { useConnectModal } from '@rainbow-me/rainbowkit' import type { BotPerformance } from '@/types' import { useDashboardStore } from '@/store/dashboard' import { formatPct, formatHold } from '@/lib/utils' const MOCK_PERFORMANCE: BotPerformance = { period_days: 30, total_trades: 89, win_rate: 0.73, net_pnl_usd: 12840, avg_hold_seconds: 14 * 60, max_drawdown_pct: 8.2, } interface BotPanelProps { performance?: BotPerformance } export default function BotPanel({ performance = MOCK_PERFORMANCE }: BotPanelProps) { const t = useTranslations('bot') const { isSubscribed, setSubscribed } = useDashboardStore() const { address, isConnected } = useAccount() const { openConnectModal } = useConnectModal() const [apiKey, setApiKey] = useState('') const stats = [ { label: t('winRate'), value: formatPct(performance.win_rate * 100 - 100 + performance.win_rate * 100), display: `${Math.round(performance.win_rate * 100)}%` }, { label: t('netPnl'), value: `+$${performance.net_pnl_usd.toLocaleString()}`, positive: true }, { label: t('totalTrades'), value: String(performance.total_trades) }, { label: t('avgHold'), value: formatHold(performance.avg_hold_seconds) }, ] return (
{/* Performance card */}

{t('title')} ยท {t('period')}

{stats.map((stat) => (

{stat.label}

{stat.display ?? stat.value}

))}
{/* Divider */}
{/* Conditional bottom section */} {!isConnected && (

{t('connectCta')}

{t('connectDesc')}

)} {isConnected && !isSubscribed && (

{t('settingsTitle')}

Locked
{/* Disabled API key input */}
)} {isConnected && isSubscribed && (

{t('settingsTitle')}

{t('activeStatus')}
setApiKey(e.target.value)} placeholder={t('apiKeyPlaceholder')} className="w-full bg-[#060606] border border-[#141414] rounded-lg px-3 py-2 text-[12px] text-white placeholder-[#333333] focus:outline-none focus:border-[#222222]" />
)}
) }