import { _decorator, Component, Node, Event } from "cc";
import BaseUI from "../../scripts/base/BaseUI";
import { Tips } from "../../scripts/mgr/Tips";
import WalletM, { TogHomeDto } from "../../scripts/api/WalletM";
import UserM from "../../scripts/api/UserM";
import { GoodsId } from "../../scripts/api/GoodsId";
import Utils from "../../scripts/utils/Utils";
import { TipsData, TipsLayer } from "../layer/TipsLayer";
import ConfigM, { Config } from "../../scripts/api/ConfigM";
const { ccclass, property } = _decorator;

@ccclass("WalletPageTOG")
export class WalletPageTOG extends BaseUI {
  public onShow(): void {
    this.init();
  }
  async init() {
    this.setText("lbl_pog_balance", UserM.ins.getPogDisplay());
    this.setText("lbl_tog_balance", UserM.ins.getTogDisplay());

    let data: TogHomeDto = await WalletM.ins.togHome();

    // this.setText(
    //   "lbl_tog_next_refresh_time",
    //   "Next Refresh Time:" + "00:00:00"
    // );
    this.setText("lbl_obtain_pog", Utils.formatNumber(data.rewardTog, 2));
    this.setText("lbl_my_pog", Utils.formatNumber(data.myPog, 5));
    this.setText(
      "lbl_platform_total_pog",
      Utils.formatNumber(data.totalPog, 5)
    );
    this.setText(
      "lbl_pog_grade_tog_total",
      Utils.formatNumber(data.totalTog, 2)
    );
  }

  protected simpleOnBtnClick(name: string): void {
    switch (name) {
      case "btn_utility":
        let content = Utils.setI18nLabel("Wallet.TOGUtilityDesc");
        let data = TipsLayer.build(content);
        data.title = "";
        data.link = "https://telgather.gitbook.io/telgather-litepaper/telgather-economy";
        data.show();
        break;

      case "btn_claim_tog":
        let tipsData = TipsLayer.build(`Are you sure you want to claim TOG?`);
        tipsData.onConfirm = () => {
          Tips.show("Claim TOG Coming Soon");
        };
        tipsData.show();
        break;
      case "btn_history":
        Tips.show("TOG History Coming Soon");
        break;

      case "btn_top_up":
        Tips.show("TOG Top Up Coming Soon");
        break;
      case "btn_withdraw":
        Tips.show("TOG Withdraw Coming Soon");
        break;

      case "btn_staking":
        Tips.show("TOG Staking Coming Soon");
        break;

      case "btn_go_1":
        Tips.show("Coming Soon");
        break;
      case "btn_go_2":
        let url = "https://t.me/Telgatherminigames";
        ConfigM.ins.openLink(url);
        break;
      case "btn_go_3":
        Tips.show("Coming Soon");
    }
  }
}
