import { useState, useEffect } from "react";
import { authService, UserInfo } from "../../services/authService";

export default function Wallet() {
  const [user, setUser] = useState<UserInfo | null>(null);

  useEffect(() => {
    authService.me().then(setUser).catch(() => {});
  }, []);

  return (
    <div>
      <h2 className="text-xl font-bold text-gray-900 dark:text-white mb-4">钱包</h2>

      <div className="bg-superdream-panel rounded-xl p-6 mb-4">
        <p className="text-gray-600 dark:text-gray-400 text-sm">当前余额 (USD)</p>
        <p className="text-3xl font-bold text-gray-900 dark:text-white mt-1">
          ${(user?.balance ?? 0).toFixed(4)}
        </p>
      </div>

      <div className="bg-superdream-panel rounded-xl p-4 text-sm text-gray-600 dark:text-gray-400">
        兑换码充值和交易记录暂未对接 sub2api，后续接入 <code>/api/v1/redeem</code> 后恢复。
      </div>
    </div>
  );
}