'use client'; // Redeem.tsx — 兑换激活码 + 购买渠道(本站不收款,资金流全走外部)。承袭 UCRedeem。 import React, { useState } from 'react'; import { Icon } from './icons'; import { card, input } from './shared'; import { ErrorLine } from './Login'; import type { TFn, Lang } from '../lib/i18n'; import { getClient } from '../lib/api/client'; import { bilingual } from '../lib/api/errors'; export default function Redeem({ t, lang, onRedeemed }: { t: TFn; lang: Lang; onRedeemed?: () => void }) { const api = getClient(); const [code, setCode] = useState(''); const [ok, setOk] = useState(false); const [busy, setBusy] = useState(false); const [err, setErr] = useState(''); const channels: { icon: string; name: string; sub: string; accent?: boolean; mono?: boolean }[] = [ { icon: 'shopping-bag', name: t('chStore'), sub: t('chStoreSub'), accent: true }, { icon: 'credit-card', name: 'USDT (TRC20)', sub: t('chUsdtSub') }, { icon: 'send', name: 'Telegram', sub: '@Pangolin_bot', mono: true }, { icon: 'message-circle', name: 'LINE', sub: '@pangolinvpn', mono: true }, { icon: 'mail', name: t('chEmail'), sub: 'buy@pangolin.vpn', mono: true }, ]; async function submit() { if (busy || code.trim().length < 4) return; setBusy(true); setErr(''); try { await api.redeem(code.trim()); setOk(true); onRedeemed?.(); } catch (e) { setErr(bilingual(e, lang)); } finally { setBusy(false); } } return (