import { getPosts } from '@/lib/api'
import type { Metadata } from 'next'
import DashboardClient from './DashboardClient'

export const revalidate = 30

const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || 'https://trumpsignal.com'

interface OverviewPageProps {
  params: Promise<{ locale: string }>
}

export async function generateMetadata({ params }: OverviewPageProps): Promise<Metadata> {
  const { locale } = await params
  const isZh = false  // i18n shelved — Chinese branches kept as dead code for future revival; see messages/zh.json

  const title = isZh
    ? 'Trump Alpha — 实时加密信号研究台'
    : 'Trump Alpha — Live Crypto Signal Desk'
  const description = isZh
    ? 'Endorphin 研究台追踪四个先于市场共识的信号：Trump 帖子、BTC 宏观底部、资金费率极值，以及 KOL 言行偏离。每个信号公开且带时间戳。'
    : 'Endorphin tracks four signals that move crypto before the crowd: Trump posts, BTC macro bottoms, funding-rate extremes, and what KOLs do vs say. Public and timestamped.'
  const path = `${siteUrl}/${locale}`

  return {
    title,
    description,
    alternates: {
      canonical: path,
      languages: {
        en: `${siteUrl}/en`,
        'x-default': `${siteUrl}/en`,
      },
    },
    openGraph: {
      title,
      description,
      url: path,
      locale: isZh ? 'zh_CN' : 'en_US',
      alternateLocale: isZh ? ['en_US'] : ['zh_CN'],
    },
    twitter: {
      title,
      description,
    },
  }
}

export default async function OverviewPage() {
  const posts = await getPosts(500, 1).catch(() => [])

  return (
    <DashboardClient
      initialPosts={posts}
    />
  )
}
