'use client'; import React from 'react'; import type { Locale } from '@/lib/locale'; import { pickLocaleText } from '@/lib/locale'; export interface ChannelInfo { id: string; groupId: number; name: string; platform: string; rateMultiplier: number; description: string | null; models: string[]; features: string[]; } interface ChannelCardProps { channel: ChannelInfo; onTopUp: () => void; isDark: boolean; locale: Locale; userBalance?: number; } const PLATFORM_STYLES: Record = { claude: { bg: 'bg-blue-100 dark:bg-blue-900/40', text: 'text-blue-700 dark:text-blue-300' }, openai: { bg: 'bg-green-100 dark:bg-green-900/40', text: 'text-green-700 dark:text-green-300' }, gemini: { bg: 'bg-purple-100 dark:bg-purple-900/40', text: 'text-purple-700 dark:text-purple-300' }, codex: { bg: 'bg-orange-100 dark:bg-orange-900/40', text: 'text-orange-700 dark:text-orange-300' }, sora: { bg: 'bg-pink-100 dark:bg-pink-900/40', text: 'text-pink-700 dark:text-pink-300' }, }; function getPlatformStyle(platform: string, isDark: boolean): { bg: string; text: string } { const key = platform.toLowerCase(); const match = PLATFORM_STYLES[key]; if (match) { return { bg: isDark ? match.bg.split(' ')[1]?.replace('dark:', '') || match.bg.split(' ')[0] : match.bg.split(' ')[0], text: isDark ? match.text.split(' ')[1]?.replace('dark:', '') || match.text.split(' ')[0] : match.text.split(' ')[0], }; } return { bg: isDark ? 'bg-slate-700' : 'bg-slate-100', text: isDark ? 'text-slate-300' : 'text-slate-600', }; } export default function ChannelCard({ channel, onTopUp, isDark, locale, userBalance }: ChannelCardProps) { const platformStyle = getPlatformStyle(channel.platform, isDark); const usableQuota = (1 / channel.rateMultiplier).toFixed(2); return (
{/* Header: Platform badge + Name */}
{channel.platform}

{channel.name}

{/* Rate display */}
{pickLocaleText(locale, '当前倍率', 'Rate')} 1 : {channel.rateMultiplier}
{userBalance !== undefined && (

{pickLocaleText( locale, `1元可用约${usableQuota}美元额度`, `1 CNY ≈ ${usableQuota} USD quota`, )}

)} {/* Description */} {channel.description && (

{channel.description}

)} {/* Models */} {channel.models.length > 0 && (

{pickLocaleText(locale, '支持模型', 'Supported Models')}

{channel.models.map((model) => ( {model} ))}
)} {/* Features */} {channel.features.length > 0 && (

{pickLocaleText(locale, '功能特性', 'Features')}

{channel.features.map((feature) => ( {feature} ))}
)} {/* Spacer to push button to bottom */}
{/* Top-up button */}
); }