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";
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, 0));
    this.setText("lbl_my_pog", Utils.formatNumber(data.myPog, 0));
    this.setText(
      "lbl_platform_total_pog",
      Utils.formatNumber(data.totalPog, 0)
    );
    this.setText(
      "lbl_pog_grade_tog_total",
      Utils.formatNumber(data.totalTog, 0)
    );
  }

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

      case "btn_claim_tog":
        TipsLayer.show({
          title: "Claim TOG",
          content: "Are you sure you want to claim TOG?",
          forceConfirm: true,
          link:null,
          singleName: null,
          onConfirm: () => {
            Tips.show("Claim TOG Coming Soon");
          },
        }) 
        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";
        window.open(url, "_blank");
        break;
      case "btn_go_3":
        Tips.show("Coming Soon");
    }
  }
}
